 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
NothingToShow Grandmaster Cheater Supreme
Reputation: 0
Joined: 11 Jul 2007 Posts: 1579
|
Posted: Sat Apr 05, 2008 2:52 pm Post subject: [Help] Delphi Injection |
|
|
Thanks to DoomsDay for his source code.
I've got this code for injection (modified a bit of DoomsDay source).
But it doesnt seem to work, my target is MapleStory.
I can't find the problems.
I don't understand all the functions used, so I was wondering if any of you could help me fix this, to work.
| Code: | unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, psapi, tlhelp32, StdCtrls;
type
TForm1 = class(TForm)
btnInject: TButton;
procedure btnInjectClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
WName,PName,DName:string;
DLLLocation:string;
ProcessId:DWORD;
implementation
{$R *.dfm}
procedure GetPID();
var
TempSnapshot:THandle;
Process32:TProcessEntry32;
begin
while (ProcessId=0) do
begin
TempSnapshot:=CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
Process32First(TempSnapshot,Process32);
while Process32Next(TempSnapshot,Process32) do
begin
if Process32.szExeFile = PName then
ProcessId:=Process32.th32ProcessID;
end;
CloseHandle(TempSnapshot);
end;
end;
procedure InjectDLL();
var
Process:THandle;
TempHandle:THandle;
AllocatedRegion:pointer;
Empty:DWORD;
NumberOfBytesWritten:Cardinal;
begin
Process:=OpenProcess(PROCESS_ALL_ACCESS,False,ProcessId);
AllocatedRegion:=VirtualAllocEx(Process,NIL,length(DLLLocation),MEM_COMMIT,PAGE_EXECUTE_READWRITE);
WriteProcessMemory(Process,AllocatedRegion,pchar(DLLLocation),length(DLLLocation),NumberOfBytesWritten);
if WName='' then
sleep(750)
else
while FindWindow(nil,pchar(WName))=0 do
sleep(10);
TempHandle:=CreateRemoteThread(Process,nil,0,GetProcAddress(GetModuleHandle('kernel32.dll'),'LoadLibraryA'),AllocatedRegion,0,Empty);
WaitForSingleObject(TempHandle,INFINITE);
CloseHandle(TempHandle);
end;
procedure TForm1.btnInjectClick(Sender: TObject);
begin
GetPID();
InjectDLL();
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DLLLocation := 'C:\Programs and Files\Borland\Delphi7\Projects\DLL Test\BLAH.dll';
WName := 'MapleStory';
PName := 'maplestory.exe';
DName := 'BLAH.dll';
end;
end. |
Yes, my target was/is MS. |
|
| Back to top |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Sun Apr 06, 2008 2:45 am Post subject: |
|
|
What happening?(crash, not responding,ect...)
What the dll do? |
|
| Back to top |
|
 |
NothingToShow Grandmaster Cheater Supreme
Reputation: 0
Joined: 11 Jul 2007 Posts: 1579
|
Posted: Sun Apr 06, 2008 2:53 am Post subject: |
|
|
| HolyBlah wrote: | What happening?(crash, not responding,ect...)
What the dll do? |
The delphi project freezes, and the DLL contains this:
| Code: | library Project2;
uses
SysUtils,
Dialogs,
Classes;
{$R *.res}
procedure BLAH; export;
begin
ShowMessage('Yay ur learning');
end;
exports BLAH;
begin
end. |
|
|
| Back to top |
|
 |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Sun Apr 06, 2008 5:21 am Post subject: |
|
|
| Moller wrote: | | HolyBlah wrote: | What happening?(crash, not responding,ect...)
What the dll do? |
The delphi project freezes, and the DLL contains this:
| Code: | library Project2;
uses
SysUtils,
Dialogs,
Classes;
{$R *.res}
procedure BLAH; export;
begin
ShowMessage('Yay ur learning');
end;
exports BLAH;
begin
end. |
|
Ohhh, you will need to edit the .dll, you made a .dll, where you can read the procedure "BLAH", by calling it from another application, you will need to have the showmessage at the main .dll procedure:
| Code: | begin
ShowMessage('Yay ur learning');
end. |
this is what it should look like:
| Code: | library Project2;
uses
SysUtils,
Dialogs,
Classes;
{$R *.res}
begin
ShowMessage('Yay ur learning');
end.
|
otherwise, the .dll wont work, i dont know about the freezing of your app
Btw, any1 know how to get the PID from the window name/class name? |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Apr 06, 2008 7:10 am Post subject: |
|
|
| Anden100 wrote: | | Btw, any1 know how to get the PID from the window name/class name? |
FindWindow to get the hWnd, then use GetWindowThreadProcessId to get the process id. _________________
- Retired. |
|
| Back to top |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Sun Apr 06, 2008 7:36 am Post subject: |
|
|
The injector freeze in GetPID procedure.
It keep searching for the process and wont stop until it will find it. |
|
| Back to top |
|
 |
Zand Master Cheater
Reputation: 0
Joined: 21 Jul 2006 Posts: 424
|
Posted: Sun Apr 06, 2008 9:01 am Post subject: |
|
|
| HolyBlah wrote: | The injector freeze in GetPID procedure.
It keep searching for the process and wont stop until it will find it. |
It's supposed to do that. Try changing 'maplestory.exe' to 'Maplestory.exe'.
or try this
| Code: | procedure GetPID();
var
TempSnapshot:THandle;
Process32:TProcessEntry32;
result : Integer;
begin
TempSnapshot:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
if TempSnapshot <> INVALID_HANDLE_VALUE then
begin
while Process32Next(TempSnapshot,Process32) do
begin
result := AnsiCompareText(PName, Process32.szExeFile);
if result = 0 then Break;
end;
ProcessId:=Process32.th32ProcessID;
CloseHandle(TempSnapshot);
end;
end; |
|
|
| Back to top |
|
 |
NothingToShow Grandmaster Cheater Supreme
Reputation: 0
Joined: 11 Jul 2007 Posts: 1579
|
Posted: Sun Apr 06, 2008 1:29 pm Post subject: |
|
|
Thank you Anden100 & Zand, it works now, even tough I can't find the process name for MapleStory
New request:
Any know what kind of functions would be usefull when DLL inject? Like, what should DLL do? |
|
| Back to top |
|
 |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Sun Apr 06, 2008 2:15 pm Post subject: |
|
|
| Moller wrote: | Thank you Anden100 & Zand, it works now, even tough I can't find the process name for MapleStory
New request:
Any know what kind of functions would be usefull when DLL inject? Like, what should DLL do? |
Im not sure, but i think the process name for maplestory is "MapleStory.exe" (its in case sensitive...) |
|
| Back to top |
|
 |
|
|
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
|
|