Need Help with classMemory.ahk (RHCP!) with modulePatternScan

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
deten
Posts: 4
Joined: 22 Sep 2019, 03:33

Need Help with classMemory.ahk (RHCP!) with modulePatternScan

22 Sep 2019, 03:39

Hi,

I am trying to use this script to find a hexadecimal location attached to a game. I thought I had done a half decent job but I just, cannot, for the life of me get this to work.

I found the hex using Cheat Engine and I know its good (I can confirm) but I never successfully find the scan.

Code: Select all

#Include <classMemory>
_classmemory.setSeDebugPrivilege()

lou := new _ClassMemory()

hexpattern := ["??", "??", "??", 3F, 00, 00, 80, 3F, 01, 00, 80, 3F, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 01, 00, 80, 3F, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 01, 00, 80, 3F, 00, 00, 00, 00, 0F, 00, E0, 41, 12, 00, F0, C1, 00, 00, 00, 00, 00, 00, 80, 3F, 01, 01, 01, 00, 00, 00, 80, 3F, 00, 00, 00, 00, "??", "??", 18, 00, 37]

stringAddress := lou.modulePatternScan(, hexpattern*)

if stringAddress > 0  ; you had a typo in stringAddress 
{
    msgbox AHK found string at addess: %stringAddressHex%
}
else
{
    msgbox Not Found!`nReturn Value: %stringAddress%
}
RHCP
Posts: 202
Joined: 30 Sep 2013, 10:59

Re: Need Help with classMemory.ahk (RHCP!) with modulePatternScan

22 Sep 2019, 06:31

Code: Select all

#Include <classMemory>
_classmemory.setSeDebugPrivilege()

if !A_IsAdmin
{
	Run *RunAs "%A_ScriptFullPath%"
	ExitApp
}
if (_ClassMemory.__Class != "_ClassMemory")
{
	msgbox class memory not correctly installed.
	ExitApp
}

; I don't know if you removed it on purpose in your posted code snippet,
; but you need to use a wintitle/process name when calling new _ClassMemory() eg
lou := new _ClassMemory("ahk_exe lou.exe", "", hProcess) 
if !IsObject(lou)
{
	if (hProcess = "")
		msgbox OpenProcess failed. If the target process has admin rights, then the script also needs to be ran as admin. Consult A_LastError for more information.
	else msgbox The program isn't running (not found) or you passed an incorrect program identifier parameter.
	msgbox A_LastError %A_LastError%
	ExitApp
}


; Hex numbers need a 0x prefix.
hexpattern := ["??", "??", "??", 0x3F, 0x00, 0x00, 0x80, 0x3F, 0x01, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xE0, 0x41, 0x12, 0x00, 0xF0, 0xC1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00, "??", "??", 0x18, 0x00, 0x37]

stringAddress := lou.modulePatternScan(, hexpattern*)

if stringAddress > 0  
{
    msgbox AHK found string at addess: %stringAddressHex%
}
else
{
    msgbox Not Found!`nReturn Value: %stringAddress%
}
deten
Posts: 4
Joined: 22 Sep 2019, 03:33

Re: Need Help with classMemory.ahk (RHCP!) with modulePatternScan

22 Sep 2019, 09:54

RHCP wrote:
22 Sep 2019, 06:31

; I don't know if you removed it on purpose in your posted code snippet,
; but you need to use a wintitle/process name when calling new _ClassMemory() eg
lou := new _ClassMemory("ahk_exe lou.exe", "", hProcess)
if !IsObject(lou)
{
if (hProcess = "")
msgbox OpenProcess failed. If the target process has admin rights, then the script also needs to be ran as admin. Consult A_LastError for more information.
else msgbox The program isn't running (not found) or you passed an incorrect program identifier parameter.
msgbox A_LastError %A_LastError%
ExitApp
}
Thanks, I didnt know that the process name is actually 3 words (Lords of Xulima) and the exe is Lords of Xulima.exe. So would I put:

