2003-11-18 20:49:39 +00:00
|
|
|
#ifndef _WIN32K_MSGQUEUE_H
|
|
|
|
#define _WIN32K_MSGQUEUE_H
|
2001-06-12 17:51:51 +00:00
|
|
|
|
2003-11-18 23:33:31 +00:00
|
|
|
#include <internal/ex.h>
|
2001-06-12 17:51:51 +00:00
|
|
|
#include <windows.h>
|
2003-12-20 15:42:47 +00:00
|
|
|
#include "caret.h"
|
2003-12-12 14:22:37 +00:00
|
|
|
#include "hook.h"
|
2001-06-12 17:51:51 +00:00
|
|
|
|
2004-03-11 14:47:44 +00:00
|
|
|
#define MSQ_HUNG 5000
|
|
|
|
|
2001-06-12 17:51:51 +00:00
|
|
|
typedef struct _USER_MESSAGE
|
|
|
|
{
|
|
|
|
LIST_ENTRY ListEntry;
|
2004-04-29 21:13:16 +00:00
|
|
|
BOOLEAN FreeLParam;
|
2001-06-12 17:51:51 +00:00
|
|
|
MSG Msg;
|
|
|
|
} USER_MESSAGE, *PUSER_MESSAGE;
|
|
|
|
|
2002-05-06 22:20:32 +00:00
|
|
|
struct _USER_MESSAGE_QUEUE;
|
|
|
|
|
|
|
|
typedef struct _USER_SENT_MESSAGE
|
|
|
|
{
|
|
|
|
LIST_ENTRY ListEntry;
|
|
|
|
MSG Msg;
|
|
|
|
PKEVENT CompletionEvent;
|
|
|
|
LRESULT* Result;
|
2004-05-19 18:45:31 +00:00
|
|
|
struct _USER_MESSAGE_QUEUE* SenderQueue;
|
2002-05-06 22:20:32 +00:00
|
|
|
SENDASYNCPROC CompletionCallback;
|
|
|
|
ULONG_PTR CompletionCallbackContext;
|
2004-05-19 18:45:31 +00:00
|
|
|
/* entry in the dispatching list of the sender's message queue */
|
|
|
|
LIST_ENTRY DispatchingListEntry;
|
2002-05-06 22:20:32 +00:00
|
|
|
} USER_SENT_MESSAGE, *PUSER_SENT_MESSAGE;
|
|
|
|
|
|
|
|
typedef struct _USER_SENT_MESSAGE_NOTIFY
|
|
|
|
{
|
|
|
|
SENDASYNCPROC CompletionCallback;
|
|
|
|
ULONG_PTR CompletionCallbackContext;
|
|
|
|
LRESULT Result;
|
|
|
|
HWND hWnd;
|
|
|
|
UINT Msg;
|
|
|
|
LIST_ENTRY ListEntry;
|
|
|
|
} USER_SENT_MESSAGE_NOTIFY, *PUSER_SENT_MESSAGE_NOTIFY;
|
|
|
|
|
2001-06-12 17:51:51 +00:00
|
|
|
typedef struct _USER_MESSAGE_QUEUE
|
|
|
|
{
|
2004-05-22 16:48:50 +00:00
|
|
|
/* Reference counter, only access this variable with interlocked functions! */
|
|
|
|
LONG References;
|
|
|
|
|
2003-11-18 23:33:31 +00:00
|
|
|
/* Owner of the message queue */
|
|
|
|
struct _ETHREAD *Thread;
|
2002-07-04 19:56:38 +00:00
|
|
|
/* Queue of messages sent to the queue. */
|
2002-01-13 22:52:08 +00:00
|
|
|
LIST_ENTRY SentMessagesListHead;
|
2002-07-04 19:56:38 +00:00
|
|
|
/* Queue of messages posted to the queue. */
|
2002-01-13 22:52:08 +00:00
|
|
|
LIST_ENTRY PostedMessagesListHead;
|
2002-07-04 19:56:38 +00:00
|
|
|
/* Queue of sent-message notifies for the queue. */
|
2002-05-06 22:20:32 +00:00
|
|
|
LIST_ENTRY NotifyMessagesListHead;
|
2002-10-31 00:03:31 +00:00
|
|
|
/* Queue for hardware messages for the queue. */
|
|
|
|
LIST_ENTRY HardwareMessagesListHead;
|
2003-12-08 20:40:41 +00:00
|
|
|
/* Lock for the hardware message list. */
|
2004-04-07 21:12:08 +00:00
|
|
|
KMUTEX HardwareLock;
|
2002-07-04 19:56:38 +00:00
|
|
|
/* Lock for the queue. */
|
2002-01-13 22:52:08 +00:00
|
|
|
FAST_MUTEX Lock;
|
2004-02-28 00:44:28 +00:00
|
|
|
/* Pointer to the current WM_MOUSEMOVE message */
|
|
|
|
PUSER_MESSAGE MouseMoveMsg;
|
2002-07-04 19:56:38 +00:00
|
|
|
/* True if a WM_QUIT message is pending. */
|
2002-01-13 22:52:08 +00:00
|
|
|
BOOLEAN QuitPosted;
|
2002-07-04 19:56:38 +00:00
|
|
|
/* The quit exit code. */
|
2002-01-13 22:52:08 +00:00
|
|
|
ULONG QuitExitCode;
|
2002-07-04 19:56:38 +00:00
|
|
|
/* Set if there are new messages in any of the queues. */
|
2002-01-13 22:52:08 +00:00
|
|
|
KEVENT NewMessages;
|
2004-03-11 14:47:44 +00:00
|
|
|
/* Last time PeekMessage() was called. */
|
|
|
|
ULONG LastMsgRead;
|
2003-07-05 16:04:01 +00:00
|
|
|
/* Current window with focus (ie. receives keyboard input) for this queue. */
|
2002-01-13 22:52:08 +00:00
|
|
|
HWND FocusWindow;
|
2002-07-04 19:56:38 +00:00
|
|
|
/* True if a window needs painting. */
|
|
|
|
BOOLEAN PaintPosted;
|
|
|
|
/* Count of paints pending. */
|
|
|
|
ULONG PaintCount;
|
2002-07-17 21:04:57 +00:00
|
|
|
/* Current active window for this queue. */
|
|
|
|
HWND ActiveWindow;
|
|
|
|
/* Current capture window for this queue. */
|
|
|
|
HWND CaptureWindow;
|
2003-11-23 12:04:54 +00:00
|
|
|
/* Current move/size window for this queue */
|
|
|
|
HWND MoveSize;
|
|
|
|
/* Current menu owner window for this queue */
|
|
|
|
HWND MenuOwner;
|
|
|
|
/* Identifes the menu state */
|
|
|
|
BYTE MenuState;
|
2003-12-20 15:42:47 +00:00
|
|
|
/* Caret information for this queue */
|
|
|
|
PTHRDCARETINFO CaretInfo;
|
|
|
|
|
2003-12-12 14:22:37 +00:00
|
|
|
/* Window hooks */
|
|
|
|
PHOOKTABLE Hooks;
|
2003-08-02 16:53:40 +00:00
|
|
|
|
|
|
|
/* queue state tracking */
|
|
|
|
WORD WakeBits;
|
|
|
|
WORD WakeMask;
|
|
|
|
WORD ChangedBits;
|
|
|
|
WORD ChangedMask;
|
2003-12-19 19:30:05 +00:00
|
|
|
|
|
|
|
/* extra message information */
|
|
|
|
LPARAM ExtraInfo;
|
2003-08-02 16:53:40 +00:00
|
|
|
|
2004-05-19 18:45:31 +00:00
|
|
|
/* messages that are currently dispatched by other threads */
|
|
|
|
LIST_ENTRY DispatchingMessagesHead;
|
2004-05-22 16:48:50 +00:00
|
|
|
/* messages that are currently dispatched by this message queue, required for cleanup */
|
|
|
|
LIST_ENTRY LocalDispatchingMessagesHead;
|
2001-06-12 17:51:51 +00:00
|
|
|
} USER_MESSAGE_QUEUE, *PUSER_MESSAGE_QUEUE;
|
|
|
|
|
2004-03-11 14:47:44 +00:00
|
|
|
BOOL FASTCALL
|
|
|
|
MsqIsHung(PUSER_MESSAGE_QUEUE MessageQueue);
|
|
|
|
NTSTATUS FASTCALL
|
2002-05-06 22:20:32 +00:00
|
|
|
MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue,
|
2004-03-11 14:47:44 +00:00
|
|
|
HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam,
|
|
|
|
UINT uTimeout, BOOL Block, ULONG_PTR *uResult);
|
2003-05-18 17:16:18 +00:00
|
|
|
PUSER_MESSAGE FASTCALL
|
2004-04-29 21:13:16 +00:00
|
|
|
MsqCreateMessage(LPMSG Msg, BOOLEAN FreeLParam);
|
2003-05-18 17:16:18 +00:00
|
|
|
VOID FASTCALL
|
2002-01-13 22:52:08 +00:00
|
|
|
MsqDestroyMessage(PUSER_MESSAGE Message);
|
2003-05-18 17:16:18 +00:00
|
|
|
VOID FASTCALL
|
2002-01-13 22:52:08 +00:00
|
|
|
MsqPostMessage(PUSER_MESSAGE_QUEUE MessageQueue,
|
2004-04-29 21:13:16 +00:00
|
|
|
MSG* Msg, BOOLEAN FreeLParam);
|
2003-05-21 22:58:43 +00:00
|
|
|
VOID FASTCALL
|
|
|
|
MsqPostQuitMessage(PUSER_MESSAGE_QUEUE MessageQueue, ULONG ExitCode);
|
2003-05-18 17:16:18 +00:00
|
|
|
BOOLEAN STDCALL
|
2002-01-13 22:52:08 +00:00
|
|
|
MsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue,
|
|
|
|
IN BOOLEAN Hardware,
|
|
|
|
IN BOOLEAN Remove,
|
|
|
|
IN HWND Wnd,
|
|
|
|
IN UINT MsgFilterLow,
|
|
|
|
IN UINT MsgFilterHigh,
|
|
|
|
OUT PUSER_MESSAGE* Message);
|
2003-05-18 17:16:18 +00:00
|
|
|
VOID FASTCALL
|
2003-11-18 23:33:31 +00:00
|
|
|
MsqInitializeMessageQueue(struct _ETHREAD *Thread, PUSER_MESSAGE_QUEUE MessageQueue);
|
2003-05-18 17:16:18 +00:00
|
|
|
VOID FASTCALL
|
2004-05-22 16:48:50 +00:00
|
|
|
MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue);
|
2003-05-18 17:16:18 +00:00
|
|
|
PUSER_MESSAGE_QUEUE FASTCALL
|
2003-11-18 23:33:31 +00:00
|
|
|
MsqCreateMessageQueue(struct _ETHREAD *Thread);
|
2003-05-18 17:16:18 +00:00
|
|
|
VOID FASTCALL
|
2002-01-13 22:52:08 +00:00
|
|
|
MsqDestroyMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue);
|
2003-05-18 17:16:18 +00:00
|
|
|
PUSER_MESSAGE_QUEUE FASTCALL
|
2002-01-13 22:52:08 +00:00
|
|
|
MsqGetHardwareMessageQueue(VOID);
|
2003-05-18 17:16:18 +00:00
|
|
|
NTSTATUS FASTCALL
|
2002-01-13 22:52:08 +00:00
|
|
|
MsqWaitForNewMessage(PUSER_MESSAGE_QUEUE MessageQueue);
|
2003-05-18 17:16:18 +00:00
|
|
|
NTSTATUS FASTCALL
|
2002-01-13 22:52:08 +00:00
|
|
|
MsqInitializeImpl(VOID);
|
2003-05-18 17:16:18 +00:00
|
|
|
BOOLEAN FASTCALL
|
2002-07-04 19:56:38 +00:00
|
|
|
MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue);
|
2003-05-18 17:16:18 +00:00
|
|
|
NTSTATUS FASTCALL
|
2002-07-04 19:56:38 +00:00
|
|
|
MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue);
|
2003-05-18 17:16:18 +00:00
|
|
|
VOID FASTCALL
|
2002-07-04 19:56:38 +00:00
|
|
|
MsqSendNotifyMessage(PUSER_MESSAGE_QUEUE MessageQueue,
|
|
|
|
PUSER_SENT_MESSAGE_NOTIFY NotifyMessage);
|
2003-05-18 17:16:18 +00:00
|
|
|
VOID FASTCALL
|
2002-08-26 23:20:54 +00:00
|
|
|
MsqIncPaintCountQueue(PUSER_MESSAGE_QUEUE Queue);
|
2003-05-18 17:16:18 +00:00
|
|
|
VOID FASTCALL
|
2002-08-26 23:20:54 +00:00
|
|
|
MsqDecPaintCountQueue(PUSER_MESSAGE_QUEUE Queue);
|
2004-04-13 13:50:31 +00:00
|
|
|
LRESULT FASTCALL
|
2003-08-19 11:48:50 +00:00
|
|
|
IntSendMessage(HWND hWnd,
|
2002-07-17 21:04:57 +00:00
|
|
|
UINT Msg,
|
|
|
|
WPARAM wParam,
|
2003-12-26 22:52:12 +00:00
|
|
|
LPARAM lParam);
|
2004-04-13 13:50:31 +00:00
|
|
|
LRESULT FASTCALL
|
|
|
|
IntPostOrSendMessage(HWND hWnd,
|
|
|
|
UINT Msg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam);
|
|
|
|
LRESULT FASTCALL
|
2004-03-11 14:47:44 +00:00
|
|
|
IntSendMessageTimeout(HWND hWnd,
|
|
|
|
UINT Msg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam,
|
|
|
|
UINT uFlags,
|
|
|
|
UINT uTimeout,
|
|
|
|
ULONG_PTR *uResult);
|
2003-12-28 13:53:14 +00:00
|
|
|
LRESULT FASTCALL
|
|
|
|
IntDispatchMessage(MSG* Msg);
|
2003-12-28 14:21:03 +00:00
|
|
|
BOOL FASTCALL
|
|
|
|
IntTranslateKbdMessage(LPMSG lpMsg, HKL dwhkl);
|
2003-12-28 13:53:14 +00:00
|
|
|
|
2004-04-13 13:50:31 +00:00
|
|
|
VOID FASTCALL
|
2002-10-31 00:03:31 +00:00
|
|
|
MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
2004-04-13 13:50:31 +00:00
|
|
|
VOID FASTCALL
|
2003-11-03 18:52:21 +00:00
|
|
|
MsqPostHotKeyMessage(PVOID Thread, HWND hWnd, WPARAM wParam, LPARAM lParam);
|
2003-05-18 17:16:18 +00:00
|
|
|
VOID FASTCALL
|
2004-04-16 18:53:53 +00:00
|
|
|
MsqInsertSystemMessage(MSG* Msg);
|
2004-04-15 23:36:03 +00:00
|
|
|
BOOL FASTCALL
|
|
|
|
MsqIsDblClk(LPMSG Msg, BOOL Remove);
|
|
|
|
HWND FASTCALL
|
|
|
|
MsqSetStateWindow(PUSER_MESSAGE_QUEUE MessageQueue, ULONG Type, HWND hWnd);
|
2001-06-12 17:51:51 +00:00
|
|
|
|
2003-08-02 16:53:40 +00:00
|
|
|
inline BOOL MsqIsSignaled( PUSER_MESSAGE_QUEUE queue );
|
|
|
|
inline VOID MsqSetQueueBits( PUSER_MESSAGE_QUEUE queue, WORD bits );
|
|
|
|
inline VOID MsqClearQueueBits( PUSER_MESSAGE_QUEUE queue, WORD bits );
|
2003-11-19 13:19:40 +00:00
|
|
|
BOOL IntInitMessagePumpHook();
|
|
|
|
BOOL IntUninitMessagePumpHook();
|
2002-05-06 22:20:32 +00:00
|
|
|
#define MAKE_LONG(x, y) ((((y) & 0xFFFF) << 16) | ((x) & 0xFFFF))
|
|
|
|
|
2003-12-12 14:22:37 +00:00
|
|
|
PHOOKTABLE FASTCALL MsqGetHooks(PUSER_MESSAGE_QUEUE Queue);
|
|
|
|
VOID FASTCALL MsqSetHooks(PUSER_MESSAGE_QUEUE Queue, PHOOKTABLE Hooks);
|
|
|
|
|
2003-12-19 19:30:05 +00:00
|
|
|
LPARAM FASTCALL MsqSetMessageExtraInfo(LPARAM lParam);
|
|
|
|
LPARAM FASTCALL MsqGetMessageExtraInfo(VOID);
|
|
|
|
|
2004-02-24 13:27:03 +00:00
|
|
|
#define IntLockMessageQueue(MsgQueue) \
|
2004-05-22 16:48:50 +00:00
|
|
|
ExAcquireFastMutex(&(MsgQueue)->Lock)
|
2004-02-24 13:27:03 +00:00
|
|
|
|
|
|
|
#define IntUnLockMessageQueue(MsgQueue) \
|
2004-05-22 16:48:50 +00:00
|
|
|
ExReleaseFastMutex(&(MsgQueue)->Lock)
|
2004-02-24 13:27:03 +00:00
|
|
|
|
|
|
|
#define IntLockHardwareMessageQueue(MsgQueue) \
|
2004-05-22 16:48:50 +00:00
|
|
|
KeWaitForMutexObject(&(MsgQueue)->HardwareLock, UserRequest, KernelMode, FALSE, NULL)
|
2004-02-24 13:27:03 +00:00
|
|
|
|
|
|
|
#define IntUnLockHardwareMessageQueue(MsgQueue) \
|
2004-05-22 16:48:50 +00:00
|
|
|
KeReleaseMutex(&(MsgQueue)->HardwareLock, FALSE)
|
|
|
|
|
|
|
|
#define IntReferenceMessageQueue(MsgQueue) \
|
|
|
|
InterlockedIncrement(&(MsgQueue)->References)
|
|
|
|
|
|
|
|
#define IntDereferenceMessageQueue(MsgQueue) \
|
|
|
|
do { \
|
|
|
|
if(InterlockedDecrement(&(MsgQueue)->References) == 0) \
|
|
|
|
{ \
|
|
|
|
DPRINT("Free message queue 0x%x\n", (MsgQueue)); \
|
|
|
|
ExFreePool((MsgQueue)); \
|
|
|
|
} \
|
|
|
|
} while(0)
|
2004-02-24 13:27:03 +00:00
|
|
|
|
|
|
|
/* check the queue status */
|
|
|
|
#define MsqIsSignaled(MsgQueue) \
|
2004-05-22 16:48:50 +00:00
|
|
|
(((MsgQueue)->WakeBits & (MsgQueue)->WakeMask) || ((MsgQueue)->ChangedBits & (MsgQueue)->ChangedMask))
|
2004-02-24 13:27:03 +00:00
|
|
|
|
2004-04-15 23:36:03 +00:00
|
|
|
#define IS_BTN_MESSAGE(message,code) \
|
|
|
|
((message) == WM_LBUTTON##code || \
|
|
|
|
(message) == WM_MBUTTON##code || \
|
|
|
|
(message) == WM_RBUTTON##code || \
|
|
|
|
(message) == WM_XBUTTON##code )
|
|
|
|
|
2003-11-18 20:49:39 +00:00
|
|
|
#endif /* _WIN32K_MSGQUEUE_H */
|
2001-06-12 17:51:51 +00:00
|
|
|
|
|
|
|
/* EOF */
|