 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
mop Advanced Cheater
Reputation: 7
Joined: 05 Mar 2009 Posts: 55
|
Posted: Sun Apr 10, 2022 11:20 pm Post subject: Cannot use registered values from one table to another? |
|
|
Hi,
I have written 2 scripts one is a auto assemble script which injects into the game exe but the other is a Createthread script which only runes on its own,
I am trying to get a value from the injected script into the create thread script but no matter what I do the the create thread script does not turn on unless I removed all reference to the value from injected script being used in the create thread script then it turs on, why is that?
is it a intended limitation ? am I missing something?
I am on CH v7.4, i had used Lazarus to build CE
Script 1 - I am trying to access [PlayerResBase] in Script 2 from Script 1
| Code: |
[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
aobscanmodule(Resources,Sp1.exe,F3 0F 10 8B ?? ?? 00 00 4C 89 E1 E8 A5 9B 3F) // should be unique
alloc(newmem,$1000,Resources)
alloc(PlayerResBase,4)
label(code)
label(return)
newmem:
cmp [PlayerResBase],0
jne code
mov [PlayerResBase],rbx
jmp code
code:
movss xmm1,[rbx+00000198]
jmp return
PlayerResBase:
dd 00
Resources:
jmp newmem
nop 3
return:
registersymbol(Resources)
registersymbol(code)
registersymbol(PlayerResBase)
[DISABLE]
//code from here till the end of the code will be used to disable the cheat
Resources:
db F3 0F 10 8B 98 01 00 00
unregistersymbol(Resources)
unregistersymbol(PlayerResBase)
dealloc(newmem)
dealloc(PlayerResBase) |
Script 2 - CreateThread, script does not turn on when i hit the check box why? but it will turn on when i get rid of any code in script 2 referring to [PlayerResBase]?
| Code: |
[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
//globalalloc(CodeThread2,1500)
alloc(CodeThread3,500)
createthread(CodeThread3)
registersymbol(end2)
registersymbol(val2)
label(end2)
label(val2)
CodeThread3:
mov rbx,[PlayerResBase]
cmp [end2],0
jne CodeThread3
ret
end2:
dd 1
val2:
dd 1
[DISABLE]
//code from here till the end of the code will be used to disable the cheat
unregistersymbol(end2)
unregistersymbol(val2)
end2:
dd 0 |
am I not understanding something is there a work around or......?
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4724
|
Posted: Mon Apr 11, 2022 12:09 am Post subject: |
|
|
The auto assembler assembles assembly (i.e. `mov rbx,[PlayerResBase]`) into machine code. If PlayerResBase isn't defined, it can't assemble that instruction into anything meaningful. You need to activate script 1 before script 2, and make sure to never disable script 1 while script 2 is running since script 2 is accessing memory managed by script 1.
It would be safer to use globalalloc in both scripts and address that memory location through a register in script 1. e.g.:
| Code: | globalalloc(PlayerResBase ,8)
...
push rdi
mov rdi,PlayerResBase
mov [rdi],rbx
pop rdi |
Other minor nitpicks:
| Code: | alloc(PlayerResBase,4) // Should be 8
...
jmp code // useless jmp
code:
...
PlayerResBase:
dd 00 // should be dq
...
registersymbol(code) // never unregistered; probably useless anyway |
| Code: | alloc(CodeThread3,500) // memory leak
...
CodeThread3:
mov rbx,[PlayerResBase]
// should have a call to sleep in this busy loop
cmp [end2],0
jne CodeThread3
...
end2: // unaligned data- put "align 4 CC" before this label
dd 1 | See this topic for a guide on how to manage a thread's memory safely:
https://forum.cheatengine.org/viewtopic.php?t=619046
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
|
|
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
|
|