Author: jimtabor Date: Thu Jul 24 06:38:08 2008 New Revision: 34736
URL: http://svn.reactos.org/svn/reactos?rev=34736&view=rev Log: - Added more hook points. Setup WH_MOUSE with callbacks, seems to be preloaded. Started BroadcastSystemMessage. - Tested with Opera 9.51, FF, Seamonkey, Abiword, Miranda and the rest of our applications.
Modified: trunk/reactos/dll/win32/user32/windows/hook.c trunk/reactos/dll/win32/user32/windows/message.c trunk/reactos/include/reactos/win32k/ntuser.h trunk/reactos/subsystems/win32/win32k/ntuser/callback.c trunk/reactos/subsystems/win32/win32k/ntuser/message.c trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c
Modified: trunk/reactos/dll/win32/user32/windows/hook.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/ho... ============================================================================== --- trunk/reactos/dll/win32/user32/windows/hook.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/hook.c [iso-8859-1] Thu Jul 24 06:38:08 2008 @@ -422,6 +422,7 @@ PKBDLLHOOKSTRUCT KeyboardLlData; PMSLLHOOKSTRUCT MouseLlData; PMSG Msg; + PMOUSEHOOKSTRUCT MHook;
Common = (PHOOKPROC_CALLBACK_ARGUMENTS) Arguments;
@@ -502,6 +503,10 @@ MouseLlData = (PMSLLHOOKSTRUCT)((PCHAR) Common + Common->lParam); Result = Common->Proc(Common->Code, Common->wParam, (LPARAM) MouseLlData); break; + case WH_MOUSE: + MHook = (PMOUSEHOOKSTRUCT)((PCHAR) Common + Common->lParam); + Result = Common->Proc(Common->Code, Common->wParam, (LPARAM) MHook); + break; case WH_MSGFILTER: case WH_SYSMSGFILTER: case WH_GETMESSAGE:
Modified: trunk/reactos/dll/win32/user32/windows/message.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/me... ============================================================================== --- trunk/reactos/dll/win32/user32/windows/message.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/message.c [iso-8859-1] Thu Jul 24 06:38:08 2008 @@ -2560,15 +2560,6 @@ return IsDialogMessageW( hwndDlg, &msg ); }
-typedef struct _BROADCASTPARM -{ - DWORD flags; - DWORD recipients; - HDESK hDesk; - HWND hWnd; - LUID luid; -} BROADCASTPARM, *PBROADCASTPARM; - LONG STDCALL IntBroadcastSystemMessage(
Modified: trunk/reactos/include/reactos/win32k/ntuser.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntus... ============================================================================== --- trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] (original) +++ trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] Thu Jul 24 06:38:08 2008 @@ -392,7 +392,14 @@ ATOM Atom; } PROPERTY, *PPROPERTY;
- +typedef struct _BROADCASTPARM +{ + DWORD flags; + DWORD recipients; + HDESK hDesk; + HWND hWnd; + LUID luid; +} BROADCASTPARM, *PBROADCASTPARM;
PW32THREADINFO GetW32ThreadInfo(VOID); PW32PROCESSINFO GetW32ProcessInfo(VOID);
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/callback.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/callback.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/callback.c [iso-8859-1] Thu Jul 24 06:38:08 2008 @@ -379,6 +379,9 @@ case WH_MOUSE_LL: ArgumentLength += sizeof(MSLLHOOKSTRUCT); break; + case WH_MOUSE: + ArgumentLength += sizeof(MOUSEHOOKSTRUCT); + break; case WH_MSGFILTER: case WH_SYSMSGFILTER: case WH_GETMESSAGE: @@ -444,6 +447,10 @@ RtlCopyMemory(Extra, (PVOID) lParam, sizeof(MSLLHOOKSTRUCT)); Common->lParam = (LPARAM) (Extra - (PCHAR) Common); break; + case WH_MOUSE: + RtlCopyMemory(Extra, (PVOID) lParam, sizeof(MOUSEHOOKSTRUCT)); + Common->lParam = (LPARAM) (Extra - (PCHAR) Common); + break; case WH_MSGFILTER: case WH_SYSMSGFILTER: case WH_GETMESSAGE:
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/message.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] Thu Jul 24 06:38:08 2008 @@ -658,6 +658,7 @@ BOOL Present, RemoveMessages; USER_REFERENCE_ENTRY Ref; USHORT HitTest; + MOUSEHOOKSTRUCT MHook;
/* The queues and order in which they are checked are documented in the MSDN article on GetMessage() */ @@ -814,9 +815,51 @@ goto CheckMessages; } MsgExit: + if ( ISITHOOKED(WH_MOUSE) && + Msg->Msg.message >= WM_MOUSEFIRST && + Msg->Msg.message <= WM_MOUSELAST ) + { + MHook.pt = Msg->Msg.pt; + MHook.hwnd = Msg->Msg.hwnd; + MHook.wHitTestCode = HitTest; + MHook.dwExtraInfo = 0; + if (co_HOOK_CallHooks( WH_MOUSE, + RemoveMsg ? HC_ACTION : HC_NOREMOVE, + Msg->Msg.message, + (LPARAM)&MHook )) + { + if (ISITHOOKED(WH_CBT)) + { + MHook.pt = Msg->Msg.pt; + MHook.hwnd = Msg->Msg.hwnd; + MHook.wHitTestCode = HitTest; + MHook.dwExtraInfo = 0; + co_HOOK_CallHooks( WH_CBT, HCBT_CLICKSKIPPED, + Msg->Msg.message, (LPARAM)&MHook); + } + return FALSE; + } + } + if ( ISITHOOKED(WH_KEYBOARD) && + (Msg->Msg.message == WM_KEYDOWN || Msg->Msg.message == WM_KEYUP) ) + { + if (co_HOOK_CallHooks( WH_KEYBOARD, + RemoveMsg ? HC_ACTION : HC_NOREMOVE, + LOWORD(Msg->Msg.wParam), + Msg->Msg.lParam)) + { + if (ISITHOOKED(WH_CBT)) + { + /* skip this message */ + co_HOOK_CallHooks( WH_CBT, HCBT_KEYSKIPPED, + LOWORD(Msg->Msg.wParam), Msg->Msg.lParam ); + } + return FALSE; + } + } // The WH_GETMESSAGE hook enables an application to monitor messages about to // be returned by the GetMessage or PeekMessage function. - if(ISITHOOKED(WH_GETMESSAGE)) + if (ISITHOOKED(WH_GETMESSAGE)) { //DPRINT1("Peek WH_GETMESSAGE -> %x\n",&Msg); co_HOOK_CallHooks( WH_GETMESSAGE, HC_ACTION, RemoveMsg & PM_REMOVE, (LPARAM)&Msg->Msg); @@ -863,7 +906,6 @@ }
Present = co_IntPeekMessage(&Msg, hWnd, MsgFilterMin, MsgFilterMax, RemoveMsg); - if (Present) {
@@ -1506,8 +1548,7 @@ } else { - if(!co_IntSendMessageTimeoutSingle(hWnd, Msg, wParam, lParam, SMTO_NORMAL, 0, &Result)) - { + if(!co_IntSendMessageTimeoutSingle(hWnd, Msg, wParam, lParam, SMTO_NORMAL, 0, &Result)) { Result = 0; } } @@ -1863,14 +1904,93 @@ { return 0; } - UserRefObjectCo(Window, &Ref); switch(dwType) { case FNID_DEFWINDOWPROC: + UserRefObjectCo(Window, &Ref); lResult = IntDefWindowProc(Window, Msg, wParam, lParam, Ansi); + UserDerefObjectCo(Window); break; - } - UserDerefObjectCo(Window); + case FNID_BROADCASTSYSTEMMESSAGE: + { + PBROADCASTPARM parm; + BOOL BadChk = FALSE; + DWORD_PTR RetVal = 0; + lResult = -1; + + if (ResultInfo) + { + _SEH_TRY + { + ProbeForWrite((PVOID)ResultInfo, + sizeof(BROADCASTPARM), + 1); + parm = (PBROADCASTPARM)ResultInfo; + } + _SEH_HANDLE + { + BadChk = TRUE; + } + _SEH_END; + if (BadChk) break; + } + else + break; + + if ( parm->recipients & BSM_ALLDESKTOPS || + parm->recipients == BSM_ALLCOMPONENTS ) + { + } + else if (parm->recipients & BSM_APPLICATIONS) + { + if (parm->flags & BSF_QUERY) + { + if (parm->flags & BSF_FORCEIFHUNG || parm->flags & BSF_NOHANG) + { + co_IntSendMessageTimeout( HWND_BROADCAST, + Msg, + wParam, + lParam, + SMTO_ABORTIFHUNG, + 2000, + &RetVal); + } + else if (parm->flags & BSF_NOTIMEOUTIFNOTHUNG) + { +#define SMTO_NOTIMEOUTIFNOTHUNG 0x0008 + co_IntSendMessageTimeout( HWND_BROADCAST, + Msg, + wParam, + lParam, + SMTO_NOTIMEOUTIFNOTHUNG, + 2000, + &RetVal); + } + else + { + co_IntSendMessageTimeout( HWND_BROADCAST, + Msg, + wParam, + lParam, + SMTO_NORMAL, + 2000, + &RetVal); + } + } + else if (parm->flags & BSF_POSTMESSAGE) + { + lResult = UserPostMessage(HWND_BROADCAST, Msg, wParam, lParam); + } + else if ( parm->flags & BSF_SENDNOTIFYMESSAGE) + { + lResult = UserSendNotifyMessage(HWND_BROADCAST, Msg, wParam, lParam); + } + } + } + break; + case FNID_SENDMESSAGECALLBACK: + break; + } UserLeave(); return lResult; }
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c [iso-8859-1] Thu Jul 24 06:38:08 2008 @@ -70,7 +70,22 @@ static VOID FASTCALL IdlePing(VOID) { + HWND hWnd; + PWINDOW_OBJECT Window; PW32PROCESS W32d = PsGetCurrentProcessWin32Process(); + + hWnd = UserGetForegroundWindow(); + + Window = UserGetWindowObject(hWnd); + + if (Window && Window->Wnd && (Window->Wnd->ti == GetW32ThreadInfo())) + { + if (ISITHOOKED(WH_FOREGROUNDIDLE)) + { + co_HOOK_CallHooks(WH_FOREGROUNDIDLE,HC_ACTION,0,0); + } + } + if (W32d && W32d->InputIdleEvent) KePulseEvent( W32d->InputIdleEvent, EVENT_INCREMENT, TRUE); } @@ -159,6 +174,7 @@ LARGE_INTEGER LargeTickCount; KIRQL OldIrql; ULONG Prev; + EVENTMSG Event;
IntLockSystemMessageQueue(OldIrql);
@@ -175,6 +191,13 @@
KeQueryTickCount(&LargeTickCount); Msg->time = MsqCalculateMessageTime(&LargeTickCount); + + Event.message = Msg->message; + Event.time = Msg->time; + Event.hwnd = Msg->hwnd; + Event.paramL = Msg->pt.x; + Event.paramH = Msg->pt.y; + co_HOOK_CallHooks( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&Event);
/* * If we got WM_MOUSEMOVE and there are already messages in the @@ -713,20 +736,36 @@ MSG Msg; LARGE_INTEGER LargeTickCount; KBDLLHOOKSTRUCT KbdHookData; + EVENTMSG Event; + + DPRINT("MsqPostKeyboardMessage(uMsg 0x%x, wParam 0x%x, lParam 0x%x)\n", + uMsg, wParam, lParam);
// Condition may arise when calling MsqPostMessage and waiting for an event. if (!UserIsEntered()) UserEnterExclusive(); // Fixme: Not sure ATM if this thread is locked.
- DPRINT("MsqPostKeyboardMessage(uMsg 0x%x, wParam 0x%x, lParam 0x%x)\n", - uMsg, wParam, lParam); + FocusMessageQueue = IntGetFocusMessageQueue();
Msg.hwnd = 0; + + if (FocusMessageQueue && (FocusMessageQueue->FocusWindow != (HWND)0)) + Msg.hwnd = FocusMessageQueue->FocusWindow; + Msg.message = uMsg; Msg.wParam = wParam; Msg.lParam = lParam;
KeQueryTickCount(&LargeTickCount); Msg.time = MsqCalculateMessageTime(&LargeTickCount); + + Event.message = Msg.message; + Event.hwnd = Msg.hwnd; + Event.time = Msg.time; + Event.paramL = (Msg.wParam & 0xFF) | (HIWORD(Msg.lParam) << 8); + Event.paramH = Msg.lParam & 0x7FFF; + if (HIWORD(Msg.lParam) & 0x0100) Event.paramH |= 0x8000; + co_HOOK_CallHooks( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&Event); + /* We can't get the Msg.pt point here since we don't know thread (and thus the window station) the message will end up in yet. */
@@ -744,7 +783,6 @@ return; }
- FocusMessageQueue = IntGetFocusMessageQueue(); if (FocusMessageQueue == NULL) { DPRINT("No focus message queue\n");