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 


Calculating MOV/CMP in 64bit

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Hatschi
Master Cheater
Reputation: 2

Joined: 28 Jan 2010
Posts: 327

PostPosted: Sat Oct 31, 2015 2:27 pm    Post subject: Calculating MOV/CMP in 64bit Reply with quote

Hey,

I'm curious how CE knows what bytes to write to resolve this [newmem+100]. Please take a look at the following pictures:



So here we have [newmem+100]. The 64bit address cannot be written directly because a 64bit address is 8 byte long, but we have only 4. So the address is written as EF 00 00 00.

Now I try to imagine the logic why its EF 00 00 00. The [newmem+100] is at address 7FF76B74000A + 0x3 = 7FF76B74000D

7FF76B740100 (which is the newmem+100) - 7FF76B74000D = F3

F3 is not EF. So how do I get to EF? Well I can subtract 0x4 so

7FF76B740100 - 7FF76B74000D - 0x4 = EF

Great but lets check out how it works on CMP DWORD PTR for example:



Its again EF 00 00 00 but this time at address 7FF76B74000A + 0x2 = 7FF76B74000C

If I take the logic above I would get to:

7FF76B740100 - 7FF76B74000C - 0x4 = F0

Now instead of 0x4 I would have to subtract 0x5. However is the calculation really that different? How does CE calculates the address in 64bit ? How does CE knows it has to write EF 00 00 00 at point X to get to point Z.

I hope it clears what Im asking for.
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat Oct 31, 2015 2:53 pm    Post subject: Reply with quote

It is RIP relative addressing.



Code:
00400500 - 48 89 35 49000000     - mov [00400550],rsi


instruction has 7 bytes, offset is 00000049
00400500 + 7 + 49 = 00400550



Code:
7FF76B74000A - 83 3D EF000000 01     - cmp dword ptr [7FF76B740100],01

7FF76B74000A + 7 + EF = 7FF76B740100

_________________


Last edited by mgr.inz.Player on Sat Oct 31, 2015 3:27 pm; edited 3 times in total
Back to top
View user's profile Send private message MSN Messenger
Hatschi
Master Cheater
Reputation: 2

Joined: 28 Jan 2010
Posts: 327

PostPosted: Sat Oct 31, 2015 2:58 pm    Post subject: Reply with quote

So:
[target address] - [instruction length] = Remaining length in bytes
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat Oct 31, 2015 3:04 pm    Post subject: Reply with quote

[address of instruction] + [instruction size] + [RIP offset] = [target address]

Or

[address of next instruction] + [RIP offset] = [target address]

_________________
Back to top
View user's profile Send private message MSN Messenger
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat Oct 31, 2015 3:11 pm    Post subject: Reply with quote

variable_address - instruction_address - instruction_length = byte_offset
7FF76B740100 - 7FF76B74000A - 7 = EF
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