[win32k]
[reactos.git] / win32ss / user / ntuser / message.c
index 4dbe59f..eb1e127 100644 (file)
@@ -851,6 +851,17 @@ co_IntPeekMessage( PMSG Msg,
             return TRUE;
         }
 
+        if ((ProcessMask & QS_MOUSE) &&
+            co_MsqPeekMouseMove( pti,
+                                 RemoveMessages,
+                                 Window,
+                                 MsgFilterMin,
+                                 MsgFilterMax,
+                                 Msg ))
+        {
+            return TRUE;
+        }
+
         /* Check for hardware events. */
         if ((ProcessMask & QS_INPUT) &&
             co_MsqPeekHardwareMessage( pti,
@@ -864,17 +875,6 @@ co_IntPeekMessage( PMSG Msg,
             return TRUE;
         }
 
-        if ((ProcessMask & QS_MOUSE) &&
-            co_MsqPeekMouseMove( pti,
-                                 RemoveMessages,
-                                 Window,
-                                 MsgFilterMin,
-                                 MsgFilterMax,
-                                 Msg ))
-        {
-            return TRUE;
-        }
-
         /* Check for sent messages again. */
         while ( co_MsqDispatchOneSentMessage(pti) )
         {
@@ -2882,6 +2882,13 @@ NtUserWaitForInputIdle( IN HANDLE hProcess,
 
     TRACE("WFII: ppi %p\n", W32Process);
     TRACE("WFII: waiting for %p\n", Handles[1] );
+
+    /*
+     * We must add a refcount to our current PROCESSINFO,
+     * because anything could happen (including process death) we're leaving win32k
+     */
+    IntReferenceProcessInfo(W32Process);
+
     do
     {
         UserLeave();
@@ -2935,6 +2942,7 @@ WaitExit:
        pti->pClientInfo->dwTIFlags = pti->TIF_flags;
     }
     W32Process->W32PF_flags &= ~W32PF_WAITFORINPUTIDLE;
+    IntDereferenceProcessInfo(W32Process);
     ObDereferenceObject(Process);
     UserLeave();
     return Status;