Author: jimtabor
Date: Fri Dec 17 01:09:42 2010
New Revision: 50047

URL: http://svn.reactos.org/svn/reactos?rev=50047&view=rev
Log:
[Win32k|User32]
- Finish 50030 (work by Giannis), Now PostMessage passes all the correct data 
based on Get/PeekMessage. Example: Post A, Get/Peek A, Translate A, Dispatch A, 
should be that simple. FYI: DDE memory handling should be in win32k not user32 
and why,,,,, ~see next point~
- Patch up problems (at a minimum) going into the SendMessage/Timeout A2U U2A 
support in win32k and fixed SMTO callback if local.

Modified:
    trunk/reactos/dll/win32/user32/include/user32p.h
    trunk/reactos/dll/win32/user32/windows/message.c
    trunk/reactos/subsystems/win32/win32k/ntuser/message.c
    trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c

Modified: trunk/reactos/dll/win32/user32/include/user32p.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/include/user32p.h?rev=50047&r1=50046&r2=50047&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/include/user32p.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/include/user32p.h [iso-8859-1] Fri Dec 17 
01:09:42 2010
@@ -116,7 +116,6 @@
 
 typedef struct _USER32_THREAD_DATA
 {
-    MSG LastMessage;
     USER32_TRACKINGLIST tracking_info; /* TrackMouseEvent stuff */
 } USER32_THREAD_DATA, *PUSER32_THREAD_DATA;
 

Modified: trunk/reactos/dll/win32/user32/windows/message.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/message.c?rev=50047&r1=50046&r2=50047&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/message.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/message.c [iso-8859-1] Fri Dec 17 
01:09:42 2010
@@ -145,7 +145,8 @@
   return Ret;
 }
 
-static BOOL FASTCALL
+static
+BOOL FASTCALL
 MsgiUMToKMMessage(PMSG UMMsg, PMSG KMMsg, BOOL Posted)
 {
   *KMMsg = *UMMsg;
@@ -249,7 +250,8 @@
   return TRUE;
 }
 
-static VOID FASTCALL
+static
+VOID FASTCALL
 MsgiUMToKMCleanup(PMSG UMMsg, PMSG KMMsg)
 {
   switch (KMMsg->message)
@@ -949,9 +951,7 @@
 WINAPI
 GetMessagePos(VOID)
 {
-  PUSER32_THREAD_DATA ThreadData = User32GetThreadData();
-  return(MAKELONG(ThreadData->LastMessage.pt.x, ThreadData->LastMessage.pt.y));
-  //return NtUserCallNoParam(NOPARAM_ROUTINE_GETMSESSAGEPOS);
+  return NtUserCallNoParam(NOPARAM_ROUTINE_GETMSESSAGEPOS);
 }
 
 
@@ -961,9 +961,7 @@
 LONG WINAPI
 GetMessageTime(VOID)
 {
-  PUSER32_THREAD_DATA ThreadData = User32GetThreadData();
-  return(ThreadData->LastMessage.time);
-//  return NtUserGetThreadState(THREADSTATE_GETMESSAGETIME);
+  return NtUserGetThreadState(THREADSTATE_GETMESSAGETIME);
 }
 
 
@@ -1602,17 +1600,17 @@
                UINT wMsgFilterMax)
 {
   BOOL Res;
-  PUSER32_THREAD_DATA ThreadData = User32GetThreadData();
+
+  if ( (wMsgFilterMin|wMsgFilterMax) & ~WM_MAXIMUM )
+  {
+     SetLastError( ERROR_INVALID_PARAMETER );
+     return FALSE;
+  }
 
   Res = NtUserGetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
   if (-1 == (int) Res)
     {
       return Res;
-    }
-
-  if (Res && lpMsg->message != WM_PAINT && lpMsg->message != WM_QUIT)
-    {
-      ThreadData->LastMessage = *lpMsg;
     }
 
   return Res;
@@ -1628,7 +1626,12 @@
            UINT wMsgFilterMax)
 {
   BOOL Res;
-  PUSER32_THREAD_DATA ThreadData = User32GetThreadData();
+
+  if ( (wMsgFilterMin|wMsgFilterMax) & ~WM_MAXIMUM )
+  {
+     SetLastError( ERROR_INVALID_PARAMETER );
+     return FALSE;
+  }
 
   Res = NtUserGetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
   if (-1 == (int) Res)
@@ -1636,20 +1639,15 @@
       return Res;
     }
 
