I used cheat engine to search for a string in 'Notepad++'. Then I got '1897E119A50' address that contain the string. I want to read 100 bytes of strings starting from that address.
However ProcessMemory.ReadByteArray function will only accept IntPtr address. How do I convert the cheat engine address to IntPtr?
ProcessMemory p3 = new ProcessMemory("Notepad++");
var b2 = p3.ReadByteArray((IntPtr)0x1897E119A50, 100); //<-I get 'Arithmetic operation resulted in an overflow'
var str = getStringFromBytes(b2);
Let's take a look at the documentation, shall we?
Exceptions
OverflowException
In a 32-bit process, value is too large to represent as an IntPtr.
Well, there you have it. IntPtr
has the size of a pointer, so its maximum size depends on whether you're building a 32 bit or 64 bit application. In a 32 bit process, it's also 32 bits, so it cannot hold anything larger than uint.MaxValue
. There's just not enough bytes in there.
0x1897E119A50
is too big for it (it's a long
), so you'll have to make the switch by targeting x64.