/[RomCheater]/trunk/Win32/Sojaner.MemoryScanner/MemoryProviers/BaseMemoryProvider.cs
ViewVC logotype

Diff of /trunk/Win32/Sojaner.MemoryScanner/MemoryProviers/BaseMemoryProvider.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/Win32/Sojaner.MemoryScanner/MemoryProviers/BaseMemoryProvider.cs	2012/06/10 04:20:04	369
+++ trunk/Win32/Sojaner.MemoryScanner/MemoryProviers/BaseMemoryProvider.cs	2012/06/10 05:40:24	370
@@ -128,110 +128,56 @@
         public virtual bool PatchMemory(int address, byte value)
         {
             if (!EnsureProviderIsOpen()) { return false; }
-            int bytesWritten;
-            byte[] bitData = BitConverter.GetBytes(value);
-            provider.WriteProcessMemory(address, bitData, out bytesWritten);
-            byte check = 0;
-            ReadMemory(address, out check);
-            if (check == value) return true;
-            return false;
+            return provider.PatchMemory(address, value);
         }
         #endregion
         #region public virtual bool PatchMemory(int address, sbyte value)
         public virtual bool PatchMemory(int address, sbyte value)
         {
             if (!EnsureProviderIsOpen()) { return false; }
-            int bytesWritten;
-            byte[] bitData = BitConverter.GetBytes(value);
-            provider.WriteProcessMemory(address, bitData, out bytesWritten);
-            sbyte check = 0;
-            ReadMemory(address, out check);
-            if (check == value) return true;
-            return false;
+            return provider.PatchMemory(address, value);
         }
         #endregion
         #region public virtual bool PatchMemory(int address, ushort value)
         public virtual bool PatchMemory(int address, ushort value)
         {
             if (!EnsureProviderIsOpen()) { return false; }
-            int bytesWritten;
-            byte[] bitData = BitConverter.GetBytes(value);
-            provider.WriteProcessMemory(address, bitData, out bytesWritten);
-
-            ushort check = 0;
-            ReadMemory(address, out check);
-            if (check == value) return true;
-            return false;
+            return provider.PatchMemory(address, value);
         }
         #endregion
         #region public virtual bool PatchMemory(int address, short value)
         public virtual bool PatchMemory(int address, short value)
         {
             if (!EnsureProviderIsOpen()) { return false; }
-            int bytesWritten;
-            byte[] bitData = BitConverter.GetBytes(value);
-            provider.WriteProcessMemory(address, bitData, out bytesWritten);
-
-            short check = 0;
-            ReadMemory(address, out check);
-            if (check == value) return true;
-            return false;
+            return provider.PatchMemory(address, value);
         }
         #endregion
         #region public virtual bool PatchMemory(int address, uint value)
         public virtual bool PatchMemory(int address, uint value)
         {
             if (!EnsureProviderIsOpen()) { return false; }
-            int bytesWritten;
-            byte[] bitData = BitConverter.GetBytes(value);
-            provider.WriteProcessMemory(address, bitData, out bytesWritten);
-
-            uint check = 0;
-            ReadMemory(address, out check);
-            if (check == value) return true;
-            return false;
+            return provider.PatchMemory(address, value);
         }
         #endregion
         #region public virtual bool PatchMemory(int address, int value)
         public virtual bool PatchMemory(int address, int value)
         {
             if (!EnsureProviderIsOpen()) { return false; }
-            int bytesWritten;
-            byte[] bitData = BitConverter.GetBytes(value);
-            provider.WriteProcessMemory(address, bitData, out bytesWritten);
-
-            int check = 0;
-            ReadMemory(address, out check);
-            if (check == value) return true;
-            return false;
+            return provider.PatchMemory(address, value);
         }
         #endregion
         #region public virtual bool PatchMemory(int address, ulong value)
         public virtual bool PatchMemory(int address, ulong value)
         {
             if (!EnsureProviderIsOpen()) { return false; }
-            int bytesWritten;
-            byte[] bitData = BitConverter.GetBytes(value);
-            provider.WriteProcessMemory(address, bitData, out bytesWritten);
-
-            ulong check = 0;
-            ReadMemory(address, out check);
-            if (check == value) return true;
-            return false;
+            return provider.PatchMemory(address, value);
         }
         #endregion
         #region public virtual bool PatchMemory(int address, long value)
         public virtual bool PatchMemory(int address, long value)
         {
             if (!EnsureProviderIsOpen()) { return false; }
-            int bytesWritten;
-            byte[] bitData = BitConverter.GetBytes(value);
-            provider.WriteProcessMemory(address, bitData, out bytesWritten);
-
-            long check = 0;
-            ReadMemory(address, out check);
-            if (check == value) return true;
-            return false;
+            return provider.PatchMemory(address, value);
         }
         #endregion
         #endregion
