http://www.52hxw.com/ 这个网站提供了一个输入法外挂的程序,启动程序后,无论是用什么输入法,输入的文字上屏后都会被自动转换为异体字。这个程序的原理我猜测应该是用了消息HOOK技术,拦截并修改了输入法发送给应用程序的wm_char消息。程序安装后有一个dll文件,这个dll会被注入到系统所有进程,实现HOOK
我知道纯vb无法写出标准dll,可以使用vb+vc的方法实现。我对hook不是很熟,想问一下拦截wm_char消息需要安装哪个hook,vb具体怎么实现(有现成的dll模块更好),还有注入其它进程的dll如何与主程序通信?请高手指点一下,谢谢了

解决方案 »

  1.   

    ni 你放到API里面才有人回答的
      

  2.   

    设置全局的WH_GETMESSAGE这个HOOK是不是一定要用dll啊?怎么做呢,谁有没有示例代码啊
      

  3.   

    设置全局的WH_GETMESSAGE这个HOOK是不是一定要用dll啊?怎么做呢,谁有没有示例代码啊
    不一定的,VB也直接可以用的,简单思路:
    下钩
    SetWindowsHookEx WH_GETMESSAGE...钩子函数
    function...除钩
    UnhookWindowsEx...
      

  4.   

    汗,按照LS的思路的话,所有程序都很简单了
    加载
    运行ing
    结束
      

  5.   

    我就是不知道钩子函数该怎么写吖。SetWindowsHookEx   和UnhookWindowsEx都没什么问题。。
      

  6.   

    SyntaxLRESULT CALLBACK GetMsgProc(          int code,
        WPARAM wParam,
        LPARAM lParam
    );
    Parameterscode
    [in] Specifies whether the hook procedure must process the message. If code is HC_ACTION, the hook procedure must process the message. If code is less than zero, the hook procedure must pass the message to the CallNextHookEx function without further processing and should return the value returned by CallNextHookEx. 
    wParam
    [in] Specifies whether the message has been removed from the queue. This parameter can be one of the following values. 
    PM_NOREMOVE
    Specifies that the message has not been removed from the queue. (An application called the PeekMessage function, specifying the PM_NOREMOVE flag.)
    PM_REMOVE
    Specifies that the message has been removed from the queue. (An application called GetMessage, or it called the PeekMessage function, specifying the PM_REMOVE flag.)
    lParam
    [in] Pointer to an MSG structure that contains details about the message. 
    Return ValueIf code is less than zero, the hook procedure must return the value returned by CallNextHookEx. If code is greater than or equal to zero, it is highly recommended that you call CallNextHookEx and return the value it returns; otherwise, other applications that have installed WH_GETMESSAGE hooks will not receive hook notifications and may behave incorrectly as a result. If the hook procedure does not call CallNextHookEx, the return value should be zero. 
      

  7.   

    这是VC的片断代码,相信你看得懂LRESULT     CALLBACK   CallWndProc(int   nCode,WPARAM wParam,LPARAM lParam)   
      {   
      AFX_MANAGE_STATE(AfxGetStaticModuleState());   
      PCWPSTRUCT   pcw=(PCWPSTRUCT)   lParam;   
        
      if(nCode>=0   &&   pcw   &&   pcw->hwnd)   
      {   
      if(pcw->message==WM_CHAR)   
      {   
    ..............
      

  8.   

    谢谢大家咯
    谢谢asa5880 ^_^