-  if (Res && lpMsg->message != WM_PAINT && lpMsg->message != WM_QUIT)
-    {
-      ThreadData->LastMessage = *lpMsg;
-    }
-
   return Res;
 }
 
 BOOL WINAPI
-PeekMessageWorker(PMSG pMsg,
-                     HWND hWnd,
-                     UINT wMsgFilterMin,
-                     UINT wMsgFilterMax,
-                     UINT wRemoveMsg)
+PeekMessageWorker( PMSG pMsg,
+                   HWND hWnd,
+                   UINT wMsgFilterMin,
+                   UINT wMsgFilterMax,
+                   UINT wRemoveMsg)
 {
   PCLIENTINFO pci;
   PCLIENTTHREADINFO pcti;
@@ -1692,17 +1690,11 @@
             UINT wRemoveMsg)
 {
   BOOL Res;
-  PUSER32_THREAD_DATA ThreadData = User32GetThreadData();
 
   Res = PeekMessageWorker(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, 
wRemoveMsg);
   if (-1 == (int) Res || !Res)
     {
       return FALSE;
-    }
-
-  if (Res && lpMsg->message != WM_PAINT && lpMsg->message != WM_QUIT)
-    {
-        ThreadData->LastMessage = *lpMsg;
     }
 
   return Res;
@@ -1722,7 +1714,6 @@
   UINT wRemoveMsg)
 {
   BOOL Res;
-  PUSER32_THREAD_DATA ThreadData = User32GetThreadData();
 
   Res = PeekMessageWorker(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, 
wRemoveMsg);
   if (-1 == (int) Res || !Res)
@@ -1730,44 +1721,7 @@
       return FALSE;
     }
 
-  if (Res && lpMsg->message != WM_PAINT && lpMsg->message != WM_QUIT)
-    {
-      ThreadData->LastMessage = *lpMsg;
-    }
-
   return Res;
-}
-
-//
-// Worker function for post message.
-//
-BOOL
-FASTCALL
-PostMessageWorker(
-  HWND Wnd,
-  UINT Msg,
-  WPARAM wParam,
-  LPARAM lParam)
-{
-  MSG UMMsg, KMMsg;
-  LRESULT Result;
-
-  UMMsg.hwnd = Wnd;
-  UMMsg.message = Msg;
-  UMMsg.wParam = wParam;
-  UMMsg.lParam = lParam;
-  if (! MsgiUMToKMMessage(&UMMsg, &KMMsg, TRUE))
-  {
-     return FALSE;
-  }
-  Result = NtUserPostMessage( Wnd,
-                              KMMsg.message,
-                              KMMsg.wParam,
-                              KMMsg.lParam);
-
-  MsgiUMToKMCleanup(&UMMsg, &KMMsg);
-
-  return Result;
 }
 
 /*
@@ -1781,24 +1735,38 @@
   WPARAM wParam,
   LPARAM lParam)
 {
-  MSG AnsiMsg, UcMsg;
-  BOOL Ret;
-
-  AnsiMsg.hwnd = hWnd;
-  AnsiMsg.message = Msg;
-  AnsiMsg.wParam = wParam;
-  AnsiMsg.lParam = lParam;
-
-  if (!MsgiAnsiToUnicodeMessage(&UcMsg, &AnsiMsg))
-  {
-      return FALSE;
-  }
-
-  Ret = PostMessageW( hWnd, UcMsg.message, UcMsg.wParam, UcMsg.lParam);
-
-  MsgiAnsiToUnicodeCleanup(&UcMsg, &AnsiMsg);
-
-  return Ret;
+  LRESULT Ret;
+
+  /* Check for combo box or a list box to send names. */
+  if (Msg == CB_DIR || Msg == LB_DIR)
+  {
+  /*
+     Set DDL_POSTMSGS, so use the PostMessage function to send messages to the
+     combo/list box. Forces a call like DlgDirListComboBox.
+  */
+    //wParam |= DDL_POSTMSGS;
+    return NtUserPostMessage(hWnd, Msg, wParam, lParam);
+  }
+
+  /* No drop files or current Process, just post message. */
+  if ( (Msg != WM_DROPFILES) ||
+       ( NtUserQueryWindow( hWnd, QUERY_WINDOW_UNIQUE_PROCESS_ID) == 
+                  PtrToUint(NtCurrentTeb()->ClientId.UniqueProcess) ) )
+  {
+    return NtUserPostMessage(hWnd, Msg, wParam, lParam);
+  }
+
+  /* We have drop files and this is not the same process for this window. */
+
+  /* Just incase, check wParam for Global memory handle and send size. */
+  Ret = SendMessageA( hWnd,
+                      WM_COPYGLOBALDATA,
+                      (WPARAM)GlobalSize((HGLOBAL)wParam), // Zero if not a 
handle.
+                      (LPARAM)wParam);                     // Send wParam as 
lParam.
+
+  if ( Ret ) return NtUserPostMessage(hWnd, Msg, (WPARAM)Ret, lParam);
+
+  return FALSE;
 }
 
 /*
@@ -1821,8 +1789,8 @@
      Set DDL_POSTMSGS, so use the PostMessage function to send messages to the
      combo/list box. Forces a call like DlgDirListComboBox.
   */
