怎么在游戏里面呼叫自己做的程序中的一个form |
尚未結案
|
luck
一般會員 ![]() ![]() 發表:1 回覆:0 積分:0 註冊:2004-09-16 發送簡訊給我 |
|
likush
高階會員 ![]() ![]() ![]() ![]() 發表:5 回覆:235 積分:103 註冊:2002-10-08 發送簡訊給我 |
|
billwillman
一般會員 ![]() ![]() 發表:0 回覆:7 積分:1 註冊:2006-11-06 發送簡訊給我 |
|
a321852123
一般會員 ![]() ![]() 發表:1 回覆:2 積分:0 註冊:2012-07-04 發送簡訊給我 |
|
kimpkok02
一般會員 ![]() ![]() 發表:1 回覆:1 積分:0 註冊:2012-11-20 發送簡訊給我 |
我給你發個例子吧
首先是EXE 注入的代碼 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, XPMan; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; hhk:Longint; function HookOn(lpHwnd:HWND):Longint;stdcall;external 'Hook.dll' name 'HookOn'; function HookOff:Boolean;stdcall;external 'Hook.dll' name 'HookOff'; implementation function UninstallHook(hk:HHOOK):Boolean;stdcall;export; //卸載HOOK begin if hk<>0 then begin UnHookWindowsHookEx(hHk); hk :=0; Result :=true; end else Result :=false; end; //------------------------------------------------------------------------------ {$R *.dfm} procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin hookoff; //退出時 卸載HOOK end; procedure TForm1.Button1Click(Sender: TObject); var h1:HWND; txt:string; begin //txt:=edit1.text; h1:=FindWindow('這裡填寫要注入的窗口類名',nil); //第2個參數是窗口名稱.一般寫其中一個就好 if h1>0 then begin hhk:=HookOn(h1); showmessage('找到進程已注入!'); Caption:=IntToStr(hhk); end else showmessage('沒有找到進程!'); end; procedure TForm1.Button2Click(Sender: TObject); begin UninstallHook(hhk); showmessage('已取消注入!'); end; end.
下面是 要注入的DLL 代碼 library Hook; uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,StrUtils, myDLl in 'myDLl.pas' {Form1}; var hHk:HHOOK=0; hThread:Cardinal; hmod:Pointer; //===========接收按鍵HOME呼出隱藏窗體================== function HookProc(nCode:Integer;WParam: WPARAM;LParam:LPARAM):LRESULT;stdcall; label theExit; begin if nCode < 0 then goto theExit; if (nCode <> HC_ACTION) then goto theExit; if ((lParam and $80000000) = 0) { or (GetAsyncKeyState(VK_Control)=0) } then goto theExit; case wParam of VK_HOME: begin if form1 <> nil then begin if form1.Visible = true then Form1.Hide else Form1.Show; end else //窗体还没有加载 Form1:=TForm1.Create(Application); end; end; theExit: result := CallNextHookEx(hHk, nCode, wParam, lParam); end; //------------------------------------------------------------------------------ function HookOn(lpHwnd:HWND):Longint;stdcall;export; //安裝HOOK begin hThread :=GetWindowThreadProcessId(lpHwnd,hmod); if lpHwnd<>0 then hHk :=SetWindowsHookEx(WH_KEYBOARD,@HookProc,hInstance,hThread); Result :=hHk end; //------------------------------------------------------------------------------ function HookOff:Boolean;stdcall;export; 卸載HOOK begin if hHk<>0 then begin UnHookWindowsHookEx(hHk); hHk :=0; Result :=true; end else Result :=false; end; //------------------------------------------------------------------------------ {$R *.res} exports HookOn,HookOff; begin end. 好了 .就這麼多,希望能幫到你 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |