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 


Conditional AOBScan on a single Script

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
LewcowVaal
Advanced Cheater
Reputation: 0

Joined: 30 Dec 2017
Posts: 63

PostPosted: Sat Apr 06, 2024 4:57 am    Post subject: Conditional AOBScan on a single Script Reply with quote

I have a classic Script made with the AOB Injection template of CE (that, of course, registers a SymbolName at the found address).

What i would like to do is to check if the SymbolName already exists. If not, run the aobscan, otherwise, use the already existing Symbol for the ASM code, all in a single Script.

What's the best way of doing it? Is it possible to do it with ASM only or is it better to use LUA in this case?


I was thinking about doing something like this:

Code:

[ENABLE]

{$LUA}
if not getAddressSafe'mynewaob' then

local resultaddr = AOBScan('48 63 52 34 89 95 80 FD FF FF')

registerSymbol('mynewaob', resultaddr)

end

{$ASM}

// aobscan(mynewaob,48 63 52 34 89 95 80 FD FF FF) // this is commented out


alloc(newmem,$1000,mynewaob)


label(code)
label(return)

newmem:

code:
  // code here
  jmp return

mynewaob:
  jmp newmem
  nop 5
return:
// registersymbol(mynewaob) //commented


[DISABLE]

mynewaob:
  db 48 63 52 34 89 95 80 FD FF FF

//unregistersymbol(mynewaob)   i don't want to unregister it since i'm gonna reuse it later.
dealloc(newmem)


Beside the fact that Cheat Engine tells me that the code is not Injectable (the AutoAssembler does not understand what mynewaob is since i defined it in LUA and not in the ASM part), i think i am misunderstanding code execution order (between LUA and ASM).

What's the best practice? Is it possible to do it in ASM only?

Thanks!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 459

Joined: 09 May 2003
Posts: 25317
Location: The netherlands

PostPosted: Sat Apr 06, 2024 6:49 am    Post subject: Reply with quote

Code:

{$lua}
if not getAddressSafe("symbol") then
  return [[aobscan(symbol, xx xx xx)
registersymbol(symbol)
]]
end

{$asm}


_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
LewcowVaal
Advanced Cheater
Reputation: 0

Joined: 30 Dec 2017
Posts: 63

PostPosted: Sat Apr 06, 2024 7:00 am    Post subject: Reply with quote

Dark Byte wrote:
Code:

{$lua}
if not getAddressSafe("symbol") then
  return [[aobscan(symbol, xx xx xx)
registersymbol(symbol)
]]
end

{$asm}



Works perfectly.

Am i returning ASM? Also, is it possible to define custom templates in the Auto Assemble?

Thanks!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 459

Joined: 09 May 2003
Posts: 25317
Location: The netherlands

PostPosted: Sat Apr 06, 2024 8:46 am    Post subject: Reply with quote

yes, what a lua block returns will be interpreted as AA code

for custom templates the 8 functions at https://github.com/cheat-engine/cheat-engine/blob/dc08c7db1d9b936e4e486ad78e7aa73308b6bb5b/Cheat%20Engine/bin/celua.txt#L331 can be helpful

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
LewcowVaal
Advanced Cheater
Reputation: 0

Joined: 30 Dec 2017
Posts: 63

PostPosted: Sat Apr 06, 2024 11:15 am    Post subject: Reply with quote

Dark Byte wrote:
yes, what a lua block returns will be interpreted as AA code

for custom templates the 8 functions at https://github.com/cheat-engine/cheat-engine/blob/dc08c7db1d9b936e4e486ad78e7aa73308b6bb5b/Cheat%20Engine/bin/celua.txt#L331 can be helpful


That's perfect. Thank you Cool

Is the default AOB Injection template written in LUA? So i can look at it and make my own modifications

EDIT: I found what i was looking for, boss
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 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