-    wParam |= DDL_POSTMSGS;
-    return PostMessageWorker(hWnd, Msg, wParam, lParam);
+    //wParam |= DDL_POSTMSGS;
+    return NtUserPostMessage(hWnd, Msg, wParam, lParam);
   }
 
   /* No drop files or current Process, just post message. */
@@ -1830,7 +1798,7 @@
        ( NtUserQueryWindow( hWnd, QUERY_WINDOW_UNIQUE_PROCESS_ID) == 
                   PtrToUint(NtCurrentTeb()->ClientId.UniqueProcess) ) )
   {
-    return PostMessageWorker(hWnd, Msg, wParam, lParam);
+    return NtUserPostMessage(hWnd, Msg, wParam, lParam);
   }
 
   /* We have drop files and this is not the same process for this window. */
@@ -1841,7 +1809,7 @@
                       (WPARAM)GlobalSize((HGLOBAL)wParam), // Zero if not a 
handle.
                       (LPARAM)wParam);                     // Send wParam as 
lParam.
 
-  if ( Ret ) return PostMessageWorker(hWnd, Msg, (WPARAM)Ret, lParam);
+  if ( Ret ) return NtUserPostMessage(hWnd, Msg, (WPARAM)Ret, lParam);
 
   return FALSE;
 }
@@ -1902,11 +1870,16 @@
   PWND Window;
   PTHREADINFO ti = GetW32ThreadInfo();
 
