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 


Free Pascal Injectable .dll

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

Joined: 24 Sep 2010
Posts: 26

PostPosted: Sun Feb 20, 2011 9:12 pm    Post subject: Free Pascal Injectable .dll Reply with quote

I am trying to re make my Delphi 7 .dll trainer tutorial in Free Pascal. I'm having issues creating a simple injectable .dll . Heres the simple code:

Code:
library test;

uses
  Interfaces, Dialogs, Classes, SysUtils, Windows;

{$R test.rc}

var dwTemp: DWORD;
procedure funcStart;
begin
ShowMessage('This is a test');
end;

begin
CreateThread(nil,dwTemp,@funcStart,nil,dwTemp,dwTemp);
end.   


The following code compiles but ends up crashing the client on injection.
Btw I am using Lazarus.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Mon Feb 21, 2011 9:20 am    Post subject: Reply with quote

why are you passing dwTemp in as the creation flags ?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Mon Feb 21, 2011 9:49 am    Post subject: Reply with quote

and wrong parameters for funcStart

try function funcStart(parameter: pointer): DWORD; stdcall;

also, try replacing showMessage with messagebox(0,'xxx','xxx',MB_OK);

and are you using the 32 or 64-bit version of freepascal?
(you can't inject a 64-bit dll into a 32-bit app)

_________________
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
Luig
Cheater
Reputation: 0

Joined: 24 Sep 2010
Posts: 26

PostPosted: Mon Feb 21, 2011 10:11 am    Post subject: Reply with quote

Ok thanks Slugsnack and Dark Byte for your reply. The little message test now works with this code:
Code:
library test;

uses
  Interfaces, Dialogs, Classes, SysUtils, Windows;

{$R test.rc}

var dwTemp: DWORD;
function funcStart(parameter: pointer): DWORD; stdcall;
begin
messagebox(0,'xxx','xxx',MB_OK);
end;

begin
CreateThread(nil,0,@funcStart,nil,0,dwTemp);
end.   


Now I'm trying to add a GUI to the .dll the way I used to do it in Delphi. Code:
Code:
library DemoTrainer;

uses
  Classes, SysUtils, Windows, main;

{$R DemoTrainer.rc}

var dwTemp: DWORD;
function funcStart(parameter: pointer): DWORD; stdcall;
begin
Form1 := TForm1.Create(nil);
Form1.ShowModal;
end;
begin
CreateThread(nil,0,@funcStart,nil,0,dwTemp);
end.

This just crashes my client. I'm using 32 bit version of free pascal and testing it on this machine.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Mon Feb 21, 2011 11:24 am    Post subject: Reply with quote

lazarus gui is a little different from delphi

one way to make it work:
Code:

function funcStart(parameter: pointer): DWORD; stdcall;
begin
  MainThreadID:=GetCurrentThreadId; //mainthreadid is a global var defined in lazarus. (So don't define it yourself)
  Application.initialize;
  Application.CreateForm(Tform1, form1);
  application.run;   
end;

_________________
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
Luig
Cheater
Reputation: 0

Joined: 24 Sep 2010
Posts: 26

PostPosted: Mon Feb 21, 2011 11:33 am    Post subject: Reply with quote

I get the following:
Code:
DemoTrainer.lpr(12,14) Error: Identifier not found "Application"
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Mon Feb 21, 2011 11:43 am    Post subject: Reply with quote

add the forms 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
Luig
Cheater
Reputation: 0

Joined: 24 Sep 2010
Posts: 26

PostPosted: Mon Feb 21, 2011 12:24 pm    Post subject: Reply with quote

That seemed to work. Can this thread remain open as I might have a couple more questions as I port my work to Free Pascal and I don't want to spam your forum with threads. Thanks again Dark Byte.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Mon Feb 21, 2011 1:52 pm    Post subject: Reply with quote

We wont close a thread unless there is something either:
A. Illegal.
B. Completely off-topic or has nothing to do with this section.
C. Turns into a flame fest.

Or other things similar to that. You are free to keep posting for help here. Just be sure to stay on topic with programming, which so far you are fine.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
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