//////////////////////////////////////////////////////////////////////////////// public Boolean ReadProcessMemoryChecked( IntPtr lpBaseAddress, IntPtr lpBuffer, UInt32 dwSize, string sectionName ) { UInt32 dwNumberOfBytesRead = 0; Boolean readProcessMemoryResult = Unmanaged.ReadProcessMemory( hProcess, lpBaseAddress, lpBuffer, dwSize, ref dwNumberOfBytesRead ); if (readProcessMemoryResult) { WriteOutputGood("Section " + sectionName.Trim() + " (" + dwNumberOfBytesRead + " bytes), Read From To " + lpBaseAddress.ToString("X4")); return(true); } else { WriteOutputBad( "Unable to read process memory" + "\n\tResult: " + readProcessMemoryResult + "\n\tdwSize " + dwSize + "\n\tlpBaseAddress " + lpBaseAddress.ToString("X4") + "\n\tlpBuffer " + lpBuffer.ToString("X4") + "\n\tdwNumberOfBytesRead " + dwNumberOfBytesRead ); //This is dumb return(false); } }
//////////////////////////////////////////////////////////////////////////////// public Boolean ReadProcessMemoryUnChecked( IntPtr lpBaseAddress, IntPtr lpBuffer, UInt32 dwSize, string sectionName ) { UInt32 dwNumberOfBytesRead = 0; Boolean readProcessMemoryResult = Unmanaged.ReadProcessMemory( hProcess, lpBaseAddress, lpBuffer, dwSize, ref dwNumberOfBytesRead ); if (readProcessMemoryResult) { return(true); } else { WriteOutputNeutral("Unable to read process memory"); return(false); } }