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

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

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

revision 155 by william, Wed May 9 20:52:20 2012 UTC revision 156 by william, Mon May 28 04:14:03 2012 UTC
# Line 4  using System.Text; Line 4  using System.Text;
4  using System.Diagnostics;  using System.Diagnostics;
5  using System.Threading;  using System.Threading;
6  using System.Runtime.InteropServices;  using System.Runtime.InteropServices;
7    using RomCheater.Logging;
8    
9  namespace Sojaner.MemoryScanner  namespace Sojaner.MemoryScanner
10  {  {
# Line 67  namespace Sojaner.MemoryScanner Line 68  namespace Sojaner.MemoryScanner
68    
69          public byte[] ReadProcessMemory(IntPtr MemoryAddress, uint bytesToRead, out int bytesRead)          public byte[] ReadProcessMemory(IntPtr MemoryAddress, uint bytesToRead, out int bytesRead)
70          {          {
71              byte[] buffer = new byte[bytesToRead];              try
72                {
73                    byte[] buffer = new byte[bytesToRead - 1];
74    
75              IntPtr ptrBytesRead;                  IntPtr ptrBytesRead;
76              ProcessMemoryReaderApi.ReadProcessMemory(m_hProcess, MemoryAddress, buffer, bytesToRead, out ptrBytesRead);                  ProcessMemoryReaderApi.ReadProcessMemory(m_hProcess, MemoryAddress, buffer, bytesToRead, out ptrBytesRead);
77    
78              bytesRead = ptrBytesRead.ToInt32();                  bytesRead = ptrBytesRead.ToInt32();
79    
80              return buffer;                  return buffer;
81                }
82                catch (OutOfMemoryException ex)
83                {
84                    logger.Error.WriteLine("ReadProcessMemory(): OutOfMemoryException");
85                    logger.Error.WriteLine(ex.ToString());
86                }
87                catch (Exception ex)
88                {
89                    logger.Error.WriteLine("ReadProcessMemory(): Exception");
90                    logger.Error.WriteLine(ex.ToString());
91                }
92                bytesRead = 0;
93                return new byte[] { };
94          }          }
95    
96          public void WriteProcessMemory(IntPtr MemoryAddress, byte[] bytesToWrite, out int bytesWritten)          public void WriteProcessMemory(IntPtr MemoryAddress, byte[] bytesToWrite, out int bytesWritten)

Legend:
Removed from v.155  
changed lines
  Added in v.156

  ViewVC Help
Powered by ViewVC 1.1.22