Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

WH_KEYBOARD_LL Keyboard Hook not functional

CheeseyCheesey Member Posts: 1
I am attempting to install a low level keyboard hook using:

[italic]hDll = LoadLibrary("steves_hooks.dll");
procAddress = GetProcAddress(hDll, "SYS_KeyboardHookLL");
wHookKeyboardLL = SetWindowsHookEx(WH_KEYBOARD_LL, procAddress, hDll, 0);[/italic]

SYS_KeyboardHookLL looks like this:

[italic]__declspec (dllexport) LRESULT CALLBACK SYS_KeyboardHookLL (int nCode, WPARAM wParam, LPARAM lParam)
{
int bControlKeyDown = 0;

printf("nCode = %d
", nCode);

if (nCode < 0)
return CallNextHookEx(0, nCode, wParam, lParam);

if (nCode == HC_ACTION)
{
KBDLLHOOKSTRUCT *kbdHookStruct = (KBDLLHOOKSTRUCT*)lParam;

printf("%d %d
", kbdHookStruct->flags, kbdHookStruct->vkCode);

bControlKeyDown = GetAsyncKeyState (VK_CONTROL);

// Disable Left Window and Right Window Keys
if ((kbdHookStruct->vkCode == VK_LWIN) || (kbdHookStruct->vkCode == VK_RWIN))
{
printf("Left or Right Windows Swallowed
");
return 1;
}

// Disable CTRL+ESC
if (kbdHookStruct->vkCode == VK_ESCAPE && bControlKeyDown)
{
printf("CTRL+ESC Swallowed
");
return 1;
}

// Disable ALT
if (kbdHookStruct->flags & LLKHF_ALTDOWN)
{
printf("ALT Swallowed
");
return 1;
}
}
return CallNextHookEx(0, nCode, wParam, lParam);
}[/italic]

Everything compiles OK and when I run it everything seems to return sensible values (I don't get any NULLS back). However SYS_KeyboardHookLL doesn't appear to be called on key presses (I certainly don't see any printf's).

If anyone has any thoughts I would appreciate them.

Regards

Steve


Sign In or Register to comment.