@@ -1072,7 +1072,7 @@ MsqRemoveWindowMessagesFromQueue(PVOID pWindow)
1072
1072
{
1073
1073
DPRINT ("Notify the sender and remove a message from the queue that had not been dispatched\n" );
1074
1074
1075
- RemoveEntryList (& SentMessage -> ListEntry );
1075
+ RemoveEntryList (& SentMessage -> ListEntry );
1076
1076
1077
1077
/* remove the message from the dispatching list */
1078
1078
if (SentMessage -> DispatchingListEntry .Flink != NULL )
@@ -1086,9 +1086,19 @@ MsqRemoveWindowMessagesFromQueue(PVOID pWindow)
1086
1086
KeSetEvent (SentMessage -> CompletionEvent , IO_NO_INCREMENT , FALSE);
1087
1087
}
1088
1088
1089
- /* dereference our and the sender's message queue */
1090
- IntDereferenceMessageQueue (MessageQueue );
1091
- IntDereferenceMessageQueue (SentMessage -> SenderQueue );
1089
+ if (SentMessage -> HasPackedLParam == TRUE)
1090
+ {
1091
+ if (SentMessage -> Msg .lParam )
1092
+ ExFreePool ((PVOID )SentMessage -> Msg .lParam );
1093
+ }
1094
+
1095
+ /* Only if it is not a no wait message */
1096
+ if (!(SentMessage -> HookMessage & MSQ_SENTNOWAIT ))
1097
+ {
1098
+ /* dereference our and the sender's message queue */
1099
+ IntDereferenceMessageQueue (MessageQueue );
1100
+ IntDereferenceMessageQueue (SentMessage -> SenderQueue );
1101
+ }
1092
1102
1093
1103
/* free the message */
1094
1104
ExFreePool (SentMessage );
@@ -1509,9 +1519,19 @@ MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue)
1509
1519
KeSetEvent (CurrentSentMessage -> CompletionEvent , IO_NO_INCREMENT , FALSE);
1510
1520
}
1511
1521
1512
- /* dereference our and the sender's message queue */
1513
- IntDereferenceMessageQueue (MessageQueue );
1514
- IntDereferenceMessageQueue (CurrentSentMessage -> SenderQueue );
1522
+ if (CurrentSentMessage -> HasPackedLParam == TRUE)
1523
+ {
1524
+ if (CurrentSentMessage -> Msg .lParam )
1525
+ ExFreePool ((PVOID )CurrentSentMessage -> Msg .lParam );
1526
+ }
1527
+
1528
+ /* Only if it is not a no wait message */
1529
+ if (!(CurrentSentMessage -> HookMessage & MSQ_SENTNOWAIT ))
1530
+ {
1531
+ /* dereference our and the sender's message queue */
1532
+ IntDereferenceMessageQueue (MessageQueue );
1533
+ IntDereferenceMessageQueue (CurrentSentMessage -> SenderQueue );
1534
+ }
1515
1535
1516
1536
/* free the message */
1517
1537
ExFreePool (CurrentSentMessage );
@@ -1547,10 +1567,19 @@ MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue)
1547
1567
KeSetEvent (CurrentSentMessage -> CompletionEvent , IO_NO_INCREMENT , FALSE);
1548
1568
}
1549
1569
1550
- /* dereference our and the sender's message queue */
1551
- IntDereferenceMessageQueue (MessageQueue );
1552
- IntDereferenceMessageQueue (CurrentSentMessage -> SenderQueue );
1570
+ if (CurrentSentMessage -> HasPackedLParam == TRUE)
1571
+ {
1572
+ if (CurrentSentMessage -> Msg .lParam )
1573
+ ExFreePool ((PVOID )CurrentSentMessage -> Msg .lParam );
1574
+ }
1553
1575
1576
+ /* Only if it is not a no wait message */
1577
+ if (!(CurrentSentMessage -> HookMessage & MSQ_SENTNOWAIT ))
1578
+ {
1579
+ /* dereference our and the sender's message queue */
1580
+ IntDereferenceMessageQueue (MessageQueue );
1581
+ IntDereferenceMessageQueue (CurrentSentMessage -> SenderQueue );
1582
+ }
1554
1583
/* free the message */
1555
1584
ExFreePool (CurrentSentMessage );
1556
1585
}
0 commit comments