@@ -242,20 +188,7 @@
         {
             value = 0;
             if (!EnsureProviderIsOpen()) { return false; }
-            try
-            {
-                int bytesReadSize;
-                byte[] bitData;
-                provider.ReadProcessMemory(address, sizeof(byte), out bytesReadSize, out bitData);
-                value = bitData[0];
-
-                return true;
-            }
-            catch
-            {
-                value = 0x00;
-                return false;
-            }
+            return provider.ReadMemory(address, out value);
         }
         #endregion
         #region public virtual bool ReadMemory(int address, out sbyte value)
@@ -263,20 +196,7 @@
         {
             value = 0;
             if (!EnsureProviderIsOpen()) { return false; }
-            try
-            {
-                int bytesReadSize;
-                byte[] bitData = new byte[sizeof(sbyte)];
-                provider.ReadProcessMemory(address, sizeof(sbyte), out bytesReadSize, out bitData);
-                value = Convert.ToSByte(bitData[0]);
-
-                return true;
-            }
-            catch
-            {
-                value = 0x00;
-                return false;
-            }
+            return provider.ReadMemory(address, out value);
         }
         #endregion
         #region public virtual bool ReadMemory(int address, out ushort value)
@@ -284,19 +204,7 @@
         {
             value = 0;
             if (!EnsureProviderIsOpen()) { return false; }
-            try
-            {
-                int bytesReadSize;
-                byte[] bitData = new byte[sizeof(ushort)];
-                provider.ReadProcessMemory(address, sizeof(ushort), out bytesReadSize, out bitData);
-                value = BitConverter.ToUInt16(bitData, 0);
-                return true;
-            }
-            catch
-            {
-                value = 0x00;
-                return false;
-            }
+            return provider.ReadMemory(address, out value);
         }
         #endregion
         #region public virtual bool ReadMemory(int address, out short value)
@@ -304,20 +212,7 @@
         {
             value = 0;
             if (!EnsureProviderIsOpen()) { return false; }
-            try
-            {
-                int bytesReadSize;
-                byte[] bitData = new byte[sizeof(short)];
-                provider.ReadProcessMemory(address, sizeof(short), out bytesReadSize, out bitData);
-                value = BitConverter.ToInt16(bitData, 0);
-
-                return true;
-            }
-            catch
-            {
-                value = 0x00;
-                return false;
-            }
+            return provider.ReadMemory(address, out value);
         }
         #endregion
         #region public virtual bool ReadMemory(int address, out uint value)
@@ -325,20 +220,7 @@
         {
             value = 0;
             if (!EnsureProviderIsOpen()) { return false; }
-            try
-            {
-                int bytesReadSize;
-                byte[] bitData = new byte[sizeof(uint)];
-                provider.ReadProcessMemory(address, sizeof(uint), out bytesReadSize, out bitData);
-                value = BitConverter.ToUInt32(bitData, 0);
-
-                return true;
-            }
-            catch
-            {
-                value = 0x00;
-                return false;
-            }
+            return provider.ReadMemory(address, out value);
         }
         #endregion
         #region public virtual bool ReadMemory(int address, out int value)
@@ -346,20 +228,7 @@
         {
             value = 0;
             if (!EnsureProviderIsOpen()) { return false; }
-            try
-            {
-                int bytesReadSize;
-                byte[] bitData = new byte[sizeof(int)];
-                provider.ReadProcessMemory(address, sizeof(int), out bytesReadSize, out bitData);
-                value = BitConverter.ToInt32(bitData, 0);
-
-                return true;
-            }
-            catch
-            {
-                value = 0x00;
-                return false;
-            }
+            return provider.ReadMemory(address, out value);
         }
         #endregion
         #region public virtual bool ReadMemory(int address, out ulong value)
@@ -367,20 +236,7 @@
         {
             value = 0;
             if (!EnsureProviderIsOpen()) { return false; }
-            try
-            {
-                int bytesReadSize;
-                byte[] bitData = new byte[sizeof(ulong)];
-                provider.ReadProcessMemory(address, sizeof(ulong), out bytesReadSize, out bitData);
-                value = BitConverter.ToUInt64(bitData, 0);
-
-                return true;
-            }
-            catch
-            {
-                value = 0x00;
-                return false;
-            }
+            return provider.ReadMemory(address, out value);
         }
         #endregion
         #region public virtual bool ReadMemory(int address, out long value)
@@ -388,20 +244,7 @@
         {
             value = 0;
             if (!EnsureProviderIsOpen()) { return false; }
-            try
-            {
-                int bytesReadSize;
-                byte[] bitData = new byte[sizeof(long)];
-                provider.ReadProcessMemory(address, sizeof(long), out bytesReadSize, out bitData);
-                value = BitConverter.ToInt64(bitData, 0);
-
-                return true;
-            }
-            catch
-            {
-                value = 0x00;
-                return false;
-            }
+            return provider.ReadMemory(address, out value);
         }
         #endregion
         #endregion

 

  ViewVC Help
Powered by ViewVC 1.1.22