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 


Distance between allocated memory and original address

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

Joined: 21 Feb 2011
Posts: 146
Location: Italia

PostPosted: Fri Mar 09, 2012 2:38 pm    Post subject: Distance between allocated memory and original address Reply with quote

Hi guys. I'm tryng to calculate distance from allocated memory and original address for create a jump to code cave.. i've used this code in delphi:

Code:

AllocatedMem:= VirtualAllocEx(ProcHandle, nil, mySize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
VirtualProtectEx(ProcHandle, AllocatedMem, mySize, PAGE_EXECUTE_READWRITE, nil);


now i've need to use WriteProcessMemory function for write my E9 (jmp) to allocated memory.
Is there a function in delphi that i can use for calculate the distance in byte?

Thanks

_________________
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Mar 09, 2012 3:57 pm    Post subject: Reply with quote

(CaveAddr - OriginalAddr) - 5

To calculate the distance.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Smanettone83
Expert Cheater
Reputation: 3

Joined: 21 Feb 2011
Posts: 146
Location: Italia

PostPosted: Fri Mar 09, 2012 4:39 pm    Post subject: Reply with quote

Wiccaan wrote:
(CaveAddr - OriginalAddr) - 5

To calculate the distance.


why - 5 ?

_________________
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Mar 09, 2012 5:16 pm    Post subject: Reply with quote

You need to account for the bytes used by your call/jmp.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Smanettone83
Expert Cheater
Reputation: 3

Joined: 21 Feb 2011
Posts: 146
Location: Italia

PostPosted: Sat Mar 10, 2012 8:37 am    Post subject: Reply with quote

Wiccaan wrote:
You need to account for the bytes used by your call/jmp.


example of calculation:

Code:

var
AllocatedMem,Original,JmpToAlloc:int64;
begin
JmpToAlloc:= (AllocatedMem - Original) -5;
WriteProcessMemory(ProcHandle, pointer(AllocatedMem), @MyArray, SizeOf(MyArray), myWrite);
end;


it's right?

_________________
Back to top
View user's profile Send private message MSN Messenger
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