I am having issues reading from offsets, I have used a couple of sites to no avail, can someone tell me what i'm doing wrong here
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
;
#Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
MemoryOpenFromPID(PID, Privilege=0x00B6D0C4)
{
HWND := DllCall("OpenProcess", "Uint", Privilege, "int", 0, "int", PID)
return HWND
}
MemoryOpenFromName(Name, Privilege=0x00B6D0C4)
{
Process, Exist, %Name%
PID := ErrorLevel
Return MemoryOpenFromPID(PID, Privilege)
}
MemoryOpenFromTitle(title, privilege=0x00B6D0C4)
{
WinGet, PID, PID, %title%
Return MemoryOpenFromPID(PID, Privilege)
}
MemoryClose(hwnd)
{
return DllCall("CloseHandle", "int", hwnd)
}
MemoryWrite(hwnd, address, writevalue, datatype="int", length=4, offset=0)
{
VarSetCapacity(finalvalue, length, 0)
NumPut(writevalue, finalvalue, 0, datatype)
return DllCall("WriteProcessMemory", "Uint", hwnd, "Uint", address+offset, "Uint", &finalvalue, "Uint", length, "Uint", 0)
}
MemoryRead(hwnd, address, datatype="int", length=4, offset=0)
{
VarSetCapacity(readvalue,length, 0)
DllCall("ReadProcessMemory","Uint",hwnd,"Uint",add ress+offset,"Str",readvalue,"Uint",length,"Uint *",0)
finalvalue := NumGet(readvalue,0,datatype)
return finalvalue
}
MemoryWritePointer(hwnd, base, writevalue, 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%
{
baseresult := MemoryRead(hwnd,base)
Offset := Offset_%A_Index%
SetFormat, integer, h
base := baseresult + Offset
SetFormat, integer, d
}
SetFormat, Integer, %B_FormatInteger%
return MemoryWrite(hwnd,address,writevalue,datatype,lengt h)
}
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%
{
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,datatype,length)
}
WinGet, PID,, "Trove"
hwnd := MemoryOpenFromPID(%PID%)
loop,{
memory := MemoryReadPointer(hwnd, 0x00B6D0C4, datatype="int", length=1, offsets=3, offset_1=0x19C, offset_2=0xC8, offset_3=0x78)
MsgBox, %memory%
}
return
esc::exitapp
return
I got the functions from a forum on autohotkey but I can't post it.