10 typedef struct _USER_MESSAGE
15 } USER_MESSAGE
, *PUSER_MESSAGE
;
17 struct _USER_MESSAGE_QUEUE
;
19 typedef struct _USER_SENT_MESSAGE
23 PKEVENT CompletionEvent
;
25 struct _USER_MESSAGE_QUEUE
* SenderQueue
;
26 SENDASYNCPROC CompletionCallback
;
27 ULONG_PTR CompletionCallbackContext
;
28 /* entry in the dispatching list of the sender's message queue */
29 LIST_ENTRY DispatchingListEntry
;
31 } USER_SENT_MESSAGE
, *PUSER_SENT_MESSAGE
;
33 typedef struct _USER_SENT_MESSAGE_NOTIFY
35 SENDASYNCPROC CompletionCallback
;
36 ULONG_PTR CompletionCallbackContext
;
41 } USER_SENT_MESSAGE_NOTIFY
, *PUSER_SENT_MESSAGE_NOTIFY
;
43 typedef struct _TIMER_ENTRY
{
45 LARGE_INTEGER ExpiryTime
;
51 } TIMER_ENTRY
, *PTIMER_ENTRY
;
53 typedef struct _USER_MESSAGE_QUEUE
55 /* Reference counter, only access this variable with interlocked functions! */
58 /* Owner of the message queue */
59 struct _ETHREAD
*Thread
;
60 /* Queue of messages sent to the queue. */
61 LIST_ENTRY SentMessagesListHead
;
62 /* Queue of messages posted to the queue. */
63 LIST_ENTRY PostedMessagesListHead
;
64 /* Queue of sent-message notifies for the queue. */
65 LIST_ENTRY NotifyMessagesListHead
;
66 /* Queue for hardware messages for the queue. */
67 LIST_ENTRY HardwareMessagesListHead
;
68 /* List of timers, sorted on expiry time (earliest first) */
69 LIST_ENTRY TimerListHead
;
70 /* Lock for the hardware message list. */
72 /* Pointer to the current WM_MOUSEMOVE message */
73 PUSER_MESSAGE MouseMoveMsg
;
74 /* True if a WM_QUIT message is pending. */
76 /* The quit exit code. */
78 /* Set if there are new messages specified by WakeMask in any of the queues. */
80 /* Handle for the above event (in the context of the process owning the queue). */
81 HANDLE NewMessagesHandle
;
82 /* Last time PeekMessage() was called. */
84 /* Current window with focus (ie. receives keyboard input) for this queue. */
86 /* Count of paints pending. */
88 /* Current active window for this queue. */
90 /* Current capture window for this queue. */
92 /* Current move/size window for this queue */
94 /* Current menu owner window for this queue */
96 /* Identifes the menu state */
98 /* Caret information for this queue */
99 PTHRDCARETINFO CaretInfo
;
104 /* queue state tracking */
109 /* extra message information */
112 /* messages that are currently dispatched by other threads */
113 LIST_ENTRY DispatchingMessagesHead
;
114 /* messages that are currently dispatched by this message queue, required for cleanup */
115 LIST_ENTRY LocalDispatchingMessagesHead
;
117 /* Desktop that the message queue is attached to */
118 struct _DESKTOP
*Desktop
;
119 } USER_MESSAGE_QUEUE
, *PUSER_MESSAGE_QUEUE
;
122 MsqIsHung(PUSER_MESSAGE_QUEUE MessageQueue
);
124 co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue
,
125 HWND Wnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
,
126 UINT uTimeout
, BOOL Block
, INT HookMessage
,
128 PUSER_MESSAGE FASTCALL
129 MsqCreateMessage(LPMSG Msg
, BOOLEAN FreeLParam
);
131 MsqDestroyMessage(PUSER_MESSAGE Message
);
133 MsqPostMessage(PUSER_MESSAGE_QUEUE MessageQueue
,
134 MSG
* Msg
, BOOLEAN FreeLParam
, DWORD MessageBits
);
136 MsqPostQuitMessage(PUSER_MESSAGE_QUEUE MessageQueue
, ULONG ExitCode
);
138 co_MsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue
,
141 IN PWINDOW_OBJECT Window
,
142 IN UINT MsgFilterLow
,
143 IN UINT MsgFilterHigh
,
144 OUT PUSER_MESSAGE
* Message
);
146 MsqInitializeMessageQueue(struct _ETHREAD
*Thread
, PUSER_MESSAGE_QUEUE MessageQueue
);
148 MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue
);
149 PUSER_MESSAGE_QUEUE FASTCALL
150 MsqCreateMessageQueue(struct _ETHREAD
*Thread
);
152 MsqDestroyMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue
);
153 PUSER_MESSAGE_QUEUE FASTCALL
154 MsqGetHardwareMessageQueue(VOID
);
156 MsqInitializeImpl(VOID
);
158 co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue
);
160 co_MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue
, PWINDOW_OBJECT WndFilter
,
161 UINT MsgFilterMin
, UINT MsgFilterMax
);
163 MsqSendNotifyMessage(PUSER_MESSAGE_QUEUE MessageQueue
,
164 PUSER_SENT_MESSAGE_NOTIFY NotifyMessage
);
166 MsqIncPaintCountQueue(PUSER_MESSAGE_QUEUE Queue
);
168 MsqDecPaintCountQueue(PUSER_MESSAGE_QUEUE Queue
);
170 co_IntSendMessage(HWND hWnd
,
175 co_IntPostOrSendMessage(HWND hWnd
,
180 co_IntSendMessageTimeout(HWND hWnd
,
188 IntDispatchMessage(MSG
* Msg
);
190 IntTranslateKbdMessage(LPMSG lpMsg
, HKL dwhkl
);
193 co_MsqPostKeyboardMessage(UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
195 MsqPostHotKeyMessage(PVOID Thread
, HWND hWnd
, WPARAM wParam
, LPARAM lParam
);
197 MsqInsertSystemMessage(MSG
* Msg
);
199 MsqIsClkLck(LPMSG Msg
, BOOL Remove
);
201 MsqIsDblClk(LPMSG Msg
, BOOL Remove
);
203 MsqSetStateWindow(PUSER_MESSAGE_QUEUE MessageQueue
, ULONG Type
, HWND hWnd
);
205 __inline BOOL
MsqIsSignaled( PUSER_MESSAGE_QUEUE queue
);
206 __inline VOID
MsqSetQueueBits( PUSER_MESSAGE_QUEUE queue
, WORD bits
);
207 __inline VOID
MsqClearQueueBits( PUSER_MESSAGE_QUEUE queue
, WORD bits
);
208 BOOL APIENTRY
IntInitMessagePumpHook();
209 BOOL APIENTRY
IntUninitMessagePumpHook();
210 #define MAKE_LONG(x, y) ((((y) & 0xFFFF) << 16) | ((x) & 0xFFFF))
212 PHOOKTABLE FASTCALL
MsqGetHooks(PUSER_MESSAGE_QUEUE Queue
);
213 VOID FASTCALL
MsqSetHooks(PUSER_MESSAGE_QUEUE Queue
, PHOOKTABLE Hooks
);
215 LPARAM FASTCALL
MsqSetMessageExtraInfo(LPARAM lParam
);
216 LPARAM FASTCALL
MsqGetMessageExtraInfo(VOID
);
217 VOID APIENTRY
MsqRemoveWindowMessagesFromQueue(PVOID pWindow
); /* F*(&$ headers, will be gone in the rewrite! */
219 #define IntLockHardwareMessageQueue(MsgQueue) \
220 KeWaitForMutexObject(&(MsgQueue)->HardwareLock, UserRequest, KernelMode, FALSE, NULL)
222 #define IntUnLockHardwareMessageQueue(MsgQueue) \
223 KeReleaseMutex(&(MsgQueue)->HardwareLock, FALSE)
225 #define IntReferenceMessageQueue(MsgQueue) \
226 InterlockedIncrement(&(MsgQueue)->References)
228 #define IntDereferenceMessageQueue(MsgQueue) \
230 if(InterlockedDecrement(&(MsgQueue)->References) == 0) \
232 DPRINT("Free message queue 0x%x\n", (MsgQueue)); \
233 if ((MsgQueue)->NewMessages != NULL) \
234 ObDereferenceObject((MsgQueue)->NewMessages); \
235 if ((MsgQueue)->NewMessagesHandle != NULL) \
236 ZwClose((MsgQueue)->NewMessagesHandle); \
237 ExFreePool((MsgQueue)); \
241 #define IS_BTN_MESSAGE(message,code) \
242 ((message) == WM_LBUTTON##code || \
243 (message) == WM_MBUTTON##code || \
244 (message) == WM_RBUTTON##code || \
245 (message) == WM_XBUTTON##code || \
246 (message) == WM_NCLBUTTON##code || \
247 (message) == WM_NCMBUTTON##code || \
248 (message) == WM_NCRBUTTON##code || \
249 (message) == WM_NCXBUTTON##code )
252 IntMsqSetWakeMask(DWORD WakeMask
);
255 IntMsqClearWakeMask(VOID
);
258 MsqSetTimer(PUSER_MESSAGE_QUEUE MessageQueue
, HWND Wnd
,
259 UINT_PTR IDEvent
, UINT Period
, TIMERPROC TimerFunc
,
262 MsqKillTimer(PUSER_MESSAGE_QUEUE MessageQueue
, HWND Wnd
,
263 UINT_PTR IDEvent
, UINT Msg
);
265 MsqGetTimerMessage(PUSER_MESSAGE_QUEUE MessageQueue
,
266 PWINDOW_OBJECT WindowFilter
, UINT MsgFilterMin
, UINT MsgFilterMax
,
267 MSG
*Msg
, BOOLEAN Restart
);
269 MsqGetFirstTimerExpiry(PUSER_MESSAGE_QUEUE MessageQueue
,
270 PWINDOW_OBJECT WndFilter
, UINT MsgFilterMin
, UINT MsgFilterMax
,
271 PLARGE_INTEGER FirstTimerExpiry
);
273 MsqRemoveTimersWindow(PUSER_MESSAGE_QUEUE MessageQueue
, HWND Wnd
);
276 MsqCalculateMessageTime(IN PLARGE_INTEGER TickCount
)
278 return (LONG
)(TickCount
->QuadPart
* (KeQueryTimeIncrement() / 10000));