Code: Select all
ReadMemory(MADDRESS,PROGRAM,byte := 4)
{
winget, pid, PID, ahk_id %program%
VarSetCapacity(MVALUE,4,0)
ProcessHandle := DllCall("OpenProcess", "Int", 24, "Char", 0, "UInt", pid, "UInt")
DllCall("ReadProcessMemory","UInt",ProcessHandle,"UInt",MADDRESS,"Str",MVALUE,"UInt",4,"UInt *",0)
Loop % byte
result += *(&MVALUE + A_Index-1) << 8*(A_Index-1)
return, result
}
Code: Select all
ReadMemory(MADDRESS,PROGRAM,byte := 4)
{
pid := WinGetPID("ahk_id " program)
MVALUE := Buffer(4, 0) ; V1toV2: if 'MVALUE' is a UTF-16 string, use 'VarSetStrCapacity(&MVALUE, 4)'
ProcessHandle := DllCall("OpenProcess", "Int", 24, "Char", 0, "UInt", pid, "UInt")
DllCall("ReadProcessMemory", "UInt", ProcessHandle, "UInt", MADDRESS, "Str", MVALUE, "UInt", 4, "UInt *", 0)
Loop byte
result += *(&MVALUE + A_Index-1) << 8*(A_Index-1) ;<<<
return result
}