mirror of
https://github.com/reactos/reactos.git
synced 2024-10-04 16:36:11 +00:00
[win32]
- Rafal Harabien: - Always call IntKeyboardInput and co_MsqPostKeyboardMessage while holding the user lock - Simplify cleaning up sent messages See issue #5580 for more details. svn path=/trunk/; revision=51031
This commit is contained in:
parent
58b9a229c5
commit
d1a2f235a3
|
@ -708,6 +708,7 @@ KeyboardThreadMain(PVOID StartContext)
|
||||||
|
|
||||||
if (ModifierState == 0)
|
if (ModifierState == 0)
|
||||||
{
|
{
|
||||||
|
UserEnterExclusive();
|
||||||
if (fsModifiers == MOD_WIN)
|
if (fsModifiers == MOD_WIN)
|
||||||
IntKeyboardSendWinKeyMsg();
|
IntKeyboardSendWinKeyMsg();
|
||||||
else if (fsModifiers == MOD_ALT)
|
else if (fsModifiers == MOD_ALT)
|
||||||
|
@ -723,6 +724,7 @@ KeyboardThreadMain(PVOID StartContext)
|
||||||
}
|
}
|
||||||
co_IntKeyboardSendAltKeyMsg();
|
co_IntKeyboardSendAltKeyMsg();
|
||||||
}
|
}
|
||||||
|
UserLeave();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -731,6 +733,8 @@ KeyboardThreadMain(PVOID StartContext)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UserEnterExclusive();
|
||||||
|
|
||||||
for (;NumKeys;memcpy(&KeyInput, &NextKeyInput, sizeof(KeyInput)),
|
for (;NumKeys;memcpy(&KeyInput, &NextKeyInput, sizeof(KeyInput)),
|
||||||
NumKeys--)
|
NumKeys--)
|
||||||
{
|
{
|
||||||
|
@ -860,6 +864,8 @@ KeyboardThreadMain(PVOID StartContext)
|
||||||
*/
|
*/
|
||||||
co_MsqPostKeyboardMessage(msg.message,msg.wParam,msg.lParam);
|
co_MsqPostKeyboardMessage(msg.message,msg.wParam,msg.lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UserLeave();
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyboardEscape:
|
KeyboardEscape:
|
||||||
|
@ -1243,17 +1249,11 @@ IntKeyboardInput(KEYBDINPUT *ki)
|
||||||
LARGE_INTEGER LargeTickCount;
|
LARGE_INTEGER LargeTickCount;
|
||||||
KBDLLHOOKSTRUCT KbdHookData;
|
KBDLLHOOKSTRUCT KbdHookData;
|
||||||
WORD flags, wVkStripped, wVkL, wVkR, wVk = ki->wVk, vk_hook = ki->wVk;
|
WORD flags, wVkStripped, wVkL, wVkR, wVk = ki->wVk, vk_hook = ki->wVk;
|
||||||
BOOLEAN Entered = FALSE;
|
|
||||||
|
|
||||||
Msg.lParam = 0;
|
Msg.lParam = 0;
|
||||||
|
|
||||||
// Condition may arise when calling MsqPostMessage and waiting for an event.
|
// Condition may arise when calling MsqPostMessage and waiting for an event.
|
||||||
if (!UserIsEntered())
|
ASSERT (UserIsEntered());
|
||||||
{
|
|
||||||
// Fixme: Not sure ATM if this thread is locked.
|
|
||||||
UserEnterExclusive();
|
|
||||||
Entered = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
wVk = LOBYTE(wVk);
|
wVk = LOBYTE(wVk);
|
||||||
Msg.wParam = wVk;
|
Msg.wParam = wVk;
|
||||||
|
@ -1352,7 +1352,7 @@ IntKeyboardInput(KEYBDINPUT *ki)
|
||||||
{
|
{
|
||||||
DPRINT1("Kbd msg %d wParam %d lParam 0x%08x dropped by WH_KEYBOARD_LL hook\n",
|
DPRINT1("Kbd msg %d wParam %d lParam 0x%08x dropped by WH_KEYBOARD_LL hook\n",
|
||||||
Msg.message, vk_hook, Msg.lParam);
|
Msg.message, vk_hook, Msg.lParam);
|
||||||
if (Entered) UserLeave();
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1380,7 +1380,7 @@ IntKeyboardInput(KEYBDINPUT *ki)
|
||||||
if (FocusMessageQueue == NULL)
|
if (FocusMessageQueue == NULL)
|
||||||
{
|
{
|
||||||
DPRINT("No focus message queue\n");
|
DPRINT("No focus message queue\n");
|
||||||
if (Entered) UserLeave();
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1401,8 +1401,6 @@ IntKeyboardInput(KEYBDINPUT *ki)
|
||||||
DPRINT("Invalid focus window handle\n");
|
DPRINT("Invalid focus window handle\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Entered) UserLeave();
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1447,7 +1447,7 @@ co_IntSendMessageWithCallBack( HWND hWnd,
|
||||||
if(!(Message = ExAllocatePoolWithTag(NonPagedPool, sizeof(USER_SENT_MESSAGE), TAG_USRMSG)))
|
if(!(Message = ExAllocatePoolWithTag(NonPagedPool, sizeof(USER_SENT_MESSAGE), TAG_USRMSG)))
|
||||||
{
|
{
|
||||||
DPRINT1("MsqSendMessage(): Not enough memory to allocate a message");
|
DPRINT1("MsqSendMessage(): Not enough memory to allocate a message");
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
RETURN( FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Message->Msg.hwnd = hWnd;
|
Message->Msg.hwnd = hWnd;
|
||||||
|
@ -1459,19 +1459,21 @@ co_IntSendMessageWithCallBack( HWND hWnd,
|
||||||
Message->lResult = 0;
|
Message->lResult = 0;
|
||||||
Message->QS_Flags = 0;
|
Message->QS_Flags = 0;
|
||||||
Message->SenderQueue = NULL; // mjmartin, you are right! This is null.
|
Message->SenderQueue = NULL; // mjmartin, you are right! This is null.
|
||||||
|
IntReferenceMessageQueue(Win32Thread->MessageQueue);
|
||||||
Message->CallBackSenderQueue = Win32Thread->MessageQueue;
|
Message->CallBackSenderQueue = Win32Thread->MessageQueue;
|
||||||
|
|
||||||
IntReferenceMessageQueue(Window->head.pti->MessageQueue);
|
|
||||||
Message->CompletionCallback = CompletionCallback;
|
Message->CompletionCallback = CompletionCallback;
|
||||||
Message->CompletionCallbackContext = CompletionCallbackContext;
|
Message->CompletionCallbackContext = CompletionCallbackContext;
|
||||||
Message->HookMessage = MSQ_NORMAL | MSQ_SENTNOWAIT;
|
Message->HookMessage = MSQ_NORMAL; // | MSQ_SENTNOWAIT
|
||||||
Message->HasPackedLParam = (lParamBufferSize > 0);
|
Message->HasPackedLParam = (lParamBufferSize > 0);
|
||||||
|
Message->DispatchingListEntry.Flink = NULL;
|
||||||
Message->QS_Flags = QS_SENDMESSAGE;
|
Message->QS_Flags = QS_SENDMESSAGE;
|
||||||
|
|
||||||
|
IntReferenceMessageQueue(Window->head.pti->MessageQueue);
|
||||||
|
|
||||||
MsqWakeQueue(Window->head.pti->MessageQueue, QS_SENDMESSAGE, FALSE);
|
MsqWakeQueue(Window->head.pti->MessageQueue, QS_SENDMESSAGE, FALSE);
|
||||||
|
|
||||||
InsertTailList(&Window->head.pti->MessageQueue->SentMessagesListHead, &Message->ListEntry);
|
InsertTailList(&Window->head.pti->MessageQueue->SentMessagesListHead, &Message->ListEntry);
|
||||||
IntDereferenceMessageQueue(Window->head.pti->MessageQueue);
|
//IntDereferenceMessageQueue(Window->head.pti->MessageQueue);
|
||||||
|
|
||||||
RETURN(TRUE);
|
RETURN(TRUE);
|
||||||
|
|
||||||
|
|
|
@ -279,18 +279,12 @@ co_MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
MSG Msg;
|
MSG Msg;
|
||||||
LARGE_INTEGER LargeTickCount;
|
LARGE_INTEGER LargeTickCount;
|
||||||
KBDLLHOOKSTRUCT KbdHookData;
|
KBDLLHOOKSTRUCT KbdHookData;
|
||||||
BOOLEAN Entered = FALSE;
|
|
||||||
|
|
||||||
DPRINT("MsqPostKeyboardMessage(uMsg 0x%x, wParam 0x%x, lParam 0x%x)\n",
|
DPRINT("MsqPostKeyboardMessage(uMsg 0x%x, wParam 0x%x, lParam 0x%x)\n",
|
||||||
uMsg, wParam, lParam);
|
uMsg, wParam, lParam);
|
||||||
|
|
||||||
// Condition may arise when calling MsqPostMessage and waiting for an event.
|
// Condition may arise when calling MsqPostMessage and waiting for an event.
|
||||||
if (!UserIsEntered())
|
ASSERT(UserIsEntered());
|
||||||
{
|
|
||||||
// Fixme: Not sure ATM if this thread is locked.
|
|
||||||
UserEnterExclusive();
|
|
||||||
Entered = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
FocusMessageQueue = IntGetFocusMessageQueue();
|
FocusMessageQueue = IntGetFocusMessageQueue();
|
||||||
|
|
||||||
|
@ -320,14 +314,12 @@ co_MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
DPRINT1("Kbd msg %d wParam %d lParam 0x%08x dropped by WH_KEYBOARD_LL hook\n",
|
DPRINT1("Kbd msg %d wParam %d lParam 0x%08x dropped by WH_KEYBOARD_LL hook\n",
|
||||||
Msg.message, Msg.wParam, Msg.lParam);
|
Msg.message, Msg.wParam, Msg.lParam);
|
||||||
if (Entered) UserLeave();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FocusMessageQueue == NULL)
|
if (FocusMessageQueue == NULL)
|
||||||
{
|
{
|
||||||
DPRINT("No focus message queue\n");
|
DPRINT("No focus message queue\n");
|
||||||
if (Entered) UserLeave();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,7 +338,6 @@ co_MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
DPRINT("Invalid focus window handle\n");
|
DPRINT("Invalid focus window handle\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Entered) UserLeave();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,6 +406,42 @@ MsqDestroyMessage(PUSER_MESSAGE Message)
|
||||||
ExFreeToPagedLookasideList(&MessageLookasideList, Message);
|
ExFreeToPagedLookasideList(&MessageLookasideList, Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID FASTCALL
|
||||||
|
MsqDestroySentMessage(PUSER_MESSAGE_QUEUE MessageQueue, PUSER_SENT_MESSAGE SentMessage)
|
||||||
|
{
|
||||||
|
/* remove the message from the dispatching list if needed */
|
||||||
|
if (SentMessage->DispatchingListEntry.Flink != NULL)
|
||||||
|
{
|
||||||
|
RemoveEntryList(&SentMessage->DispatchingListEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* wake the sender's thread */
|
||||||
|
if (SentMessage->CompletionEvent != NULL)
|
||||||
|
{
|
||||||
|
KeSetEvent(SentMessage->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* dereference message queues */
|
||||||
|
IntDereferenceMessageQueue(MessageQueue);
|
||||||
|
if (SentMessage->SenderQueue)
|
||||||
|
{
|
||||||
|
IntDereferenceMessageQueue(SentMessage->SenderQueue);
|
||||||
|
}
|
||||||
|
if (SentMessage->CallBackSenderQueue)
|
||||||
|
{
|
||||||
|
IntDereferenceMessageQueue(SentMessage->CallBackSenderQueue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free lParam if needed */
|
||||||
|
if (SentMessage->HasPackedLParam == TRUE && SentMessage->Msg.lParam)
|
||||||
|
{
|
||||||
|
ExFreePool((PVOID)SentMessage->Msg.lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free the message */
|
||||||
|
ExFreePoolWithTag(SentMessage, TAG_USRMSG);
|
||||||
|
}
|
||||||
|
|
||||||
BOOLEAN FASTCALL
|
BOOLEAN FASTCALL
|
||||||
co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue)
|
co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue)
|
||||||
{
|
{
|
||||||
|
@ -478,13 +505,10 @@ co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue)
|
||||||
RemoveEntryList(&Message->ListEntry);
|
RemoveEntryList(&Message->ListEntry);
|
||||||
|
|
||||||
/* remove the message from the dispatching list if needed, so lock the sender's message queue */
|
/* remove the message from the dispatching list if needed, so lock the sender's message queue */
|
||||||
if (!(Message->HookMessage & MSQ_SENTNOWAIT))
|
if (Message->DispatchingListEntry.Flink != NULL)
|
||||||
{
|
{
|
||||||
if (Message->DispatchingListEntry.Flink != NULL)
|
RemoveEntryList(&Message->DispatchingListEntry);
|
||||||
{
|
Message->DispatchingListEntry.Flink = NULL;
|
||||||
/* 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
|
/* still keep the sender's message queue locked, so the sender can't exit the
|
||||||
MsqSendMessage() function (if timed out) */
|
MsqSendMessage() function (if timed out) */
|
||||||
|
@ -500,16 +524,11 @@ co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue)
|
||||||
*Message->Result = Result;
|
*Message->Result = Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Message->HasPackedLParam == TRUE)
|
|
||||||
{
|
|
||||||
if (Message->Msg.lParam)
|
|
||||||
ExFreePool((PVOID)Message->Msg.lParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Notify the sender. */
|
/* Notify the sender. */
|
||||||
if (Message->CompletionEvent != NULL)
|
if (Message->CompletionEvent != NULL)
|
||||||
{
|
{
|
||||||
KeSetEvent(Message->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
KeSetEvent(Message->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||||
|
Message->CompletionEvent = NULL; /* prevent MsqDestroySentMessage from setting this event again */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call the callback if the message was sent with SendMessageCallback */
|
/* Call the callback if the message was sent with SendMessageCallback */
|
||||||
|
@ -522,15 +541,7 @@ co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue)
|
||||||
Result);
|
Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only if it is not a no wait message */
|
MsqDestroySentMessage(MessageQueue, Message);
|
||||||
if (!(Message->HookMessage & MSQ_SENTNOWAIT))
|
|
||||||
{
|
|
||||||
IntDereferenceMessageQueue(Message->SenderQueue);
|
|
||||||
IntDereferenceMessageQueue(MessageQueue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* free the message */
|
|
||||||
ExFreePoolWithTag(Message, TAG_USRMSG);
|
|
||||||
|
|
||||||
/* do not hangup on the user if this is reentering */
|
/* do not hangup on the user if this is reentering */
|
||||||
if (!SaveMsg) pti->pcti->CTI_flags &= ~CTI_INSENDMESSAGE;
|
if (!SaveMsg) pti->pcti->CTI_flags &= ~CTI_INSENDMESSAGE;
|
||||||
|
@ -560,16 +571,14 @@ MsqRemoveWindowMessagesFromQueue(PVOID pWindow)
|
||||||
{
|
{
|
||||||
PostedMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE,
|
PostedMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE,
|
||||||
ListEntry);
|
ListEntry);
|
||||||
|
/* set CurrentEntry to next before destroying message */
|
||||||
|
CurrentEntry = CurrentEntry->Flink;
|
||||||
|
|
||||||
if (PostedMessage->Msg.hwnd == Window->head.h)
|
if (PostedMessage->Msg.hwnd == Window->head.h)
|
||||||
{
|
{
|
||||||
RemoveEntryList(&PostedMessage->ListEntry);
|
RemoveEntryList(&PostedMessage->ListEntry);
|
||||||
ClearMsgBitsMask(MessageQueue, PostedMessage->QS_Flags);
|
ClearMsgBitsMask(MessageQueue, PostedMessage->QS_Flags);
|
||||||
MsqDestroyMessage(PostedMessage);
|
MsqDestroyMessage(PostedMessage);
|
||||||
CurrentEntry = MessageQueue->PostedMessagesListHead.Flink;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CurrentEntry = CurrentEntry->Flink;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,6 +589,9 @@ MsqRemoveWindowMessagesFromQueue(PVOID pWindow)
|
||||||
{
|
{
|
||||||
SentMessage = CONTAINING_RECORD(CurrentEntry, USER_SENT_MESSAGE,
|
SentMessage = CONTAINING_RECORD(CurrentEntry, USER_SENT_MESSAGE,
|
||||||
ListEntry);
|
ListEntry);
|
||||||
|
/* set CurrentEntry to next before destroying message */
|
||||||
|
CurrentEntry = CurrentEntry->Flink;
|
||||||
|
|
||||||
if(SentMessage->Msg.hwnd == Window->head.h)
|
if(SentMessage->Msg.hwnd == Window->head.h)
|
||||||
{
|
{
|
||||||
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");
|
||||||
|
@ -587,41 +599,7 @@ MsqRemoveWindowMessagesFromQueue(PVOID pWindow)
|
||||||
RemoveEntryList(&SentMessage->ListEntry);
|
RemoveEntryList(&SentMessage->ListEntry);
|
||||||
ClearMsgBitsMask(MessageQueue, SentMessage->QS_Flags);
|
ClearMsgBitsMask(MessageQueue, SentMessage->QS_Flags);
|
||||||
|
|
||||||
/* remove the message from the dispatching list if neede */
|
MsqDestroySentMessage(MessageQueue, SentMessage);
|
||||||
if ((!(SentMessage->HookMessage & MSQ_SENTNOWAIT))
|
|
||||||
&& (SentMessage->DispatchingListEntry.Flink != NULL))
|
|
||||||
{
|
|
||||||
RemoveEntryList(&SentMessage->DispatchingListEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* wake the sender's thread */
|
|
||||||
if (SentMessage->CompletionEvent != NULL)
|
|
||||||
{
|
|
||||||
KeSetEvent(SentMessage->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SentMessage->HasPackedLParam == TRUE)
|
|
||||||
{
|
|
||||||
if (SentMessage->Msg.lParam)
|
|
||||||
ExFreePool((PVOID)SentMessage->Msg.lParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Only if it is not a no wait message */
|
|
||||||
if (!(SentMessage->HookMessage & MSQ_SENTNOWAIT))
|
|
||||||
{
|
|
||||||
/* dereference our and the sender's message queue */
|
|
||||||
IntDereferenceMessageQueue(MessageQueue);
|
|
||||||
IntDereferenceMessageQueue(SentMessage->SenderQueue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* free the message */
|
|
||||||
ExFreePoolWithTag(SentMessage, TAG_USRMSG);
|
|
||||||
|
|
||||||
CurrentEntry = MessageQueue->SentMessagesListHead.Flink;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CurrentEntry = CurrentEntry->Flink;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -655,7 +633,7 @@ co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue,
|
||||||
|
|
||||||
Timeout.QuadPart = (LONGLONG) uTimeout * (LONGLONG) -10000;
|
Timeout.QuadPart = (LONGLONG) uTimeout * (LONGLONG) -10000;
|
||||||
|
|
||||||
/* FIXME - increase reference counter of sender's message queue here */
|
/* FIXME - increase reference counter of sender's message queue here - isn't it done? */
|
||||||
|
|
||||||
Message->Msg.hwnd = Wnd;
|
Message->Msg.hwnd = Wnd;
|
||||||
Message->Msg.message = Msg;
|
Message->Msg.message = Msg;
|
||||||
|
@ -665,9 +643,9 @@ co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue,
|
||||||
Message->Result = &Result;
|
Message->Result = &Result;
|
||||||
Message->lResult = 0;
|
Message->lResult = 0;
|
||||||
Message->QS_Flags = 0;
|
Message->QS_Flags = 0;
|
||||||
|
IntReferenceMessageQueue(ThreadQueue);
|
||||||
Message->SenderQueue = ThreadQueue;
|
Message->SenderQueue = ThreadQueue;
|
||||||
Message->CallBackSenderQueue = NULL;
|
Message->CallBackSenderQueue = NULL;
|
||||||
IntReferenceMessageQueue(ThreadQueue);
|
|
||||||
Message->CompletionCallback = NULL;
|
Message->CompletionCallback = NULL;
|
||||||
Message->CompletionCallbackContext = 0;
|
Message->CompletionCallbackContext = 0;
|
||||||
Message->HookMessage = HookMessage;
|
Message->HookMessage = HookMessage;
|
||||||
|
@ -1436,35 +1414,7 @@ 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 needed */
|
MsqDestroySentMessage(MessageQueue, CurrentSentMessage);
|
||||||
if ((!(CurrentSentMessage->HookMessage & MSQ_SENTNOWAIT))
|
|
||||||
&& (CurrentSentMessage->DispatchingListEntry.Flink != NULL))
|
|
||||||
{
|
|
||||||
RemoveEntryList(&CurrentSentMessage->DispatchingListEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* wake the sender's thread */
|
|
||||||
if (CurrentSentMessage->CompletionEvent != NULL)
|
|
||||||
{
|
|
||||||
KeSetEvent(CurrentSentMessage->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CurrentSentMessage->HasPackedLParam == TRUE)
|
|
||||||
{
|
|
||||||
if (CurrentSentMessage->Msg.lParam)
|
|
||||||
ExFreePool((PVOID)CurrentSentMessage->Msg.lParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Only if it is not a no wait message */
|
|
||||||
if (!(CurrentSentMessage->HookMessage & MSQ_SENTNOWAIT))
|
|
||||||
{
|
|
||||||
/* dereference our and the sender's message queue */
|
|
||||||
IntDereferenceMessageQueue(MessageQueue);
|
|
||||||
IntDereferenceMessageQueue(CurrentSentMessage->SenderQueue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* free the message */
|
|
||||||
ExFreePool(CurrentSentMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* notify senders of dispatching messages. This needs to be cleaned up if e.g.
|
/* notify senders of dispatching messages. This needs to be cleaned up if e.g.
|
||||||
|
@ -1475,36 +1425,9 @@ MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue)
|
||||||
CurrentSentMessage = CONTAINING_RECORD(CurrentEntry, USER_SENT_MESSAGE,
|
CurrentSentMessage = CONTAINING_RECORD(CurrentEntry, USER_SENT_MESSAGE,
|
||||||
ListEntry);
|
ListEntry);
|
||||||
|
|
||||||
/* remove the message from the dispatching list */
|
|
||||||
if(CurrentSentMessage->DispatchingListEntry.Flink != NULL)
|
|
||||||
{
|
|
||||||
RemoveEntryList(&CurrentSentMessage->DispatchingListEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("Notify the sender, the thread has been terminated while dispatching a message!\n");
|
DPRINT("Notify the sender, the thread has been terminated while dispatching a message!\n");
|
||||||
|
|
||||||
/* wake the sender's thread */
|
MsqDestroySentMessage(MessageQueue, CurrentSentMessage);
|
||||||
if (CurrentSentMessage->CompletionEvent != NULL)
|
|
||||||
{
|
|
||||||
KeSetEvent(CurrentSentMessage->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CurrentSentMessage->HasPackedLParam == TRUE)
|
|
||||||
{
|
|
||||||
if (CurrentSentMessage->Msg.lParam)
|
|
||||||
ExFreePool((PVOID)CurrentSentMessage->Msg.lParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Only if it is not a no wait message */
|
|
||||||
if (!(CurrentSentMessage->HookMessage & MSQ_SENTNOWAIT))
|
|
||||||
{
|
|
||||||
/* dereference our and the sender's message queue */
|
|
||||||
IntDereferenceMessageQueue(MessageQueue);
|
|
||||||
IntDereferenceMessageQueue(CurrentSentMessage->SenderQueue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* free the message */
|
|
||||||
ExFreePool(CurrentSentMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* tell other threads not to bother returning any info to us */
|
/* tell other threads not to bother returning any info to us */
|
||||||
|
@ -1515,6 +1438,7 @@ MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue)
|
||||||
DispatchingListEntry);
|
DispatchingListEntry);
|
||||||
CurrentSentMessage->CompletionEvent = NULL;
|
CurrentSentMessage->CompletionEvent = NULL;
|
||||||
CurrentSentMessage->Result = NULL;
|
CurrentSentMessage->Result = NULL;
|
||||||
|
CurrentSentMessage->DispatchingListEntry.Flink = NULL; // yeah!
|
||||||
|
|
||||||
/* do NOT dereference our message queue as it might get attempted to be
|
/* do NOT dereference our message queue as it might get attempted to be
|
||||||
locked later */
|
locked later */
|
||||||
|
|
Loading…
Reference in a new issue