-1

I'm trying to read a process's memory, but the address I would like to start reading from exceeds the IntPtr and UIntPtr limit.

[DllImport("kernel32.dll", EntryPoint = "ReadProcessMemory")]
    private static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [Out] byte[] lpBuffer, int dwSize, [Out] int lpNumberOfBytesRead);

ReadProcessMemory(ProcessHandle, (IntPtr)0x14EC7B38A, buffer, buffer.Length, bytesused);

Doing this produces a OverflowException exception even if I use a UIntPtr. I have tried using a ulong, but this produces an AccessViolationException exception. What other data type should I use?

Rikus Honey
  • 534
  • 1
  • 3
  • 17

1 Answers1

1

Windows is a 64-bit OS. UInt is 64bits wide. I assume the problem is that your application is either built for 32bit or is built to "Prefer 32bit" (the Visual Studio defaults).

This answer has the details of the setting you want to change.

Community
  • 1
  • 1
Jonathan Dickinson
  • 9,050
  • 1
  • 37
  • 60