Page 1 of 1

failed to install hook in client

Posted: 2004-09-26 15:39:48
by vale
i have this problem...


how can resolve it?


in english plz :(

Posted: 2004-10-02 09:37:02
by Lord Ruslan Nightmare
Try to dig up hook installing.

Code: Select all

    g_patch_hhook = SetWindowsHookEx(WH_GETMESSAGE, patch_GetMsgProc,
        g_hinstance, client_thread_id);

    if(g_patch_hhook == 0)
    {
        api_error("Failed to install hook in client");
        return false;
    }


WinAPI SDK says:

Code: Select all


HHOOK SetWindowsHookEx(

    int idHook,   // type of hook to install
    HOOKPROC lpfn,   // address of hook procedure
    HINSTANCE hMod,   // handle of application instance
    DWORD dwThreadId    // identity of thread to install hook for
   );
An error may occur if the hMod parameter is NULL and the dwThreadId parameter is zero or specifies the identifier of a thread created by another process.

So, try to vary thease things, and call SetLastError(0) before SetWindowsHookEx() call, and call GetLastError() and FormatMessage() after.