A程序:注入程序
B程序:DLL程序我把DLL利用钩子wh_getMessage将DLL注入游戏里,并发个空消息,让DLL显示出窗体来,可是窗体是显示在游戏外部的,有没什么办法在消息GetMsgProc里把窗体设置下,让窗体在游戏窗体内部,这样看上去像游戏本身的功能样,请各位大大指教!我在A程序里启动远程注入,代码如下:
procedure TForm1.Button1Click(Sender: TObject);
type
TClientSPDLL=function(i:Dword):Boolean;stdcall;
var
hwins:dword;
Dll:Thandle;
Tp:TFarProc;
Tf:TClientSPDLL;
tid:longword;
begin
hwins:=FindWindow(nil,'游戏窗体');
if hwins <> 0 then begin
Dll:=LoadLibrary('Client.dll');
if Dll = 0 then Exit;
Try
Tp:=GetProcAddress(Dll,PChar('ClientDll'));
if Tp = nil then Exit;
Tf:=TClientSPDLL(Tp);
if not Tf(hwins) then Showmessage('NO');
Finally
FreeLibrary(Dll);
End;
end;
end;在B程序里写入DLL程序 代码如下:
library Client;uses
Windows,
SysUtils,
Messages,
Classes,
Forms,
Main in 'Main.pas' {Form1};{$R *.res}var
Hook: HHOOK;
ShowF:Boolean=False;
EHandle:Dword;
FirstTime:boolean = true;procedure DllEnterProc(reason:integer);
begin
case reason of
windows.DLL_PROCESS_ATTACH: begin end;
windows.DLL_PROCESS_DETACH: begin Form1.Free;form1:=nil; end;
end;
end;Function GetMsgProc(code: Integer; wparam: WPARAM; lparam: LPARAM): LRESULT; stdcall;
begin
if FirstTime then begin
FirstTime := False;
Form1:=TForm1.Create(nil);
{
Application.Handle:=EHandle;
Form1.ParentWindow :=EHandle;
//以上两句是无效的,EHandle为0了
}
Form1.Visible:=True;
end;
end;Function ClientDll(Handle:Dword):Boolean;stdcall;export;
var
GameTid:THandle;
begin
EHandle:=Handle;
GameTid:=GetWindowThreadProcessId(Handle);
Hook := SetWindowsHookEx(wh_getMessage,GetMsgProc,hInstance, GameTid);
Result := hook <> 0;
if Result then PostThreadMessage(GameTid, wm_Null,0,0);
sleep(500);
end;exports
ClientDll;begin
DllProc:=@DllEnterProc;
end.
B程序:DLL程序我把DLL利用钩子wh_getMessage将DLL注入游戏里,并发个空消息,让DLL显示出窗体来,可是窗体是显示在游戏外部的,有没什么办法在消息GetMsgProc里把窗体设置下,让窗体在游戏窗体内部,这样看上去像游戏本身的功能样,请各位大大指教!我在A程序里启动远程注入,代码如下:
procedure TForm1.Button1Click(Sender: TObject);
type
TClientSPDLL=function(i:Dword):Boolean;stdcall;
var
hwins:dword;
Dll:Thandle;
Tp:TFarProc;
Tf:TClientSPDLL;
tid:longword;
begin
hwins:=FindWindow(nil,'游戏窗体');
if hwins <> 0 then begin
Dll:=LoadLibrary('Client.dll');
if Dll = 0 then Exit;
Try
Tp:=GetProcAddress(Dll,PChar('ClientDll'));
if Tp = nil then Exit;
Tf:=TClientSPDLL(Tp);
if not Tf(hwins) then Showmessage('NO');
Finally
FreeLibrary(Dll);
End;
end;
end;在B程序里写入DLL程序 代码如下:
library Client;uses
Windows,
SysUtils,
Messages,
Classes,
Forms,
Main in 'Main.pas' {Form1};{$R *.res}var
Hook: HHOOK;
ShowF:Boolean=False;
EHandle:Dword;
FirstTime:boolean = true;procedure DllEnterProc(reason:integer);
begin
case reason of
windows.DLL_PROCESS_ATTACH: begin end;
windows.DLL_PROCESS_DETACH: begin Form1.Free;form1:=nil; end;
end;
end;Function GetMsgProc(code: Integer; wparam: WPARAM; lparam: LPARAM): LRESULT; stdcall;
begin
if FirstTime then begin
FirstTime := False;
Form1:=TForm1.Create(nil);
{
Application.Handle:=EHandle;
Form1.ParentWindow :=EHandle;
//以上两句是无效的,EHandle为0了
}
Form1.Visible:=True;
end;
end;Function ClientDll(Handle:Dword):Boolean;stdcall;export;
var
GameTid:THandle;
begin
EHandle:=Handle;
GameTid:=GetWindowThreadProcessId(Handle);
Hook := SetWindowsHookEx(wh_getMessage,GetMsgProc,hInstance, GameTid);
Result := hook <> 0;
if Result then PostThreadMessage(GameTid, wm_Null,0,0);
sleep(500);
end;exports
ClientDll;begin
DllProc:=@DllEnterProc;
end.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货