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 


Value not updating when changed in memory?

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

Joined: 15 Jan 2024
Posts: 7

PostPosted: Sun Feb 18, 2024 2:23 pm    Post subject: Value not updating when changed in memory? Reply with quote

Hey so in this game Wizard With a Gun on version 1.0.1 the following instruction handles the cooldown between shooting.
Code:
 movss [rbx + rdi + 0C],xmm3

I verified this by finding what addresses access this instruction and when i fired my gun an address populated, I added it to the address table and changed that value to 0, and the gun turned fully automatic. However when changing the instruction from
Code:
movss [rbx + rdi + 0C], xmm3
to
Code:
mov [rbx + rdi + 0C], (double)0
it does not have the same effect. Any thoughts why? I would be more then happy to share any necessary information.
If any screenshots are needed you can add me on discord:
Code:
topskid
as my account is not eligible to post urls yet
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4719

PostPosted: Sun Feb 18, 2024 4:11 pm    Post subject: Reply with quote

There is no `mov r/m64,imm64` instruction (that double is a 64-bit immediate). CE automatically truncates that 64-bit immediate to a 32-bit one and assumes the destination memory address is 32 bits. This overwrites the least significant half of the double with zeros, but leaves the more significant half unchanged. Due to how doubles are encoded, this leaves the double value itself mostly the same.

There is a `mov r/m64,imm32` instruction. The 32-bit immediate gets sign-extended to 64 bits. In this specific case, because `(double)0` is just 8 zero bytes, you can use `mov qword ptr [rbx+rdi+0C],0`.

In general, you'd go through a register.
Code:
push rax
mov rax,(double)1234.5
mov [wherever],rax
pop rax

Alternatively, you could just zero the xmm register before the write.
Code:
pxor xmm3,xmm3
movss [rbx+rdi+0C],xmm3
This will also zero the other 3 floats in the xmm register, but they're probably zero anyway.

The bigger issue is whether or not that instruction accesses other addresses. You should check that. Right click it in the disassembler and select "Find out what addresses this instruction accesses".

_________________
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
JustHim24
How do I cheat?
Reputation: 0

Joined: 15 Jan 2024
Posts: 7

PostPosted: Sun Feb 18, 2024 4:36 pm    Post subject: Reply with quote

ParkourPenguin wrote:
There is no `mov r/m64,imm64` instruction (that double is a 64-bit immediate). CE automatically truncates that 64-bit immediate to a 32-bit one and assumes the destination memory address is 32 bits. This overwrites the least significant half of the double with zeros, but leaves the more significant half unchanged. Due to how doubles are encoded, this leaves the double value itself mostly the same.

There is a `mov r/m64,imm32` instruction. The 32-bit immediate gets sign-extended to 64 bits. In this specific case, because `(double)0` is just 8 zero bytes, you can use `mov qword ptr [rbx+rdi+0C],0`.

In general, you'd go through a register.
Code:
push rax
mov rax,(double)1234.5
mov [wherever],rax
pop rax

Alternatively, you could just zero the xmm register before the write.
Code:
pxor xmm3,xmm3
movss [rbx+rdi+0C],xmm3
This will also zero the other 3 floats in the xmm register, but they're probably zero anyway.

The bigger issue is whether or not that instruction accesses other addresses. You should check that. Right click it in the disassembler and select "Find out what addresses this instruction accesses".


Thanks for the feedback!! I already have checked if that instruction access other addresses and the only addresses it accesses from what i can tell is the different guns.
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