1 #ifndef _WIN32K_MSGQUEUE_H
2 #define _WIN32K_MSGQUEUE_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 /* Pointer to the current WM_MOUSEMOVE message */
74 PUSER_MESSAGE MouseMoveMsg
;
75 /* True if a WM_QUIT message is pending. */
77 /* The quit exit code. */
79 /* Set if there are new messages specified by WakeMask in any of the queues. */
81 /* Handle for the above event (in the context of the process owning the queue). */
82 HANDLE NewMessagesHandle
;
83 /* Last time PeekMessage() was called. */
85 /* Current window with focus (ie. receives keyboard input) for this queue. */
87 /* Count of paints pending. */
89 /* Current active window for this queue. */
91 /* Current capture window for this queue. */
93 /* Current move/size window for this queue */
95 /* Current menu owner window for this queue */
97 /* Identifes the menu state */
99 /* Caret information for this queue */
100 PTHRDCARETINFO CaretInfo
;
105 /* queue state tracking */
110 /* extra message information */
113 /* messages that are currently dispatched by other threads */
114 LIST_ENTRY DispatchingMessagesHead
;
115 /* messages that are currently dispatched by this message queue, required for cleanup */
116 LIST_ENTRY LocalDispatchingMessagesHead
;
118 /* Desktop that the message queue is attached to */
119 struct _DESKTOP
*Desktop
;
120 } USER_MESSAGE_QUEUE
, *PUSER_MESSAGE_QUEUE
;
123 MsqIsHung(PUSER_MESSAGE_QUEUE MessageQueue
);
125 co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue
,
126 HWND Wnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
,
127 UINT uTimeout
, BOOL Block
, INT HookMessage
,
129 PUSER_MESSAGE FASTCALL
130 MsqCreateMessage(LPMSG Msg
, BOOLEAN FreeLParam
);
132 MsqDestroyMessage(PUSER_MESSAGE Message
);
134 MsqPostMessage(PUSER_MESSAGE_QUEUE MessageQueue
,
135 MSG
* Msg
, BOOLEAN FreeLParam
, DWORD MessageBits
);
137 MsqPostQuitMessage(PUSER_MESSAGE_QUEUE MessageQueue
, ULONG ExitCode
);
139 co_MsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue
,
142 IN PWINDOW_OBJECT Window
,
143 IN UINT MsgFilterLow
,
144 IN UINT MsgFilterHigh
,
145 OUT PUSER_MESSAGE
* Message
);
147 MsqInitializeMessageQueue(struct _ETHREAD
*Thread
, PUSER_MESSAGE_QUEUE MessageQueue
);
149 MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue
);
150 PUSER_MESSAGE_QUEUE FASTCALL
151 MsqCreateMessageQueue(struct _ETHREAD
*Thread
);
153 MsqDestroyMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue
);
154 PUSER_MESSAGE_QUEUE FASTCALL
155 MsqGetHardwareMessageQueue(VOID
);
157 MsqInitializeImpl(VOID
);
159 co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue
);
161 co_MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue
, PWINDOW_OBJECT WndFilter
,
162 UINT MsgFilterMin
, UINT MsgFilterMax
);
164 MsqSendNotifyMessage(PUSER_MESSAGE_QUEUE MessageQueue
,
165 PUSER_SENT_MESSAGE_NOTIFY NotifyMessage
);
167 MsqIncPaintCountQueue(PUSER_MESSAGE_QUEUE Queue
);
169 MsqDecPaintCountQueue(PUSER_MESSAGE_QUEUE Queue
);
171 co_IntSendMessage(HWND hWnd
,
176 co_IntPostOrSendMessage(HWND hWnd
,
181 co_IntSendMessageTimeout(HWND hWnd
,
189 IntDispatchMessage(MSG
* Msg
);
191 IntTranslateKbdMessage(LPMSG lpMsg
, UINT flags
);
194 co_MsqPostKeyboardMessage(UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
196 MsqPostHotKeyMessage(PVOID Thread
, HWND hWnd
, WPARAM wParam
, LPARAM lParam
);
198 MsqInsertSystemMessage(MSG
* Msg
);
200 MsqIsClkLck(LPMSG Msg
, BOOL Remove
);
202 MsqIsDblClk(LPMSG Msg
, BOOL Remove
);
204 MsqSetStateWindow(PUSER_MESSAGE_QUEUE MessageQueue
, ULONG Type
, HWND hWnd
);
206 __inline BOOL
MsqIsSignaled( PUSER_MESSAGE_QUEUE queue
);
207 __inline VOID
MsqSetQueueBits( PUSER_MESSAGE_QUEUE queue
, WORD bits
);
208 __inline VOID
MsqClearQueueBits( PUSER_MESSAGE_QUEUE queue
, WORD bits
);
209 BOOL APIENTRY
IntInitMessagePumpHook();
210 BOOL APIENTRY
IntUninitMessagePumpHook();
211 #define MAKE_LONG(x, y) ((((y) & 0xFFFF) << 16) | ((x) & 0xFFFF))
213 PHOOKTABLE FASTCALL
MsqGetHooks(PUSER_MESSAGE_QUEUE Queue
);
214 VOID FASTCALL
MsqSetHooks(PUSER_MESSAGE_QUEUE Queue
, PHOOKTABLE Hooks
);
216 LPARAM FASTCALL
MsqSetMessageExtraInfo(LPARAM lParam
);
217 LPARAM FASTCALL
MsqGetMessageExtraInfo(VOID
);
218 VOID APIENTRY
MsqRemoveWindowMessagesFromQueue(PVOID pWindow
); /* F*(&$ headers, will be gone in the rewrite! */
220 #define IntLockHardwareMessageQueue(MsgQueue) \
221 KeWaitForMutexObject(&(MsgQueue)->HardwareLock, UserRequest, KernelMode, FALSE, NULL)
223 #define IntUnLockHardwareMessageQueue(MsgQueue) \
224 KeReleaseMutex(&(MsgQueue)->HardwareLock, FALSE)
226 #define IntReferenceMessageQueue(MsgQueue) \
227 InterlockedIncrement(&(MsgQueue)->References)
229 #define IntDereferenceMessageQueue(MsgQueue) \
231 if(InterlockedDecrement(&(MsgQueue)->References) == 0) \
233 DPRINT("Free message queue 0x%x\n", (MsgQueue)); \
234 if ((MsgQueue)->NewMessages != NULL) \
235 ObDereferenceObject((MsgQueue)->NewMessages); \
236 if ((MsgQueue)->NewMessagesHandle != NULL) \
237 ZwClose((MsgQueue)->NewMessagesHandle); \
238 ExFreePool((MsgQueue)); \
242 #define IS_BTN_MESSAGE(message,code) \
243 ((message) == WM_LBUTTON##code || \
244 (message) == WM_MBUTTON##code || \
245 (message) == WM_RBUTTON##code || \
246 (message) == WM_XBUTTON##code || \
247 (message) == WM_NCLBUTTON##code || \
248 (message) == WM_NCMBUTTON##code || \
249 (message) == WM_NCRBUTTON##code || \
250 (message) == WM_NCXBUTTON##code )
253 IntMsqSetWakeMask(DWORD WakeMask
);
256 IntMsqClearWakeMask(VOID
);
259 MsqSetTimer(PUSER_MESSAGE_QUEUE MessageQueue
, HWND Wnd
,
260 UINT_PTR IDEvent
, UINT Period
, TIMERPROC TimerFunc
,
263 MsqKillTimer(PUSER_MESSAGE_QUEUE MessageQueue
, HWND Wnd
,
264 UINT_PTR IDEvent
, UINT Msg
);
266 MsqGetTimerMessage(PUSER_MESSAGE_QUEUE MessageQueue
,
267 PWINDOW_OBJECT WindowFilter
, UINT MsgFilterMin
, UINT MsgFilterMax
,
268 MSG
*Msg
, BOOLEAN Restart
);
270 MsqGetFirstTimerExpiry(PUSER_MESSAGE_QUEUE MessageQueue
,
271 PWINDOW_OBJECT WndFilter
, UINT MsgFilterMin
, UINT MsgFilterMax
,
272 PLARGE_INTEGER FirstTimerExpiry
);
274 MsqRemoveTimersWindow(PUSER_MESSAGE_QUEUE MessageQueue
, HWND Wnd
);
277 MsqCalculateMessageTime(IN PLARGE_INTEGER TickCount
)
279 return (LONG
)(TickCount
->QuadPart
* (KeQueryTimeIncrement() / 10000));
282 #endif /* _WIN32K_MSGQUEUE_H */