/[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 234 by william, Sun Jun 3 12:36:47 2012 UTC revision 235 by william, Sun Jun 3 12:44:26 2012 UTC
# Line 214  namespace Sojaner.MemoryScanner Line 214  namespace Sojaner.MemoryScanner
214          }          }
215    
216          #region IMemoryReader Members          #region IMemoryReader Members
217          public bool ReadFirstNonZeroByte(uint MemoryAddress, int bytesToRead, out uint address)          public bool ReadFirstNonZeroByte(uint MemoryAddress, uint bytesToRead, out uint address)
218          {          {
219              //logger.Info.WriteLine("Dumping memory (0x{0:x8}-0x{1:x8}) from pid=({2})", MemoryAddress, MemoryAddress + bytesToRead, string.Format("0x{0:x4} {1}.exe", ppid.Id, ppid.ProcessName));              //logger.Info.WriteLine("Dumping memory (0x{0:x8}-0x{1:x8}) from pid=({2})", MemoryAddress, MemoryAddress + bytesToRead, string.Format("0x{0:x4} {1}.exe", ppid.Id, ppid.ProcessName));
220              address = 0;              address = 0;
221              int byte_alignment = 1;              uint byte_alignment = 1;
222              // get common init parameters              // get common init parameters
223              //InitMemoryDump(out byte_alignment);              //InitMemoryDump(out byte_alignment);
224              uint mem_address = MemoryAddress;              uint mem_address = MemoryAddress;
225              int _bytesToRead = bytesToRead;              uint _bytesToRead = bytesToRead;
226              byte[] buffer = new byte[] { };              byte[] buffer = new byte[] { };
227              try              try
228              {              {
# Line 230  namespace Sojaner.MemoryScanner Line 230  namespace Sojaner.MemoryScanner
230                  //{                  //{
231                  //    //BinaryWriter bw = new BinaryWriter(ms);                  //    //BinaryWriter bw = new BinaryWriter(ms);
232                  //    //foreach (byte b in data) { bw.Write(b); }                  //    //foreach (byte b in data) { bw.Write(b); }
233                  for (int i = 0; i <= bytesToRead; )                  for (uint i = 0; i <= bytesToRead; )
234                  {                  {
235                      if (_bytesToRead < byte_alignment)                      if (_bytesToRead < byte_alignment)
236                      {                      {
# Line 286  namespace Sojaner.MemoryScanner Line 286  namespace Sojaner.MemoryScanner
286              }              }
287              return false;              return false;
288          }          }
289          public void ReadProcessMemory(uint MemoryAddress, int bytesToRead, out int bytesRead, out byte[] data)          public void ReadProcessMemory(uint MemoryAddress, uint bytesToRead, out int bytesRead, out byte[] data)
290          {          {
291              byte[] buffer = new byte[] { };              byte[] buffer = new byte[] { };
292              IntPtr ptrBytesRead;              IntPtr ptrBytesRead;
293              uint _bytesToRead = (uint)bytesToRead;              ProcessMemoryReader.ProcessMemoryReaderApi.ReadProcessMemory(m_hProcess, (UIntPtr)MemoryAddress, buffer, bytesToRead, out ptrBytesRead);
             ProcessMemoryReader.ProcessMemoryReaderApi.ReadProcessMemory(m_hProcess, (UIntPtr)MemoryAddress, buffer, _bytesToRead, out ptrBytesRead);  
294              bytesRead = ptrBytesRead.ToInt32();              bytesRead = ptrBytesRead.ToInt32();
295              data = buffer;              data = buffer;
296          }          }
# Line 312  namespace Sojaner.MemoryScanner Line 311  namespace Sojaner.MemoryScanner
311    
312          #region IFileWriter Members          #region IFileWriter Members
313    
314          public bool WriteProcessMemoryToFile(string filename, uint MemoryAddress, int bytesToRead, out int bytesRead)          public bool WriteProcessMemoryToFile(string filename, uint MemoryAddress, uint bytesToRead, out int bytesRead)
315          {          {
316              //logger.Info.WriteLine("Dumping memory (0x{0:x8}-0x{1:x8}) from pid=({3}) to file {2}", MemoryAddress, MemoryAddress + bytesToRead, filename, string.Format("0x{0:x4} {1}.exe", ppid.Id, ppid.ProcessName));              //logger.Info.WriteLine("Dumping memory (0x{0:x8}-0x{1:x8}) from pid=({3}) to file {2}", MemoryAddress, MemoryAddress + bytesToRead, filename, string.Format("0x{0:x4} {1}.exe", ppid.Id, ppid.ProcessName));
317              bytesRead = 0;              bytesRead = 0;
318              int byte_alignment = 102400;              uint byte_alignment = 102400;
319              uint address = MemoryAddress;              uint address = MemoryAddress;
320              int _bytesToRead = bytesToRead;              uint _bytesToRead = bytesToRead;
321              byte[] buffer = new byte[] { };              byte[] buffer = new byte[] { };
322              try              try
323              {              {
# Line 330  namespace Sojaner.MemoryScanner Line 329  namespace Sojaner.MemoryScanner
329                      BinaryWriter bw = new BinaryWriter(fs);                      BinaryWriter bw = new BinaryWriter(fs);
330                      //foreach (byte b in data) { bw.Write(b); }                      //foreach (byte b in data) { bw.Write(b); }
331    
332                      for (int i = 0; i <= bytesToRead; )                      for (uint i = 0; i <= bytesToRead; )
333                      {                      {
334                          if (_bytesToRead < byte_alignment)                          if (_bytesToRead < byte_alignment)
335                          {                          {

Legend:
Removed from v.234  
changed lines
  Added in v.235

  ViewVC Help
Powered by ViewVC 1.1.22