I’m trying to extract the value from a memory address using the base address of a .dll + offsets.
I used Cheat Engine to find the base address, and pymem to get the base address as hex.
Here’s the code I used to find the base address:
JavaScript
x
8
1
import pymem
2
pm = pymem.Pymem("PD.exe")
3
baseAddress = pymem.process.module_from_name(pm.process_handle, "jvm.dll").lpBaseOfDll
4
5
print(hex(baseAddress))
6
7
#output: 0x51250000
8
For reading the value I’m using ReadWriteMemory.
JavaScript
1
11
11
1
from ReadWriteMemory import ReadWriteMemory
2
3
rwm = ReadWriteMemory()
4
5
process = rwm.get_process_by_id(4372)
6
process.open()
7
8
hp_pointer = process.get_pointer(0x51250000 + 0x0036e654, offsets=[0x28, 0x1d0, 0x26, 0x3a, 0x12])
9
hp = process.read(hp_pointer)
10
print(hp)
11
I used the output from the first code as the base address and added +0036e654
to it, but the output is always 0.
If I replace “jvm.dll” with 51250000 in Cheat Engine the addresses are still calculated correctly.
Advertisement
Answer
I was getting it all wrong from the start. The pointer offsets showed in Cheat Engine are hex values, so the offsets should be offsets=[0x40, 0x464, 0x38, 0x58, 0x18]
.