Code: Select all

lou := new _ClassMemory("ahk_exe Lords of Xulima.exe", "", hProcess) 
RHCP wrote:
22 Sep 2019, 06:31
; Hex numbers need a 0x prefix.
hexpattern := ["??", "??", "??", 0x3F, 0x00, 0x00, 0x80, 0x3F, 0x01, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xE0, 0x41, 0x12, 0x00, 0xF0, 0xC1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00, "??", "??", 0x18, 0x00, 0x37]
Should unknown hex numbers have prefix? 4 question marks? 2 question marks? Or just 1 question mark?
  • "????"
    "??"
    "?"
    "0x??"
Thanks
deten
Posts: 4
Joined: 22 Sep 2019, 03:33

Re: Need Help with classMemory.ahk (RHCP!) with modulePatternScan

22 Sep 2019, 21:17

To Add on, here is my current code:

Code: Select all

#Include <classMemory>
_classmemory.setSeDebugPrivilege()

if !A_IsAdmin
{
	Run *RunAs "%A_ScriptFullPath%"
	ExitApp
}
if (_ClassMemory.__Class != "_ClassMemory")
{
	msgbox class memory not correctly installed.
	ExitApp
}

lox := new _ClassMemory("ahk_exe Legends of Xulima.exe", "", hProcess) 

if !IsObject(lox)
{
	if (hProcess = 0)
        msgbox The program isn't running (not found) or you passed an incorrect program identifier parameter. In some cases _ClassMemory.setSeDebugPrivilege() may be required. 
    else if (hProcessCopy = "")
         msgbox OpenProcess failed. If the target process has admin rights, then the script also needs to be ran as admin. _ClassMemory.setSeDebugPrivilege() may also be required. Consult A_LastError for more information.
    ExitApp
}


; Hex numbers need a 0x prefix.
hexpattern := [0x00, 0x00, 0x80, 0x3F, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "?", "?", "?", "?", "?", "?", 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "?", "?", "?", "?", "?", "?", 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "?", "?", "?", "?", "?", "?", 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "?", "?", "?", "?", "?", "?", 0x00, 0x00, "?", "?", "?", 0x3F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "?", "?", "?", "?", "?", "?", 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "?", "?", "?", "?", "?", "?", 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "?", "?", "?", "?", "?", "?", 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "?", "?", "?", "?", "?", "?", 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "?", "?", "?", "?", "?", "?", 0x00, 0x00, 0x00, 0x00]

stringAddress := lox.modulePatternScan("Legends of Xulima.exe", hexpattern*)

if stringAddress > 0  
{
    msgbox AHK found string at addess: %stringAddressHex%
}
else
{
    msgbox Not Found!`nReturn Value: %stringAddress%
}
In Cheat Engine, searching for this find it right away:

AoB Search: 00 00 80 3F 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? ?? 00 00 ?? ?? ?? 3F 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? ?? 00 00 00 00 80 3F 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? ?? 00 00 00 00

https i.imgur.com /knWvCxn.png Broken Link for safety

Using the AHK searching for the same in the correct format gives me this:

0x00, 0x00, 0x80, 0x3F, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "?", "?", "?", "?", "?", "?", 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "?", "?", "?", "?", "?", "?", 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "?", "?", "?", "?", "?", "?", 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "?", "?", "?", "?", "?", "?", 0x00, 0x00, "?", "?", "?", 0x3F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "?", "?", "?", "?", "?", "?", 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "?", "?", "?", "?", "?", "?", 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "?", "?", "?", "?", "?", "?", 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "?", "?", "?", "?", "?", "?", 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "?", "?", "?", "?", "?", "?", 0x00, 0x00, 0x00, 0x00

https i.imgur.com /68VbFti.png Broken Link for safety

And last item. The value is actually Float, is there an easy way to convert to Float format? (assuming it works)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 402 guests