--- trunk/Win32/Sojaner.MemoryScanner/MemoryScanner.cs 2012/05/28 07:12:37 162 +++ trunk/Win32/Sojaner.MemoryScanner/MemoryScanner.cs 2012/05/28 07:49:48 164 @@ -72,7 +72,7 @@ namespace Sojaner.MemoryScanner public bool DumpMemory(string filename, uint MemoryAddress, uint bytesToRead, out int bytesRead) { bytesRead = 0; - uint byte_alignment = 512; // 4mb alignment + uint byte_alignment = 16; // 16 byte alignment uint address = MemoryAddress; try { @@ -86,7 +86,7 @@ namespace Sojaner.MemoryScanner byte[] buffer = new byte[byte_alignment]; uint bytes_to_read = byte_alignment; IntPtr ptrBytesRead; - ProcessMemoryReaderApi.ReadProcessMemory(m_hProcess, (IntPtr)address, buffer, bytes_to_read, out ptrBytesRead); + ProcessMemoryReaderApi.ReadProcessMemory(m_hProcess, (UIntPtr)address, buffer, bytes_to_read, out ptrBytesRead); bytesRead = ptrBytesRead.ToInt32(); bw.Write(buffer); bw.Flush(); @@ -124,7 +124,7 @@ namespace Sojaner.MemoryScanner byte[] buffer = new byte[byte_alignment]; uint bytes_to_read = byte_alignment; IntPtr ptrBytesRead; - ProcessMemoryReaderApi.ReadProcessMemory(m_hProcess, (IntPtr)address, buffer, bytes_to_read, out ptrBytesRead); + ProcessMemoryReaderApi.ReadProcessMemory(m_hProcess, (UIntPtr)address, buffer, bytes_to_read, out ptrBytesRead); bytesRead = ptrBytesRead.ToInt32(); aligned_array_list.Add(buffer); address += byte_alignment; @@ -148,7 +148,7 @@ namespace Sojaner.MemoryScanner return new byte[] { }; } - public void WriteProcessMemory(IntPtr MemoryAddress, byte[] bytesToWrite, out int bytesWritten) + public void WriteProcessMemory(UIntPtr MemoryAddress, byte[] bytesToWrite, out int bytesWritten) { IntPtr ptrBytesWritten; ProcessMemoryReaderApi.WriteProcessMemory(m_hProcess, MemoryAddress, bytesToWrite, (uint)bytesToWrite.Length, out ptrBytesWritten); @@ -203,7 +203,7 @@ namespace Sojaner.MemoryScanner // SIZE_T * lpNumberOfBytesRead // number of bytes read // ); [DllImport("kernel32.dll")] - public static extern Int32 ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesRead); + public static extern Int32 ReadProcessMemory(IntPtr hProcess, UIntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesRead); // BOOL WriteProcessMemory( // HANDLE hProcess, // handle to process @@ -213,7 +213,7 @@ namespace Sojaner.MemoryScanner // SIZE_T * lpNumberOfBytesWritten // count of bytes written // ); [DllImport("kernel32.dll")] - public static extern Int32 WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesWritten); + public static extern Int32 WriteProcessMemory(IntPtr hProcess, UIntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesWritten); } |