| View previous topic :: View next topic |
| Author |
Message |
Luig Cheater
Reputation: 0
Joined: 24 Sep 2010 Posts: 26
|
Posted: Sun Feb 20, 2011 9:12 pm Post subject: Free Pascal Injectable .dll |
|
|
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 |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Mon Feb 21, 2011 9:20 am Post subject: |
|
|
| why are you passing dwTemp in as the creation flags ?
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25859 Location: The netherlands
|
Posted: Mon Feb 21, 2011 9:49 am Post subject: |
|
|
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 |
|
 |
Luig Cheater
Reputation: 0
Joined: 24 Sep 2010 Posts: 26
|
Posted: Mon Feb 21, 2011 10:11 am Post subject: |
|
|
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 |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25859 Location: The netherlands
|
Posted: Mon Feb 21, 2011 11:24 am Post subject: |
|
|
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 |
|
 |
Luig Cheater
Reputation: 0
Joined: 24 Sep 2010 Posts: 26
|
Posted: Mon Feb 21, 2011 11:33 am Post subject: |
|
|
I get the following:
| Code: | DemoTrainer.lpr(12,14) Error: Identifier not found "Application"
|
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25859 Location: The netherlands
|
Posted: Mon Feb 21, 2011 11:43 am Post subject: |
|
|
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 |
|
 |
Luig Cheater
Reputation: 0
Joined: 24 Sep 2010 Posts: 26
|
Posted: Mon Feb 21, 2011 12:24 pm Post subject: |
|
|
| 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 |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Mon Feb 21, 2011 1:52 pm Post subject: |
|
|
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 |
|
 |
|