1 #ifndef _WIN32K_MSGQUEUE_H
2 #define _WIN32K_MSGQUEUE_H
4 #include <internal/ex.h>
11 typedef struct _USER_MESSAGE
16 } USER_MESSAGE
, *PUSER_MESSAGE
;
18 struct _USER_MESSAGE_QUEUE
;
20 typedef struct _USER_SENT_MESSAGE
24 PKEVENT CompletionEvent
;
26 struct _USER_MESSAGE_QUEUE
* SenderQueue
;
27 SENDASYNCPROC CompletionCallback
;
28 ULONG_PTR CompletionCallbackContext
;
29 /* entry in the dispatching list of the sender's message queue */
30 LIST_ENTRY DispatchingListEntry
;
32 } USER_SENT_MESSAGE
, *PUSER_SENT_MESSAGE
;
34 typedef struct _USER_SENT_MESSAGE_NOTIFY
36 SENDASYNCPROC CompletionCallback
;
37 ULONG_PTR CompletionCallbackContext
;
42 } USER_SENT_MESSAGE_NOTIFY
, *PUSER_SENT_MESSAGE_NOTIFY
;
44 typedef struct _TIMER_ENTRY
{
46 LARGE_INTEGER ExpiryTime
;
52 } TIMER_ENTRY
, *PTIMER_ENTRY
;
54 typedef struct _USER_MESSAGE_QUEUE
56 /* Reference counter, only access this variable with interlocked functions! */
59 /* Owner of the message queue */
60 struct _ETHREAD
*Thread
;
61 /* Queue of messages sent to the queue. */
62 LIST_ENTRY SentMessagesListHead
;
63 /* Queue of messages posted to the queue. */
64 LIST_ENTRY PostedMessagesListHead
;
65 /* Queue of sent-message notifies for the queue. */
66 LIST_ENTRY NotifyMessagesListHead
;
67 /* Queue for hardware messages for the queue. */
68 LIST_ENTRY HardwareMessagesListHead
;
69 /* List of timers, sorted on expiry time (earliest first) */
70 LIST_ENTRY TimerListHead
;
71 /* Lock for the hardware message list. */
73 /* Lock for the queue. */
75 /* Pointer to the current WM_MOUSEMOVE message */
76 PUSER_MESSAGE MouseMoveMsg
;
77 /* True if a WM_QUIT message is pending. */
79 /* The quit exit code. */
81 /* Set if there are new messages specified by WakeMask in any of the queues. */
83 /* Handle for the above event (in the context of the process owning the queue). */
84 HANDLE NewMessagesHandle
;
85 /* Last time PeekMessage() was called. */
87 /* Current window with focus (ie. receives keyboard input) for this queue. */
89 /* True if a window needs painting. */
91 /* Count of paints pending. */
93 /* Current active window for this queue. */
95 /* Current capture window for this queue. */
97 /* Current move/size window for this queue */
99 /* Current menu owner window for this queue */
101 /* Identifes the menu state */
103 /* Caret information for this queue */
104 PTHRDCARETINFO CaretInfo
;
109 /* queue state tracking */
114 /* extra message information */
117 /* messages that are currently dispatched by other threads */
118 LIST_ENTRY DispatchingMessagesHead
;
119 /* messages that are currently dispatched by this message queue, required for cleanup */
120 LIST_ENTRY LocalDispatchingMessagesHead
;
122 /* Desktop that the message queue is attached to */
123 struct _DESKTOP_OBJECT
*Desktop
;
124 } USER_MESSAGE_QUEUE
, *PUSER_MESSAGE_QUEUE
;
127 MsqIsHung(PUSER_MESSAGE_QUEUE MessageQueue
);
129 MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue
,
130 HWND Wnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
,
131 UINT uTimeout
, BOOL Block
, BOOL HookMessage
,
133 PUSER_MESSAGE FASTCALL
134 MsqCreateMessage(LPMSG Msg
, BOOLEAN FreeLParam
);
136 MsqDestroyMessage(PUSER_MESSAGE Message
);
138 MsqPostMessage(PUSER_MESSAGE_QUEUE MessageQueue
,
139 MSG
* Msg
, BOOLEAN FreeLParam
, DWORD MessageBits
);
141 MsqPostQuitMessage(PUSER_MESSAGE_QUEUE MessageQueue
, ULONG ExitCode
);
143 MsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue
,
147 IN UINT MsgFilterLow
,
148 IN UINT MsgFilterHigh
,
149 OUT PUSER_MESSAGE
* Message
);
151 MsqInitializeMessageQueue(struct _ETHREAD
*Thread
, PUSER_MESSAGE_QUEUE MessageQueue
);
153 MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue
);
154 PUSER_MESSAGE_QUEUE FASTCALL
155 MsqCreateMessageQueue(struct _ETHREAD
*Thread
);
157 MsqDestroyMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue
);
158 PUSER_MESSAGE_QUEUE FASTCALL
159 MsqGetHardwareMessageQueue(VOID
);
161 MsqInitializeImpl(VOID
);
163 MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue
);
165 MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue
, HWND WndFilter
,
166 UINT MsgFilterMin
, UINT MsgFilterMax
);
168 MsqSendNotifyMessage(PUSER_MESSAGE_QUEUE MessageQueue
,
169 PUSER_SENT_MESSAGE_NOTIFY NotifyMessage
);
171 MsqIncPaintCountQueue(PUSER_MESSAGE_QUEUE Queue
);
173 MsqDecPaintCountQueue(PUSER_MESSAGE_QUEUE Queue
);
175 IntSendMessage(HWND hWnd
,
180 IntPostOrSendMessage(HWND hWnd
,
185 IntSendMessageTimeout(HWND hWnd
,
193 IntDispatchMessage(MSG
* Msg
);
195 IntTranslateKbdMessage(LPMSG lpMsg
, HKL dwhkl
);
198 MsqPostKeyboardMessage(UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
200 MsqPostHotKeyMessage(PVOID Thread
, HWND hWnd
, WPARAM wParam
, LPARAM lParam
);
202 MsqInsertSystemMessage(MSG
* Msg
);
204 MsqIsDblClk(LPMSG Msg
, BOOL Remove
);
206 MsqSetStateWindow(PUSER_MESSAGE_QUEUE MessageQueue
, ULONG Type
, HWND hWnd
);
208 inline BOOL
MsqIsSignaled( PUSER_MESSAGE_QUEUE queue
);
209 inline VOID
MsqSetQueueBits( PUSER_MESSAGE_QUEUE queue
, WORD bits
);
210 inline VOID
MsqClearQueueBits( PUSER_MESSAGE_QUEUE queue
, WORD bits
);
211 BOOL STDCALL
IntInitMessagePumpHook();
212 BOOL STDCALL
IntUninitMessagePumpHook();
213 #define MAKE_LONG(x, y) ((((y) & 0xFFFF) << 16) | ((x) & 0xFFFF))
215 PHOOKTABLE FASTCALL
MsqGetHooks(PUSER_MESSAGE_QUEUE Queue
);
216 VOID FASTCALL
MsqSetHooks(PUSER_MESSAGE_QUEUE Queue
, PHOOKTABLE Hooks
);
218 LPARAM FASTCALL
MsqSetMessageExtraInfo(LPARAM lParam
);
219 LPARAM FASTCALL
MsqGetMessageExtraInfo(VOID
);
220 VOID STDCALL
MsqRemoveWindowMessagesFromQueue(PVOID pWindow
); /* F*(&$ headers, will be gone in the rewrite! */
222 #define IntLockMessageQueue(MsgQueue) \
223 ExAcquireFastMutex(&(MsgQueue)->Lock)
225 #define IntUnLockMessageQueue(MsgQueue) \
226 ExReleaseFastMutex(&(MsgQueue)->Lock)
228 #define IntLockHardwareMessageQueue(MsgQueue) \
229 KeWaitForMutexObject(&(MsgQueue)->HardwareLock, UserRequest, KernelMode, FALSE, NULL)
231 #define IntUnLockHardwareMessageQueue(MsgQueue) \
232 KeReleaseMutex(&(MsgQueue)->HardwareLock, FALSE)
234 #define IntReferenceMessageQueue(MsgQueue) \
235 InterlockedIncrement(&(MsgQueue)->References)
237 #define IntDereferenceMessageQueue(MsgQueue) \
239 if(InterlockedDecrement(&(MsgQueue)->References) == 0) \
241 DPRINT("Free message queue 0x%x\n", (MsgQueue)); \
242 if ((MsgQueue)->NewMessagesHandle != NULL) \
243 ZwClose((MsgQueue)->NewMessagesHandle); \
244 ExFreePool((MsgQueue)); \
248 #define IS_BTN_MESSAGE(message,code) \
249 ((message) == WM_LBUTTON##code || \
250 (message) == WM_MBUTTON##code || \
251 (message) == WM_RBUTTON##code || \
252 (message) == WM_XBUTTON##code || \
253 (message) == WM_NCLBUTTON##code || \
254 (message) == WM_NCMBUTTON##code || \
255 (message) == WM_NCRBUTTON##code || \
256 (message) == WM_NCXBUTTON##code )
259 IntMsqSetWakeMask(DWORD WakeMask
);
262 IntMsqClearWakeMask(VOID
);
265 MsqSetTimer(PUSER_MESSAGE_QUEUE MessageQueue
, HWND Wnd
,
266 UINT_PTR IDEvent
, UINT Period
, TIMERPROC TimerFunc
,
269 MsqKillTimer(PUSER_MESSAGE_QUEUE MessageQueue
, HWND Wnd
,
270 UINT_PTR IDEvent
, UINT Msg
);
272 MsqGetTimerMessage(PUSER_MESSAGE_QUEUE MessageQueue
,
273 HWND WndFilter
, UINT MsgFilterMin
, UINT MsgFilterMax
,
274 MSG
*Msg
, BOOLEAN Restart
);
276 MsqGetFirstTimerExpiry(PUSER_MESSAGE_QUEUE MessageQueue
,
277 HWND WndFilter
, UINT MsgFilterMin
, UINT MsgFilterMax
,
278 PLARGE_INTEGER FirstTimerExpiry
);
280 MsqRemoveTimersWindow(PUSER_MESSAGE_QUEUE MessageQueue
, HWND Wnd
);
282 #endif /* _WIN32K_MSGQUEUE_H */