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 


Problem using non-static symbols in another script

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Pathologic
How do I cheat?
Reputation: 0

Joined: 19 Aug 2020
Posts: 2

PostPosted: Wed Aug 19, 2020 12:16 pm    Post subject: Problem using non-static symbols in another script Reply with quote

I'm trying to write a pair of Auto Assembly scripts that can be enabled at the same time and work as intended. I need to be able to reference an address used in an instruction which doesn't stay the same, so here's what I've tried:

The first script takes the address I want from rsi during an instruction, and stores it in memory for later use:

Script 1 snippet:
Code:
newmem:
mov [currentAddress], rsi
pop rsi
ret

currentAddress:
dq 00

registersymbol(currentAddress)


That symbol is registered and I can see it updating properly in the address list every time that instruction is called.

In the second script, I use the registered symbol to reference the current address stored there, with an offset to access whatever value I want near there:

Script 2 snippet:
Code:
newmem:
add rax,[[currentAddress]+2CD8]
mov [rbp+r11*8+0007F8A0],rax


The problem is that the value given by "currentAddress" in Script 2 is only ever the same as what it was when Script 2 was enabled. So, when enabling both scripts at once before the instructions occur, Script 2 reads a null address from currentAddress. Activating Script 2 after the instruction in Script 1 occurs gives the correct address, but the address read from "currentAddress" by Script 2 does not change when the instruction in Script 1 fires again, even though it looks fine in the address list.

What can I do here? I don't know enough about CE to know why exactly this is happening or what to do about it.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Wed Aug 19, 2020 12:36 pm    Post subject: Reply with quote

add rax,xxx does not support direct 64-bit addresses

mov reg,imm64 does though (and mov rax,[xxxx] does as well, but that's a special case, and rax is already in use here, so let's keep it simple)

so you could try
Code:

push rbx
mov rbx,currentaddress
mov rbx,[rbx]
add rax,[rbx+2cd8]
pop rbx
mov [rbp+r11*8+0007F8A0],rax

_________________
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


Last edited by Dark Byte on Wed Aug 19, 2020 2:24 pm; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
panraven
Grandmaster Cheater
Reputation: 62

Joined: 01 Oct 2008
Posts: 959

PostPosted: Wed Aug 19, 2020 1:37 pm    Post subject: Reply with quote

I'll suggest

1. use globalalloc(currentAddress,16) instead of using registerSymbol, this prevent in case script 1 is somehow deactivated and dealloc (global will not dealloc in same process) before script 2, and cause script 2 reference an unreadable symbol; global symbol is auto registered, so no need registerSymbol command;
2. same as 1, place script 2 under script 1, and tick 1st 3 group property of script 1, this is because globalalloc symbol may stay the same as previous process sometime if it is readable (changing process may not clear the global symbol); these config will force reset the global symbol if need;
3. set the symbol content value to null during script 1 activated, and check the symbol non-null during executing script 2 native code, ie.
Code:

///script 1
globalalloc(currentAddress,16)
...
currentAddress:
dq 0                       /////only set null once during script executed
...
newmem:
push    rbx
mov     rbx,currentAddress
mov     [rbx], rsi       ///// update currentAddress content when this cave executed
pop     rbx
pop rsi
ret
...

////script 2 -- same as DB's code, but check the symbol non-null before using it
...
push    rbx
mov     rbx,currentaddress   
mov     rbx,[rbx]    ///// is content null?
test    rbx,rbx
je      short @f
  add   rax,[rbx+2cd8]
@@:
pop rbx
mov [rbp+r11*8+0007F8A0],rax
...


_________________
- Retarded.
Back to top
View user's profile Send private message
Pathologic
How do I cheat?
Reputation: 0

Joined: 19 Aug 2020
Posts: 2

PostPosted: Wed Aug 19, 2020 2:12 pm    Post subject: Reply with quote

Dark Byte wrote:
add rax,xxx does not support direct 64-bit addresses

mov reg,imm64 does though (and mov rax,[xxxx] does as well, but that's a special case, and rax is already in use here, so let's keep it simple)

so you could try
Code:

push rbx
mov rbx,currentaddress
mov rbx,[rbx]
add rax,[rbx+2cd8]
pop rbx
mov [rbp+r11*8+0007F8A0],rax


This simple solution works for me. Thanks! I understand the problem now.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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