-  Window = ValidateHwnd(Wnd);
-  if (!Window) return FALSE;
+  if ( Msg & ~WM_MAXIMUM )
+  {
+     SetLastError( ERROR_INVALID_PARAMETER );
+     return 0;
+  }
 
   if (Wnd != HWND_BROADCAST && (Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST))
   {
+      Window = ValidateHwnd(Wnd);
+
       if ( Window != NULL &&
            Window->head.pti == ti &&
 //          !IsThreadHooked(GetWin32ClientInfo()) && // Enable to test message 
system bug.
@@ -1937,7 +1910,7 @@
      return FALSE;
   }
 
-  Result = NtUserMessageCall( KMMsg.hwnd,
+  Result = NtUserMessageCall( Wnd,
                               KMMsg.message, 
                               KMMsg.wParam,
                               KMMsg.lParam,
@@ -1962,11 +1935,16 @@
   PWND Window;
   PTHREADINFO ti = GetW32ThreadInfo();
 
-  Window = ValidateHwnd(Wnd);
-  if (!Window) return FALSE;
+  if ( Msg & ~WM_MAXIMUM )
+  {
+     SetLastError( ERROR_INVALID_PARAMETER );
+     return 0;
+  }
 
   if (Wnd != HWND_BROADCAST && (Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST))
   {
+      Window = ValidateHwnd(Wnd);
+
       if ( Window != NULL &&
            Window->head.pti == ti &&
 //          !IsThreadHooked(GetWin32ClientInfo()) && // Enable to test message 
system bug.
@@ -2003,7 +1981,7 @@
       return FALSE;
   }
 
-  Result = NtUserMessageCall( KMMsg.hwnd,
+  Result = NtUserMessageCall( Wnd,
                               KMMsg.message, 
                               KMMsg.wParam,
                               KMMsg.lParam,
@@ -2047,7 +2025,7 @@
       return FALSE;
   }
 
-  Result = NtUserMessageCall( UcMsg.hwnd,
+  Result = NtUserMessageCall( hWnd,
                               UcMsg.message,
                               UcMsg.wParam,
                               UcMsg.lParam,
@@ -2104,8 +2082,8 @@
   MSG AnsiMsg, UcMsg;
   LRESULT Result;
   DOSENDMESSAGE dsm;
-
-  SPY_EnterMessage(SPY_SENDMESSAGE, hWnd, Msg, wParam, lParam);
+  PWND Window;
+  PTHREADINFO ti = GetW32ThreadInfo();
 
   if ( Msg & ~WM_MAXIMUM || fuFlags & 
~(SMTO_NOTIMEOUTIFNOTHUNG|SMTO_ABORTIFHUNG|SMTO_BLOCK))
   {
@@ -2114,6 +2092,23 @@
   }
   
   if (lpdwResult) *lpdwResult = 0;
+
+  if (hWnd != HWND_BROADCAST && (Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST))
+  {
+      Window = ValidateHwnd(hWnd);
+
+      if ( Window != NULL &&
+           Window->head.pti == ti &&
+          !ISITHOOKED(WH_CALLWNDPROC) &&
+          !ISITHOOKED(WH_CALLWNDPROCRET) &&
+          !(Window->state & WNDS_SERVERSIDEWINDOWPROC) )
+      {
+          Result = IntCallMessageProc(Window, hWnd, Msg, wParam, lParam, TRUE);
+          if (lpdwResult) *lpdwResult = Result;
+          return TRUE;
+      }
+  }
+  SPY_EnterMessage(SPY_SENDMESSAGE, hWnd, Msg, wParam, lParam);
 
   dsm.uFlags = fuFlags;
   dsm.uTimeout = uTimeout;
@@ -2128,7 +2123,7 @@
       return FALSE;
   }
 
-  Result = NtUserMessageCall( UcMsg.hwnd,
+  Result = NtUserMessageCall( hWnd,
                               UcMsg.message,
                               UcMsg.wParam,
                               UcMsg.lParam,
@@ -2162,8 +2157,8 @@
 {
   LRESULT Result;
   DOSENDMESSAGE dsm;
-
-  SPY_EnterMessage(SPY_SENDMESSAGE, hWnd, Msg, wParam, lParam);
+  PWND Window;
+  PTHREADINFO ti = GetW32ThreadInfo();
 
   if ( Msg & ~WM_MAXIMUM || fuFlags & 
~(SMTO_NOTIMEOUTIFNOTHUNG|SMTO_ABORTIFHUNG|SMTO_BLOCK))
   {
@@ -2172,6 +2167,23 @@
   }
   
   if (lpdwResult) *lpdwResult = 0;
+
+  if (hWnd != HWND_BROADCAST && (Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST))
+  {
+      Window = ValidateHwnd(hWnd);
+
+      if ( Window != NULL &&
+           Window->head.pti == ti &&
+          !ISITHOOKED(WH_CALLWNDPROC) &&
+          !ISITHOOKED(WH_CALLWNDPROCRET) &&
+          !(Window->state & WNDS_SERVERSIDEWINDOWPROC) )
+      {
+          Result = IntCallMessageProc(Window, hWnd, Msg, wParam, lParam, 
FALSE);
+          if (lpdwResult) *lpdwResult = Result;
+          return TRUE;
+      }
+  }
+  SPY_EnterMessage(SPY_SENDMESSAGE, hWnd, Msg, wParam, lParam);
 
   dsm.uFlags = fuFlags;
   dsm.uTimeout = uTimeout;

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/message.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/message.c?rev=50047&r1=50046&r2=50047&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] Fri Dec 
17 01:09:42 2010
@@ -61,6 +61,7 @@
     { WM_STYLECHANGED, sizeof(STYLESTRUCT), MMS_FLAG_READ },
     { WM_STYLECHANGING, sizeof(STYLESTRUCT), MMS_FLAG_READWRITE },
     { WM_COPYDATA, MMS_SIZE_SPECIAL, MMS_FLAG_READ },
+    { WM_COPYGLOBALDATA, MMS_SIZE_WPARAM, MMS_FLAG_READ },
     { WM_WINDOWPOSCHANGED, sizeof(WINDOWPOS), MMS_FLAG_READ },
     { WM_WINDOWPOSCHANGING, sizeof(WINDOWPOS), MMS_FLAG_READWRITE },
 };
@@ -134,10 +135,6 @@
                 Size = sizeof(COPYDATASTRUCT) + 
((PCOPYDATASTRUCT)lParam)->cbData;
                 break;
 
-            case WM_COPYGLOBALDATA:
-                Size = wParam;
-                break;
-
             default:
                 ASSERT(FALSE);
                 Size = 0;
@@ -243,7 +240,6 @@
         ASSERT(CsData == (PCHAR) PackedCs + Size);
         *lParamPacked = (LPARAM) PackedCs;
     }
-
     else if (PoolType == NonPagedPool)
     {
         PMSGMEMORY MsgMemoryEntry;
@@ -315,6 +311,100 @@
     ASSERT(FALSE);
 
     return STATUS_INVALID_PARAMETER;
+}
+
+static NTSTATUS FASTCALL
+CopyMsgToKernelMem(MSG *KernelModeMsg, MSG *UserModeMsg, PMSGMEMORY 
MsgMemoryEntry)
+{
+    NTSTATUS Status;
+
+    PVOID KernelMem;
+    UINT Size;
+
+    *KernelModeMsg = *UserModeMsg;
+
+    /* See if this message type is present in the table */
+    if (NULL == MsgMemoryEntry)
+    {
+        /* Not present, no copying needed */
+        return STATUS_SUCCESS;
+    }
+
+    /* Determine required size */
+    Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, 
UserModeMsg->lParam);
+
+    if (0 != Size)
+    {
+        /* Allocate kernel mem */
+        KernelMem = ExAllocatePoolWithTag(PagedPool, Size, TAG_MSG);
+        if (NULL == KernelMem)
+        {
+            DPRINT1("Not enough memory to copy message to kernel mem\n");
+            return STATUS_NO_MEMORY;
+        }
+        KernelModeMsg->lParam = (LPARAM) KernelMem;
+
+        /* Copy data if required */
+        if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_READ))
+        {
+            Status = MmCopyFromCaller(KernelMem, (PVOID) UserModeMsg->lParam, 
Size);
+            if (! NT_SUCCESS(Status))
+            {
+                DPRINT1("Failed to copy message to kernel: invalid usermode 
buffer\n");
+                ExFreePoolWithTag(KernelMem, TAG_MSG);
+                return Status;
+            }
+        }
+        else
+        {
+            /* Make sure we don't pass any secrets to usermode */
+            RtlZeroMemory(KernelMem, Size);
+        }
+    }
+    else
+    {
+        KernelModeMsg->lParam = 0;
+    }
+
+    return STATUS_SUCCESS;
+}
+
+static NTSTATUS FASTCALL
+CopyMsgToUserMem(MSG *UserModeMsg, MSG *KernelModeMsg)
+{
+    NTSTATUS Status;
+    PMSGMEMORY MsgMemoryEntry;
+    UINT Size;
+
+    /* See if this message type is present in the table */
+    MsgMemoryEntry = FindMsgMemory(UserModeMsg->message);
+    if (NULL == MsgMemoryEntry)
+    {
+        /* Not present, no copying needed */
+        return STATUS_SUCCESS;
+    }
+
+    /* Determine required size */
+    Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, 
UserModeMsg->lParam);
+
+    if (0 != Size)
+    {
+        /* Copy data if required */
+        if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_WRITE))
+        {
+            Status = MmCopyToCaller((PVOID) UserModeMsg->lParam, (PVOID) 
KernelModeMsg->lParam, Size);
+            if (! NT_SUCCESS(Status))
+            {
+                DPRINT1("Failed to copy message from kernel: invalid usermode 
buffer\n");
+                ExFreePool((PVOID) KernelModeMsg->lParam);
+                return Status;
+            }
+        }
+
+        ExFreePool((PVOID) KernelModeMsg->lParam);
+    }
+
+    return STATUS_SUCCESS;
 }
 
 //
@@ -654,100 +744,6 @@
     return TRUE;
 }
 
-static NTSTATUS FASTCALL
-CopyMsgToKernelMem(MSG *KernelModeMsg, MSG *UserModeMsg, PMSGMEMORY 
MsgMemoryEntry)
-{
-    NTSTATUS Status;
-
-    PVOID KernelMem;
-    UINT Size;
-
-    *KernelModeMsg = *UserModeMsg;
-
-    /* See if this message type is present in the table */
-    if (NULL == MsgMemoryEntry)
-    {
-        /* Not present, no copying needed */
-        return STATUS_SUCCESS;
-    }
-
-    /* Determine required size */
-    Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, 
UserModeMsg->lParam);
-
-    if (0 != Size)
-    {
-        /* Allocate kernel mem */
-        KernelMem = ExAllocatePoolWithTag(PagedPool, Size, TAG_MSG);
-        if (NULL == KernelMem)
-        {
-            DPRINT1("Not enough memory to copy message to kernel mem\n");
-            return STATUS_NO_MEMORY;
-        }
-        KernelModeMsg->lParam = (LPARAM) KernelMem;
-
-        /* Copy data if required */
-        if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_READ))
-        {
-            Status = MmCopyFromCaller(KernelMem, (PVOID) UserModeMsg->lParam, 
Size);
-            if (! NT_SUCCESS(Status))
-            {
-                DPRINT1("Failed to copy message to kernel: invalid usermode 
buffer\n");
-                ExFreePoolWithTag(KernelMem, TAG_MSG);
-                return Status;
-            }
-        }
-        else
-        {
-            /* Make sure we don't pass any secrets to usermode */
-            RtlZeroMemory(KernelMem, Size);
-        }
-    }
-    else
-    {
-        KernelModeMsg->lParam = 0;
-    }
-
-    return STATUS_SUCCESS;
-}
-
-static NTSTATUS FASTCALL
-CopyMsgToUserMem(MSG *UserModeMsg, MSG *KernelModeMsg)
-{
-    NTSTATUS Status;
-    PMSGMEMORY MsgMemoryEntry;
-    UINT Size;
-
-    /* See if this message type is present in the table */
-    MsgMemoryEntry = FindMsgMemory(UserModeMsg->message);
-    if (NULL == MsgMemoryEntry)
-    {
-        /* Not present, no copying needed */
-        return STATUS_SUCCESS;
-    }
-
-    /* Determine required size */
-    Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, 
UserModeMsg->lParam);
-
-    if (0 != Size)
-    {
-        /* Copy data if required */
-        if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_WRITE))
-        {
-            Status = MmCopyToCaller((PVOID) UserModeMsg->lParam, (PVOID) 
KernelModeMsg->lParam, Size);
-            if (! NT_SUCCESS(Status))
-            {
-                DPRINT1("Failed to copy message from kernel: invalid usermode 
buffer\n");
-                ExFreePool((PVOID) KernelModeMsg->lParam);
-                return Status;
-            }
-        }
-
-        ExFreePool((PVOID) KernelModeMsg->lParam);
-    }
-
-    return STATUS_SUCCESS;
-}
-
 static BOOL FASTCALL
 co_IntWaitMessage( PWND Window,
                    UINT MsgFilterMin,
@@ -775,9 +771,9 @@
 
         /* Nothing found. Wait for new messages. */
         Status = co_MsqWaitForNewMessages( ThreadQueue,
-                                            Window,
-                                            MsgFilterMin,
-                                            MsgFilterMax);
+                                           Window,
+                                           MsgFilterMin,
+                                           MsgFilterMax);
     }
     while ( (STATUS_WAIT_0 <= Status && Status <= STATUS_WAIT_63) ||
             STATUS_TIMEOUT == Status );
