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 


[fpc] calling a proc in a binary from an injected DLL

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
mezzo
Cheater
Reputation: 1

Joined: 08 Sep 2010
Posts: 28

PostPosted: Tue Jan 03, 2012 6:19 pm    Post subject: [fpc] calling a proc in a binary from an injected DLL Reply with quote

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 ?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 473

Joined: 09 May 2003
Posts: 25907
Location: The netherlands

PostPosted: Tue Jan 03, 2012 10:14 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message MSN Messenger
mezzo
Cheater
Reputation: 1

Joined: 08 Sep 2010
Posts: 28

PostPosted: Wed Jan 04, 2012 12:09 pm    Post subject: Reply with quote

Works great ! thanks dark byte
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