- Value of HINSTANCE from DllMain causing system to lock-up
- Posted by Greg Roberts on January 9th, 2004
I write a system hook to listen for certain events. The DLL loads and
seems to go through the correct steps but there is a problem when I
assign the value to the HISTANCE that is going to be used in my call
to SetWindowsHookEx with the value from DllMain this causes my system
to lock up. I know this is the problem cause if I don't assign it
before calling the SetHook then the SetWindowsHookEx returns NULL. As
soon as I set this value and run it my machine completely locks and I
need to restart.
Any ideas?
Thank you,
- Posted by lev on January 11th, 2004
What value are you specifying for the forth paramaeter (dwThreadId) ?
Quote from MSDN
hMod
[in] Handle to the DLL containing the hook procedure pointed to by the lpfn
parameter. The hMod parameter must be set to NULL if the dwThreadId
parameter specifies a thread created by the current process and if the hook
procedure is within the code associated with the current process.
"Greg Roberts" <gwrobert@us.ibm.com> wrote in message
news:92498645.0401091206.27aa3744@posting.google.c om...
- Posted by Greg Roberts on January 12th, 2004
I have set that to NULL.
SetWindowsHookEx(WH_GETMESSAGE,(HOOKPROC) GetMsgProc,g_hinstDLL,NULL);
And in DllMain I do this...
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
{
....
g_hinstDll = hinstDLL;
....
}
Thank you.
"lev" <ltsentsiper@brandsoft.com> wrote in message news:<vg1Mb.18796$nt4.40498@attbi_s51>...