这是我在计时器上的当前代码
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();
这段代码可以很好地写入地址,但是当我尝试读取它时,它总是返回 0。顺便说一下,HealthToFill 是一个浮点数,是的,我已经尝试过了BitConverter.ToSingle(oldHealth,0)
。但我调试了它,似乎字节数组oldHealth
没有写入任何数据。如果我要读取的浮点数可以介于 3-6 个整数和多个小数位之间,那么使用什么值会是一个好的值uint valueToRead
?