I am able to use packet.dll and it's so easy to send packets to the game by this way
I really want to do it by injecting dll, but if there is no chance (or it's harder) could you tell me more about CreateRemoteThread in delphi? Maybe any tutorial/example ?
By the way. That's how my
Code:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Button3: TButton;
Button4: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
PID:Cardinal;
hWndF:hwnd;
implementation
Procedure FSpeech (TalkMode: Integer;Text: Pchar);cdecl ;external 'say.dll';
{$R *.dfm}
procedure InjectDll(PID: dword; DLL: pChar);
var
BytesWritten, hProcess, hThread, TID: Cardinal;
Parameters: pointer;
pThreadStartRoutine: Pointer;
begin
hProcess := OpenProcess(PROCESS_ALL_ACCESS, False, PID);
Parameters := VirtualAllocEx( hProcess, nil, Length(DLL)+1, MEM_COMMIT or MEM_RESERVE, PAGE_READWRITE);
WriteProcessMemory(hProcess,Parameters,Pointer(DLL),Length(DLL)+1,BytesWritten);
pThreadStartRoutine := GetProcAddress(GetModuleHandle('KERNEL32.DLL'), 'LoadLibraryA');
hThread := CreateRemoteThread(hProcess, nil, 0, pThreadStartRoutine, Parameters, 0, TID);
CloseHandle(hProcess);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
hwndf:=findwindow(nil,'Tibia');
Getwindowthreadprocessid(hwndf,@PID);
InjectDll(PID,pchar(ExtractFilePath(Application.ExeName)+'say.dll'));
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
FSpeech(1,'lolek');
end;
end.
and that's how my .dll looks like:
Code:
library say;
uses
SysUtils,
Classes,
Messages,
Windows;
{$R *.res}
procedure FSpeech (AType: Byte; AText:PChar); cdecl;
const
Adr = $004073F0;
var
FSpeech: procedure(AType: Byte; AText:PChar); cdecl;
begin
@FSpeech := Ptr(Adr);
end;
exports
FSpeech;
end.
And one more think. As you said exacly I would like to export the procedure from .dll and I want to use this procedure in my .exe by clicking on button.