[win32k]
authorMichael Martin <michael.martin@reactos.org>
Sat, 26 Jun 2010 09:15:32 +0000 (09:15 +0000)
committerMichael Martin <michael.martin@reactos.org>
Sat, 26 Jun 2010 09:15:32 +0000 (09:15 +0000)
- co_IntSendMessageWithCallBack is called for two reasons; for messages that originate from win32k and from user mode when using Callbacks.
For both cases do not do anything with the sendqueue member of message struct and do not add the message to the senders dispatch message list.
- In msgqueue related functions, check if the message is a nowait messages before attempting to remove and entry from the dispatch message list as it doesnt exist.
- Fixes a NonPagedPool corruption that was occurring on regtest bootcd. Thanks Caemyr for testing.

svn path=/trunk/; revision=47849

reactos/subsystems/win32/win32k/ntuser/message.c
reactos/subsystems/win32/win32k/ntuser/msgqueue.c

index e78ce5a..5d1cf8e 100644 (file)
@@ -1646,8 +1646,8 @@ co_IntSendMessageWithCallBack( HWND hWnd,
    Message->Msg.lParam = lParamPacked;
    Message->CompletionEvent = NULL;
    Message->Result = 0;
    Message->Msg.lParam = lParamPacked;
    Message->CompletionEvent = NULL;
    Message->Result = 0;
-   Message->SenderQueue = Win32Thread->MessageQueue;
-   IntReferenceMessageQueue(Message->SenderQueue);
+   Message->SenderQueue = NULL; //Win32Thread->MessageQueue;
+
    IntReferenceMessageQueue(Window->pti->MessageQueue);
    Message->CompletionCallback = CompletionCallback;
    Message->CompletionCallbackContext = CompletionCallbackContext;
    IntReferenceMessageQueue(Window->pti->MessageQueue);
    Message->CompletionCallback = CompletionCallback;
    Message->CompletionCallbackContext = CompletionCallbackContext;
@@ -1655,9 +1655,7 @@ co_IntSendMessageWithCallBack( HWND hWnd,
    Message->HasPackedLParam = (lParamBufferSize > 0);
 
    InsertTailList(&Window->pti->MessageQueue->SentMessagesListHead, &Message->ListEntry);
    Message->HasPackedLParam = (lParamBufferSize > 0);
 
    InsertTailList(&Window->pti->MessageQueue->SentMessagesListHead, &Message->ListEntry);
-   InsertTailList(&Win32Thread->MessageQueue->DispatchingMessagesHead, &Message->DispatchingListEntry);
    IntDereferenceMessageQueue(Window->pti->MessageQueue);
    IntDereferenceMessageQueue(Window->pti->MessageQueue);
-   IntDereferenceMessageQueue(Message->SenderQueue);
 
    RETURN(TRUE);
 
 
    RETURN(TRUE);
 
index 33b8119..1bba2a1 100644 (file)
@@ -936,12 +936,15 @@ co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue)
       to be cleaned up on thread termination anymore */
    RemoveEntryList(&Message->ListEntry);
 
       to be cleaned up on thread termination anymore */
    RemoveEntryList(&Message->ListEntry);
 
-   /* remove the message from the dispatching list, so lock the sender's message queue */
-   SenderReturned = (Message->DispatchingListEntry.Flink == NULL);
-   if (!SenderReturned)
+   /* remove the message from the dispatching list if needed, so lock the sender's message queue */
+   if (!(Message->HookMessage & MSQ_SENTNOWAIT))
    {
    {
-      /* only remove it from the dispatching list if not already removed by a timeout */
-      RemoveEntryList(&Message->DispatchingListEntry);
+      SenderReturned = (Message->DispatchingListEntry.Flink == NULL);
+      if (!SenderReturned)
+      {
+         /* only remove it from the dispatching list if not already removed by a timeout */
+         RemoveEntryList(&Message->DispatchingListEntry);
+      }
    }
    /* still keep the sender's message queue locked, so the sender can't exit the
       MsqSendMessage() function (if timed out) */
    }
    /* still keep the sender's message queue locked, so the sender can't exit the
       MsqSendMessage() function (if timed out) */
@@ -974,7 +977,6 @@ co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue)
                                     Result);
    }
 
                                     Result);
    }
 
-
    /* Only if it is not a no wait message */
    if (!(Message->HookMessage & MSQ_SENTNOWAIT))
    {
    /* Only if it is not a no wait message */
    if (!(Message->HookMessage & MSQ_SENTNOWAIT))
    {
@@ -1033,8 +1035,9 @@ MsqRemoveWindowMessagesFromQueue(PVOID pWindow)
 
          RemoveEntryList(&SentMessage->ListEntry);
 
 
          RemoveEntryList(&SentMessage->ListEntry);
 
-         /* remove the message from the dispatching list */
-         if(SentMessage->DispatchingListEntry.Flink != NULL)
+         /* remove the message from the dispatching list if neede */
+         if ((!(SentMessage->HookMessage & MSQ_SENTNOWAIT))
+            && (SentMessage->DispatchingListEntry.Flink != NULL))
          {
             RemoveEntryList(&SentMessage->DispatchingListEntry);
          }
          {
             RemoveEntryList(&SentMessage->DispatchingListEntry);
          }
@@ -1453,8 +1456,9 @@ MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue)
 
       DPRINT("Notify the sender and remove a message from the queue that had not been dispatched\n");
 
 
       DPRINT("Notify the sender and remove a message from the queue that had not been dispatched\n");
 
-      /* remove the message from the dispatching list */
-      if(CurrentSentMessage->DispatchingListEntry.Flink != NULL)
+      /* remove the message from the dispatching list if needed */
+      if ((!(CurrentSentMessage->HookMessage & MSQ_SENTNOWAIT)) 
+         && (CurrentSentMessage->DispatchingListEntry.Flink != NULL))
       {
          RemoveEntryList(&CurrentSentMessage->DispatchingListEntry);
       }
       {
          RemoveEntryList(&CurrentSentMessage->DispatchingListEntry);
       }
@@ -1526,6 +1530,7 @@ MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue)
          IntDereferenceMessageQueue(MessageQueue);
          IntDereferenceMessageQueue(CurrentSentMessage->SenderQueue);
       }
          IntDereferenceMessageQueue(MessageQueue);
          IntDereferenceMessageQueue(CurrentSentMessage->SenderQueue);
       }
+
       /* free the message */
       ExFreePool(CurrentSentMessage);
    }
       /* free the message */
       ExFreePool(CurrentSentMessage);
    }