在AHK中读取程序存储器

时间:2017-05-28 07:25:42

标签: memory autohotkey memory-address

所以我正在开发一个程序来读取游戏中的值(Mitos.is:The Game)。 它与Agar.io

类似

你有一个大小(质量),我想得到质量,它是一个程序,而不是像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中我冒昧地找到了如下所示的基址: Cheat Engine Base Address

所以我把这里的地址圈起来了:Red Circle

并将其插入到“Address Here”的程序中,如果这不是正确的地址,请更正我,但是当我重新启动游戏并运行我的脚本时会显示“失败”,但在Cheat Engine中,地址是还是有效。帮助

1 个答案:

答案 0 :(得分:0)

检查地址是否在重新启动游戏后发生变化,或者不重启游戏只是在没有重启的情况下运行脚本而你没有定义字节,所以请尝试关注,

        ReadMemory(MADDRESS=0, PROGRAM="", BYTES=4 )
mass := ReadMemory("0x123456", "Mitos.is: The Game", "4") 

“PROGRAM”应该是正确的窗口标题使用间谍来获得正确的窗口标题,地址必须是十六进制值,即“0x15B29DD0”,我不知道你的作弊引擎如何读取程序存储器地址。