Search code examples
c#readprocessmemory

ReadProcessMemory not working


Basically this isn't returning all of the bytes I'm asking it to.

// ReadBytes Method
byte[] ReadBytes(uint address, int len)
{
    int bytesread = 0;
    byte[] output = new byte[len];
    ReadProcessMemory(HO_Handle, (IntPtr)address, output, len, out bytesread);
    return ouput; // by the time we get here, bytesread == 0x0031E000
}

// Call
byte[] region = ReadBytes(0x0C000000, 0x08000000);

Any ideas as to why this isn't working and how I would go about fixing it?


Solution

  • I still haven't found the cause as to why this isn't working but I restarted my PC and now it works fine. Windows must have been acting up for whatever reason.