|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Kidades Newbie cheater Reputation: 0
Joined: 08 May 2013 Posts: 11 Location: Serbia, Nis
|
Posted: Sun May 23, 2021 4:05 pm Post subject: How to check what value is going to be writen to an address? |
|
|
I have an address that the game constantly changes. I want to allow all values to be set except one.
For example, the game constantly changes the address to various values ranging from 0 to 100. I want to allow all those changes, except when it's going to be set to 25. In that case, I want it set to 26 instead.
How would I do this?
Currently I have a lua script with a 1ms timer that checks this address and when it finds 25 as the value it changes it to 26. This works but there is flicker, since this address determines the animation that is playing for a particular character. I'm assuming the 1ms as the timer isn't actually 1ms or maybe it takes some time to execute it so the animation starts playing for a few frames then stops.
I want to inject code that would add a condition that if the value to be set is 25, it should either just return or set 26 instead but I don't know how to do this. Can anyone give me an example?
|
|
Back to top |
|
|
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Sun May 23, 2021 4:45 pm Post subject: |
|
|
I don't think an arbitrary example will really help, I think you need to start with the CE tutorial and learn a little ASM. But here is an arbitrary example.
Code: |
cmp eax,19
jne @f
mov eax,1A
@@:
|
_________________
|
|
Back to top |
|
|
Kidades Newbie cheater Reputation: 0
Joined: 08 May 2013 Posts: 11 Location: Serbia, Nis
|
Posted: Tue May 25, 2021 4:36 pm Post subject: |
|
|
Thanks for the reply. It does help and I'm closer to doing what I wanted.
Now I'm having a different problem.
The instruction that I'm replacing writes to different addresses so I need to compare both the address and the value.
Code: | newmem:
cmp rdi+00000218,1434D65D8
jne @f
cmp rax,B859706C
jne @f
mov [rdi+00000218],B859711C
@@:
originalcode:
mov [rdi+00000218],rax |
When I inject this, I get an error on the 4th line cmp rax,B859706C
It seems to only accept values that are 2 bytes long and compiles only if I cut the first 2 bytes.
The first cmp works, but the value gets trimmed to 4 bytes and becomes 434D65D8 instead of 1434D65D8.
How come the first cmp accepts 4 bytes but the second one doesn't take more than 2? How can I make it compare longer values? I'm assuming the problem is caused by the fact that it's a 64 bit game.
Also, even though the address that I'm changing is a 2 byte address, the code always writes 4 bytes to that location. I only need to modify the 2 byte part. Don't know what the other 2 bytes are used for but the game crashes if I change it. Is there a way to compare only the first 2 bytes in a register? In my example, rax has 4 bytes (B859706C) but I'm only interested in checking and changing the first 2 (706C). Those first 2 bytes are always the same, while the other part seems to change on every map load.
Description: |
|
Filesize: |
8.63 KB |
Viewed: |
2862 Time(s) |
|
|
|
Back to top |
|
|
Kidades Newbie cheater Reputation: 0
Joined: 08 May 2013 Posts: 11 Location: Serbia, Nis
|
Posted: Thu May 27, 2021 10:20 am Post subject: |
|
|
Finally made it work.
Fixed the cmp issue by putting the value in a register and then using cmp on 2 registers.
As for comparing and changing only the first 2 bytes, I used the smaller 2 byte register ax instead of rax, which happened to contain the value that I needed.
Code: | newmem:
mov r10,00000001434D63C0
cmp rdi,r10 ;works
mov r10, 0000000000000001 ;restoring r10 to original value otherwise the game crashes
jne @f
cmp ax,9B18
jne @f
mov ax,9BC8
originalcode:
mov [rdi+00000218],rax
jmp return |
|
|
Back to top |
|
|
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Thu May 27, 2021 3:51 pm Post subject: |
|
|
For any registry you change it should be restored, if it's set just after your code then that's fine. But to save and restore a registry use PUSH and POP. Just remember it's pushing and popping the stack and it's LIFO (last in, first out).
https://wiki.cheatengine.org/index.php?title=Tutorial:Stack
Code: | push rax
push rbx
...
pop rbx
pop rax |
_________________
|
|
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
|
|