Posted: Tue Jan 03, 2012 6:19 pm Post subject: [fpc] calling a proc in a binary from an injected DLL
I use the below code from my injected DLL to make the game print a message on screen.
Code:
procedure nhwrite(texttoprint:PChar);stdcall;
var
nhprint:^Integer;
begin
nhprint := POINTER($004A1DD0);
asm
PUSH texttoprint //ASCII string to be printed
CALL nhprint //call $004A1F10 makes the game print the msg
end;
end;
It works, but feels like an ugly hack.
Is this how it is supposed to be done ? Is there some way to 'declare' a function location in main binary from inside the DLL ?
Joined: 09 May 2003 Posts: 25907 Location: The netherlands
Posted: Tue Jan 03, 2012 10:14 pm Post subject:
assuming delphi mode, else place an @ in front of nhprint:=...
Code:
var
nhprint:procedure (s: pchar); stdcall;
...
nhprint('your message')
...
initialization
nhprint:=pointer($004a1dd0);
instead of initialization you could put in between the begin/end in the .lpr of the library (just make sure that nhprint is declared in the interface of a unit) _________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping
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