@@ -834,6 +830,7 @@
     }
 
     pti = PsGetCurrentThreadWin32Thread();
+    pti->pClientInfo->cSpins++; // Bump up the spin count.
 
     do
     {
@@ -848,8 +845,11 @@
            /* GetMessage or PostMessage must never get messages that contain 
pointers */
            ASSERT(FindMsgMemory(pMsg->message) == NULL);
 
-           pti->timeLast = pMsg->time;
-           pti->ptLast   = pMsg->pt;
+           if (pMsg->message != WM_PAINT && pMsg->message != WM_QUIT)
+           {
+              pti->timeLast = pMsg->time;
+              pti->ptLast   = pMsg->pt;
+           }
 
            // The WH_GETMESSAGE hook enables an application to monitor 
messages about to
            // be returned by the GetMessage or PeekMessage function.
@@ -984,7 +984,7 @@
                                 KernelModeMsg.wParam, 
                                 KernelModeMsg.lParam);
 
-        if(MsgMemoryEntry)
+        if (MsgMemoryEntry && KernelModeMsg.lParam)
             ExFreePool((PVOID) KernelModeMsg.lParam);
 
         return TRUE;
@@ -1019,7 +1019,7 @@
             {
                 UserPostMessage(List[i], Msg, wParam, lParam);
             }
-            ExFreePool(List);
+            ExFreePoolWithTag(List,TAG_WINLIST);//ExFreePool(List);
         }
     }
     else

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c?rev=50047&r1=50046&r2=50047&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c [iso-8859-1] Fri 
Dec 17 01:09:42 2010
@@ -1624,7 +1624,7 @@
    pti = PsGetCurrentThreadWin32Thread();
    Message = pti->pusmCurrent;
 
-   if(!Message) return FALSE;
+   if (!Message) return FALSE;
 
    if (Message->QS_Flags & QS_SMRESULT) return FALSE;
 


Reply via email to