I need to read the amount of arrows on an archer (0-500). I have the pointer and offset, and i can get the right number in cheat engine, however whenever i try to read it from autohotkey i always get 0. Don't know why. I've always read 4 byte data before so i don't really know if i have the right code for 2 byte data. Here's the autohotkey code
Code:
ExtInt(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4); From AutoHotKey Help
{
Loop %pSize%
result += *(&pSource + pOffset + A_Index-1) << 8*(A_Index-1)
if (!pIsSigned OR pSize > 4 OR result < 0x80000000)
return result
return -(0xFFFFFFFF - result + 1)
}
WinGet, pid, PID, [Con
;Check if Process Available
if pid
{
;Base Address
VarSetCapacity(arrowbase,4,0)
;Create 2 Byte (Int) Structure for Arrows
VarSetCapacity(arrows,2,0)
;Open the Process for Handling
ProcessHandle := DllCall("OpenProcess", "Int", 24, "Char", 0, "UInt", pid, "UInt")
;Check if Handle Created
if ProcessHandle
{
;Get the raw 4 Bytes for Arrows Base Address
DllCall("ReadProcessMemory","UInt",ProcessHandle,"UInt",0x0051307C,"Str",arrowbase,"UInt",4,"UInt *",0)
;Get the raw 2 Bytes for Arrows
;DllCall("ReadProcessMemory","UInt",ProcessHandle,"UInt",ExtInt(arrowbase)+46,"Str",arrows,"UInt",2,"UInt *",0)
;Close the Process Handler
DllCall("CloseHandle","int",ProcessHandle)
;Display amount of arrows
MsgBox % "Arrows: " . ExtInt(arrows)
}
}






