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 


Compare RAX to an existing address in ASM?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Kamd
Cheater
Reputation: 1

Joined: 02 May 2018
Posts: 28

PostPosted: Sun Sep 01, 2019 4:42 am    Post subject: Compare RAX to an existing address in ASM? Reply with quote

I am pretty new to Assembly, so please try explain easily.

Basically, I am working with a shared opcode, for example, a HP damage opcode. I need to make this damage opcode to only effect things that are not writing to my player (health) address.

I already have an assembly script that locates my player structure, and +10 is the offset to my health.

To determine if the damage opcode is writing to my player's health address, I want to compare RAX (write address) to my already-found health address.

Example script:
NOTE: _player is start of player struct defined in the prior script (simplified):
Code:
...
registersymbol(_player)
...
customCode:
    ...
    mov [_player],rdx

So _player+10 is address of my health.

Code:
hpWrite:
    cmp [rax],GetAddress(_player+10) // check if write address is player health address
    jne runNormalCode // if rax != playerHpAddress we run the normal damage code

    // We didn't jump so this is our player's health. Don't do anything
Back to top
View user's profile Send private message
sbryzl
Master Cheater
Reputation: 6

Joined: 25 Jul 2016
Posts: 252

PostPosted: Sun Sep 01, 2019 4:26 pm    Post subject: Reply with quote

I'm not too certain about your situation but I think you can just preserve a register, load your address, add 10 and compare it.


Code:
push rcx
mov rcx,[_player]
add rcx,10
cmp rax,rcx
pop rcx
jne runNormalCode
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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