在 AHK 中读取程序存储器
Reading Program Memory In AHK
所以我正在开发一个从游戏(Mitos.is:游戏)中读取值的程序。
它类似于 Agar.io
你有一个size(mass),我要获取mass amount,是程序,不是像Agar.io这样的网游。
我找到了这个自动热键脚本:
#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.
ReadMemory(MADDRESS=0,PROGRAM="",BYTES=4)
{
Static OLDPROC, ProcessHandle
VarSetCapacity(MVALUE, BYTES,0)
If PROGRAM != %OLDPROC%
{
WinGet, pid, pid, % OLDPROC := PROGRAM
ProcessHandle := ( ProcessHandle ? 0*(closed:=DllCall("CloseHandle"
,"UInt",ProcessHandle)) : 0 )+(pid ? DllCall("OpenProcess"
,"Int",16,"Int",0,"UInt",pid) : 0)
}
If (ProcessHandle) && DllCall("ReadProcessMemory","UInt",ProcessHandle,"UInt",MADDRESS,"Str",MVALUE,"UInt",BYTES,"UInt *",0)
{ Loop % BYTES
Result += *(&MVALUE + A_Index-1) << 8*(A_Index-1)
Return Result
}
return !ProcessHandle ? "Handle Closed:" closed : "Fail"
}
mass := ReadMemory(Address here, "Mitos.is: The Game")
MsgBox, %mass%
它可以无缝运行,但有一个小问题,在 Cheat Engine 中我冒昧地找到了基地址,如下所示:
所以我把这里圈出来的地址拿走了:
然后将其插入程序中显示 "Address Here" 的位置,如果地址不正确请纠正我,但是当我重新启动游戏和 运行 我的脚本时显示 "Fail",但在 Cheat Engine 中地址仍然有效。帮忙?
如果重新启动游戏后地址发生变化,请检查地址,或者不要重新启动游戏只是 运行 没有重新启动的脚本并且您还没有定义字节所以请尝试以下,
ReadMemory(MADDRESS=0, PROGRAM="", BYTES=4 )
mass := ReadMemory("0x123456", "Mitos.is: The Game", "4")
"PROGRAM" 应该是正确的 window 标题使用间谍获得正确的 window 标题,地址必须是十六进制值,即“0x15B29DD0”,我不知道你的如何作弊引擎读取程序内存地址。
所以我正在开发一个从游戏(Mitos.is:游戏)中读取值的程序。 它类似于 Agar.io
你有一个size(mass),我要获取mass amount,是程序,不是像Agar.io这样的网游。
我找到了这个自动热键脚本:
#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.
ReadMemory(MADDRESS=0,PROGRAM="",BYTES=4)
{
Static OLDPROC, ProcessHandle
VarSetCapacity(MVALUE, BYTES,0)
If PROGRAM != %OLDPROC%
{
WinGet, pid, pid, % OLDPROC := PROGRAM
ProcessHandle := ( ProcessHandle ? 0*(closed:=DllCall("CloseHandle"
,"UInt",ProcessHandle)) : 0 )+(pid ? DllCall("OpenProcess"
,"Int",16,"Int",0,"UInt",pid) : 0)
}
If (ProcessHandle) && DllCall("ReadProcessMemory","UInt",ProcessHandle,"UInt",MADDRESS,"Str",MVALUE,"UInt",BYTES,"UInt *",0)
{ Loop % BYTES
Result += *(&MVALUE + A_Index-1) << 8*(A_Index-1)
Return Result
}
return !ProcessHandle ? "Handle Closed:" closed : "Fail"
}
mass := ReadMemory(Address here, "Mitos.is: The Game")
MsgBox, %mass%
它可以无缝运行,但有一个小问题,在 Cheat Engine 中我冒昧地找到了基地址,如下所示:
所以我把这里圈出来的地址拿走了:
然后将其插入程序中显示 "Address Here" 的位置,如果地址不正确请纠正我,但是当我重新启动游戏和 运行 我的脚本时显示 "Fail",但在 Cheat Engine 中地址仍然有效。帮忙?
如果重新启动游戏后地址发生变化,请检查地址,或者不要重新启动游戏只是 运行 没有重新启动的脚本并且您还没有定义字节所以请尝试以下,
ReadMemory(MADDRESS=0, PROGRAM="", BYTES=4 )
mass := ReadMemory("0x123456", "Mitos.is: The Game", "4")
"PROGRAM" 应该是正确的 window 标题使用间谍获得正确的 window 标题,地址必须是十六进制值,即“0x15B29DD0”,我不知道你的如何作弊引擎读取程序内存地址。