Implement WH_MOUSE_LL hook
Modified: trunk/reactos/lib/user32/windows/hook.c
Modified: trunk/reactos/subsys/win32k/ntuser/callback.c
Modified: trunk/reactos/subsys/win32k/ntuser/hook.c
Modified: trunk/reactos/subsys/win32k/ntuser/msgqueue.c
Modified: trunk/reactos/subsys/win32k/w32k.h
Modified: trunk/reactos/w32api/include/winuser.h
_____
Modified: trunk/reactos/lib/user32/windows/hook.c
--- trunk/reactos/lib/user32/windows/hook.c 2005-05-14 18:57:07 UTC
(rev 15283)
+++ trunk/reactos/lib/user32/windows/hook.c 2005-05-14 19:09:02 UTC
(rev 15284)
@@ -281,7 +281,8 @@
PHOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS CbtCreatewndExtra;
WPARAM wParam;
LPARAM lParam;
- KBDLLHOOKSTRUCT *KeyboardLlData;
+ PKBDLLHOOKSTRUCT KeyboardLlData;
+ PMSLLHOOKSTRUCT MouseLlData;
Common = (PHOOKPROC_CALLBACK_ARGUMENTS) Arguments;
@@ -355,9 +356,13 @@
}
break;
case WH_KEYBOARD_LL:
- KeyboardLlData = (KBDLLHOOKSTRUCT *)((PCHAR) Common +
Common->lParam);
+ KeyboardLlData = (PKBDLLHOOKSTRUCT)((PCHAR) Common +
Common->lParam);
Result = Common->Proc(Common->Code, Common->wParam, (LPARAM)
KeyboardLlData);
break;
+ case WH_MOUSE_LL:
+ MouseLlData = (PMSLLHOOKSTRUCT)((PCHAR) Common + Common->lParam);
+ Result = Common->Proc(Common->Code, Common->wParam, (LPARAM)
MouseLlData);
+ break;
default:
return ZwCallbackReturn(NULL, 0, STATUS_NOT_SUPPORTED);
}
_____
Modified: trunk/reactos/subsys/win32k/ntuser/callback.c
--- trunk/reactos/subsys/win32k/ntuser/callback.c 2005-05-14
18:57:07 UTC (rev 15283)
+++ trunk/reactos/subsys/win32k/ntuser/callback.c 2005-05-14
19:09:02 UTC (rev 15284)
@@ -296,6 +296,9 @@
case WH_KEYBOARD_LL:
ArgumentLength += sizeof(KBDLLHOOKSTRUCT);
break;
+ case WH_MOUSE_LL:
+ ArgumentLength += sizeof(MSLLHOOKSTRUCT);
+ break;
default:
DPRINT1("Trying to call unsupported window hook %d\n", HookId);
return 0;
@@ -350,6 +353,10 @@
RtlCopyMemory(Extra, (PVOID) lParam, sizeof(KBDLLHOOKSTRUCT));
Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
break;
+ case WH_MOUSE_LL:
+ RtlCopyMemory(Extra, (PVOID) lParam, sizeof(MSLLHOOKSTRUCT));
+ Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
+ break;
}
ResultPointer = &Result;
_____
Modified: trunk/reactos/subsys/win32k/ntuser/hook.c
--- trunk/reactos/subsys/win32k/ntuser/hook.c 2005-05-14 18:57:07 UTC
(rev 15283)
+++ trunk/reactos/subsys/win32k/ntuser/hook.c 2005-05-14 19:09:02 UTC
(rev 15284)
@@ -266,7 +266,7 @@
/* FIXME should get timeout from
* HKEY_CURRENT_USER\Control Panel\Desktop\LowLevelHooksTimeout */
Status = MsqSendMessage(Hook->Thread->Tcb.Win32Thread->MessageQueue,
(HWND) Code, HookId,
- wParam, lParam, /*500*/0, TRUE, TRUE,
&uResult);
+ wParam, lParam, 5000, TRUE, TRUE, &uResult);
return NT_SUCCESS(Status) ? uResult : 0;
}
_____
Modified: trunk/reactos/subsys/win32k/ntuser/msgqueue.c
--- trunk/reactos/subsys/win32k/ntuser/msgqueue.c 2005-05-14
18:57:07 UTC (rev 15283)
+++ trunk/reactos/subsys/win32k/ntuser/msgqueue.c 2005-05-14
19:09:02 UTC (rev 15284)
@@ -515,6 +515,7 @@
{
PUSER_MESSAGE UserMsg;
MSG Msg;
+ BOOL ProcessMessage;
ASSERT(SystemMessageQueueHead < SYSTEM_MESSAGE_QUEUE_SIZE);
Msg = SystemMessageQueue[SystemMessageQueueHead];
@@ -522,12 +523,48 @@
(SystemMessageQueueHead + 1) % SYSTEM_MESSAGE_QUEUE_SIZE;
SystemMessageQueueCount--;
IntUnLockSystemMessageQueue(OldIrql);
- UserMsg =
ExAllocateFromPagedLookasideList(&MessageLookasideList);
- /* What to do if out of memory? For now we just panic a bit in
debug */
- ASSERT(UserMsg);
- UserMsg->FreeLParam = FALSE;
- UserMsg->Msg = Msg;
- InsertTailList(&HardwareMessageQueueHead, &UserMsg->ListEntry);
+ if (WM_MOUSEFIRST <= Msg.message && Msg.message <= WM_MOUSELAST)
+ {
+ MSLLHOOKSTRUCT MouseHookData;
+
+ MouseHookData.pt.x = GET_X_LPARAM(Msg.lParam);
+ MouseHookData.pt.y = GET_Y_LPARAM(Msg.lParam);
+ switch(Msg.message)
+ {
+ case WM_MOUSEWHEEL:
+ MouseHookData.mouseData = MAKELONG(0,
GET_WHEEL_DELTA_WPARAM(Msg.wParam));
+ break;
+ case WM_XBUTTONDOWN:
+ case WM_XBUTTONUP:
+ case WM_XBUTTONDBLCLK:
+ case WM_NCXBUTTONDOWN:
+ case WM_NCXBUTTONUP:
+ case WM_NCXBUTTONDBLCLK:
+ MouseHookData.mouseData = MAKELONG(0,
HIWORD(Msg.wParam));
+ break;
+ default:
+ MouseHookData.mouseData = 0;
+ break;
+ }
+ MouseHookData.flags = 0;
+ MouseHookData.time = Msg.time;
+ MouseHookData.dwExtraInfo = 0;
+ ProcessMessage = (0 == HOOK_CallHooks(WH_MOUSE_LL, HC_ACTION,
+ Msg.message, (LPARAM)
&MouseHookData));
+ }
+ else
+ {
+ ProcessMessage = TRUE;
+ }
+ if (ProcessMessage)
+ {
+ UserMsg =
ExAllocateFromPagedLookasideList(&MessageLookasideList);
+ /* What to do if out of memory? For now we just panic a bit
in debug */
+ ASSERT(UserMsg);
+ UserMsg->FreeLParam = FALSE;
+ UserMsg->Msg = Msg;
+ InsertTailList(&HardwareMessageQueueHead,
&UserMsg->ListEntry);
+ }
IntLockSystemMessageQueue(OldIrql);
}
/*
_____
Modified: trunk/reactos/subsys/win32k/w32k.h
--- trunk/reactos/subsys/win32k/w32k.h 2005-05-14 18:57:07 UTC (rev
15283)
+++ trunk/reactos/subsys/win32k/w32k.h 2005-05-14 19:09:02 UTC (rev
15284)
@@ -27,6 +27,7 @@
#include <math.h>
#include <float.h>
#include <windows.h>
+#include <windowsx.h>
#include <rosrtl/string.h>
#include <user32/callback.h>
_____
Modified: trunk/reactos/w32api/include/winuser.h
--- trunk/reactos/w32api/include/winuser.h 2005-05-14 18:57:07 UTC
(rev 15283)
+++ trunk/reactos/w32api/include/winuser.h 2005-05-14 19:09:02 UTC
(rev 15284)
@@ -2151,6 +2151,7 @@
#define LLKHF_INJECTED 0x00000010
#define LLKHF_ALTDOWN 0x00000020
#define LLKHF_UP 0x00000080
+#define LLMHF_INJECTED 0x00000001
#if (WINVER >= 0x0500)
#define FLASHW_STOP 0
#define FLASHW_CAPTION 1
@@ -3065,6 +3066,14 @@
DWORD time;
DWORD dwExtraInfo;
} KBDLLHOOKSTRUCT,*LPKBDLLHOOKSTRUCT,*PKBDLLHOOKSTRUCT;
+typedef struct tagMSLLHOOKSTRUCT
+{
+ POINT pt;
+ DWORD mouseData;
+ DWORD flags;
+ DWORD time;
+ ULONG_PTR dwExtraInfo;
+} MSLLHOOKSTRUCT, *LPMSLLHOOKSTRUCT, *PMSLLHOOKSTRUCT;
#if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410)
typedef struct {
UINT cbSize;