C#C
C#3y ago
Popzi

❔ Reading Memory comes out backwards?

I'm learning assembly / how to read and write from it and having an issue reading memory as hex values... it for some reason comes out backwards?
The program I'm reading from is 64-bit

const int PROCESS_WM_READ = 0x0010;
[DllImport("kernel32.dll")]
static extern bool ReadProcessMemory(int hProcess, Int64 lpBaseAddress, byte[] lpBuffer, int dwSize, ref int lpNumberOfBytesRead);

Process P = Process.GetProcessesByName(ProcessName)[0];    // Process
IntPtr PH = OpenProcess(PROCESS_WM_READ, false, P.Id);    // ProcessHandle
IntPTr BA = P.MainModule.BaseAddress;                     // BaseAddress

int bytesRead = 0;                      // Keep track of how many bytes we've read
byte[] buffer = new byte[4];            // Prepare a byte array which we'll populate as we read
ReadProcessMemory((int) this.PH , 0x2445BC56E00, buffer, buffer.Length, ref bytesRead);
Console.WriteLine(BitConverter.ToString(buffer));

>>
54-B1-01-00

It should be 1B154, as that's what Decimel 110932 is in Hex.
110932 is the decimal value I'm trying to read from memory.

Whats going on here?
Was this page helpful?