Commit in reactos/subsys/win32k on win32k_user_rewrite
include/internal.h+11.1.4.4 -> 1.1.4.5
ntuser/desktop.c+2-21.17.2.2 -> 1.17.2.3
      /message.c+62-21.71.4.3 -> 1.71.4.4
      /ntuser.c+55-171.1.4.5 -> 1.1.4.6
+120-21
4 modified files
fixed a dead-lock while switching to gui mode

reactos/subsys/win32k/include
internal.h 1.1.4.4 -> 1.1.4.5
diff -u -r1.1.4.4 -r1.1.4.5
--- internal.h	31 Aug 2004 11:38:56 -0000	1.1.4.4
+++ internal.h	31 Aug 2004 14:34:38 -0000	1.1.4.5
@@ -609,6 +609,7 @@
 LRESULT             FASTCALL IntSendMessageTimeout(PWINDOW_OBJECT Window, UINT Msg, WPARAM wParam, LPARAM lParam, 
                                                    UINT uFlags, UINT uTimeout, ULONG_PTR *uResult);
 BOOL                FASTCALL IntPostThreadMessage(PW32THREAD W32Thread, UINT Msg, WPARAM wParam, LPARAM lParam);
+BOOL                FASTCALL IntPostMessage(PWINDOW_OBJECT Window, UINT Msg, WPARAM wParam, LPARAM lParam);
 BOOL                FASTCALL IntWaitMessage(PWINDOW_OBJECT Window, UINT MsgFilterMin, UINT MsgFilterMax);
 BOOL                FASTCALL IntTranslateKbdMessage(PKMSG lpMsg, HKL dwhkl);
 inline VOID                  MsqSetQueueBits(PUSER_MESSAGE_QUEUE queue, WORD bits);

reactos/subsys/win32k/ntuser
desktop.c 1.17.2.2 -> 1.17.2.3
diff -u -r1.17.2.2 -r1.17.2.3
--- desktop.c	18 Jul 2004 23:44:01 -0000	1.17.2.2
+++ desktop.c	31 Aug 2004 14:34:39 -0000	1.17.2.3
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- *  $Id: desktop.c,v 1.17.2.2 2004/07/18 23:44:01 weiden Exp $
+ *  $Id: desktop.c,v 1.17.2.3 2004/08/31 14:34:39 weiden Exp $
  *
  *  COPYRIGHT:        See COPYING in the top level directory
  *  PROJECT:          ReactOS kernel
