/[RomCheater]/trunk/RomCheater/Docking/FloatingMemorySearcher.cs
ViewVC logotype

Diff of /trunk/RomCheater/Docking/FloatingMemorySearcher.cs

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

--- trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2012/06/03 12:48:09	237
+++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2012/06/03 13:04:02	242
@@ -15,6 +15,7 @@
 using System.Threading;
 using RomCheater.Logging;
 using System.IO;
+using Sojaner.MemoryScanner.MemoryProviers;
 
 namespace RomCheater.Docking
 {
@@ -316,13 +317,10 @@
                 ResultDataType _result = (ResultDataType)ResultItems[i].Tag;
                 
                 Address = Convert.ToUInt32(ResultItems[i].SubItems[col_Found_Address].Text, 16);
-                //r_ms.BaseStream.Seek(Address, SeekOrigin.Begin);
-                Sojaner.MemoryScanner.ProcessMemoryReader reader = new Sojaner.MemoryScanner.ProcessMemoryReader();
-                reader.ReadProcess = Process.GetProcessById(this.AcceptedProcess.Id);
-                if (reader.ReadProcess == null) { logger.Error.WriteLine("Could not attach to process: {0}", this.AcceptedProcess.Id); return; }
-                reader.OpenProcess();
+                //r_ms.BaseStream.Seek(Address, SeekOrigin.Begin);                
+                GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this);
                 int bytesReadSize;
-                byte[] data;
+                byte[] data;    
                 uint bytesToRead = 0;
                 switch (_result.ValueType)
                 {
@@ -339,7 +337,7 @@
                         bytesToRead = 8;
                         break;
                 }
-                reader.ReadProcessMemory(Address, bytesToRead, out bytesReadSize, out data);
+                provider.ReadProcessMemory(Address, bytesToRead, out bytesReadSize, out data);
                 MemoryStream ms = new MemoryStream(data);
                 BinaryReader r_ms = new BinaryReader(ms);
                 switch (_result.ValueType)
@@ -362,7 +360,6 @@
                         break;
                 }
                 r_ms.Close();
-                reader.CloseHandle();
                 Application.DoEvents();
             }
             #endregion
@@ -395,10 +392,7 @@
                 uint Address = 0;
                 ResultDataType _result = (ResultDataType)AddedItems[i].Tag;
                 Address = Convert.ToUInt32(AddedItems[i].SubItems[col_Added_Address].Text, 16);
-                Sojaner.MemoryScanner.ProcessMemoryReader reader = new Sojaner.MemoryScanner.ProcessMemoryReader();
-                reader.ReadProcess = Process.GetProcessById(this.AcceptedProcess.Id);
-                if (reader.ReadProcess == null) { logger.Error.WriteLine("Could not attach to process: {0}", this.AcceptedProcess.Id); return; }
-                reader.OpenProcess();
+                GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this);
                 int bytesReadSize;
                 byte[] data;
                 uint bytesToRead = 0;
@@ -417,7 +411,7 @@
                         bytesToRead = 8;
                         break;
                 }
-                reader.ReadProcessMemory(Address, bytesToRead, out bytesReadSize, out data);
+                provider.ReadProcessMemory(Address, bytesToRead, out bytesReadSize, out data);
                 MemoryStream ms = new MemoryStream(data);
                 BinaryReader r_ms = new BinaryReader(ms);
                 switch (_result.ValueType)
@@ -440,7 +434,6 @@
                         break;
                 }
                 r_ms.Close();
-                reader.CloseHandle();
                 Application.DoEvents();
             }
             #endregion

 

  ViewVC Help
Powered by ViewVC 1.1.22