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 


create simple trampoline hook in delphi

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
rovnix
Newbie cheater
Reputation: 0

Joined: 09 Feb 2014
Posts: 18

PostPosted: Tue Jul 22, 2014 5:17 am    Post subject: create simple trampoline hook in delphi Reply with quote

been looking at this code for a simple trampoiline, just that i got lost along the line

Quote:

library Project2;

uses
windows; //reduce size Smile

{$R *.res}

procedure hook(target, newfunc:pointer);
var
jmpto:dword;
begin
jmpto:=dword(newfunc)-dword(target)-5;
VirtualProtect(target, 5, PAGE_EXECUTE_READWRITE, nil);
pbyte(target)^:=$e9;
pdword(dword(target)+1)^:=jmpto;
end;

procedure MySleep(time:dword);
begin
MessageBox(0, 'You have called "Sleep!"', 'Good!', MB_OK);
end;

begin
hook(GetProcAddress(GetModuleHandle('kernel32.dll'), 'Sleep'), @MySleep);
end.


now i saw someone talking about the Sleep() return function, how do i go about it, i am kind of lost. How do i go about this, kinda lost and i'm new to this.[/url]
Back to top
View user's profile Send private message Yahoo Messenger
661089799107
Expert Cheater
Reputation: 3

Joined: 25 Jan 2009
Posts: 186

PostPosted: Tue Jul 22, 2014 9:18 pm    Post subject: Reply with quote

1). Allocate 10 bytes of memory to store the original 5 bytes of Sleep, and a JMP instruction to Sleep+5.

2). Replace the first 5 bytes of Sleep with a JMP to your own function

3). Somewhere in your own function do a call to the 10 bytes of memory you allocated, and return the value that is returned.
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