I want to expand my knowledge about reading values out of processes. So i want to read the health of my char in the game Trove.
With Cheatengine i got a multilevel pointer to the Health value of my Char. With Cheatengine i can read the value, but how can i read it with Autohotkey?
The problem is the value is not frome trove.exe, it is from iggy_w32.dll and i dont know how to read values out of .dll files with Autohotkey.
I have to following program, which should read the value out of the iggy_w32.dll but when i try to start the script it throws an error. You can copy the code in a script and will get the error, so you can see the error message.
Please help me
Code: Select all
;My Program for reading the Health value with a multilevel pointer out of iggy_w32.dll:
hwnd := MemoryOpenFromName("iggy_w32.dll")
Health := MemoryReadPointer(hwnd, 0x000B5860, "int", 4, 4, 0x8, 0x10, 0x64, 0x364)
MsgBox HP = %Health%.
;Library(Methoden)
MemoryReadPointer(hwnd, base, datatype="int", length=4, offsets=0, offset_1=0, offset_2=0, offset_3=0, offset_4=0, offset_5=0, offset_6=0, offset_7=0, offset_8=0, offset_9=0)
{
B_FormatInteger := A_FormatInteger
Loop, %offsets%s
{
baseresult := MemoryRead(hwnd,base)
Offset := Offset_%A_Index%
SetFormat, integer, h
base := baseresult + Offset
SetFormat, integer, d
}
SetFormat, Integer, %B_FormatInteger%
return MemoryRead(hwnd,base,datatyp,length)
}
MemoryOpenFromName(Name, Privilege=0x1F0FFF)
{
Process, Exist, %Name%
PID := ErrorLevel
Return MemoryOpenFromPID(PID, Privilege)
}
MemoryOpenFromPID(PID, Privilege=0x1F0FFF)
{
HWND := DllCall("OpenProcess", "Uint", Privilege, "int", 0, "int", PID)
return HWND
}
MemoryRead(hwnd, address, datatype="int", length=4, offset=0)
{
VarSetCapacity(readvalue,length, 0)
DllCall("ReadProcessMemory","Uint",hwnd,"Uint",address+offset,"Str",readvalue,"Uint",length,"Uint *",0)
finalvalue := NumGet(readvalue,0,datatype)
return finalvalue
}