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

# Line 11 | Line 11 | using Microsoft.Win32.SafeHandles;
11   using Microsoft.Win32.Interop;
12   using System.ComponentModel;
13   using ManagedWinapi;
14 + using RomCheater.PluginFramework.Events;
15  
16   namespace Sojaner.MemoryScanner
17   {
# Line 18 | Line 19 | namespace Sojaner.MemoryScanner
19      #region ProcessMemoryReader class
20      //Thanks goes to Arik Poznanski for P/Invokes and methods needed to read and write the Memory
21      //For more information refer to "Minesweeper, Behind the scenes" article by Arik Poznanski at Codeproject.com
22 <    internal class ProcessMemoryReader : IMemoryReader, IMemoryWriter, IFileWriter, IPatchMemory,IReadMemory
22 >    internal class ProcessMemoryReader : IMemoryReader, IMemoryWriter, IFileWriter, IPatchMemory,IReadMemory, IAcceptsBytesReadEvent
23      {
24          // constants information can be found in <winnt.h>
25          [Flags]
# Line 68 | Line 69 | namespace Sojaner.MemoryScanner
69          public ProcessMemoryReader()
70          {
71          }
72 <
72 >        public event BaseEventHandler<OnBytesReadEventArgs> OnBytesRead;
73          /// <summary>  
74          /// Process from which to read          
75          /// </summary>
# Line 153 | Line 154 | namespace Sojaner.MemoryScanner
154          /// </summary>
155          private class ProcessMemoryReaderApi
156          {
156          
157        
157              [DllImport("kernel32.dll")]
158              public static extern int VirtualQueryEx(IntPtr hProcess, IntPtr lpAddress, out MEMORY_BASIC_INFORMATION lpBuffer, uint dwLength);
159  
# Line 293 | Line 292 | namespace Sojaner.MemoryScanner
292          }
293          #endregion
294  
295 +        public void ReadProcessMemoryAtOnce(uint MemoryAddress, uint bytesToRead,object UserState)
296 +        {
297 +            uint size = 1024 * 128;
298 +            for (uint j = MemoryAddress; j < bytesToRead; j += size)
299 +            {
300 +                ProcessMemoryChunk mem = new ProcessMemoryChunk(m_ReadProcess, (IntPtr)j, (int)size);
301 +                byte[] bigMem = mem.Read();
302 +                if (this.OnBytesRead != null)
303 +                    this.OnBytesRead.Invoke(new OnBytesReadEventArgs(this, UserState, bigMem, j, bytesToRead));
304 +                bigMem = null;
305 +            }
306 +            
307 +        }
308          public void ReadProcessMemoryAtOnce(uint MemoryAddress, uint bytesToRead, out int bytesRead, out byte[] data)
309          {
310              Stopwatch st = new Stopwatch();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines