[ros-diffs] [jimtabor] 56538: [Win32k] - Fix crash when sending activate application message and check if thread is in cleanup. Use kernel functions for thread data types.

jimtabor at svn.reactos.org jimtabor at svn.reactos.org
Tue May 8 05:55:44 UTC 2012


Author: jimtabor
Date: Tue May  8 05:55:42 2012
New Revision: 56538

URL: http://svn.reactos.org/svn/reactos?rev=56538&view=rev
Log:
[Win32k]
- Fix crash when sending activate application message and check if thread is in cleanup. Use kernel functions for thread data types.

Modified:
    trunk/reactos/win32ss/user/ntuser/focus.c
    trunk/reactos/win32ss/user/ntuser/message.c
    trunk/reactos/win32ss/user/ntuser/window.h

Modified: trunk/reactos/win32ss/user/ntuser/focus.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/focus.c?rev=56538&r1=56537&r2=56538&view=diff
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/focus.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/focus.c [iso-8859-1] Tue May  8 05:55:42 2012
@@ -84,6 +84,7 @@
    USER_REFERENCE_ENTRY Ref, RefPrev;
    PWND Window, WindowPrev = NULL;
    HANDLE OldTID, NewTID;
+   PTHREADINFO ptiOld, ptiNew;
 
    if ((Window = UserGetWindowObject(hWnd)))
    { 
@@ -127,6 +128,8 @@
 
       OldTID = WindowPrev ? IntGetWndThreadId(WindowPrev) : NULL;
       NewTID = Window ? IntGetWndThreadId(Window) : NULL;
+      ptiOld = WindowPrev ? WindowPrev->head.pti : NULL;
+      ptiNew = Window ? Window->head.pti : NULL;
 
       TRACE("SendActiveMessage Old -> %x, New -> %x\n", OldTID, NewTID);
 
@@ -136,27 +139,26 @@
          HWND *List, *phWnd;
 
          List = IntWinListChildren(UserGetWindowObject(IntGetDesktopWindow()));
-         if (List)
-         {
-            if (OldTID)
+         if ( List )
+         {
+            if ( OldTid )
             {
                for (phWnd = List; *phWnd; ++phWnd)
                {
                   cWindow = UserGetWindowObject(*phWnd);
-
-                  if (cWindow && (IntGetWndThreadId(cWindow) == OldTID))
+                  if (cWindow && cWindow->head.pti == ptiOld)
                   {  // FALSE if the window is being deactivated,
                      // ThreadId that owns the window being activated.
                     co_IntSendMessageNoWait(*phWnd, WM_ACTIVATEAPP, FALSE, (LPARAM)NewTID);
                   }
                }
             }
-            if (NewTID)
+            if ( NewTID )
             {
                for (phWnd = List; *phWnd; ++phWnd)
                {
                   cWindow = UserGetWindowObject(*phWnd);
-                  if (cWindow && (IntGetWndThreadId(cWindow) == NewTID))
+                  if (cWindow && cWindow->head.pti == ptiNew)
                   { // TRUE if the window is being activated,
                     // ThreadId that owns the window being deactivated.
                     co_IntSendMessageNoWait(*phWnd, WM_ACTIVATEAPP, TRUE, (LPARAM)OldTID);
@@ -306,9 +308,14 @@
       IntSetFocusMessageQueue(Wnd->head.pti->MessageQueue);
       gptiForeground = Wnd->head.pti;
       fgRet = TRUE;
-   }
-
-//// Fix FG Bounce with regedit but breaks test_SFW todos 
+   } 
+/*
+     Fix FG Bounce with regedit but breaks test_SFW todos:
+     Henri Verbeet,
+     What happens is that we get the WM_WINE_SETACTIVEWINDOW message sent by the
+     other thread after we already changed the foreground window back to our own
+     window.
+ */
    if (hWndPrev != hWnd )
    {
       if (PrevForegroundQueue &&
@@ -316,6 +323,13 @@
           Wnd->head.pti->MessageQueue != PrevForegroundQueue &&
           PrevForegroundQueue->spwndActive)
       {
+         //ERR("SFGW: Send NULL to 0x%x\n",hWndPrev);
+         if (pti->MessageQueue == PrevForegroundQueue)
+         {
+            //ERR("SFGW: TI same as Prev TI\n");
+            co_IntSetActiveWindow(NULL, NULL, FALSE, TRUE);
+         }
+         else
          co_IntSendMessageNoWait(hWndPrev, WM_ASYNC_SETACTIVEWINDOW, 0, 0 );
       }
    }

Modified: trunk/reactos/win32ss/user/ntuser/message.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/message.c?rev=56538&r1=56537&r2=56538&view=diff
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/message.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/message.c [iso-8859-1] Tue May  8 05:55:42 2012
@@ -1498,7 +1498,8 @@
 
     Win32Thread = PsGetCurrentThreadWin32Thread();
 
-    if (Win32Thread == NULL)
+    if (Win32Thread == NULL ||
+        Win32Thread->TIF_flags & TIF_INCLEANUP)
     {
         RETURN(FALSE);
     }

Modified: trunk/reactos/win32ss/user/ntuser/window.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/window.h?rev=56538&r1=56537&r2=56538&view=diff
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/window.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/window.h [iso-8859-1] Tue May  8 05:55:42 2012
@@ -29,10 +29,10 @@
   ((WndObj->head.pti) && (WndObj->head.pti == W32Thread))
 
 #define IntGetWndThreadId(WndObj) \
-  WndObj->head.pti->pEThread->Cid.UniqueThread
+  PsGetThreadId(WndObj->head.pti->pEThread)
 
 #define IntGetWndProcessId(WndObj) \
-  WndObj->head.pti->pEThread->ThreadsProcess->UniqueProcessId
+  PsGetProcessId(WndObj->head.pti->ppi->peProcess)
 
   
 BOOL FASTCALL UserUpdateUiState(PWND Wnd, WPARAM wParam);




More information about the Ros-diffs mailing list