Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How to Optimize AOBScan?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
MustangNil
Newbie cheater
Reputation: 0

Joined: 13 Jun 2022
Posts: 12
Location: South America

PostPosted: Tue May 07, 2024 8:12 am    Post subject: How to Optimize AOBScan? Reply with quote

Hello everyone, I'm facing a small issue. The game I'm modifying frequently changes its dynamic address. So, I've created this script to ensure that every time the dynamic address disappears, the AOB ReScan runs normally. The problem is, every time I perform an AOB, the game freezes for a bit, indicating that it's not very optimized. Is there any way to 'save' the dynamic address without losing it after the first AOB? Repeating AOBs doesn't seem very feasible. And of course, pointers aren't an option for me either.

Code:

{$lua}


[ENABLE]

ResultadoAobInvenLeon = AOBScan("C1 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 48 43 00 00 C8 42 ?? ?? ?? ?? ?? ?? 02")

if ResultadoAobInvenLeon == nil then
    FalhaScanInvenLeon = 1
else
    if readInteger("bio4+BF8") == 3 then
        EnderecoParaInvenLeon = ResultadoAobInvenLeon[0]
        EnderecoParaInvenLeon = tonumber(EnderecoParaInvenLeon, 16)
        ValorInvenLeon = EnderecoParaInvenLeon - 0x1E
        FalhaScanInvenLeon = 0
        print("Sucesso!")
        --print(string.format("%X", EnderecoParaInvenLeon - 0x1E))
    end
end

function InvenLeon()
    if FalhaScanInvenLeon ~= 1 then
        writeInteger(ValorInvenLeon, 218)
    end
end


function InvenLeonScan()
    if readInteger("bio4+BF8") ~= 3 and readInteger("bio4+BF8") ~= 262 then
        FalhaScanInvenLeon = 1
        print("BBLABLALBA")
    end

    if FalhaScanInvenLeon == 1 and readInteger("bio4+BF8") == 3 then
        ResultadoAobInvenLeon = AOBScan("C1 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 48 43 00 00 C8 42 ?? ?? ?? ?? ?? ?? 02")
        EnderecoParaInvenLeon = ResultadoAobInvenLeon[0]
        EnderecoParaInvenLeon = tonumber(EnderecoParaInvenLeon, 16)
        ValorInvenLeon = EnderecoParaInvenLeon - 0x1E
        FalhaScanInvenLeon = 0
        print("Sucesso [ReScan]")
    end
end



if ResultadoAobInvenLeon ~= nil then
    if InvenLeonT then InvenLeonT.destroy(); InvenLeonT=nil end
    InvenLeonT = createTimer()
    InvenLeonT.interval = 100
    InvenLeonT.ontimer = InvenLeon
end



if InvenLeonScanT then InvenLeonScanT.destroy(); InvenLeonScanT=nil end
InvenLeonScanT = createTimer()
InvenLeonScanT.interval = 1000
InvenLeonScanT.ontimer = InvenLeonScan




[DISABLE]
if FalhaScanInvenLeon == 0 then
    writeInteger(ValorInvenLeon, 0)
end

if InvenLeonT then InvenLeonT.destroy(); InvenLeonT=nil end
if InvenLeonScanT then InvenLeonScanT.destroy(); InvenLeonScanT=nil end

_________________
As always, with doubts...
Back to top
View user's profile Send private message
Game Hacking Dojo
Master Cheater
Reputation: 1

Joined: 17 Sep 2023
Posts: 250

PostPosted: Tue May 07, 2024 8:28 am    Post subject: Reply with quote

There's no instruction in assembly that is above 15 bytes. Your AOB should at least get the first byte of each line (except if the line is one byte long, then ignore it)

Secondly, you should use module AOB scan which will make your scan 10x faster.

Code:
{$asm}aobscanmodule(aob_example, bio4.exe, C3 C3 C3 C3 C3 C3 C3)


celua.txt
Quote:
AOBScanModuleUnique(modulename, aobstring, OPTIONAL protectionflags, OPTIONAL alignmenttype, OPTIONAL alignmentparam)- Integer : scans for the aobstring in the designated module


The return of AOBScanModuleUnique is the address of the found AOB. So, once you find your AOB the first time check if your variable holding the AOB is 0.

Example in lua:
Code:
AOBScanModuleUnique(process, "48xxxxxxxxxx48xxxxxx48xxxx48xxxx8BxxFFxxxx84xx74xx48xxxxxx48xxxxxx44xxxxxxxx41xxxx41xxxxxx77xx48xxxx8Bxx48xxxx48xxxxxxxxFFxxxxxxxxxx8DxxxxF7xxxxxxxxxx75xx83xxxx74xx40xxxxEBxx40xxxx48xxxxxxxxxxxxE8xxxxxxxx41xxxxxxxxxx40xxxxxxxx44xxxx8Bxx48xxxxE8xxxxxxxx48xxxxxxxx48xxxxxxxx48xxxxxxxxxx")
Back to top
View user's profile Send private message Visit poster's website
MustangNil
Newbie cheater
Reputation: 0

Joined: 13 Jun 2022
Posts: 12
Location: South America

PostPosted: Tue May 07, 2024 9:37 am    Post subject: Reply with quote

Stopped crashing as a magicic, thank you very much!
_________________
As always, with doubts...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites