关于网友提出的“ dll注入,处理多线程”问题疑问,本网通过在网上对“ dll注入,处理多线程”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: dll注入,处理多线程
描述: 语言基础区没人回答啊。郁闷
就剩120分 另外一帖是100分 没人回答 谁能帮帮我 另外100分的帖在这:
http://topic.csdn.net/u/20100511/17/30647f54-4142-4b93-beb6-6b348028de54.html?33251
前提:
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);//hookdll为本dll
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.
解决方案1: 你第二个没注入进去
FindWindow 只能找到一个
遍历窗口, 然后判断进程等,从那取句柄
以上介绍了“ dll注入,处理多线程”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/2245640.html