This is my current code I have on a timer
myMemory.ReadProcess = myProcess[0];
myMemory.Open();
int pointerAddress = HexToDec(HealthPointer);
int[] pointerOffset = HealthOffest;
int tempBytesToRead;
uint valueToRead = 8;
byte[] oldHealth = myMemory.PointerRead((IntPtr)pointerAddress, valueToRead, pointerOffset, out tempBytesToRead);
HealthToFill = BitConverter.ToInt32(oldHealth, 0) + 1;
int bytesWritten;
//Get current health
byte[] valueToWrite = BitConverter.GetBytes(HealthToFill);
string writtenAddress = myMemory.PointerWrite((IntPtr)pointerAddress, valueToWrite, pointerOffset, out bytesWritten);
myMemory.CloseHandle();
This code writes to the address just fine but when I try to read it always returns 0. By the way, HealthToFill is a float and yes I have tried BitConverter.ToSingle(oldHealth,0)
. But I debugged it and it seems the byte array oldHealth
isn't getting any data written to it. If the float I'm trying to read can be between 3-6 integers and numerous decimal places what would be a good value to use for uint valueToRead
?