Author: jimtabor
Date: Sun Oct 31 23:42:37 2010
New Revision: 49386
URL:
http://svn.reactos.org/svn/reactos?rev=49386&view=rev
Log:
[Win32k] - Lock thread when removing hooks.
Modified:
trunk/reactos/subsystems/win32/win32k/ntuser/hook.c
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/hook.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/hook.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/hook.c [iso-8859-1] Sun Oct 31 23:42:37
2010
@@ -801,12 +801,20 @@
HOOK_DestroyThreadHooks(PETHREAD Thread)
{
PTHREADINFO pti;
+ PDESKTOP pdo;
int HookId;
PHOOK HookObj;
PLIST_ENTRY pElem;
pti = Thread->Tcb.Win32Thread;
- if (!pti || !pti->pDeskInfo) return;
+ pdo = IntGetActiveDesktop();
+
+ if (!pti || !pdo)
+ {
+ DPRINT1("Kill Thread Hooks pti 0x%x pdo 0x%x\n",pti,pdo);
+ return;
+ }
+ ObReferenceObject(pti->pEThread);
// Local Thread cleanup.
if (pti->fsHooks)
@@ -831,11 +839,11 @@
pti->fsHooks = 0;
}
// Global search based on Thread and cleanup.
- if (pti->rpdesk->pDeskInfo->fsHooks)
+ if (pdo->pDeskInfo->fsHooks)
{
for (HookId = WH_MINHOOK; HookId <= WH_MAXHOOK; HookId++)
{
- PLIST_ENTRY pGLE =
&pti->pDeskInfo->aphkStart[HOOKID_TO_INDEX(HookId)];
+ PLIST_ENTRY pGLE =
&pdo->pDeskInfo->aphkStart[HOOKID_TO_INDEX(HookId)];
if (IsListEmpty(pGLE)) continue;
@@ -845,7 +853,7 @@
{
if (!HookObj) break;
if (HookObj->head.pti == pti)
- {
+ { DPRINT1("Global Hook Removed\n");
if (IntRemoveHook(HookObj)) break;
}
pElem = HookObj->Chain.Flink;
@@ -854,6 +862,7 @@
while (pElem != pGLE);
}
}
+ ObDereferenceObject(pti->pEThread);
return;
}