PyMemoryEditor icon indicating copy to clipboard operation
PyMemoryEditor copied to clipboard

Wrong value at the address

Open Seraphli opened this issue 1 year ago • 5 comments

address = 0x819E5F00

pm = Pymem(process.pid)
value = pm.read_float(address)
print(value)

with OpenProcess(pid=process.pid) as process:
    value = process.read_process_memory(address, float, 4)
    print(value)

pymem read the right value, while PyMemoryEditor get a wrong value. Is any thing wrong with this code?

Seraphli avatar May 22 '24 17:05 Seraphli

There is nothing wrong with this code. Did you make sure that the value in that process memory was not changed?

JeanExtreme002 avatar May 22 '24 23:05 JeanExtreme002

The value (like 5.xxxe-115) PyMemoryEditor given is quite small compare to the value (0.30...) given by Pymem. It's clearly a wrong value.

Seraphli avatar May 23 '24 19:05 Seraphli

Ok, I got it. But, I would like to know if that process is totally under your control and you did make sure that the process is not changing the value during the execution of the PyMemoryEditor method.

JeanExtreme002 avatar May 23 '24 20:05 JeanExtreme002

The process is changing the value, but in a small range. The value is one axis of the camera position. I can watch the value using Cheat Engine, so I can comfirm it didn't change that much.

Seraphli avatar May 24 '24 04:05 Seraphli

I have the same issue but with scanning for float values. And I'm sure that many values from the scan don't change the value after scanning for 100%. I'm scanning for 196.1... and all results are like 3.6... Maybe the scan results are wrong because of the wrong float read issue.

Quazonish avatar Sep 23 '24 13:09 Quazonish

The problem is that the c_type converter utility in this library doesn't consider 32 bit floats.

This function https://github.com/JeanExtreme002/PyMemoryEditor/blob/master/PyMemoryEditor/util/convert.py#L37 should be corrected to:

    elif pytype is float:
        if length == 4: return ctypes.c_float()
        return ctypes.c_double()

cromachina avatar Jun 03 '25 04:06 cromachina