Im trying to fool around with Windows’s Minesweeper, getting how many bombs left and such.
Got this up and working:
public static byte[] ReadBytes(IntPtr memoryAddress, uint bytesToRead, out int bytesReaded)
{
byte[] buffer = new byte[bytesToRead];
IntPtr ptrBytesReaded;
ReadProcessMemory(process, memoryAddress, buffer, bytesToRead, out ptrBytesReaded);
bytesReaded = ptrBytesReaded.ToInt32();
return buffer;
}
But I need some help, how do I read a int and a string? Guess i pass the size of a int to the function? what about string?
thanks 🙂
}
I think you have read the Code Project article how to patch minesweeper from Arik Poznanski. Your code is copied from that article.
How to read a int is shown there. If you know the address of the string you can use the string constructor which takes a void * as argument when you use unsafe code. That is the easiest way.
But you should read the article completeley before asking questions which are already answered by the really good writeup.