Author: jimtabor
Date: Sat Oct  3 04:30:47 2009
New Revision: 43259

URL: http://svn.reactos.org/svn/reactos?rev=43259&view=rev
Log:
- Prevent kernel bug check in win32k when calling a hook proc when thread is in 
cleanup.
- This is not a hack and not a fix. Please retest related bug report 
applications. Tested Firefox 3.5 and the new putty. Need new debug print outs. 
ATM Ff 3.5 send out WH_JOURNALRECORD hook calls when the thread is in cleanup. 
Look like this: Thread is in cleanup and trying to call hook 0
- Reference bug 4298.

Modified:
    trunk/reactos/subsystems/win32/win32k/main/dllmain.c
    trunk/reactos/subsystems/win32/win32k/ntuser/callback.c
    trunk/reactos/subsystems/win32/win32k/ntuser/window.c

Modified: trunk/reactos/subsystems/win32/win32k/main/dllmain.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/main/dllmain.c?rev=43259&r1=43258&r2=43259&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/main/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/main/dllmain.c [iso-8859-1] Sat Oct  
3 04:30:47 2009
@@ -16,8 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id$
- *
+/*
  *  Entry Point for win32k.sys
  */
 
@@ -285,6 +284,7 @@
       DPRINT("Destroying W32 thread TID:%d at IRQ level: %lu\n", 
Thread->Cid.UniqueThread, KeGetCurrentIrql());
 
       Win32Thread->IsExiting = TRUE;
+      Win32Thread->TIF_flags |= TIF_INCLEANUP;
       HOOK_DestroyThreadHooks(Thread);
       UnregisterThreadHotKeys(Thread);
       /* what if this co_ func crash in umode? what will clean us up then? */

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/callback.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/callback.c?rev=43259&r1=43258&r2=43259&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/callback.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/callback.c [iso-8859-1] Sat 
Oct  3 04:30:47 2009
@@ -326,6 +326,14 @@
    UNICODE_STRING ClassName;
    PANSI_STRING asWindowName;
    PANSI_STRING asClassName;
+   PTHREADINFO pti;
+
+   pti = PsGetCurrentThreadWin32Thread();
+   if (pti->TIF_flags & TIF_INCLEANUP)
+   {
+      DPRINT1("Thread is in cleanup and trying to call hook %d\n", Code);
+      return 0;
+   }
 
    ArgumentLength = sizeof(HOOKPROC_CALLBACK_ARGUMENTS) - sizeof(WCHAR)
                     + ModuleName->Length;

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/window.c?rev=43259&r1=43258&r2=43259&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] Sat Oct  
3 04:30:47 2009
@@ -425,6 +425,7 @@
          co_IntSendMessage(Window->hSelf, WM_NCDESTROY, 0, 0);
    }
    MsqRemoveTimersWindow(ThreadData->MessageQueue, Window->hSelf);
+   HOOK_DestroyThreadHooks(ThreadData->pEThread); // This is needed here too!
 
    /* flush the message queue */
    MsqRemoveWindowMessagesFromQueue(Window);


Reply via email to