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;
Message->HasPackedLParam = (lParamBufferSize > 0);
InsertTailList(&Window->pti->MessageQueue->SentMessagesListHead, &Message->ListEntry);
- InsertTailList(&Win32Thread->MessageQueue->DispatchingMessagesHead, &Message->DispatchingListEntry);
IntDereferenceMessageQueue(Window->pti->MessageQueue);
- IntDereferenceMessageQueue(Message->SenderQueue);
RETURN(TRUE);
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) */
Result);
}
-
/* Only if it is not a no wait message */
if (!(Message->HookMessage & MSQ_SENTNOWAIT))
{
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);
}
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);
}
IntDereferenceMessageQueue(MessageQueue);
IntDereferenceMessageQueue(CurrentSentMessage->SenderQueue);
}
+
/* free the message */
ExFreePool(CurrentSentMessage);
}