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 JMP's address

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

Joined: 25 Jan 2011
Posts: 5

PostPosted: Fri Sep 30, 2011 4:20 am    Post subject: Calculating JMP's address Reply with quote

Hello. I am writing a hook (trying to write to be more correct) in Delphi (so I can't use detours or whatever its called) to function via writing jmp to function's beginning which readdresses it to my function. My function is placed in DLL, which is injected to process dynamically, so it's base address can be higher than function's I want to hook, or lower. Although when it is higher it seems not to be a problem, but when it is lower I simply don't know how to calculate address to jump back.
For example: I want to hook GetTickCount64. If address of function in my DLL is higher that GetTickCount's64 (or rather myDLL's base address is higher than Kernel32's) I simply write to memory "E9(MyFunc's address-HookedFunc's address)", but I have no idea how to determine address if it is lower.
Back to top
View user's profile Send private message
FLiNG
Newbie cheater
Reputation: 0

Joined: 09 Apr 2011
Posts: 19

PostPosted: Fri Sep 30, 2011 7:57 am    Post subject: Reply with quote

Isn't this method work for both situations, no matter your dll is higher or lower than the original fucntion adrress?

I am not sure if this work in delphi, although it should. I use this method in C# and c++ to calculate jump to a codecave and jump back as well.
Back to top
View user's profile Send private message
RCard
How do I cheat?
Reputation: 0

Joined: 25 Jan 2011
Posts: 5

PostPosted: Fri Sep 30, 2011 9:02 am    Post subject: Reply with quote

Oh, yeah. Exactly. Sorry for my stupidity, I was simply sure it won't work Very Happy
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Fri Sep 30, 2011 10:23 am    Post subject: Reply with quote

Think about it, that formula gives you the number of bytes to pass in order to get to your function.
It doesn't matter if it's lower or higher since it'll take it as an unsigned value.

_________________
Stylo
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 programming 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