mirror of
https://github.com/reactos/reactos.git
synced 2024-06-29 01:12:06 +00:00
[Win32k|User32]
- Add fix for KsStudio for Olaf Siejka and debug prints for WH_KEYBOARD_LL. See bug 5670 for more details. svn path=/trunk/; revision=49278
This commit is contained in:
parent
f46ca6e613
commit
4588fc7dc5
|
@ -452,8 +452,6 @@ User32CallHookProcFromKernel(PVOID Arguments, ULONG ArgumentLength)
|
|||
LRESULT Result;
|
||||
CREATESTRUCTW Csw;
|
||||
CBT_CREATEWNDW CbtCreatewndw;
|
||||
CREATESTRUCTA Csa;
|
||||
CBT_CREATEWNDA CbtCreatewnda;
|
||||
PHOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS CbtCreatewndExtra = NULL;
|
||||
WPARAM wParam = 0;
|
||||
LPARAM lParam = 0;
|
||||
|
@ -479,30 +477,12 @@ User32CallHookProcFromKernel(PVOID Arguments, ULONG ArgumentLength)
|
|||
CbtCreatewndExtra = (PHOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS)
|
||||
((PCHAR) Common + Common->lParam);
|
||||
Csw = CbtCreatewndExtra->Cs;
|
||||
if (NULL != CbtCreatewndExtra->Cs.lpszName)
|
||||
{
|
||||
Csw.lpszName = (LPCWSTR)((PCHAR) CbtCreatewndExtra
|
||||
+ (ULONG_PTR) CbtCreatewndExtra->Cs.lpszName);
|
||||
}
|
||||
if (0 != HIWORD(CbtCreatewndExtra->Cs.lpszClass))
|
||||
{
|
||||
Csw.lpszClass = (LPCWSTR)((PCHAR) CbtCreatewndExtra
|
||||
+ LOWORD((ULONG_PTR) CbtCreatewndExtra->Cs.lpszClass));
|
||||
}
|
||||
Csw.lpszName = CbtCreatewndExtra->Cs.lpszName;
|
||||
Csw.lpszClass = CbtCreatewndExtra->Cs.lpszClass;
|
||||
wParam = Common->wParam;
|
||||
if (Common->Ansi)
|
||||
{
|
||||
memcpy(&Csa, &Csw, sizeof(CREATESTRUCTW));
|
||||
CbtCreatewnda.lpcs = &Csa;
|
||||
CbtCreatewnda.hwndInsertAfter = CbtCreatewndExtra->WndInsertAfter;
|
||||
lParam = (LPARAM) &CbtCreatewnda;
|
||||
}
|
||||
else
|
||||
{
|
||||
CbtCreatewndw.lpcs = &Csw;
|
||||
CbtCreatewndw.hwndInsertAfter = CbtCreatewndExtra->WndInsertAfter;
|
||||
lParam = (LPARAM) &CbtCreatewndw;
|
||||
}
|
||||
CbtCreatewndw.lpcs = &Csw;
|
||||
CbtCreatewndw.hwndInsertAfter = CbtCreatewndExtra->WndInsertAfter;
|
||||
lParam = (LPARAM) &CbtCreatewndw;
|
||||
break;
|
||||
case HCBT_CLICKSKIPPED:
|
||||
pMHook = (PMOUSEHOOKSTRUCT)((PCHAR) Common + Common->lParam);
|
||||
|
@ -555,6 +535,7 @@ User32CallHookProcFromKernel(PVOID Arguments, ULONG ArgumentLength)
|
|||
break;
|
||||
}
|
||||
case WH_KEYBOARD_LL:
|
||||
ERR("WH_KEYBOARD_LL: Code %d, wParam %d\n",Common->Code,Common->wParam);
|
||||
pKeyboardLlData = (PKBDLLHOOKSTRUCT)((PCHAR) Common + Common->lParam);
|
||||
Result = Common->Proc(Common->Code, Common->wParam, (LPARAM) pKeyboardLlData);
|
||||
break;
|
||||
|
|
|
@ -333,8 +333,6 @@ co_IntCallHookProc(INT HookId,
|
|||
CBT_CREATEWNDW *CbtCreateWnd = NULL;
|
||||
PCHAR Extra;
|
||||
PHOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS CbtCreatewndExtra = NULL;
|
||||
UNICODE_STRING WindowName, ClassName;
|
||||
ANSI_STRING asWindowName, asClassName;
|
||||
PTHREADINFO pti;
|
||||
PWND pWnd;
|
||||
BOOL Hit = FALSE;
|
||||
|
@ -362,64 +360,11 @@ co_IntCallHookProc(INT HookId,
|
|||
DPRINT1("WH_CBT HCBT_CREATEWND wParam bad hWnd!\n");
|
||||
goto Fault_Exit;
|
||||
}
|
||||
|
||||
// Due to KsStudio.exe, just pass the callers original pointers
|
||||
// except class which point to kernel space if not an atom.
|
||||
// Found by, Olaf Siejka
|
||||
CbtCreateWnd = (CBT_CREATEWNDW *) lParam;
|
||||
ArgumentLength += sizeof(HOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS);
|
||||
|
||||
if (Ansi)
|
||||
{
|
||||
RtlInitAnsiString(&asWindowName, NULL);
|
||||
_SEH2_TRY
|
||||
{
|
||||
ProbeForRead(CbtCreateWnd->lpcs->lpszName, sizeof(CHAR), 1);
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
Hit = TRUE;
|
||||
}
|
||||
_SEH2_END;
|
||||
if (Hit) // Client is at deaths door.
|
||||
goto Fault_Exit;
|
||||
if (CbtCreateWnd->lpcs->lpszName)
|
||||
RtlInitAnsiString(&asWindowName, (PCSZ)CbtCreateWnd->lpcs->lpszName);
|
||||
ArgumentLength += asWindowName.Length + sizeof(CHAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
RtlInitUnicodeString(&WindowName, NULL);
|
||||
_SEH2_TRY
|
||||
{
|
||||
ProbeForRead(CbtCreateWnd->lpcs->lpszName, sizeof(WCHAR), 1);
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
Hit = TRUE;
|
||||
}
|
||||
_SEH2_END;
|
||||
if (Hit)
|
||||
goto Fault_Exit;
|
||||
if (CbtCreateWnd->lpcs->lpszName)
|
||||
RtlInitUnicodeString(&WindowName, CbtCreateWnd->lpcs->lpszName);
|
||||
ArgumentLength += WindowName.Length + sizeof(WCHAR);
|
||||
}
|
||||
|
||||
if (!IS_ATOM(CbtCreateWnd->lpcs->lpszClass))
|
||||
{
|
||||
if (Ansi)
|
||||
{
|
||||
RtlInitAnsiString(&asClassName, NULL);
|
||||
if (CbtCreateWnd->lpcs->lpszClass)
|
||||
RtlInitAnsiString(&asClassName, (PCSZ)CbtCreateWnd->lpcs->lpszClass);
|
||||
ArgumentLength += asClassName.Length + sizeof(CHAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
RtlInitUnicodeString(&ClassName, NULL);
|
||||
if (CbtCreateWnd->lpcs->lpszClass)
|
||||
RtlInitUnicodeString(&ClassName, CbtCreateWnd->lpcs->lpszClass);
|
||||
ArgumentLength += ClassName.Length + sizeof(WCHAR);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case HCBT_MOVESIZE:
|
||||
|
@ -502,55 +447,9 @@ co_IntCallHookProc(INT HookId,
|
|||
CbtCreatewndExtra = (PHOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS) Extra;
|
||||
RtlCopyMemory( &CbtCreatewndExtra->Cs, CbtCreateWnd->lpcs, sizeof(CREATESTRUCTW) );
|
||||
CbtCreatewndExtra->WndInsertAfter = CbtCreateWnd->hwndInsertAfter;
|
||||
Extra = (PCHAR) (CbtCreatewndExtra + 1);
|
||||
CbtCreatewndExtra->Cs.lpszClass = CbtCreateWnd->lpcs->lpszClass; // if Atom
|
||||
|
||||
if (Ansi)
|
||||
{
|
||||
if (asWindowName.Buffer)
|
||||
RtlCopyMemory(Extra, asWindowName.Buffer, asWindowName.Length);
|
||||
CbtCreatewndExtra->Cs.lpszName = (LPCWSTR) (Extra - (PCHAR) CbtCreatewndExtra);
|
||||
Extra += asWindowName.Length;
|
||||
|
||||
*((CHAR *) Extra) = '\0';
|
||||
Extra += sizeof(CHAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WindowName.Buffer)
|
||||
RtlCopyMemory(Extra, WindowName.Buffer, WindowName.Length);
|
||||
CbtCreatewndExtra->Cs.lpszName = (LPCWSTR) (Extra - (PCHAR) CbtCreatewndExtra);
|
||||
Extra += WindowName.Length;
|
||||
|
||||
*((WCHAR *) Extra) = L'\0';
|
||||
Extra += sizeof(WCHAR);
|
||||
}
|
||||
|
||||
if (!IS_ATOM(CbtCreateWnd->lpcs->lpszClass))
|
||||
{
|
||||
if (Ansi)
|
||||
{
|
||||
if (asClassName.Buffer)
|
||||
RtlCopyMemory(Extra, asClassName.Buffer, asClassName.Length);
|
||||
CbtCreatewndExtra->Cs.lpszClass =
|
||||
(LPCWSTR)(ULONG_PTR) MAKELONG(Extra - (PCHAR) CbtCreatewndExtra, 1);
|
||||
Extra += asClassName.Length;
|
||||
|
||||
*((CHAR *) Extra) = '\0';
|
||||
Extra += sizeof(CHAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ClassName.Buffer)
|
||||
RtlCopyMemory(Extra, ClassName.Buffer, ClassName.Length);
|
||||
CbtCreatewndExtra->Cs.lpszClass =
|
||||
(LPCWSTR)(ULONG_PTR) MAKELONG(Extra - (PCHAR) CbtCreatewndExtra, 1);
|
||||
Extra += ClassName.Length;
|
||||
|
||||
*((WCHAR *) Extra) = L'\0';
|
||||
Extra += sizeof(WCHAR);
|
||||
}
|
||||
}
|
||||
CbtCreatewndExtra->Cs.lpszName = CbtCreateWnd->lpcs->lpszName;
|
||||
Extra = (PCHAR) (CbtCreatewndExtra + 1);
|
||||
break;
|
||||
case HCBT_CLICKSKIPPED:
|
||||
RtlCopyMemory(Extra, (PVOID) lParam, sizeof(MOUSEHOOKSTRUCT));
|
||||
|
|
|
@ -987,11 +987,14 @@ co_HOOK_CallHooks( INT HookId,
|
|||
ObReferenceObject(ptiHook->pEThread);
|
||||
if (ptiHook != pti )
|
||||
{
|
||||
DPRINT("\nGlobal Hook posting to another Thread! %d\n",HookId );
|
||||
if (HookId == WH_KEYBOARD_LL){
|
||||
DPRINT1("\nGlobal Hook posting to another Thread! %d\n",HookId );}
|
||||
Result = IntCallLowLevelHook(Hook, Code, wParam, lParam);
|
||||
}
|
||||
else
|
||||
{ /* Make the direct call. */
|
||||
if (HookId == WH_KEYBOARD_LL){
|
||||
DPRINT1("\nLocal Hook calling to Thread! %d\n",HookId );}
|
||||
Result = co_IntCallHookProc( HookId,
|
||||
Code,
|
||||
wParam,
|
||||
|
|
|
@ -1347,7 +1347,7 @@ IntKeyboardInput(KEYBDINPUT *ki)
|
|||
KbdHookData.dwExtraInfo = ki->dwExtraInfo;
|
||||
if (co_HOOK_CallHooks(WH_KEYBOARD_LL, HC_ACTION, Msg.message, (LPARAM) &KbdHookData))
|
||||
{
|
||||
DPRINT("Kbd msg %d wParam %d lParam 0x%08x dropped by WH_KEYBOARD_LL hook\n",
|
||||
DPRINT1("Kbd msg %d wParam %d lParam 0x%08x dropped by WH_KEYBOARD_LL hook\n",
|
||||
Msg.message, vk_hook, Msg.lParam);
|
||||
if (Entered) UserLeave();
|
||||
return FALSE;
|
||||
|
|
Loading…
Reference in a new issue