mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 20:56:26 +00:00
- Added more hook points, WH_FOREGROUNDIDLE and WH_KEYBOARD.
- Fixed WH_CALLWNDPROC/RET, now the posted test program works as it should. - Tested with Opera 9.51, FF, Seamonkey, Abiword, Miranda, Mirc and the rest of our applications. svn path=/trunk/; revision=34922
This commit is contained in:
parent
2bd0499500
commit
274bd6b2ab
4 changed files with 93 additions and 59 deletions
|
@ -524,7 +524,9 @@ User32CallHookProcFromKernel(PVOID Arguments, ULONG ArgumentLength)
|
||||||
// FIXME("UHOOK Memory: %x: %x\n",Common, Msg);
|
// FIXME("UHOOK Memory: %x: %x\n",Common, Msg);
|
||||||
Result = Common->Proc(Common->Code, Common->wParam, (LPARAM) Msg);
|
Result = Common->Proc(Common->Code, Common->wParam, (LPARAM) Msg);
|
||||||
break;
|
break;
|
||||||
|
case WH_FOREGROUNDIDLE:
|
||||||
case WH_KEYBOARD:
|
case WH_KEYBOARD:
|
||||||
|
case WH_SHELL:
|
||||||
Result = Common->Proc(Common->Code, Common->wParam, Common->lParam);
|
Result = Common->Proc(Common->Code, Common->wParam, Common->lParam);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -393,8 +393,9 @@ co_IntCallHookProc(INT HookId,
|
||||||
case WH_GETMESSAGE:
|
case WH_GETMESSAGE:
|
||||||
ArgumentLength += sizeof(MSG);
|
ArgumentLength += sizeof(MSG);
|
||||||
break;
|
break;
|
||||||
|
case WH_FOREGROUNDIDLE:
|
||||||
case WH_KEYBOARD:
|
case WH_KEYBOARD:
|
||||||
// case WH_SHELL:
|
case WH_SHELL:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DPRINT1("Trying to call unsupported window hook %d\n", HookId);
|
DPRINT1("Trying to call unsupported window hook %d\n", HookId);
|
||||||
|
@ -473,10 +474,9 @@ co_IntCallHookProc(INT HookId,
|
||||||
Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
|
Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
|
||||||
// DPRINT1("KHOOK Memory: %x\n",Common);
|
// DPRINT1("KHOOK Memory: %x\n",Common);
|
||||||
break;
|
break;
|
||||||
|
case WH_FOREGROUNDIDLE:
|
||||||
case WH_KEYBOARD:
|
case WH_KEYBOARD:
|
||||||
break;
|
case WH_SHELL:
|
||||||
// case WH_SHELL:
|
|
||||||
// Extra = lParam;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -267,15 +267,22 @@ IntReleaseHookChain(PHOOKTABLE Table, int HookId, PWINSTATION_OBJECT WinStaObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static LRESULT FASTCALL
|
static LRESULT FASTCALL
|
||||||
IntCallLowLevelHook(INT HookId, INT Code, WPARAM wParam, LPARAM lParam, PHOOK Hook)
|
IntCallLowLevelHook(PHOOK Hook, INT Code, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG_PTR uResult;
|
ULONG_PTR uResult;
|
||||||
|
|
||||||
/* FIXME should get timeout from
|
/* FIXME should get timeout from
|
||||||
* HKEY_CURRENT_USER\Control Panel\Desktop\LowLevelHooksTimeout */
|
* HKEY_CURRENT_USER\Control Panel\Desktop\LowLevelHooksTimeout */
|
||||||
Status = co_MsqSendMessage(((PW32THREAD)Hook->Thread->Tcb.Win32Thread)->MessageQueue, (HWND) Code, HookId,
|
Status = co_MsqSendMessage(((PW32THREAD)Hook->Thread->Tcb.Win32Thread)->MessageQueue,
|
||||||
wParam, lParam, 5000, TRUE, TRUE, &uResult);
|
(HWND) Code,
|
||||||
|
Hook->HookId,
|
||||||
|
wParam,
|
||||||
|
lParam,
|
||||||
|
5000,
|
||||||
|
TRUE,
|
||||||
|
TRUE,
|
||||||
|
&uResult);
|
||||||
|
|
||||||
return NT_SUCCESS(Status) ? uResult : 0;
|
return NT_SUCCESS(Status) ? uResult : 0;
|
||||||
}
|
}
|
||||||
|
@ -317,17 +324,10 @@ co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Hook->Thread != PsGetCurrentThread()
|
|
||||||
&& (WH_KEYBOARD_LL == HookId || WH_MOUSE_LL == HookId))
|
|
||||||
{
|
|
||||||
DPRINT("Calling hook in owning thread\n");
|
|
||||||
return IntCallLowLevelHook(HookId, Code, wParam, lParam, Hook);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((Hook->Thread != PsGetCurrentThread()) && (Hook->Thread != NULL))
|
if ((Hook->Thread != PsGetCurrentThread()) && (Hook->Thread != NULL))
|
||||||
{
|
{
|
||||||
DPRINT1("Calling hooks in other threads not implemented yet");
|
// Post it in message queue.
|
||||||
return 0;
|
return IntCallLowLevelHook(Hook, Code, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
Table->Counts[HOOKID_TO_INDEX(HookId)]++;
|
Table->Counts[HOOKID_TO_INDEX(HookId)]++;
|
||||||
|
@ -340,8 +340,13 @@ co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
|
||||||
SaveHook = ClientInfo->phkCurrent;
|
SaveHook = ClientInfo->phkCurrent;
|
||||||
ClientInfo->phkCurrent = Hook; // Load the call.
|
ClientInfo->phkCurrent = Hook; // Load the call.
|
||||||
|
|
||||||
Result = co_IntCallHookProc(HookId, Code, wParam, lParam, Hook->Proc,
|
Result = co_IntCallHookProc( HookId,
|
||||||
Hook->Ansi, &Hook->ModuleName);
|
Code,
|
||||||
|
wParam,
|
||||||
|
lParam,
|
||||||
|
Hook->Proc,
|
||||||
|
Hook->Ansi,
|
||||||
|
&Hook->ModuleName);
|
||||||
|
|
||||||
ClientInfo->phkCurrent = SaveHook;
|
ClientInfo->phkCurrent = SaveHook;
|
||||||
|
|
||||||
|
@ -413,9 +418,19 @@ static LRESULT
|
||||||
FASTCALL
|
FASTCALL
|
||||||
co_HOOK_CallHookNext(PHOOK Hook, INT Code, WPARAM wParam, LPARAM lParam)
|
co_HOOK_CallHookNext(PHOOK Hook, INT Code, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
if ((Hook->Thread != PsGetCurrentThread()) && (Hook->Thread != NULL))
|
||||||
|
{
|
||||||
|
DPRINT1("CALLING HOOK from another Thread. %d\n",Hook->HookId);
|
||||||
|
return IntCallLowLevelHook(Hook, Code, wParam, lParam);
|
||||||
|
}
|
||||||
DPRINT("CALLING HOOK %d\n",Hook->HookId);
|
DPRINT("CALLING HOOK %d\n",Hook->HookId);
|
||||||
return co_IntCallHookProc(Hook->HookId, Code, wParam, lParam, Hook->Proc,
|
return co_IntCallHookProc(Hook->HookId,
|
||||||
Hook->Ansi, &Hook->ModuleName);
|
Code,
|
||||||
|
wParam,
|
||||||
|
lParam,
|
||||||
|
Hook->Proc,
|
||||||
|
Hook->Ansi,
|
||||||
|
&Hook->ModuleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1030,9 +1045,7 @@ NtUserSetWindowsHookEx(
|
||||||
if (Global ||
|
if (Global ||
|
||||||
WH_DEBUG == HookId ||
|
WH_DEBUG == HookId ||
|
||||||
WH_JOURNALPLAYBACK == HookId ||
|
WH_JOURNALPLAYBACK == HookId ||
|
||||||
WH_JOURNALRECORD == HookId ||
|
WH_JOURNALRECORD == HookId)
|
||||||
WH_FOREGROUNDIDLE == HookId ||
|
|
||||||
WH_SHELL == HookId)
|
|
||||||
{
|
{
|
||||||
#if 0 /* Removed to get winEmbed working again */
|
#if 0 /* Removed to get winEmbed working again */
|
||||||
UNIMPLEMENTED
|
UNIMPLEMENTED
|
||||||
|
|
|
@ -295,6 +295,53 @@ UnpackParam(LPARAM lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
VOID
|
||||||
|
FASTCALL
|
||||||
|
IntCallWndProc
|
||||||
|
( PWINDOW_OBJECT Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
BOOL SameThread = FALSE;
|
||||||
|
|
||||||
|
if (Window->ti == PsGetCurrentThreadWin32Thread()->ThreadInfo)
|
||||||
|
SameThread = TRUE;
|
||||||
|
|
||||||
|
if ((!SameThread && (Window->ti->Hooks & HOOKID_TO_FLAG(WH_CALLWNDPROC))) ||
|
||||||
|
(SameThread && ISITHOOKED(WH_CALLWNDPROC)) )
|
||||||
|
{
|
||||||
|
CWPSTRUCT CWP;
|
||||||
|
CWP.hwnd = hWnd;
|
||||||
|
CWP.message = Msg;
|
||||||
|
CWP.wParam = wParam;
|
||||||
|
CWP.lParam = lParam;
|
||||||
|
co_HOOK_CallHooks( WH_CALLWNDPROC, HC_ACTION, SameThread, (LPARAM)&CWP );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static
|
||||||
|
VOID
|
||||||
|
FASTCALL
|
||||||
|
IntCallWndProcRet
|
||||||
|
( PWINDOW_OBJECT Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *uResult)
|
||||||
|
{
|
||||||
|
BOOL SameThread = FALSE;
|
||||||
|
|
||||||
|
if (Window->ti == PsGetCurrentThreadWin32Thread()->ThreadInfo)
|
||||||
|
SameThread = TRUE;
|
||||||
|
|
||||||
|
if ((!SameThread && (Window->ti->Hooks & HOOKID_TO_FLAG(WH_CALLWNDPROCRET))) ||
|
||||||
|
(SameThread && ISITHOOKED(WH_CALLWNDPROCRET)) )
|
||||||
|
{
|
||||||
|
CWPRETSTRUCT CWPR;
|
||||||
|
CWPR.hwnd = hWnd;
|
||||||
|
CWPR.message = Msg;
|
||||||
|
CWPR.wParam = wParam;
|
||||||
|
CWPR.lParam = lParam;
|
||||||
|
CWPR.lResult = *uResult;
|
||||||
|
co_HOOK_CallHooks( WH_CALLWNDPROCRET, HC_ACTION, SameThread, (LPARAM)&CWPR );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
STDCALL
|
STDCALL
|
||||||
NtUserCallMsgFilter(
|
NtUserCallMsgFilter(
|
||||||
|
@ -1429,7 +1476,6 @@ co_IntSendMessageTimeoutSingle(HWND hWnd,
|
||||||
PW32THREAD Win32Thread;
|
PW32THREAD Win32Thread;
|
||||||
DECLARE_RETURN(LRESULT);
|
DECLARE_RETURN(LRESULT);
|
||||||
USER_REFERENCE_ENTRY Ref;
|
USER_REFERENCE_ENTRY Ref;
|
||||||
BOOL SameThread = FALSE;
|
|
||||||
|
|
||||||
if (!(Window = UserGetWindowObject(hWnd)))
|
if (!(Window = UserGetWindowObject(hWnd)))
|
||||||
{
|
{
|
||||||
|
@ -1440,19 +1486,7 @@ co_IntSendMessageTimeoutSingle(HWND hWnd,
|
||||||
|
|
||||||
Win32Thread = PsGetCurrentThreadWin32Thread();
|
Win32Thread = PsGetCurrentThreadWin32Thread();
|
||||||
|
|
||||||
if (Window->ti == Win32Thread->ThreadInfo)
|
IntCallWndProc( Window, hWnd, Msg, wParam, lParam);
|
||||||
SameThread = TRUE;
|
|
||||||
|
|
||||||
if ((!SameThread && (Window->ti->Hooks & HOOKID_TO_FLAG(WH_CALLWNDPROC))) ||
|
|
||||||
(SameThread && ISITHOOKED(WH_CALLWNDPROC)) )
|
|
||||||
{
|
|
||||||
CWPSTRUCT CWP;
|
|
||||||
CWP.hwnd = hWnd;
|
|
||||||
CWP.message = Msg;
|
|
||||||
CWP.wParam = wParam;
|
|
||||||
CWP.lParam = lParam;
|
|
||||||
co_HOOK_CallHooks( WH_CALLWNDPROC, HC_ACTION, SameThread, (LPARAM)&CWP );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL != Win32Thread &&
|
if (NULL != Win32Thread &&
|
||||||
Window->MessageQueue == Win32Thread->MessageQueue)
|
Window->MessageQueue == Win32Thread->MessageQueue)
|
||||||
|
@ -1488,17 +1522,7 @@ co_IntSendMessageTimeoutSingle(HWND hWnd,
|
||||||
*uResult = Result;
|
*uResult = Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!SameThread && (Window->ti->Hooks & HOOKID_TO_FLAG(WH_CALLWNDPROCRET))) ||
|
IntCallWndProcRet( Window, hWnd, Msg, wParam, lParam, (LRESULT *)uResult);
|
||||||
(SameThread && ISITHOOKED(WH_CALLWNDPROCRET)) )
|
|
||||||
{
|
|
||||||
CWPRETSTRUCT CWPR;
|
|
||||||
CWPR.hwnd = hWnd;
|
|
||||||
CWPR.message = Msg;
|
|
||||||
CWPR.wParam = wParam;
|
|
||||||
CWPR.lParam = lParam;
|
|
||||||
CWPR.lResult = Result;
|
|
||||||
co_HOOK_CallHooks( WH_CALLWNDPROCRET, HC_ACTION, SameThread, (LPARAM)&CWPR );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! NT_SUCCESS(UnpackParam(lParamPacked, Msg, wParam, lParam)))
|
if (! NT_SUCCESS(UnpackParam(lParamPacked, Msg, wParam, lParam)))
|
||||||
{
|
{
|
||||||
|
@ -1538,17 +1562,7 @@ co_IntSendMessageTimeoutSingle(HWND hWnd,
|
||||||
(uFlags & SMTO_NOTIMEOUTIFNOTHUNG) &&
|
(uFlags & SMTO_NOTIMEOUTIFNOTHUNG) &&
|
||||||
!MsqIsHung(Window->MessageQueue));
|
!MsqIsHung(Window->MessageQueue));
|
||||||
|
|
||||||
if ((!SameThread && (Window->ti->Hooks & HOOKID_TO_FLAG(WH_CALLWNDPROCRET))) ||
|
IntCallWndProcRet( Window, hWnd, Msg, wParam, lParam, (LRESULT *)uResult);
|
||||||
(SameThread && ISITHOOKED(WH_CALLWNDPROCRET)) )
|
|
||||||
{
|
|
||||||
CWPRETSTRUCT CWPR;
|
|
||||||
CWPR.hwnd = hWnd;
|
|
||||||
CWPR.message = Msg;
|
|
||||||
CWPR.wParam = wParam;
|
|
||||||
CWPR.lParam = lParam;
|
|
||||||
CWPR.lResult = *uResult;
|
|
||||||
co_HOOK_CallHooks( WH_CALLWNDPROCRET, HC_ACTION, SameThread, (LPARAM)&CWPR );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (STATUS_TIMEOUT == Status)
|
if (STATUS_TIMEOUT == Status)
|
||||||
{
|
{
|
||||||
|
@ -1703,6 +1717,8 @@ co_IntDoSendMessage(HWND hWnd,
|
||||||
Info.Ansi = ! Window->Wnd->Unicode;
|
Info.Ansi = ! Window->Wnd->Unicode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IntCallWndProc( Window, hWnd, Msg, wParam, lParam);
|
||||||
|
|
||||||
if (Window->Wnd->IsSystem)
|
if (Window->Wnd->IsSystem)
|
||||||
{
|
{
|
||||||
Info.Proc = (!Info.Ansi ? Window->Wnd->WndProc : Window->Wnd->WndProcExtra);
|
Info.Proc = (!Info.Ansi ? Window->Wnd->WndProc : Window->Wnd->WndProcExtra);
|
||||||
|
@ -1712,6 +1728,9 @@ co_IntDoSendMessage(HWND hWnd,
|
||||||
Info.Ansi = !Window->Wnd->Unicode;
|
Info.Ansi = !Window->Wnd->Unicode;
|
||||||
Info.Proc = Window->Wnd->WndProc;
|
Info.Proc = Window->Wnd->WndProc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IntCallWndProcRet( Window, hWnd, Msg, wParam, lParam, &Result);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue