ahk and memory read/write like cheat engine? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Trigun
Posts: 41
Joined: 29 Mar 2017, 01:33

ahk and memory read/write like cheat engine?

01 May 2020, 10:40

hello,
i found old posts (2015) with functions for read and write on the memory but they use always a memory position for read the value

some1 already made a function for search a value in the memory like cheat engine ?

i don't think is hard to do something like

Code: Select all

checkValue(mem, value) {
valuebyte = firstbyteof value
value = value.substring(firstbyte)

if (valuebyte == valueInMem(mem)) {
if (value.length > 0)
	return checkvalue(mem+1,value)
else return true
else false;
}

searchValue(program, value) {
results[] 
for (i=0, i<program.memorysize;i++) {
if (checkValue(program + i, value)) result.push(program+i)
return results
}
writed now in pseudocode :-)

the main problem of this method is that u query every position of the memory and i don't think the dllcall used in the functions for read the memory is fast enought for check everything

u know if there is a lib or something already done ?
i wanna read some values from a game but i can't find the static address, and with ocr i have a 20% of wrong reads, but the search of the value is easy to do in cheat engine with 2 searchs
Trigun
Posts: 41
Joined: 29 Mar 2017, 01:33

Re: ahk and memory read/write like cheat engine?

09 May 2020, 13:33

thanks for the link, didn't finded that library but only functions for read and write

Code: Select all

tempVar := 0x00000000
        ;~ SetFormat, integer, hex
        memory.readRaw(0x21E2B010, tempVar,10240000) ;the start value is finded with cheatengine for tests 
        results := searchValue(tempVar,temp2,10240000) ;temp2 is an array of charcodes
                ListVars
                MsgBox

checkValue(ByRef s1, v1, c1) {
    t1 := NumGet(s1,c1 -1,"UChar") ;test var for breakpoints
    t2 := v1[c1] ;test var for breakpoints
    if (NumGet(s1,c1 -1,"UChar") == v1[c1]) {
        if (c1 < v1.length())
            return checkvalue(s1,v1,c1+1)
        else return true
        }
    else return false
}

searchValue(ByRef memory, values,dim) {
    results[] 
    Loop, %dim% {
        if (checkValue(memory, values,A_Index))
            results.push(memory+A_Index)
        }
    return results
}
i writed this lines but i have a few problems
1- the results is empty .. i think bc memory is ByRef and it fails, need to understand how i can save the result but not a big deal... worst case i can use result byref and bypass the problem
2- the loop is slow, any idea how i can improve the speed of the check? it can be reduced minimally by prevent the recursion and force only 1 scan for each byte, but this will not decrease alot and i plan to scan the entire memory (untill 0xFFFFFFFF), i think the problem is in if (NumGet(s1,c1 -1,"UChar") == v1[c1]) { probably the numget isn't the best way?
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: ahk and memory read/write like cheat engine?

09 May 2020, 13:53

why dont u use one of the patternscan functions the lib already u provides instead of doing... whatever the hell that recursion is meant to do?
also results[] doesnt declare and instantiate an array
Trigun
Posts: 41
Joined: 29 Mar 2017, 01:33

Re: ahk and memory read/write like cheat engine?

09 May 2020, 16:00

emm about the scan function... didn't noticed was already made :-D saw only the "common function" and was thinking the less common was some subfunction needed for the other functions :-D
and since i didn't saw in the exemple code the use of the search i just skipped the comment of every function :-)
i'll study better and try again :-) tnx for the reminder :-)

for the declaration... yep i forgot :-) i was writing in javascript before write that code and in js u can basically do what u want with all the vars :-D

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: GooGooPark and 127 guests