I'm currently getting garbage data when using ReadProcessMemory to read from another process.

This is my definition:
BOOL ReadProcessMemory(HANDLE hProcess, LPCVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize, SIZE_T *lpNumberOfBytesRead);

And I'm reading it like this:
if (!ReadProcessMemory(process,
      cast(PCVOID)address, cast(PVOID)&data,
      cast(DWORD)stringSize, cast(PDWORD)&bytesRead)) {
      return defaultValue;
    }

process is a HANDLE that I got from OpenProcess()
address is a DWORD
data is char[1024]
stringSize is size_t
bytesRead is PDWORD

The address I obtained was from Ollydbg and it's a static address. I'm not sure if I however need some kind of offset etc.

I tried to search and found you might have to use GetModuleHandleA() but I tried that and I still get garbage data with the offset from that.

What am I doing wrong?

Reply via email to