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 155 by william, Wed May 9 20:52:20 2012 UTC vs.
Revision 156 by william, Mon May 28 04:14:03 2012 UTC

# Line 4 | Line 4 | using System.Text;
4   using System.Diagnostics;
5   using System.Threading;
6   using System.Runtime.InteropServices;
7 + using RomCheater.Logging;
8  
9   namespace Sojaner.MemoryScanner
10   {
# Line 67 | Line 68 | namespace Sojaner.MemoryScanner
68  
69          public byte[] ReadProcessMemory(IntPtr MemoryAddress, uint bytesToRead, out int bytesRead)
70          {
71 <            byte[] buffer = new byte[bytesToRead];
71 >            try
72 >            {
73 >                byte[] buffer = new byte[bytesToRead - 1];
74  
75 <            IntPtr ptrBytesRead;
76 <            ProcessMemoryReaderApi.ReadProcessMemory(m_hProcess, MemoryAddress, buffer, bytesToRead, out ptrBytesRead);
75 >                IntPtr ptrBytesRead;
76 >                ProcessMemoryReaderApi.ReadProcessMemory(m_hProcess, MemoryAddress, buffer, bytesToRead, out ptrBytesRead);
77  
78 <            bytesRead = ptrBytesRead.ToInt32();
78 >                bytesRead = ptrBytesRead.ToInt32();
79  
80 <            return buffer;
80 >                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)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines