封装dll出问题(100)

W

wjy1986

Unregistered / Unconfirmed
GUEST, unregistred user!
小弟写了一个钩子程序,当程序调用系统MessageBoxA这个API时,改变输出消息。在本程序内可以实现。后来我想对任何一个调用到这个API的程序都起到同样的作用。于是我封装了一个DLL文件,但用另外的程序调用MessageBox时没有任何反应。这是为什么?
 
我是用静态方式调用的DLL文件。代码如下:library TryDLL;uses Windows, SysUtils, Classes, MessUnt in 'MessUnt.pas', APIHookUnt in 'APIHookUnt.pas';{$R *.res}function GetMsgProc(code: integer; removal: integer; msg: Pointer): Integer; stdcall;begin Result:=0;end;var HookHandle : THandle;procedure StartHook;stdcall;begin HookHandle:=SetWindowsHookEx(WH_GETMESSAGE,@GetMsgProc,HInstance,0);end;procedure StopHook;stdcall;begin UnhookWindowsHookEx(HookHandle);end;exports StartHook,StopHook;begin API_Hookup;end.
 
老老实实的把LApplication 句柄传进去 procedure MSGOK(value:string) begin _MSGOK(LApplication,value); end; procedure _MSGOK(LApplication: TApplication;value:string) begin LApplication.messagebox("fdfdfdkdfkfdk");end;
 
封装的句柄应该是可以在任何时候都可以用,我的意思是,用这个DLL中的HOOK函数,把MessageBoxA这个系统API挂上钩子。其他程序调用时,只要用到这个DLL文件,这个钩子就会起作用。
 
顶部