Windows explorer getting hung if SetWindowsHookEx is used with keyboard or mouse hook and if I switch between the tabs using alt +tab on win10.

  • Thread starter Thread starter coder969
  • Start date Start date
C

coder969

Guest
I am using SetWindowsHookEx to monitor the keyboard eveNts. The code is working fine on Windows7 but when I ran the same code on the windows 10 then I am seeing the windows explore hang when I switch between the windows using alt tab

If I remove the hooking(SetWindowsHookEx ) then not seeing any hang

I am loading my dll from other exe where it will show the GUI

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
hInst=(HINSTANCE)hModule;
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
::DisableThreadLibraryCalls((HMODULE)hModule);
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
UnInstallKBHook();
break;

}
return TRUE;
}

extern "C" __declspec(dllexport) void InstallKBHook()
{

hkb=SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)KeyboardHook,hInst,0);

}
int UnInstallKBHook()
{
if(hkb)UnhookWindowsHookEx(hkb);
return 1;
}


LRESULT __declspec(dllexport)__stdcall CALLBACK KeyboardHook(int nCode,WPARAM wParam, LPARAM lParam)
{

if (((DWORD)lParam & 0x40000000) &&(HC_ACTION==nCode))
{
//nothing
}

LRESULT RetVal = CallNextHookEx( hkb, nCode, wParam, lParam );
return RetVal;
}


Do I need to enable any permission on windows 10?

Continue reading...
 
Back
Top