 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Sp4rt How do I cheat?
Reputation: 0
Joined: 28 May 2020 Posts: 8
|
Posted: Tue Feb 14, 2023 6:34 pm Post subject: Why do I have to use multiple brackets to reuse a symbol |
|
|
Let's say I have two scripts.
In script A I set a symbol called symbolA, and then I want to reuse that symbol in script B.
So, script A:
| Code: |
[ENABLE]
alloc(symbol, 4)
registersymbol(symbol)
symbol:
dd (float)1.5
[DISABLE]
unregistersymbol(*)
dealloc(*)
|
And then, when I want to use that symbol in script B, let's say to multiply xmm0:
| Code: |
mulss xmm0, symbol // This doesn't compile, all good!
mulss xmm0, [symbol] // This should work, right? Well, [symbol] is being interpreted as the ADDRESS of symbol, not the value!
mulss xmm0, [[symbol]] // Following the previous logic, this does work!
|
Why is this the case? I expected [symbol] to contain the value (float)1.5, since that would be the case in script A. |
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4706
|
Posted: Tue Feb 14, 2023 7:20 pm Post subject: |
|
|
`mulss xmm0, [symbol]` is correct. You're doing something wrong.
This works as expected w/ your script A:
| Code: | [ENABLE]
{$lua}
assert(getAddressSafe'symbol', 'Enable the other script first')
{$asm}
alloc(newmem,4096,symbol)
label(multiplier)
newmem:
movss xmm0,[symbol]
mulss xmm0,[multiplier]
movss [symbol],xmm0
ret
newmem+800:
multiplier:
dd (float)2.0
createthreadandwait(newmem,1000)
[DISABLE]
dealloc(*) |
Try clearing the userdefined symbols (Memory Viewer -> View -> Userdefined symbols) and restarting CE. _________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
Sp4rt How do I cheat?
Reputation: 0
Joined: 28 May 2020 Posts: 8
|
Posted: Tue Feb 14, 2023 9:54 pm Post subject: |
|
|
Hey, thanks for the response! I tried all sorts of things and it keeps working ONLY with [[symbol]], just to be sure though, what CE version are you using? I tried it on 7.5 and 7.4.
EDIT: Actually you're right, with your example it does work with [symbol], hmmm.. alright |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25807 Location: The netherlands
|
Posted: Wed Feb 15, 2023 12:39 am Post subject: |
|
|
| Code: |
mulss xmm0, [symbol]
|
will fail if the distance is greater than 2gb
to deal with this first load the address into a register
| Code: |
mov rax,symbol
mulss xmm0,[rax]
|
that way the code works regardless of where it is located _________________
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 |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4706
|
Posted: Wed Feb 15, 2023 1:31 am Post subject: |
|
|
Longer explanation of RIP-relative addressing:
https://forum.cheatengine.org/viewtopic.php?t=620587
There's still no way [[symbol]] would work if that were the problem. Unless of course OP didn't test if it actually works. Just because an instruction assembles doesn't mean it does what you expect it to do. _________________
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
|
|