S
sy0116
Unregistered / Unconfirmed
GUEST, unregistred user!
我用这种办法实现的APIHOOK,但是现在我想在mybox函数中实现仍然用MessageBoxA来显示对话框,应该怎么办呢?<br>unit Unit4;<br><br>interface<br>uses<br> Windows;<br><br>type<br> mymsgboxa=function(hWnd: HWND; lpText, lpCaption: PAnsiChar; uType: UINT): Integer; stdcall;<br> Tjump=packed record<br> jumpcode:Byte;<br> addr:mymsgboxa;<br> MoveEAX:Word;<br> reservedbyte:Byte;<br> end;<br><br>var<br> old,jmp:Tjump;<br> processhandle:THandle;<br> oldmsgboxachar;<br> dwsizeWORD;<br> hookhd:THandle;<br><br>procedure load;<br>implementation<br>function mybox(hWnd: HWND; lpText, lpCaption: PAnsiChar; uType: UINT): Integer; stdcall;<br>begin<br> MessageBoxW(hWnd,'APIHook成功,感谢各位高人相助','Hook OK',uType);<br>end; <br>procedure HookApi;<br>var<br> DllMoudle:THandle;<br>begin<br> processhandle:=GetCurrentProcess;<br> DllMoudle:=LoadLibrary('user32.dll');<br> oldmsgboxa:=GetProcAddress(DllMoudle,'MessageBoxA');<br> jmp.jumpcode:=$B8;<br> jmp.addr:=@mybox;<br> jmp.MoveEAX:=$E0FF;<br> ReadProcessMemory(processhandle,oldmsgboxa,@old,8,dwsize);<br> WriteProcessMemory(processhandle,oldmsgboxa,@jmp,8,dwsize);<br>end;<br>procedure HookEnd;<br>begin<br> WriteProcessMemory(processhandle,oldmsgboxa,@old,8,dwsize);<br>end;<br>function msghook(ncode,wparam,lparam:Integer):LRESULT;stdcall;<br>begin<br> hookapi;<br> Result:=CallNextHookEx(hookhd,ncode,wparam,lparam);<br>end;<br>procedure load;<br>begin<br> hookhd:=SetWindowsHookEx(WH_GETMESSAGE,@msghook,HInstance,0);<br>end;<br><br>end.