@@ -247,7 +247,7 @@
 {
   CSRSS_API_REQUEST Request;
   CSRSS_API_REPLY Reply;
-
+  DbgPrint("IntShowDesktop 0x%x\n", Desktop->DesktopWindow->Handle);
   Request.Type = CSRSS_SHOW_DESKTOP;
   Request.Data.ShowDesktopRequest.DesktopWindow = Desktop->DesktopWindow->Handle;
   Request.Data.ShowDesktopRequest.Width = Width;

reactos/subsys/win32k/ntuser
message.c 1.71.4.3 -> 1.71.4.4
diff -u -r1.71.4.3 -r1.71.4.4
--- message.c	31 Aug 2004 11:38:56 -0000	1.71.4.3
+++ message.c	31 Aug 2004 14:34:39 -0000	1.71.4.4
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: message.c,v 1.71.4.3 2004/08/31 11:38:56 weiden Exp $
+/* $Id: message.c,v 1.71.4.4 2004/08/31 14:34:39 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -935,7 +935,10 @@
 
   MsgMemoryEntry = FindMsgMemory(UserModeMsg.message);
   /* FIXME - what if MsgMemoryEntry == NULL? */
-  Status = CopyMsgToKernelMem(&KernelModeMsg, &UserModeMsg, MsgMemoryEntry, NULL);
+  Status = CopyMsgToKernelMem(&KernelModeMsg,
+                              &UserModeMsg,
+                              MsgMemoryEntry,
+                              NULL); /* pass NULL as the message window so it can be set in the KMSG struct */
   if(!NT_SUCCESS(Status))
   {
     SetLastWin32Error(ERROR_INVALID_PARAMETER);
@@ -950,6 +953,63 @@
   return TRUE;
 }
 
+BOOL FASTCALL
+IntPostMessage(PWINDOW_OBJECT Window,
+               UINT Msg,
+               WPARAM wParam,
+               LPARAM lParam)
+{
+  MSG UserModeMsg;
+  KMSG KernelModeMsg;
+  NTSTATUS Status;
+  PMSGMEMORY MsgMemoryEntry;
+  
+  if(Window == NULL)
+  {
+    /* Broadcast the message to all top level windows */
+
+    PWINDOW_OBJECT Wnd, Desktop;
+    
+    if(!(Desktop = IntGetDesktopWindow()))
+    {
+      DPRINT1("Failed to broadcast message 0x%x! No desktop window found!\n", Msg);
+      return FALSE;
+    }
+    
+    for(Wnd = Desktop->FirstChild; Wnd != NULL; Wnd = Wnd->NextSibling)
+    {
+      IntPostMessage(Wnd,
+                     Msg,
+                     wParam,
+                     lParam);
+    }
+
+    return TRUE; /* FIXME - return also TRUE if no top-level windows are present?! */
+  }
+
+  UserModeMsg.hwnd = (Window != NULL ? Window->Handle : NULL);
+  UserModeMsg.message = Msg;
+  UserModeMsg.wParam = wParam;
+  UserModeMsg.lParam = lParam;
+
+  MsgMemoryEntry = FindMsgMemory(UserModeMsg.message);
+  /* FIXME - what if MsgMemoryEntry == NULL? */
+  Status = CopyMsgToKernelMem(&KernelModeMsg,
+                              &UserModeMsg,
+                              MsgMemoryEntry,
+                              Window); /* pass the message window so it can be set in the KMSG struct */
+  if(!NT_SUCCESS(Status))
+  {
+    SetLastWin32Error(ERROR_INVALID_PARAMETER);
+    return FALSE;
+  }
+
+  MsqPostMessage(Window->MessageQueue, &KernelModeMsg,
+                 NULL != MsgMemoryEntry && 0 != KernelModeMsg.lParam);
+
+  return TRUE;
+}
+
 BOOL STDCALL
 IntInitMessagePumpHook()
 {

reactos/subsys/win32k/ntuser
ntuser.c 1.1.4.5 -> 1.1.4.6
diff -u -r1.1.4.5 -r1.1.4.6
--- ntuser.c	31 Aug 2004 11:38:56 -0000	1.1.4.5
+++ ntuser.c	31 Aug 2004 14:34:39 -0000	1.1.4.6
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: ntuser.c,v 1.1.4.5 2004/08/31 11:38:56 weiden Exp $
+/* $Id: ntuser.c,v 1.1.4.6 2004/08/31 14:34:39 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -143,12 +143,17 @@
  */
 
 #define ENTER_CRITICAL() \
-  IntUserEnterCritical()
+  DbgPrint("%s:%i ENTER_CRICITAL\n", __FILE__, __LINE__); \
+  IntUserEnterCritical(); \
+  DbgPrint("%s:%i ENTER_CRICITAL done\n", __FILE__, __LINE__)
 
 #define ENTER_CRITICAL_SHARED() \
-  IntUserEnterCriticalShared()
+  DbgPrint("%s:%i ENTER_CRICITAL_SHARED\n", __FILE__, __LINE__); \
+  IntUserEnterCriticalShared(); \
+  DbgPrint("%s:%i ENTER_CRICITAL_SHARED done\n", __FILE__, __LINE__)
 
 #define LEAVE_CRITICAL() \
+  DbgPrint("%s:%i LEAVE_CRITICAL\n", __FILE__, __LINE__); \
   IntUserLeaveCritical()
 
 #define IN_CRITICAL() \
@@ -909,7 +914,7 @@
   NTUSER_FAIL_INVALID_PARAMETER(pci, NULL);
   NTUSER_FAIL_INVALID_STRUCT(CURSORINFO, pci, cbSize);
   
-  ENTER_CRITICAL();
+  ENTER_CRITICAL_SHARED();
   Result = IntGetCursorInfo(&SafeCI);
   LEAVE_CRITICAL();
   
@@ -924,7 +929,7 @@
   NTUSER_USER_OBJECT(WINDOW, Window);
   BEGIN_NTUSER(HDC, NULL);
   
-  ENTER_CRITICAL();
+  ENTER_CRITICAL_SHARED();
   if(hWnd != NULL)
   {
     VALIDATE_USER_OBJECT(WINDOW, hWnd, Window);
@@ -952,7 +957,7 @@
   NTUSER_USER_OBJECT(WINDOW, Window);
   BEGIN_NTUSER(HDC, NULL);
   
-  ENTER_CRITICAL();
+  ENTER_CRITICAL_SHARED();
   if(hWnd != NULL)
   {
     VALIDATE_USER_OBJECT(WINDOW, hWnd, Window);
@@ -1435,14 +1440,35 @@
   NTUSER_USER_OBJECT(WINDOW, Window);
   BEGIN_NTUSER(LRESULT, 0);
 
-  /* don't handle HWND_BROADCAST in kmode, SendMessage() should obtain a list
-     of handles and then call NtUserSendMessage() for each window */
-  NTUSER_FAIL_INVALID_PARAMETER(Wnd, HWND_BROADCAST);
-  NTUSER_FAIL_INVALID_PARAMETER(Wnd, 0);
+  /* As opposed to NtUserSendMessage(), NtUserPostMessage() handles HWND_BROADCAST in kmode! */
 
-  ENTER_CRITICAL_SHARED();
-  VALIDATE_USER_OBJECT(WINDOW, Wnd, Window);
-  LEAVE_CRITICAL();
+  if(Wnd != NULL || Wnd == HWND_BROADCAST)
+  {
+    /* Post a single mesage */
+    
+    ENTER_CRITICAL_SHARED();
+    if(Wnd != HWND_BROADCAST)
+    {
+      VALIDATE_USER_OBJECT(WINDOW, Wnd, Window);
+    }
+    Result = IntPostMessage(Window,
+                            Msg,
+                            wParam,
+                            lParam);
+    LEAVE_CRITICAL();
+  }
+  else
+  {
+    /* According to PSDK it behaves the same way as PostThreadMessage() if no
+       window is specified. */
+
+    ENTER_CRITICAL_SHARED();
+    Result = IntPostThreadMessage(PsGetWin32Thread(),
+                                  Msg,
+                                  wParam,
+                                  lParam);
+    LEAVE_CRITICAL();
+  }
 
   END_NTUSER();
 }
@@ -1471,6 +1497,11 @@
     NTUSER_FAIL_ERROR(ERROR_ACCESS_DENIED); /* FIXME - right error code?! */
   }
   
+  /* FIXME - fail if the thread is exiting */
+  /* FIXME - fail if the thread does not belong to the same desktop or to a process
+             that doesn't have the same local unique identifier (LUID) as the
+             calling process. set the last error code to ERROR_INVALID_THREAD_ID */
+  
   ENTER_CRITICAL_SHARED();
   Result = IntPostThreadMessage(peThread->Win32Thread,
                                 Msg,
@@ -1614,19 +1645,19 @@
 {
   NTUSER_USER_OBJECT(WINDOW, Window);
   BEGIN_NTUSER(LRESULT, 0);
-  
+
   /* don't handle HWND_BROADCAST in kmode, SendMessage() should obtain a list
      of handles and then call NtUserSendMessage() for each window */
   NTUSER_FAIL_INVALID_PARAMETER(Wnd, HWND_BROADCAST);
   NTUSER_FAIL_INVALID_PARAMETER(Wnd, 0);
-  
+
   /* FIXME - probe UnsafeInfo */
   
   UnsafeInfo->HandledByKernel = TRUE;
   
   ENTER_CRITICAL_SHARED();
+
   VALIDATE_USER_OBJECT(WINDOW, Wnd, Window);
-  
   if(Window->MessageQueue->Thread == PsGetCurrentThread())
   {
     /* return to user mode and call the window proc there */
@@ -1651,11 +1682,18 @@
       UnsafeInfo->Proc = Window->WndProcA;
     }
     LEAVE_CRITICAL();
-    
+
     UnsafeInfo->HandledByKernel = FALSE;
     return TRUE;
   }
+  ObmReferenceObject(Window);
   LEAVE_CRITICAL();
+
+  Result = IntSendMessage(Window,
+                          Msg,
+                          wParam,
+                          lParam);
+  ObmDereferenceObject(Window);
   
   END_NTUSER();
 }
CVSspam 0.2.8