rovnix Newbie cheater
Reputation: 0
Joined: 09 Feb 2014 Posts: 18
|
Posted: Tue Jun 09, 2015 11:13 am Post subject: detours in pascal |
|
|
Good evening people
Recently I been doing some game hacking, hooking and some other stuff again, but api hooking a hasn't been fun with me
Someone made this api hook detour function in delphi, (lazarus) tested with a simple messagebox hook, doesn't even work as I expected. Hence I decided to come on here to seek help.
Please do help me in your own small way people
Code: |
function DetourFunction (src, dst: Pointer; len: Integer): Pointer;
var
jmp : PByteArray;
dwBack : LongWord;
jmpaddr : PtrUInt;
srcarr : PByteArray;
i : Integer;
begin
srcarr := PByteArray(src);
GetMem(jmp, len + 5);
VirtualProtect(src, len, PAGE_EXECUTE_READWRITE, @dwBack);
Move(src^, jmp^, len);
jmp^[len]:=$e9;
jmpaddr:=PtrUInt(@jmp^[len]);
PPtrUInt( @jmp^[len+1])^ := PtrUInt(src)+PtrUInt(len) - jmpaddr - 5;
srcarr^[0]:=$e9;
PPtrUInt( @srcarr^[1] )^ := PtrUInt(dst) - PtrUInt(src) - 5;
for i:=5 to len-1 do srcarr^[i]:=$90;
VirtualProtect(src, len, dwBack, @dwBack);
Result:=jmp;
end;
|
Hence it doesn't work as I expected, am quite still new to this as I don't have anyone to give me instructions here. Pls help.
|
|