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 


Use cheat table value in AOB script?

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

Joined: 21 Oct 2023
Posts: 20

PostPosted: Fri Jun 28, 2024 9:57 pm    Post subject: Use cheat table value in AOB script? Reply with quote

Hi all, I have my base player pointer held in my cheat table as BasePlayer, is there a way I can use this in an AOB script, for example to compare RCX to the address in BasePlayer?

Basically have shared op codes so was thinking if I can access that value I can just compare RCX to the address in BasePlayer.

Thanks
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4697

PostPosted: Fri Jun 28, 2024 10:36 pm    Post subject: Reply with quote

If the symbol is registered (e.g. registersymbol / globalalloc functions) you can use it directly in the script.
You won't be able to activate the script if the symbol isn't registered, however. Most people solve this by making that script a child of the script that defines the symbol, then hiding children if the parent script is disabled (right click menu).
You could also put globalalloc in both scripts. CE only allocates globalalloc memory once and never deallocates it.

Script 1:
Code:
...
alloc(BasePlayer,8)

BasePlayer:
  dq 0

newmem:
  mov [BasePlayer],rsi
  ...

registersymbol(BasePlayer)
...

Script 2:
Code:
...
newmem:
  push rbx
  mov rbx,BasePlayer  // might not be able to directly address the memory if it's not nearby
  cmp [rbx],rcx
  pop rbx
  je ...
Note that the code injection in the second script might run before script 1 has initialized BasePlayer. Check if it's 0 if that matters.
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
jonboy999
Newbie cheater
Reputation: 0

Joined: 21 Oct 2023
Posts: 20

PostPosted: Sat Jun 29, 2024 2:54 am    Post subject: Reply with quote

ParkourPenguin wrote:
If the symbol is registered (e.g. registersymbol / globalalloc functions) you can use it directly in the script.
You won't be able to activate the script if the symbol isn't registered, however. Most people solve this by making that script a child of the script that defines the symbol, then hiding children if the parent script is disabled (right click menu).
You could also put globalalloc in both scripts. CE only allocates globalalloc memory once and never deallocates it.

Script 1:
Code:
...
alloc(BasePlayer,8)

BasePlayer:
  dq 0

newmem:
  mov [BasePlayer],rsi
  ...

registersymbol(BasePlayer)
...

Script 2:
Code:
...
newmem:
  push rbx
  mov rbx,BasePlayer  // might not be able to directly address the memory if it's not nearby
  cmp [rbx],rcx
  pop rbx
  je ...
Note that the code injection in the second script might run before script 1 has initialized BasePlayer. Check if it's 0 if that matters.


Thank you, would you recommend doing it with another auto population script, or should i access it through its pointer in just one script?

Out of interest is this what cheat tables are doing when you press [enable] (populating values in the background before you actually enable the cheats)?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4697

PostPosted: Sat Jun 29, 2024 10:45 am    Post subject: Reply with quote

If it's a pointer, you could traverse the pointer path manually.
Code:
push rbx
mov rbx,[game.exe+1234]
mov rbx,[rbx+3E8]
mov rbx,[rbx+D0]
cmp rbx,rcx
pop rbx
je ...

jonboy999 wrote:
Out of interest is this what cheat tables are doing when you press [enable] (populating values in the background before you actually enable the cheats)?
I'm not sure what you mean by that. When you enable an AA script, CE's Auto Assembler does what you write in the script.
If you're talking about the assembly code written in the script, the game will execute that when the original code was supposed to be executed. e.g. if you inject code at an injection point that's only run when a button is pressed, your injected code will only run when the button is pressed. It won't magically run on its own the instant the script is enabled.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
jonboy999
Newbie cheater
Reputation: 0

Joined: 21 Oct 2023
Posts: 20

PostPosted: Sun Jun 30, 2024 8:37 am    Post subject: Reply with quote

ParkourPenguin wrote:
If it's a pointer, you could traverse the pointer path manually.
Code:
push rbx
mov rbx,[game.exe+1234]
mov rbx,[rbx+3E8]
mov rbx,[rbx+D0]
cmp rbx,rcx
pop rbx
je ...

jonboy999 wrote:
Out of interest is this what cheat tables are doing when you press [enable] (populating values in the background before you actually enable the cheats)?
I'm not sure what you mean by that. When you enable an AA script, CE's Auto Assembler does what you write in the script.
If you're talking about the assembly code written in the script, the game will execute that when the original code was supposed to be executed. e.g. if you inject code at an injection point that's only run when a button is pressed, your injected code will only run when the button is pressed. It won't magically run on its own the instant the script is enabled.


What i meant was when i download a cheat table you can't normally see anything and have to check that [enable] box and then all the options for the cheats appear, so i am guessing it forces you to press it so that everything populates, as if the game is out of date the enable button wont work so i wont see any cheats (i mean in exisiting cheat tables others have created)
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4697

PostPosted: Sun Jun 30, 2024 11:21 am    Post subject: Reply with quote

They all still exist; they're just hidden when the script is disabled. Right click a memory record that has others appended to it and select "Group config -> Hide children when deactivated"
_________________
I don't know where I'm going, but I'll figure it out when I get there.
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