7 #define MSQ_INJECTMODULE 3
11 typedef enum _QS_ROS_TYPES
19 }QS_ROS_TYPES
,*PQS_ROS_TYPES
;
21 typedef struct _USER_MESSAGE
29 } USER_MESSAGE
, *PUSER_MESSAGE
;
31 struct _USER_MESSAGE_QUEUE
;
33 typedef struct _USER_SENT_MESSAGE
37 DWORD QS_Flags
; // Original QS bits used to create this message.
38 PKEVENT CompletionEvent
;
41 struct _USER_MESSAGE_QUEUE
* SenderQueue
;
42 struct _USER_MESSAGE_QUEUE
* CallBackSenderQueue
;
43 SENDASYNCPROC CompletionCallback
;
44 ULONG_PTR CompletionCallbackContext
;
45 /* entry in the dispatching list of the sender's message queue */
46 LIST_ENTRY DispatchingListEntry
;
49 } USER_SENT_MESSAGE
, *PUSER_SENT_MESSAGE
;
51 typedef struct _USER_MESSAGE_QUEUE
53 /* Reference counter, only access this variable with interlocked functions! */
56 PTHREADINFO ptiSysLock
;
57 /* Owner of the message queue */
58 struct _ETHREAD
*Thread
;
59 /* Queue of messages sent to the queue. */
60 LIST_ENTRY SentMessagesListHead
;
61 /* Queue of messages posted to the queue. */
62 LIST_ENTRY PostedMessagesListHead
;
63 /* Queue for hardware messages for the queue. */
64 LIST_ENTRY HardwareMessagesListHead
;
65 /* True if a WM_MOUSEMOVE is pending */
67 /* Current WM_MOUSEMOVE message */
69 /* Last click message for translating double clicks */
71 /* True if a WM_QUIT message is pending. */
73 /* The quit exit code. */
75 /* Set if there are new messages specified by WakeMask in any of the queues. */
77 /* Handle for the above event (in the context of the process owning the queue). */
78 HANDLE NewMessagesHandle
;
79 /* Last time PeekMessage() was called. */
81 /* Current capture window for this queue. */
83 /* Current window with focus (ie. receives keyboard input) for this queue. */
85 /* Current active window for this queue. */
88 /* Current move/size window for this queue */
90 /* Current menu owner window for this queue */
92 /* Identifes the menu state */
94 /* Caret information for this queue */
95 PTHRDCARETINFO CaretInfo
;
96 /* Message Queue Flags */
98 DWORD cThreads
; // Shared message queue counter.
100 /* Queue state tracking */
101 // Send list QS_SENDMESSAGE
102 // Post list QS_POSTMESSAGE|QS_HOTKEY|QS_PAINT|QS_TIMER|QS_KEY
103 // Hard list QS_MOUSE|QS_KEY only
104 // Accounting of queue bit sets, the rest are flags. QS_TIMER QS_PAINT counts are handled in thread information.
105 DWORD nCntsQBits
[QSIDCOUNTS
]; // QS_KEY QS_MOUSEMOVE QS_MOUSEBUTTON QS_POSTMESSAGE QS_SENDMESSAGE QS_HOTKEY
107 /* Extra message information */
110 /* State of each key */
111 BYTE afKeyRecentDown
[256 / 8]; // 1 bit per key
112 BYTE afKeyState
[256 * 2 / 8]; // 2 bits per key
114 /* Showing cursor counter (value>=0 - cursor visible, value<0 - cursor hidden) */
117 PCURICON_OBJECT CursorObject
;
119 /* Messages that are currently dispatched by other threads */
120 LIST_ENTRY DispatchingMessagesHead
;
121 /* Messages that are currently dispatched by this message queue, required for cleanup */
122 LIST_ENTRY LocalDispatchingMessagesHead
;
124 /* Desktop that the message queue is attached to */
125 struct _DESKTOP
*Desktop
;
126 } USER_MESSAGE_QUEUE
, *PUSER_MESSAGE_QUEUE
;
128 #define QF_UPDATEKEYSTATE 0x00000001
129 #define QF_FMENUSTATUSBREAK 0x00000004
130 #define QF_FMENUSTATUS 0x00000008
131 #define QF_FF10STATUS 0x00000010
132 #define QF_MOUSEMOVED 0x00000020 // See MouseMoved.
133 #define QF_ACTIVATIONCHANGE 0x00000040
134 #define QF_TABSWITCHING 0x00000080
135 #define QF_KEYSTATERESET 0x00000100
136 #define QF_INDESTROY 0x00000200
137 #define QF_LOCKNOREMOVE 0x00000400
138 #define QF_FOCUSNULLSINCEACTIVE 0x00000800
139 #define QF_DIALOGACTIVE 0x00004000
140 #define QF_EVENTDEACTIVATEREMOVED 0x00008000
141 #define QF_TRACKMOUSELEAVE 0x00020000
142 #define QF_TRACKMOUSEHOVER 0x00040000
143 #define QF_TRACKMOUSEFIRING 0x00080000
144 #define QF_CAPTURELOCKED 0x00100000
145 #define QF_ACTIVEWNDTRACKING 0x00200000
147 /* Internal messages codes */
148 enum internal_event_message
150 WM_ASYNC_SHOWWINDOW
= 0x80000000,
151 WM_ASYNC_SETWINDOWPOS
,
152 WM_ASYNC_SETACTIVEWINDOW
155 BOOL FASTCALL
MsqIsHung(PUSER_MESSAGE_QUEUE MessageQueue
);
156 VOID CALLBACK
HungAppSysTimerProc(HWND
,UINT
,UINT_PTR
,DWORD
);
157 NTSTATUS FASTCALL
co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue
,
158 HWND Wnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
,
159 UINT uTimeout
, BOOL Block
, INT HookMessage
, ULONG_PTR
*uResult
);
160 PUSER_MESSAGE FASTCALL
MsqCreateMessage(LPMSG Msg
);
161 VOID FASTCALL
MsqDestroyMessage(PUSER_MESSAGE Message
);
162 VOID FASTCALL
MsqPostMessage(PUSER_MESSAGE_QUEUE
, MSG
*, BOOLEAN
, DWORD
, DWORD
);
163 VOID FASTCALL
MsqPostQuitMessage(PUSER_MESSAGE_QUEUE MessageQueue
, ULONG ExitCode
);
165 MsqPeekMessage(IN PUSER_MESSAGE_QUEUE MessageQueue
,
168 IN UINT MsgFilterLow
,
169 IN UINT MsgFilterHigh
,
173 co_MsqPeekHardwareMessage(IN PUSER_MESSAGE_QUEUE MessageQueue
,
176 IN UINT MsgFilterLow
,
177 IN UINT MsgFilterHigh
,
181 co_MsqPeekMouseMove(IN PUSER_MESSAGE_QUEUE MessageQueue
,
184 IN UINT MsgFilterLow
,
185 IN UINT MsgFilterHigh
,
187 BOOLEAN FASTCALL
MsqInitializeMessageQueue(PTHREADINFO
, PUSER_MESSAGE_QUEUE
);
188 PUSER_MESSAGE_QUEUE FASTCALL
MsqCreateMessageQueue(PTHREADINFO
);
189 VOID FASTCALL
MsqDestroyMessageQueue(PTHREADINFO
);
190 INIT_FUNCTION NTSTATUS NTAPI
MsqInitializeImpl(VOID
);
191 BOOLEAN FASTCALL
co_MsqDispatchOneSentMessage(_In_ PUSER_MESSAGE_QUEUE MessageQueue
);
193 co_MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue
, PWND WndFilter
,
194 UINT MsgFilterMin
, UINT MsgFilterMax
);
195 VOID FASTCALL
MsqIncPaintCountQueue(PUSER_MESSAGE_QUEUE Queue
);
196 VOID FASTCALL
MsqDecPaintCountQueue(PUSER_MESSAGE_QUEUE Queue
);
197 LRESULT FASTCALL
co_IntSendMessage(HWND hWnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
);
198 LRESULT FASTCALL
co_IntPostOrSendMessage(HWND hWnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
);
200 co_IntSendMessageTimeout(HWND hWnd
,
208 BOOL FASTCALL
UserSendNotifyMessage( HWND hWnd
,UINT Msg
,WPARAM wParam
,LPARAM lParam
);
209 LRESULT FASTCALL
co_IntSendMessageNoWait(HWND hWnd
,
214 co_IntSendMessageWithCallBack(HWND hWnd
,
218 SENDASYNCPROC CompletionCallback
,
219 ULONG_PTR CompletionCallbackContext
,
222 co_MsqSendMessageAsync(PTHREADINFO ptiReceiver
,
227 SENDASYNCPROC CompletionCallback
,
228 ULONG_PTR CompletionCallbackContext
,
229 BOOL HasPackedLParam
,
232 LRESULT FASTCALL
IntDispatchMessage(MSG
* Msg
);
233 BOOL FASTCALL
IntTranslateKbdMessage(LPMSG lpMsg
, UINT flags
);
234 VOID FASTCALL
MsqPostHotKeyMessage(PVOID Thread
, HWND hWnd
, WPARAM wParam
, LPARAM lParam
);
235 VOID FASTCALL
co_MsqInsertMouseMessage(MSG
* Msg
, DWORD flags
, ULONG_PTR dwExtraInfo
, BOOL Hook
);
236 BOOL FASTCALL
MsqIsClkLck(LPMSG Msg
, BOOL Remove
);
237 BOOL FASTCALL
MsqIsDblClk(LPMSG Msg
, BOOL Remove
);
238 HWND FASTCALL
MsqSetStateWindow(PUSER_MESSAGE_QUEUE MessageQueue
, ULONG Type
, HWND hWnd
);
239 BOOL APIENTRY
IntInitMessagePumpHook(VOID
);
240 BOOL APIENTRY
IntUninitMessagePumpHook(VOID
);
242 LPARAM FASTCALL
MsqSetMessageExtraInfo(LPARAM lParam
);
243 LPARAM FASTCALL
MsqGetMessageExtraInfo(VOID
);
244 VOID APIENTRY
MsqRemoveWindowMessagesFromQueue(PVOID pWindow
); /* F*(&$ headers, will be gone in the rewrite! */
246 #define IntReferenceMessageQueue(MsgQueue) \
247 InterlockedIncrement(&(MsgQueue)->References)
249 #define IntDereferenceMessageQueue(MsgQueue) \
251 if(InterlockedDecrement(&(MsgQueue)->References) == 0) \
253 TRACE("Free message queue 0x%p\n", (MsgQueue)); \
254 if ((MsgQueue)->NewMessages != NULL) \
255 ObDereferenceObject((MsgQueue)->NewMessages); \
256 ExFreePoolWithTag((MsgQueue), USERTAG_Q); \
260 #define IS_BTN_MESSAGE(message,code) \
261 ((message) == WM_LBUTTON##code || \
262 (message) == WM_MBUTTON##code || \
263 (message) == WM_RBUTTON##code || \
264 (message) == WM_XBUTTON##code || \
265 (message) == WM_NCLBUTTON##code || \
266 (message) == WM_NCMBUTTON##code || \
267 (message) == WM_NCRBUTTON##code || \
268 (message) == WM_NCXBUTTON##code )
270 #define WM_NCMOUSEFIRST WM_NCMOUSEMOVE
271 #define WM_NCMOUSELAST (WM_NCMOUSEFIRST+(WM_MOUSELAST-WM_MOUSEFIRST))
273 #define IS_MOUSE_MESSAGE(message) \
274 ((message >= WM_NCMOUSEFIRST && message <= WM_NCMOUSELAST) || \
275 (message >= WM_MOUSEFIRST && message <= WM_MOUSELAST))
277 #define IS_KBD_MESSAGE(message) \
278 (message >= WM_KEYFIRST && message <= WM_KEYLAST)
280 HANDLE FASTCALL
IntMsqSetWakeMask(DWORD WakeMask
);
281 BOOL FASTCALL
IntMsqClearWakeMask(VOID
);
284 MsqCalculateMessageTime(IN PLARGE_INTEGER TickCount
)
286 return (LONG
)(TickCount
->QuadPart
* (KeQueryTimeIncrement() / 10000));
289 VOID FASTCALL
IdlePing(VOID
);
290 VOID FASTCALL
IdlePong(VOID
);
291 BOOL FASTCALL
co_MsqReplyMessage(LRESULT
);
292 VOID FASTCALL
MsqWakeQueue(PUSER_MESSAGE_QUEUE
,DWORD
,BOOL
);
293 VOID FASTCALL
ClearMsgBitsMask(PUSER_MESSAGE_QUEUE
,UINT
);
295 int UserShowCursor(BOOL bShow
);
298 UserSetCursor(PCURICON_OBJECT NewCursor
,
301 DWORD APIENTRY
IntGetQueueStatus(DWORD
);
303 UINT
lParamMemorySize(UINT Msg
, WPARAM wParam
, LPARAM lParam
);
306 co_IntGetPeekMessage( PMSG pMsg
,