前提:
用SetWindowsHookEx注入到游戏进程。SetWindowsHookEx的第2个参数为回调函数 内容是按HOME呼出dll里面封装的Form.SetWindowsHookEx最后一个参数先用FindWindow获取游戏标题 然后GetWindowThreadProcessId获取该标题的id. Hook Mutex实现游戏多开。
问题:
开第一个游戏的话 按Home 可以呼出 但是如果你再开第2个游戏按Home就呼不出了。
请问该如何处理多线程 让程序只要开一个就可以注入多个游戏里?大致代码:var
keyhhk: HHOOK ;
Function keyproc(icode,wp,lp:integer):DWORD;stdcall; //键盘HOOK回调函数
begin
if (icode=HC_ACTION) then
begin
if (wp=VK_HOME)and ((1 shl 31)and lp=0) then
begin
if form1=nil then Form1:=Tform1.Create(nil);
form1.Visible:=not form1.Visible;
end;
end;
keyProc:=CallNextHookEx(keyhhk,icode,wp,lp);
end;
Function installKeyProc():boolean;stdcall;
var
h:HWND;
GameTid:THandle;
begin
Result:=false;
h:=FindWindow(nil,'武林外传11');
if h=0 then begin Messagebox(0,'未找到游戏','error',0);exit; end;//如果游戏未打开则退出
GameTid:=GetWindowThreadProcessId(h);
keyhhk:=SetWindowsHookEx(WH_KEYBOARD,@Keyproc,GetModuleHandle('HookDll.dll'),GameTid);
if keyhhk>0 then Result:=true;
end;
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;
exports //导出函数
installKeyProc;begin
dllProc:=@DllEnterProc;
end.
用SetWindowsHookEx注入到游戏进程。SetWindowsHookEx的第2个参数为回调函数 内容是按HOME呼出dll里面封装的Form.SetWindowsHookEx最后一个参数先用FindWindow获取游戏标题 然后GetWindowThreadProcessId获取该标题的id. Hook Mutex实现游戏多开。
问题:
开第一个游戏的话 按Home 可以呼出 但是如果你再开第2个游戏按Home就呼不出了。
请问该如何处理多线程 让程序只要开一个就可以注入多个游戏里?大致代码:var
keyhhk: HHOOK ;
Function keyproc(icode,wp,lp:integer):DWORD;stdcall; //键盘HOOK回调函数
begin
if (icode=HC_ACTION) then
begin
if (wp=VK_HOME)and ((1 shl 31)and lp=0) then
begin
if form1=nil then Form1:=Tform1.Create(nil);
form1.Visible:=not form1.Visible;
end;
end;
keyProc:=CallNextHookEx(keyhhk,icode,wp,lp);
end;
Function installKeyProc():boolean;stdcall;
var
h:HWND;
GameTid:THandle;
begin
Result:=false;
h:=FindWindow(nil,'武林外传11');
if h=0 then begin Messagebox(0,'未找到游戏','error',0);exit; end;//如果游戏未打开则退出
GameTid:=GetWindowThreadProcessId(h);
keyhhk:=SetWindowsHookEx(WH_KEYBOARD,@Keyproc,GetModuleHandle('HookDll.dll'),GameTid);
if keyhhk>0 then Result:=true;
end;
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;
exports //导出函数
installKeyProc;begin
dllProc:=@DllEnterProc;
end.
解决方案 »
- 初涉三层问题
- 测试用的hook代码。不知道错在哪里了。始终无法获得数据包
- 同一个界面在简繁体系统中的caption编码不同?谁能告诉我为什么??
- 自动登陆网站时,怎么样处理校验码啊?? 请大家帮帮忙啊!! 在线等待!!!!!~~~~~~~~~
- 关于浮动按钮
- 奇怪的问题---急切盼望大虾指点
- 一个系统提示,请帮手,在线等…
- 我用的wise8.14打包时,想要反安装程序在我的程序目录下怎么办?
- 内嵌汇编编译问题Inline assembler syntax error
- 请问各位高手:一台共享的打印机,我能限制其它机器打印或者打印的数量吗(用代码实现)
- DSpack 从指定时刻开始播放的问题
- 纠结。
FindWindow 只能找到一个
遍历窗口, 然后判断进程等,从那取句柄