ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/Win32/Sojaner.MemoryScanner/MemoryScanner.cs
(Generate patch)

Comparing trunk/Win32/Sojaner.MemoryScanner/MemoryScanner.cs (file contents):
Revision 407 by william, Thu Jun 21 12:51:57 2012 UTC vs.
Revision 408 by william, Thu Jun 21 18:10:21 2012 UTC

--- trunk/Win32/Sojaner.MemoryScanner/MemoryScanner.cs	2012/06/21 15:59:29	407
+++ trunk/Win32/Sojaner.MemoryScanner/MemoryScanner.cs	2012/06/21 18:10:21	408
@@ -11,6 +11,7 @@ using Microsoft.Win32.SafeHandles;
 using Microsoft.Win32.Interop;
 using System.ComponentModel;
 using ManagedWinapi;
+using RomCheater.PluginFramework.Events;
 
 namespace Sojaner.MemoryScanner
 {
@@ -18,7 +19,7 @@ namespace Sojaner.MemoryScanner
     #region ProcessMemoryReader class
     //Thanks goes to Arik Poznanski for P/Invokes and methods needed to read and write the Memory
     //For more information refer to "Minesweeper, Behind the scenes" article by Arik Poznanski at Codeproject.com
-    internal class ProcessMemoryReader : IMemoryReader, IMemoryWriter, IFileWriter, IPatchMemory,IReadMemory
+    internal class ProcessMemoryReader : IMemoryReader, IMemoryWriter, IFileWriter, IPatchMemory,IReadMemory, IAcceptsBytesReadEvent
     {
         // constants information can be found in <winnt.h>
         [Flags]
@@ -68,7 +69,7 @@ namespace Sojaner.MemoryScanner
         public ProcessMemoryReader()
         {
         }
-
+        public event BaseEventHandler<OnBytesReadEventArgs> OnBytesRead;
         /// <summary>	
         /// Process from which to read		
         /// </summary>
@@ -153,8 +154,6 @@ namespace Sojaner.MemoryScanner
         /// </summary>
         private class ProcessMemoryReaderApi
         {
-           
-        
             [DllImport("kernel32.dll")]
             public static extern int VirtualQueryEx(IntPtr hProcess, IntPtr lpAddress, out MEMORY_BASIC_INFORMATION lpBuffer, uint dwLength);
 
@@ -293,6 +292,19 @@ namespace Sojaner.MemoryScanner
         }
         #endregion
 
+        public void ReadProcessMemoryAtOnce(uint MemoryAddress, uint bytesToRead,object UserState)
+        {
+            uint size = 1024 * 128;
+            for (uint j = MemoryAddress; j < bytesToRead; j += size)
+            {
+                ProcessMemoryChunk mem = new ProcessMemoryChunk(m_ReadProcess, (IntPtr)j, (int)size);
+                byte[] bigMem = mem.Read();
+                if (this.OnBytesRead != null)
+                    this.OnBytesRead.Invoke(new OnBytesReadEventArgs(this, UserState, bigMem, j, bytesToRead));
+                bigMem = null;
+            }
+            
+        }
         public void ReadProcessMemoryAtOnce(uint MemoryAddress, uint bytesToRead, out int bytesRead, out byte[] data)
         {
             Stopwatch st = new Stopwatch();