ReactOS  0.4.14-dev-833-g5f692ed
msgqueue.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _USER_MESSAGE
 
struct  _USER_SENT_MESSAGE
 
struct  _USER_MESSAGE_QUEUE
 

Macros

#define MSQ_HUNG   5000
 
#define MSQ_NORMAL   0
 
#define MSQ_ISHOOK   1
 
#define MSQ_INJECTMODULE   2
 
#define SMF_RECEIVERDIED   0x00000002
 
#define SMF_SENDERDIED   0x00000004
 
#define SMF_RECEIVERFREE   0x00000008
 
#define SMF_RECEIVEDMESSAGE   0x00000010
 
#define SMF_RECEIVERBUSY   0x00004000
 
#define QF_UPDATEKEYSTATE   0x00000001
 
#define QF_FMENUSTATUSBREAK   0x00000004
 
#define QF_FMENUSTATUS   0x00000008
 
#define QF_FF10STATUS   0x00000010
 
#define QF_MOUSEMOVED   0x00000020
 
#define QF_ACTIVATIONCHANGE   0x00000040
 
#define QF_TABSWITCHING   0x00000080
 
#define QF_KEYSTATERESET   0x00000100
 
#define QF_INDESTROY   0x00000200
 
#define QF_LOCKNOREMOVE   0x00000400
 
#define QF_FOCUSNULLSINCEACTIVE   0x00000800
 
#define QF_DIALOGACTIVE   0x00004000
 
#define QF_EVENTDEACTIVATEREMOVED   0x00008000
 
#define QF_TRACKMOUSELEAVE   0x00020000
 
#define QF_TRACKMOUSEHOVER   0x00040000
 
#define QF_TRACKMOUSEFIRING   0x00080000
 
#define QF_CAPTURELOCKED   0x00100000
 
#define QF_ACTIVEWNDTRACKING   0x00200000
 
#define POSTEVENT_DAW   4
 
#define POSTEVENT_SAW   5
 
#define POSTEVENT_NWE   14
 
#define POSTEVENT_NONE   0xFFFF
 
#define IntReferenceMessageQueue(MsgQueue)   InterlockedIncrement(&(MsgQueue)->References)
 
#define IntDereferenceMessageQueue(MsgQueue)
 
#define IS_BTN_MESSAGE(message, code)
 
#define WM_NCMOUSEFIRST   WM_NCMOUSEMOVE
 
#define WM_NCMOUSELAST   (WM_NCMOUSEFIRST+(WM_MOUSELAST-WM_MOUSEFIRST))
 
#define IS_MOUSE_MESSAGE(message)
 
#define IS_KBD_MESSAGE(message)   (message >= WM_KEYFIRST && message <= WM_KEYLAST)
 

Typedefs

typedef struct _USER_MESSAGE USER_MESSAGE
 
typedef struct _USER_MESSAGEPUSER_MESSAGE
 
typedef struct _USER_SENT_MESSAGE USER_SENT_MESSAGE
 
typedef struct _USER_SENT_MESSAGEPUSER_SENT_MESSAGE
 
typedef struct _USER_MESSAGE_QUEUE USER_MESSAGE_QUEUE
 
typedef struct _USER_MESSAGE_QUEUEPUSER_MESSAGE_QUEUE
 

Enumerations

enum  internal_event_message { WM_ASYNC_SHOWWINDOW = 0x80000000, WM_ASYNC_SETWINDOWPOS, WM_ASYNC_SETACTIVEWINDOW, WM_ASYNC_DESTROYWINDOW }
 

Functions

BOOL FASTCALL MsqIsHung (PTHREADINFO pti, DWORD TimeOut)
 
VOID CALLBACK HungAppSysTimerProc (HWND, UINT, UINT_PTR, DWORD)
 
NTSTATUS FASTCALL co_MsqSendMessage (PTHREADINFO ptirec, HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uTimeout, BOOL Block, INT HookMessage, ULONG_PTR *uResult)
 
PUSER_MESSAGE FASTCALL MsqCreateMessage (LPMSG Msg)
 
VOID FASTCALL MsqDestroyMessage (PUSER_MESSAGE Message)
 
VOID FASTCALL MsqPostMessage (PTHREADINFO, MSG *, BOOLEAN, DWORD, DWORD, LONG_PTR)
 
VOID FASTCALL MsqPostQuitMessage (PTHREADINFO pti, ULONG ExitCode)
 
BOOLEAN APIENTRY MsqPeekMessage (IN PTHREADINFO pti, IN BOOLEAN Remove, IN PWND Window, IN UINT MsgFilterLow, IN UINT MsgFilterHigh, IN UINT QSflags, OUT LONG_PTR *ExtraInfo, OUT DWORD *dwQEvent, OUT PMSG Message)
 
BOOL APIENTRY co_MsqPeekHardwareMessage (IN PTHREADINFO pti, IN BOOL Remove, IN PWND Window, IN UINT MsgFilterLow, IN UINT MsgFilterHigh, IN UINT QSflags, OUT MSG *pMsg)
 
BOOLEAN FASTCALL MsqInitializeMessageQueue (PTHREADINFO, PUSER_MESSAGE_QUEUE)
 
PUSER_MESSAGE_QUEUE FASTCALL MsqCreateMessageQueue (PTHREADINFO)
 
VOID FASTCALL MsqCleanupThreadMsgs (PTHREADINFO)
 
VOID FASTCALL MsqDestroyMessageQueue (_In_ PTHREADINFO pti)
 
INIT_FUNCTION NTSTATUS NTAPI MsqInitializeImpl (VOID)
 
BOOLEAN FASTCALL co_MsqDispatchOneSentMessage (_In_ PTHREADINFO pti)
 
NTSTATUS FASTCALL co_MsqWaitForNewMessages (PTHREADINFO pti, PWND WndFilter, UINT MsgFilterMin, UINT MsgFilterMax)
 
VOID FASTCALL MsqIncPaintCountQueue (PTHREADINFO)
 
VOID FASTCALL MsqDecPaintCountQueue (PTHREADINFO)
 
LRESULT FASTCALL co_IntSendMessage (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
LRESULT FASTCALL co_IntPostOrSendMessage (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
LRESULT FASTCALL co_IntSendMessageTimeout (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult)
 
BOOL FASTCALL UserSendNotifyMessage (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
LRESULT FASTCALL co_IntSendMessageNoWait (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
LRESULT FASTCALL co_IntSendMessageWithCallBack (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, SENDASYNCPROC CompletionCallback, ULONG_PTR CompletionCallbackContext, ULONG_PTR *uResult)
 
BOOL FASTCALL co_MsqSendMessageAsync (PTHREADINFO ptiReceiver, HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam, SENDASYNCPROC CompletionCallback, ULONG_PTR CompletionCallbackContext, BOOL HasPackedLParam, INT HookMessage)
 
VOID FASTCALL IntCoalesceMouseMove (PTHREADINFO)
 
LRESULT FASTCALL IntDispatchMessage (MSG *Msg)
 
BOOL FASTCALL IntTranslateKbdMessage (LPMSG lpMsg, UINT flags)
 
VOID FASTCALL co_MsqInsertMouseMessage (MSG *Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
 
BOOL FASTCALL MsqIsClkLck (LPMSG Msg, BOOL Remove)
 
BOOL FASTCALL MsqIsDblClk (LPMSG Msg, BOOL Remove)
 
HWND FASTCALL MsqSetStateWindow (PTHREADINFO pti, ULONG Type, HWND hWnd)
 
BOOL APIENTRY IntInitMessagePumpHook (VOID)
 
BOOL APIENTRY IntUninitMessagePumpHook (VOID)
 
LPARAM FASTCALL MsqSetMessageExtraInfo (LPARAM lParam)
 
LPARAM FASTCALL MsqGetMessageExtraInfo (VOID)
 
VOID APIENTRY MsqRemoveWindowMessagesFromQueue (PWND pWindow)
 
HANDLE FASTCALL IntMsqSetWakeMask (DWORD WakeMask)
 
BOOL FASTCALL IntMsqClearWakeMask (VOID)
 
VOID FASTCALL IdlePing (VOID)
 
VOID FASTCALL IdlePong (VOID)
 
BOOL FASTCALL co_MsqReplyMessage (LRESULT)
 
VOID FASTCALL MsqWakeQueue (PTHREADINFO, DWORD, BOOL)
 
VOID FASTCALL ClearMsgBitsMask (PTHREADINFO, UINT)
 
BOOL FASTCALL IntCallMsgFilter (LPMSG, INT)
 
WPARAM FASTCALL MsqGetDownKeyState (PUSER_MESSAGE_QUEUE)
 
BOOL FASTCALL IsThreadSuspended (PTHREADINFO)
 
PUSER_SENT_MESSAGE FASTCALL AllocateUserMessage (BOOL)
 
VOID FASTCALL FreeUserMessage (PUSER_SENT_MESSAGE)
 
int UserShowCursor (BOOL bShow)
 
PCURICON_OBJECT FASTCALL UserSetCursor (PCURICON_OBJECT NewCursor, BOOL ForceChange)
 
DWORD APIENTRY IntGetQueueStatus (DWORD)
 
UINT lParamMemorySize (UINT Msg, WPARAM wParam, LPARAM lParam)
 
BOOL APIENTRY co_IntGetPeekMessage (PMSG pMsg, HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg, BOOL bGMSG)
 
BOOL FASTCALL UserPostThreadMessage (PTHREADINFO pti, UINT Msg, WPARAM wParam, LPARAM lParam)
 
BOOL FASTCALL co_IntWaitMessage (PWND Window, UINT MsgFilterMin, UINT MsgFilterMax)
 

Variables

LIST_ENTRY usmList
 

Macro Definition Documentation

◆ IntDereferenceMessageQueue

#define IntDereferenceMessageQueue (   MsgQueue)
Value:
do { \
if(InterlockedDecrement(&(MsgQueue)->References) == 0) \
{ \
TRACE("Free message queue 0x%p\n", (MsgQueue)); \
ExFreePoolWithTag((MsgQueue), USERTAG_Q); \
} \
} while(0)
#define USERTAG_Q
Definition: tags.h:268
#define InterlockedDecrement
Definition: armddk.h:52

Definition at line 220 of file msgqueue.h.

◆ IntReferenceMessageQueue

#define IntReferenceMessageQueue (   MsgQueue)    InterlockedIncrement(&(MsgQueue)->References)

Definition at line 217 of file msgqueue.h.

◆ IS_BTN_MESSAGE

#define IS_BTN_MESSAGE (   message,
  code 
)
Value:
((message) == WM_LBUTTON##code || \
(message) == WM_MBUTTON##code || \
(message) == WM_RBUTTON##code || \
(message) == WM_XBUTTON##code || \
(message) == WM_NCLBUTTON##code || \
(message) == WM_NCMBUTTON##code || \
(message) == WM_NCRBUTTON##code || \
(message) == WM_NCXBUTTON##code )
Definition: tftpd.h:59
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glext.h:5579
int code
Definition: i386-dis.c:3591

Definition at line 229 of file msgqueue.h.

◆ IS_KBD_MESSAGE

#define IS_KBD_MESSAGE (   message)    (message >= WM_KEYFIRST && message <= WM_KEYLAST)

Definition at line 246 of file msgqueue.h.

◆ IS_MOUSE_MESSAGE

#define IS_MOUSE_MESSAGE (   message)
Value:
Definition: tftpd.h:59
#define WM_MOUSEFIRST
Definition: winuser.h:1756
#define WM_NCMOUSELAST
Definition: msgqueue.h:240
#define WM_NCMOUSEFIRST
Definition: msgqueue.h:239
#define WM_MOUSELAST
Definition: winuser.h:1783

Definition at line 242 of file msgqueue.h.

◆ MSQ_HUNG

#define MSQ_HUNG   5000

Definition at line 3 of file msgqueue.h.

◆ MSQ_INJECTMODULE

#define MSQ_INJECTMODULE   2

Definition at line 6 of file msgqueue.h.

◆ MSQ_ISHOOK

#define MSQ_ISHOOK   1

Definition at line 5 of file msgqueue.h.

◆ MSQ_NORMAL

#define MSQ_NORMAL   0

Definition at line 4 of file msgqueue.h.

◆ POSTEVENT_DAW

#define POSTEVENT_DAW   4

Definition at line 123 of file msgqueue.h.

◆ POSTEVENT_NONE

#define POSTEVENT_NONE   0xFFFF

Definition at line 126 of file msgqueue.h.

◆ POSTEVENT_NWE

#define POSTEVENT_NWE   14

Definition at line 125 of file msgqueue.h.

◆ POSTEVENT_SAW

#define POSTEVENT_SAW   5

Definition at line 124 of file msgqueue.h.

◆ QF_ACTIVATIONCHANGE

#define QF_ACTIVATIONCHANGE   0x00000040

Definition at line 100 of file msgqueue.h.

◆ QF_ACTIVEWNDTRACKING

#define QF_ACTIVEWNDTRACKING   0x00200000

Definition at line 112 of file msgqueue.h.

◆ QF_CAPTURELOCKED

#define QF_CAPTURELOCKED   0x00100000

Definition at line 111 of file msgqueue.h.

◆ QF_DIALOGACTIVE

#define QF_DIALOGACTIVE   0x00004000

Definition at line 106 of file msgqueue.h.

◆ QF_EVENTDEACTIVATEREMOVED

#define QF_EVENTDEACTIVATEREMOVED   0x00008000

Definition at line 107 of file msgqueue.h.

◆ QF_FF10STATUS

#define QF_FF10STATUS   0x00000010

Definition at line 98 of file msgqueue.h.

◆ QF_FMENUSTATUS

#define QF_FMENUSTATUS   0x00000008

Definition at line 97 of file msgqueue.h.

◆ QF_FMENUSTATUSBREAK

#define QF_FMENUSTATUSBREAK   0x00000004

Definition at line 96 of file msgqueue.h.

◆ QF_FOCUSNULLSINCEACTIVE

#define QF_FOCUSNULLSINCEACTIVE   0x00000800

Definition at line 105 of file msgqueue.h.

◆ QF_INDESTROY

#define QF_INDESTROY   0x00000200

Definition at line 103 of file msgqueue.h.

◆ QF_KEYSTATERESET

#define QF_KEYSTATERESET   0x00000100

Definition at line 102 of file msgqueue.h.

◆ QF_LOCKNOREMOVE

#define QF_LOCKNOREMOVE   0x00000400

Definition at line 104 of file msgqueue.h.

◆ QF_MOUSEMOVED

#define QF_MOUSEMOVED   0x00000020

Definition at line 99 of file msgqueue.h.

◆ QF_TABSWITCHING

#define QF_TABSWITCHING   0x00000080

Definition at line 101 of file msgqueue.h.

◆ QF_TRACKMOUSEFIRING

#define QF_TRACKMOUSEFIRING   0x00080000

Definition at line 110 of file msgqueue.h.

◆ QF_TRACKMOUSEHOVER

#define QF_TRACKMOUSEHOVER   0x00040000

Definition at line 109 of file msgqueue.h.

◆ QF_TRACKMOUSELEAVE

#define QF_TRACKMOUSELEAVE   0x00020000

Definition at line 108 of file msgqueue.h.

◆ QF_UPDATEKEYSTATE

#define QF_UPDATEKEYSTATE   0x00000001

Definition at line 95 of file msgqueue.h.

◆ SMF_RECEIVEDMESSAGE

#define SMF_RECEIVEDMESSAGE   0x00000010

Definition at line 41 of file msgqueue.h.

◆ SMF_RECEIVERBUSY

#define SMF_RECEIVERBUSY   0x00004000

Definition at line 42 of file msgqueue.h.

◆ SMF_RECEIVERDIED

#define SMF_RECEIVERDIED   0x00000002

Definition at line 38 of file msgqueue.h.

◆ SMF_RECEIVERFREE

#define SMF_RECEIVERFREE   0x00000008

Definition at line 40 of file msgqueue.h.

◆ SMF_SENDERDIED

#define SMF_SENDERDIED   0x00000004

Definition at line 39 of file msgqueue.h.

◆ WM_NCMOUSEFIRST

#define WM_NCMOUSEFIRST   WM_NCMOUSEMOVE

Definition at line 239 of file msgqueue.h.

◆ WM_NCMOUSELAST

Definition at line 240 of file msgqueue.h.

Typedef Documentation

◆ PUSER_MESSAGE

◆ PUSER_MESSAGE_QUEUE

◆ PUSER_SENT_MESSAGE

◆ USER_MESSAGE

◆ USER_MESSAGE_QUEUE

◆ USER_SENT_MESSAGE

Enumeration Type Documentation

◆ internal_event_message

Enumerator
WM_ASYNC_SHOWWINDOW 
WM_ASYNC_SETWINDOWPOS 
WM_ASYNC_SETACTIVEWINDOW 
WM_ASYNC_DESTROYWINDOW 

Definition at line 115 of file msgqueue.h.

Function Documentation

◆ AllocateUserMessage()

PUSER_SENT_MESSAGE FASTCALL AllocateUserMessage ( BOOL  )

Definition at line 763 of file msgqueue.c.

764 {
766 
767  if(!(Message = ExAllocateFromPagedLookasideList(pgSendMsgLookasideList)))
768  {
769  ERR("AllocateUserMessage(): Not enough memory to allocate a message");
770  return NULL;
771  }
773 
774  if (KEvent)
775  {
776  Message->pkCompletionEvent = &Message->CompletionEvent;
777 
778  KeInitializeEvent(Message->pkCompletionEvent, NotificationEvent, FALSE);
779  }
780  SendMsgCount++;
781  TRACE("AUM pti %p msg %p\n",PsGetCurrentThreadWin32Thread(),Message);
782  return Message;
783 }
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
INT SendMsgCount
Definition: msgqueue.c:19
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
CHAR Message[80]
Definition: alive.c:5
#define ERR(fmt,...)
Definition: debug.h:109
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
static PPAGED_LOOKASIDE_LIST pgSendMsgLookasideList
Definition: msgqueue.c:17
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

Referenced by co_IntSendMessageWithCallBack(), co_MsqSendMessage(), and co_MsqSendMessageAsync().

◆ ClearMsgBitsMask()

VOID FASTCALL ClearMsgBitsMask ( PTHREADINFO  ,
UINT   
)

Definition at line 445 of file msgqueue.c.

446 {
447  UINT ClrMask = 0;
448 
449  if (MessageBits & QS_KEY)
450  {
451  if (--pti->nCntsQBits[QSRosKey] == 0) ClrMask |= QS_KEY;
452  }
453  if (MessageBits & QS_MOUSEMOVE)
454  { // Account for tracking mouse moves..
455  if (pti->nCntsQBits[QSRosMouseMove])
456  {
457  pti->nCntsQBits[QSRosMouseMove] = 0; // Throttle down count. Up to > 3:1 entries are ignored.
458  ClrMask |= QS_MOUSEMOVE;
459  }
460  }
461  if (MessageBits & QS_MOUSEBUTTON)
462  {
463  if (--pti->nCntsQBits[QSRosMouseButton] == 0) ClrMask |= QS_MOUSEBUTTON;
464  }
465  if (MessageBits & QS_POSTMESSAGE)
466  {
467  if (--pti->nCntsQBits[QSRosPostMessage] == 0) ClrMask |= QS_POSTMESSAGE;
468  }
469  if (MessageBits & QS_TIMER) // ReactOS hard coded.
470  { // Handle timer bits here.
471  if ( pti->cTimersReady )
472  {
473  if (--pti->cTimersReady == 0) ClrMask |= QS_TIMER;
474  }
475  }
476  if (MessageBits & QS_PAINT) // ReactOS hard coded.
477  { // Handle paint bits here.
478  if ( pti->cPaintsReady )
479  {
480  if (--pti->cPaintsReady == 0) ClrMask |= QS_PAINT;
481  }
482  }
483  if (MessageBits & QS_SENDMESSAGE)
484  {
485  if (--pti->nCntsQBits[QSRosSendMessage] == 0) ClrMask |= QS_SENDMESSAGE;
486  }
487  if (MessageBits & QS_HOTKEY)
488  {
489  if (--pti->nCntsQBits[QSRosHotKey] == 0) ClrMask |= QS_HOTKEY;
490  }
491  if (MessageBits & QS_EVENT)
492  {
493  if (--pti->nCntsQBits[QSRosEvent] == 0) ClrMask |= QS_EVENT;
494  }
495 
496  pti->pcti->fsWakeBits &= ~ClrMask;
497  pti->pcti->fsChangeBits &= ~ClrMask;
498 }
#define QS_TIMER
Definition: winuser.h:893
Definition: win32.h:40
#define QS_HOTKEY
Definition: winuser.h:877
#define QS_SENDMESSAGE
Definition: winuser.h:892
#define QS_EVENT
Definition: undocuser.h:95
#define QS_MOUSEMOVE
Definition: winuser.h:886
#define QS_POSTMESSAGE
Definition: winuser.h:888
unsigned int UINT
Definition: ndis.h:50
#define QS_MOUSEBUTTON
Definition: winuser.h:885
#define QS_PAINT
Definition: winuser.h:887
#define QS_KEY
Definition: winuser.h:883

Referenced by co_IntPeekMessage(), co_MsqDispatchOneSentMessage(), co_MsqPeekHardwareMessage(), co_MsqSendMessage(), FindRemoveEventMsg(), MsqDecPaintCountQueue(), MsqPeekMessage(), MsqRemoveWindowMessagesFromQueue(), and PostTimerMessages().

◆ co_IntGetPeekMessage()

BOOL APIENTRY co_IntGetPeekMessage ( PMSG  pMsg,
HWND  hWnd,
UINT  MsgFilterMin,
UINT  MsgFilterMax,
UINT  RemoveMsg,
BOOL  bGMSG 
)

Definition at line 1018 of file message.c.

1024 {
1025  PWND Window;
1026  PTHREADINFO pti;
1027  BOOL Present = FALSE;
1028  NTSTATUS Status;
1029  LONG_PTR ExtraInfo = 0;
1030 
1031  if ( hWnd == HWND_TOPMOST || hWnd == HWND_BROADCAST )
1032  hWnd = HWND_BOTTOM;
1033 
1034  /* Validate input */
1035  if (hWnd && hWnd != HWND_BOTTOM)
1036  {
1037  if (!(Window = UserGetWindowObject(hWnd)))
1038  {
1039  if (bGMSG)
1040  return -1;
1041  else
1042  return FALSE;
1043  }
1044  }
1045  else
1046  {
1047  Window = (PWND)hWnd;
1048  }
1049 
1050  if (MsgFilterMax < MsgFilterMin)
1051  {
1052  MsgFilterMin = 0;
1053  MsgFilterMax = 0;
1054  }
1055 
1056  if (bGMSG)
1057  {
1058  RemoveMsg |= ((GetWakeMask( MsgFilterMin, MsgFilterMax ))<< 16);
1059  }
1060 
1062  pti->pClientInfo->cSpins++; // Bump up the spin count.
1063 
1064  do
1065  {
1066  Present = co_IntPeekMessage( pMsg,
1067  Window,
1068  MsgFilterMin,
1069  MsgFilterMax,
1070  RemoveMsg,
1071  &ExtraInfo,
1072  bGMSG );
1073  if (Present)
1074  {
1075  /* GetMessage or PostMessage must never get messages that contain pointers */
1076  ASSERT(FindMsgMemory(pMsg->message) == NULL);
1077 
1078  if ( pMsg->message >= WM_DDE_FIRST && pMsg->message <= WM_DDE_LAST )
1079  {
1080  if (!IntDdeGetMessageHook(pMsg, ExtraInfo))
1081  {
1082  TRACE("DDE Get return ERROR\n");
1083  continue;
1084  }
1085  }
1086 
1087  if (pMsg->message != WM_PAINT && pMsg->message != WM_QUIT)
1088  {
1089  if (!RtlEqualMemory(&pti->ptLast, &pMsg->pt, sizeof(POINT)))
1090  {
1091  pti->TIF_flags |= TIF_MSGPOSCHANGED;
1092  }
1093  pti->timeLast = pMsg->time;
1094  pti->ptLast = pMsg->pt;
1095  }
1096 
1097  // The WH_GETMESSAGE hook enables an application to monitor messages about to
1098  // be returned by the GetMessage or PeekMessage function.
1099 
1100  co_HOOK_CallHooks( WH_GETMESSAGE, HC_ACTION, RemoveMsg & PM_REMOVE, (LPARAM)pMsg);
1101 
1102  if ( bGMSG || pMsg->message == WM_PAINT) break;
1103  }
1104 
1105  if ( bGMSG )
1106  {
1108  Window,
1109  MsgFilterMin,
1110  MsgFilterMax);
1111  if ( !NT_SUCCESS(Status) ||
1112  Status == STATUS_USER_APC ||
1113  Status == STATUS_TIMEOUT )
1114  {
1115  Present = -1;
1116  break;
1117  }
1118  }
1119  else
1120  {
1121  if (!(RemoveMsg & PM_NOYIELD))
1122  {
1123  IdlePing();
1124  // Yield this thread!
1125  UserLeave();
1126  ZwYieldExecution();
1128  // Fall through to exit.
1129  IdlePong();
1130  }
1131  break;
1132  }
1133  }
1134  while( bGMSG && !Present );
1135 
1136  // Been spinning, time to swap vinyl...
1137  if (pti->pClientInfo->cSpins >= 100)
1138  {
1139  // Clear the spin cycle to fix the mix.
1140  pti->pClientInfo->cSpins = 0;
1141  //if (!(pti->TIF_flags & TIF_SPINNING)) // FIXME: Need to swap vinyl...
1142  }
1143  return Present;
1144 }
static PMSGMEMORY FASTCALL FindMsgMemory(UINT Msg)
Definition: message.c:145
#define WH_GETMESSAGE
Definition: winuser.h:33
POINT pt
Definition: winuser.h:3094
VOID FASTCALL IdlePing(VOID)
Definition: message.c:515
FLONG TIF_flags
Definition: win32.h:94
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
LONG NTSTATUS
Definition: precomp.h:26
UINT FASTCALL GetWakeMask(UINT first, UINT last)
Definition: message.c:562
HWND hWnd
Definition: settings.c:17
#define WM_QUIT
Definition: winuser.h:1605
#define HWND_TOPMOST
Definition: winuser.h:1194
NTSTATUS FASTCALL co_MsqWaitForNewMessages(PTHREADINFO pti, PWND WndFilter, UINT MsgFilterMin, UINT MsgFilterMax)
Definition: msgqueue.c:2164
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
Definition: window.c:28
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI NTSTATUS NTAPI ZwYieldExecution(VOID)
BOOL APIENTRY co_IntPeekMessage(PMSG Msg, PWND Window, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg, LONG_PTR *ExtraInfo, BOOL bGMSG)
Definition: message.c:806
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
#define HWND_BOTTOM
Definition: winuser.h:1191
#define TRACE(s)
Definition: solgame.cpp:4
NTSYSAPI ULONG NTAPI RtlEqualMemory(CONST VOID *Source1, CONST VOID *Source2, ULONG Length)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOL APIENTRY IntDdeGetMessageHook(PMSG pMsg, LONG_PTR ExtraInfo)
Definition: dde.c:326
struct _CLIENTINFO * pClientInfo
Definition: win32.h:93
int Window
Definition: x11stubs.h:26
#define WM_PAINT
Definition: winuser.h:1602
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1103
#define WM_DDE_LAST
Definition: dde.h:46
LONG timeLast
Definition: win32.h:101
#define TIF_MSGPOSCHANGED
Definition: ntuser.h:260
POINT ptLast
Definition: win32.h:128
Status
Definition: gdiplustypes.h:24
#define STATUS_USER_APC
Definition: ntstatus.h:78
Definition: ntuser.h:657
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
struct _WND * PWND
VOID FASTCALL IdlePong(VOID)
Definition: message.c:545
#define WM_DDE_FIRST
Definition: dde.h:47
#define HC_ACTION
Definition: winuser.h:48
#define PM_NOYIELD
Definition: winuser.h:1183
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
DWORD time
Definition: winuser.h:3093
#define PM_REMOVE
Definition: winuser.h:1182
UINT message
Definition: winuser.h:3090
#define HWND_BROADCAST
Definition: winuser.h:1190

Referenced by DefWndDoSizeMove(), DefWndStartSizeMove(), DesktopThreadMain(), MENU_SuspendPopup(), MENU_TrackMenu(), NC_DoButton(), NC_HandleNCRButtonDown(), NtUserDragDetect(), NtUserGetMessage(), NtUserPeekMessage(), and NtUserWaitForInputIdle().

◆ co_IntPostOrSendMessage()

LRESULT FASTCALL co_IntPostOrSendMessage ( HWND  hWnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

◆ co_IntSendMessage()

LRESULT FASTCALL co_IntSendMessage ( HWND  hWnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1284 of file message.c.

1288 {
1289  ULONG_PTR Result = 0;
1290 
1292  {
1293  return (LRESULT)Result;
1294  }
1295  return 0;
1296 }
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
#define SMTO_NORMAL
Definition: winuser.h:1211
uint32_t ULONG_PTR
Definition: typedefs.h:63
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
LRESULT FASTCALL co_IntSendMessageTimeout(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult)
Definition: message.c:1492
struct @1587 Msg[]
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139

Referenced by co_IntDoSendMessage(), co_IntPaintWindows(), co_IntProcessKeyboardMessage(), co_IntProcessMouseMessage(), co_IntSendActivateMessages(), co_IntSendDeactivateMessages(), co_IntSetForegroundMessageQueue(), co_IntSetWindowLongPtr(), co_IntTranslateAccelerator(), co_IntUpdateWindows(), co_MsqDispatchOneSentMessage(), co_UserActivateKbl(), co_UserCreateWindowEx(), co_UserFreeWindow(), co_UserSetCapture(), co_WinPosDoNCCALCSize(), co_WinPosDoWinPosChanging(), co_WinPosGetMinMaxInfo(), co_WinPosSearchChildren(), co_WinPosShowWindow(), DefWndDoSizeMove(), DefWndHandleSysCommand(), DefWndHandleWindowPosChanged(), DefWndPrint(), DefWndStartSizeMove(), ForceNCPaintErase(), GetControlColor(), IntActivateWindow(), IntBeginPaint(), IntClientShutdown(), IntDeactivateWindow(), IntDefWindowProc(), IntEnableWindow(), IntFlashWindowEx(), IntScrollWindowEx(), IntSendDestroyMsg(), IntSendFocusMessages(), IntSendNCPaint(), IntSendParentNotify(), IntShowOwnedPopups(), IntTrackPopupMenuEx(), MENU_CalcItemSize(), MENU_DoNextMenu(), MENU_DrawBitmapItem(), MENU_DrawMenuItem(), MENU_ExitTracking(), MENU_FindItemByKey(), MENU_GetBitmapItemSize(), MENU_HideSubPopups(), MENU_InitTracking(), MENU_SelectItem(), MENU_ShowSubPopup(), MENU_TrackMenu(), MsqSendParentNotify(), NC_DoButton(), NC_DoNCPaint(), NC_HandleNCLButtonDblClk(), NC_HandleNCLButtonDown(), NC_HandleNCRButtonDown(), NtUserChangeClipboardChain(), NtUserGetClipboardData(), NtUserGetComboBoxInfo(), NtUserGetListBoxInfo(), NtUserGetMenuBarInfo(), UserClipboardRelease(), UserEmptyClipboard(), and UserPaintCaption().

◆ co_IntSendMessageNoWait()

LRESULT FASTCALL co_IntSendMessageNoWait ( HWND  hWnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1548 of file message.c.

1552 {
1553  ULONG_PTR Result = 0;
1555  Msg,
1556  wParam,
1557  lParam,
1558  NULL,
1559  0,
1560  &Result);
1561 }
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
struct @1587 Msg[]
LPARAM lParam
Definition: combotst.c:139
LRESULT FASTCALL co_IntSendMessageWithCallBack(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, SENDASYNCPROC CompletionCallback, ULONG_PTR CompletionCallbackContext, ULONG_PTR *uResult)
Definition: message.c:1570

Referenced by co_WinPosGetNonClientSize(), co_WinPosMinMaximize(), co_WinPosSendSizeMove(), co_WinPosSetWindowPos(), co_WinPosShowWindow(), IntEndDeferWindowPosEx(), IntSendSyncPaint(), IntSetWindowPlacement(), NtUserSetClipboardViewer(), NtUserShowWindowAsync(), UserClipboardRelease(), UserCloseClipboard(), and UserSendNotifyMessage().

◆ co_IntSendMessageTimeout()

LRESULT FASTCALL co_IntSendMessageTimeout ( HWND  hWnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam,
UINT  uFlags,
UINT  uTimeout,
ULONG_PTR uResult 
)

Definition at line 1492 of file message.c.

1499 {
1501  HWND *Children;
1502  HWND *Child;
1503 
1504  if (hWnd != HWND_BROADCAST && hWnd != HWND_TOPMOST)
1505  {
1506  return co_IntSendMessageTimeoutSingle(hWnd, Msg, wParam, lParam, uFlags, uTimeout, uResult);
1507  }
1508 
1509  if (!is_message_broadcastable(Msg)) return TRUE;
1510 
1512  if (NULL == DesktopWindow)
1513  {
1515  return 0;
1516  }
1517 
1518  if (hWnd != HWND_TOPMOST)
1519  {
1520  /* Send message to the desktop window too! */
1521  co_IntSendMessageTimeoutSingle(DesktopWindow->head.h, Msg, wParam, lParam, uFlags, uTimeout, uResult);
1522  }
1523 
1524  Children = IntWinListChildren(DesktopWindow);
1525  if (NULL == Children)
1526  {
1527  return 0;
1528  }
1529 
1530  for (Child = Children; NULL != *Child; Child++)
1531  {
1532  PWND pwnd = UserGetWindowObject(*Child);
1533  if (!pwnd) continue;
1534 
1535  if ( pwnd->fnid == FNID_MENU ||
1537  continue;
1538 
1539  co_IntSendMessageTimeoutSingle(*Child, Msg, wParam, lParam, uFlags, uTimeout, uResult);
1540  }
1541 
1543 
1544  return (LRESULT) TRUE;
1545 }
static LRESULT FASTCALL co_IntSendMessageTimeoutSingle(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult)
Definition: message.c:1299
#define TRUE
Definition: types.h:120
#define ERROR_INTERNAL_ERROR
Definition: winerror.h:840
static BOOL is_message_broadcastable(UINT msg)
Definition: message.c:556
#define FNID_MENU
Definition: ntuser.h:823
HWND hWnd
Definition: settings.c:17
#define HWND_TOPMOST
Definition: winuser.h:1194
UINT uFlags
Definition: api.c:59
RTL_ATOM atomClassName
Definition: ntuser.h:536
PSERVERINFO gpsi
Definition: main.c:27
WPARAM wParam
Definition: combotst.c:138
DWORD fnid
Definition: ntuser.h:673
smooth NULL
Definition: ftsmooth.c:416
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
Implementation of the Explorer desktop window.
Definition: desktop.h:51
#define ICLS_SWITCH
Definition: ntuser.h:893
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1349
HWND *FASTCALL IntWinListChildren(PWND Window)
Definition: window.c:255
Definition: ntuser.h:657
struct @1587 Msg[]
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE Child
Definition: acpixf.h:728
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define USERTAG_WINDOWLIST
Definition: tags.h:297
LONG_PTR LRESULT
Definition: windef.h:209
#define HWND_BROADCAST
Definition: winuser.h:1190
LPARAM lParam
Definition: combotst.c:139
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1013
PCLS pcls
Definition: ntuser.h:684

Referenced by co_IntDoSendMessage(), co_IntSendMessage(), NtUserMessageCall(), UserChangeDisplaySettings(), and UserSystemParametersInfo().

◆ co_IntSendMessageWithCallBack()

LRESULT FASTCALL co_IntSendMessageWithCallBack ( HWND  hWnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam,
SENDASYNCPROC  CompletionCallback,
ULONG_PTR  CompletionCallbackContext,
ULONG_PTR uResult 
)

Definition at line 1570 of file message.c.

1577 {
1578  ULONG_PTR Result;
1579  PWND Window = NULL;
1580  PMSGMEMORY MsgMemoryEntry;
1581  INT lParamBufferSize;
1582  LPARAM lParamPacked;
1583  PTHREADINFO Win32Thread, ptiSendTo = NULL;
1587  BOOL DoCallBack = TRUE;
1588 
1589  if (!(Window = UserGetWindowObject(hWnd)))
1590  {
1591  TRACE("SendMessageWithCallBack: Invalid handle 0x%p!\n",hWnd);
1592  RETURN(FALSE);
1593  }
1594 
1595  UserRefObjectCo(Window, &Ref);
1596 
1597  if (Window->state & WNDS_DESTROYED)
1598  {
1599  /* FIXME: last error? */
1600  ERR("Attempted to send message to window %p that is being destroyed!\n", hWnd);
1601  RETURN(FALSE);
1602  }
1603 
1604  Win32Thread = PsGetCurrentThreadWin32Thread();
1605 
1606  if (Win32Thread == NULL ||
1607  Win32Thread->TIF_flags & TIF_INCLEANUP)
1608  {
1609  RETURN(FALSE);
1610  }
1611 
1612  ptiSendTo = IntSendTo(Window, Win32Thread, Msg);
1613 
1614  if (Msg & 0x80000000 &&
1615  !ptiSendTo)
1616  {
1617  if (Win32Thread->TIF_flags & TIF_INCLEANUP) RETURN( FALSE);
1618 
1619  TRACE("SMWCB: Internal Message!\n");
1621  if (uResult) *uResult = Result;
1622  RETURN( TRUE);
1623  }
1624 
1625  /* See if this message type is present in the table */
1626  MsgMemoryEntry = FindMsgMemory(Msg);
1627  if (NULL == MsgMemoryEntry)
1628  {
1629  lParamBufferSize = -1;
1630  }
1631  else
1632  {
1633  lParamBufferSize = MsgMemorySize(MsgMemoryEntry, wParam, lParam);
1634  if (!lParamBufferSize) lParamBufferSize = -1;
1635  }
1636 
1637  if (! NT_SUCCESS(PackParam(&lParamPacked, Msg, wParam, lParam, !!ptiSendTo)))
1638  {
1639  ERR("Failed to pack message parameters\n");
1640  RETURN( FALSE);
1641  }
1642 
1643  /* If it can be sent now, then send it. */
1644  if ( !ptiSendTo )
1645  {
1646  if (Win32Thread->TIF_flags & TIF_INCLEANUP)
1647  {
1648  UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE);
1649  /* Never send messages to exiting threads */
1650  RETURN(FALSE);
1651  }
1652 
1654 
1655  if ( Window->state & WNDS_SERVERSIDEWINDOWPROC )
1656  {
1657  TRACE("SMWCB: Server Side Window Procedure\n");
1658  switch(Window->fnid)
1659  {
1660  case FNID_DESKTOP:
1661  DoCallBack = !DesktopWindowProc(Window, Msg, wParam, lParamPacked, (LRESULT*)&Result);
1662  break;
1663  case FNID_MESSAGEWND:
1665  break;
1666  case FNID_MENU:
1667  DoCallBack = !PopupMenuWndProc( Window, Msg, wParam, lParam,(LRESULT*)&Result);
1668  break;
1669  }
1670  }
1671 
1672  if (DoCallBack)
1673  Result = (ULONG_PTR)co_IntCallWindowProc( Window->lpfnWndProc,
1674  !Window->Unicode,
1675  hWnd,
1676  Msg,
1677  wParam,
1678  lParamPacked,
1679  lParamBufferSize );
1680  if(uResult)
1681  {
1682  *uResult = Result;
1683  }
1684 
1685  IntCallWndProcRet( Window, hWnd, Msg, wParam, lParam, (LRESULT *)uResult);
1686 
1687  if (CompletionCallback)
1688  {
1690  hWnd,
1691  Msg,
1692  CompletionCallbackContext,
1693  Result);
1694  }
1695  }
1696 
1697  if ( !ptiSendTo)
1698  {
1699  if (! NT_SUCCESS(UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE)))
1700  {
1701  ERR("Failed to unpack message parameters\n");
1702  }
1703  RETURN(TRUE);
1704  }
1705 
1707  {
1708  ERR("MsqSendMessage(): Not enough memory to allocate a message");
1709  RETURN( FALSE);
1710  }
1711 
1712  Message->Msg.hwnd = hWnd;
1713  Message->Msg.message = Msg;
1714  Message->Msg.wParam = wParam;
1715  Message->Msg.lParam = lParamPacked;
1716  Message->pkCompletionEvent = NULL; // No event needed.
1717  Message->lResult = 0;
1718  Message->QS_Flags = 0;
1719  Message->ptiReceiver = ptiSendTo;
1720  Message->ptiSender = NULL; // mjmartin, you are right! This is null.
1721  Message->ptiCallBackSender = Win32Thread;
1722  Message->CompletionCallback = CompletionCallback;
1723  Message->CompletionCallbackContext = CompletionCallbackContext;
1724  Message->HookMessage = MSQ_NORMAL;
1725  Message->HasPackedLParam = (lParamBufferSize > 0);
1726  Message->QS_Flags = QS_SENDMESSAGE;
1727  Message->flags = SMF_RECEIVERFREE;
1728 
1729  if (Msg & 0x80000000) // Higher priority event message!
1730  InsertHeadList(&ptiSendTo->SentMessagesListHead, &Message->ListEntry);
1731  else
1732  InsertTailList(&ptiSendTo->SentMessagesListHead, &Message->ListEntry);
1733  MsqWakeQueue(ptiSendTo, QS_SENDMESSAGE, TRUE);
1734 
1735  RETURN(TRUE);
1736 
1737 CLEANUP:
1739  END_CLEANUP;
1740 }
VOID FASTCALL MsqWakeQueue(PTHREADINFO pti, DWORD MessageBits, BOOL KeyEvent)
Definition: msgqueue.c:412
#define TRUE
Definition: types.h:120
static PMSGMEMORY FASTCALL FindMsgMemory(UINT Msg)
Definition: message.c:145
BOOL WINAPI PopupMenuWndProc(PWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: menu.c:4628
#define CLEANUP
Definition: ntuser.h:5
#define RETURN(value)
Definition: ntuser.h:4
static LRESULT handle_internal_message(PWND pWnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: message.c:613
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
FLONG TIF_flags
Definition: win32.h:94
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
#define FNID_MENU
Definition: ntuser.h:823
HWND hWnd
Definition: settings.c:17
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:25
BOOL FASTCALL DesktopWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: desktop.c:1401
LRESULT APIENTRY co_IntCallWindowProc(WNDPROC Proc, BOOLEAN IsAnsiProc, HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, INT lParamBufferSize)
Definition: callback.c:289
#define InsertTailList(ListHead, Entry)
int32_t INT
Definition: typedefs.h:56
WPARAM wParam
Definition: combotst.c:138
#define FNID_MESSAGEWND
Definition: ntuser.h:826
uint32_t ULONG_PTR
Definition: typedefs.h:63
Definition: window.c:28
static NTSTATUS PackParam(LPARAM *lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL NonPagedPoolNeeded)
Definition: message.c:251
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FNID_DESKTOP
Definition: ntuser.h:824
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:38
LIST_ENTRY SentMessagesListHead
Definition: win32.h:99
PTHREADINFO FASTCALL IntSendTo(PWND Window, PTHREADINFO ptiCur, UINT Msg)
Definition: message.c:1170
#define SMF_RECEIVERFREE
Definition: msgqueue.h:40
Definition: object.h:3
static NTSTATUS UnpackParam(LPARAM lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL NonPagedPoolUsed)
Definition: message.c:369
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define QS_SENDMESSAGE
Definition: winuser.h:892
LONG_PTR LPARAM
Definition: windef.h:208
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
#define TRACE(s)
Definition: solgame.cpp:4
static VOID FASTCALL IntCallWndProc(PWND Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:581
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DECLARE_RETURN(type)
Definition: ntuser.h:3
VOID APIENTRY co_IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback, HWND hWnd, UINT Msg, ULONG_PTR CompletionCallbackContext, LRESULT Result)
Definition: callback.c:245
BOOL FASTCALL UserMessageWindowProc(PWND pwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: desktop.c:1487
CHAR Message[80]
Definition: alive.c:5
PUSER_SENT_MESSAGE FASTCALL AllocateUserMessage(BOOL KEvent)
Definition: msgqueue.c:763
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
#define MSQ_NORMAL
Definition: msgqueue.h:4
static UINT FASTCALL MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam)
Definition: message.c:164
static VOID FASTCALL IntCallWndProcRet(PWND Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *uResult)
Definition: message.c:597
struct @1587 Msg[]
#define ULONG_PTR
Definition: config.h:101
const TCHAR * CompletionCallback(unsigned __int64 &rnIndex, const BOOL *pblnForward, const TCHAR *pszContext, const TCHAR *pszBegin)
Definition: Completion.cpp:439
LONG_PTR LRESULT
Definition: windef.h:209
#define WNDS_SERVERSIDEWINDOWPROC
Definition: ntuser.h:591
#define WNDS_DESTROYED
Definition: ntuser.h:604
LPARAM lParam
Definition: combotst.c:139
#define TIF_INCLEANUP
Definition: ntuser.h:240
#define END_CLEANUP
Definition: ntuser.h:6

Referenced by co_IntSendMessageNoWait(), and NtUserMessageCall().

◆ co_IntWaitMessage()

BOOL FASTCALL co_IntWaitMessage ( PWND  Window,
UINT  MsgFilterMin,
UINT  MsgFilterMax 
)

Definition at line 972 of file message.c.

975 {
976  PTHREADINFO pti;
978  MSG Msg;
979  LONG_PTR ExtraInfo = 0;
980 
982 
983  do
984  {
985  if ( co_IntPeekMessage( &Msg, // Dont reenter!
986  Window,
987  MsgFilterMin,
988  MsgFilterMax,
989  MAKELONG( PM_NOREMOVE, GetWakeMask( MsgFilterMin, MsgFilterMax)),
990  &ExtraInfo,
991  TRUE ) ) // act like GetMessage.
992  {
993  return TRUE;
994  }
995 
996  /* Nothing found. Wait for new messages. */
998  Window,
999  MsgFilterMin,
1000  MsgFilterMax);
1001  if (!NT_SUCCESS(Status))
1002  {
1004  ERR("Exit co_IntWaitMessage on error!\n");
1005  return FALSE;
1006  }
1008  {
1009  return FALSE;
1010  }
1011  }
1012  while ( TRUE );
1013 
1014  return FALSE;
1015 }
#define TRUE
Definition: types.h:120
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
LONG NTSTATUS
Definition: precomp.h:26
UINT FASTCALL GetWakeMask(UINT first, UINT last)
Definition: message.c:562
NTSTATUS FASTCALL co_MsqWaitForNewMessages(PTHREADINFO pti, PWND WndFilter, UINT MsgFilterMin, UINT MsgFilterMax)
Definition: msgqueue.c:2164
#define PM_NOREMOVE
Definition: winuser.h:1181
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
Definition: window.c:28
#define MAKELONG(a, b)
Definition: typedefs.h:248
BOOL APIENTRY co_IntPeekMessage(PMSG Msg, PWND Window, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg, LONG_PTR *ExtraInfo, BOOL bGMSG)
Definition: message.c:806
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
Status
Definition: gdiplustypes.h:24
#define STATUS_USER_APC
Definition: ntstatus.h:78
#define ERR(fmt,...)
Definition: debug.h:109
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
struct @1587 Msg[]
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by MENU_TrackMenu(), NtUserDragDetect(), and NtUserWaitMessage().

◆ co_MsqDispatchOneSentMessage()

BOOLEAN FASTCALL co_MsqDispatchOneSentMessage ( _In_ PTHREADINFO  pti)

Definition at line 873 of file msgqueue.c.

875 {
876  PUSER_SENT_MESSAGE SaveMsg, Message;
878  BOOL Ret;
879  LRESULT Result = 0;
880 
882 
883  if (IsListEmpty(&pti->SentMessagesListHead))
884  {
885  return(FALSE);
886  }
887 
888  /* remove it from the list of pending messages */
889  Entry = RemoveHeadList(&pti->SentMessagesListHead);
891 
892  // Signal this message is being processed.
894 
895  SaveMsg = pti->pusmCurrent;
896  pti->pusmCurrent = Message;
897 
898  // Processing a message sent to it from another thread.
899  if ( ( Message->ptiSender && pti != Message->ptiSender) ||
900  ( Message->ptiCallBackSender && pti != Message->ptiCallBackSender ))
901  { // most likely, but, to be sure.
902  pti->pcti->CTI_flags |= CTI_INSENDMESSAGE; // Let the user know...
903  }
904 
905  /* Now insert it to the global list of messages that can be removed Justin Case there's Trouble */
906  InsertTailList(&usmList, &Message->ListEntry);
907 
908  ClearMsgBitsMask(pti, Message->QS_Flags);
909 
910  if (Message->HookMessage == MSQ_ISHOOK)
911  { // Direct Hook Call processor
912  Result = co_CallHook( Message->Msg.message, // HookId
913  (INT)(INT_PTR)Message->Msg.hwnd, // Code
914  Message->Msg.wParam,
915  Message->Msg.lParam);
916  }
917  else if(Message->HookMessage == MSQ_INJECTMODULE)
918  {
919  Result = IntLoadHookModule(Message->Msg.message,
920  (HHOOK)Message->Msg.lParam,
921  Message->Msg.wParam);
922  }
923  else if ((Message->CompletionCallback) &&
924  (Message->ptiCallBackSender == pti))
925  { /* Call the callback routine */
926  if (Message->QS_Flags & QS_SMRESULT)
927  {
928  co_IntCallSentMessageCallback(Message->CompletionCallback,
929  Message->Msg.hwnd,
930  Message->Msg.message,
931  Message->CompletionCallbackContext,
932  Message->lResult);
933  /* Set callback to NULL to prevent reentry */
934  Message->CompletionCallback = NULL;
935  }
936  else
937  {
938  /* The message has not been processed yet, reinsert it. */
939  RemoveEntryList(&Message->ListEntry);
940  InsertTailList(&Message->ptiCallBackSender->SentMessagesListHead, &Message->ListEntry);
941  // List is occupied need to set the bit.
942  MsqWakeQueue(Message->ptiCallBackSender, QS_SENDMESSAGE, TRUE);
943  ERR("Callback Message not processed yet. Requeuing the message\n");
944  Ret = FALSE;
945  goto Exit;
946  }
947  }
948  else
949  { /* Call the window procedure. */
950  Result = co_IntSendMessage( Message->Msg.hwnd,
951  Message->Msg.message,
952  Message->Msg.wParam,
953  Message->Msg.lParam);
954  }
955 
956  /* If the message is a callback, insert it in the callback senders MessageQueue */
957  if (Message->CompletionCallback)
958  {
959  if (Message->ptiCallBackSender)
960  {
961  Message->lResult = Result;
962  Message->QS_Flags |= QS_SMRESULT;
963 
964  /* insert it in the callers message queue */
965  RemoveEntryList(&Message->ListEntry);
966  InsertTailList(&Message->ptiCallBackSender->SentMessagesListHead, &Message->ListEntry);
967  MsqWakeQueue(Message->ptiCallBackSender, QS_SENDMESSAGE, TRUE);
968  }
969  Ret = TRUE;
970  goto Exit;
971  }
972 
973  // Retrieve the result from callback.
974  if (Message->QS_Flags & QS_SMRESULT)
975  {
976  Result = Message->lResult;
977  }
978 
979  /* Let the sender know the result. */
980  Message->lResult = Result;
981 
982  if (Message->HasPackedLParam)
983  {
984  if (Message->Msg.lParam)
985  ExFreePool((PVOID)Message->Msg.lParam);
986  }
987 
988  // Clear busy signal.
989  Message->flags &= ~SMF_RECEIVERBUSY;
990 
991  /* Notify the sender. */
992  if (Message->pkCompletionEvent != NULL)
993  {
994  KeSetEvent(Message->pkCompletionEvent, IO_NO_INCREMENT, FALSE);
995  }
996 
997  /* free the message */
998  if (Message->flags & SMF_RECEIVERFREE)
999  {
1000  TRACE("Receiver Freeing Message %p\n",Message);
1002  }
1003 
1004  Ret = TRUE;
1005 Exit:
1006  /* do not hangup on the user if this is reentering */
1007  if (!SaveMsg) pti->pcti->CTI_flags &= ~CTI_INSENDMESSAGE;
1008  pti->pusmCurrent = SaveMsg;
1009 
1010  return Ret;
1011 }
VOID FASTCALL MsqWakeQueue(PTHREADINFO pti, DWORD MessageBits, BOOL KeyEvent)
Definition: msgqueue.c:412
#define TRUE
Definition: types.h:120
struct _Entry Entry
Definition: kefuncs.h:627
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
#define QS_SMRESULT
Definition: undocuser.h:93
int32_t INT_PTR
Definition: typedefs.h:62
#define InsertTailList(ListHead, Entry)
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
int32_t INT
Definition: typedefs.h:56
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MSQ_ISHOOK
Definition: msgqueue.h:5
#define SMF_RECEIVERFREE
Definition: msgqueue.h:40
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define QS_SENDMESSAGE
Definition: winuser.h:892
BOOL IntLoadHookModule(int iHookID, HHOOK hHook, BOOL Unload)
Definition: hook.c:31
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define SMF_RECEIVERBUSY
Definition: msgqueue.h:42
LRESULT APIENTRY co_CallHook(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:322
#define TRACE(s)
Definition: solgame.cpp:4
VOID FASTCALL ClearMsgBitsMask(PTHREADINFO pti, UINT MessageBits)
Definition: msgqueue.c:445
static void Exit(void)
Definition: sock.c:1331
#define CTI_INSENDMESSAGE
Definition: ntuser.h:161
#define MSQ_INJECTMODULE
Definition: msgqueue.h:6
VOID FASTCALL FreeUserMessage(PUSER_SENT_MESSAGE Message)
Definition: msgqueue.c:786
VOID APIENTRY co_IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback, HWND hWnd, UINT Msg, ULONG_PTR CompletionCallbackContext, LRESULT Result)
Definition: callback.c:245
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CHAR Message[80]
Definition: alive.c:5
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1284
Definition: typedefs.h:117
#define ERR(fmt,...)
Definition: debug.h:109
#define IO_NO_INCREMENT
Definition: iotypes.h:566
LONG_PTR LRESULT
Definition: windef.h:209
base of all file and directory entries
Definition: entries.h:82
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define SMF_RECEIVEDMESSAGE
Definition: msgqueue.h:41
LIST_ENTRY usmList
Definition: msgqueue.c:23

Referenced by co_IntPeekMessage(), and co_MsqSendMessage().

◆ co_MsqInsertMouseMessage()

VOID FASTCALL co_MsqInsertMouseMessage ( MSG Msg,
DWORD  flags,
ULONG_PTR  dwExtraInfo,
BOOL  Hook 
)

Definition at line 580 of file msgqueue.c.

581 {
582  MSLLHOOKSTRUCT MouseHookData;
583 // PDESKTOP pDesk;
584  PWND pwnd, pwndDesktop;
585  HDC hdcScreen;
586  PTHREADINFO pti;
587  PUSER_MESSAGE_QUEUE MessageQueue;
588  PSYSTEM_CURSORINFO CurInfo;
589 
590  Msg->time = EngGetTickCount32();
591 
592  MouseHookData.pt.x = LOWORD(Msg->lParam);
593  MouseHookData.pt.y = HIWORD(Msg->lParam);
594  switch (Msg->message)
595  {
596  case WM_MOUSEWHEEL:
597  MouseHookData.mouseData = MAKELONG(0, GET_WHEEL_DELTA_WPARAM(Msg->wParam));
598  break;
599  case WM_XBUTTONDOWN:
600  case WM_XBUTTONUP:
601  case WM_XBUTTONDBLCLK:
602  case WM_NCXBUTTONDOWN:
603  case WM_NCXBUTTONUP:
604  case WM_NCXBUTTONDBLCLK:
605  MouseHookData.mouseData = MAKELONG(0, HIWORD(Msg->wParam));
606  break;
607  default:
608  MouseHookData.mouseData = 0;
609  break;
610  }
611 
612  MouseHookData.flags = flags; // LLMHF_INJECTED
613  MouseHookData.time = Msg->time;
614  MouseHookData.dwExtraInfo = dwExtraInfo;
615 
616  /* If the hook procedure returned non zero, dont send the message */
617  if (Hook)
618  {
619  if (co_HOOK_CallHooks(WH_MOUSE_LL, HC_ACTION, Msg->message, (LPARAM) &MouseHookData))
620  return;
621  }
622 
623  /* Get the desktop window */
624  pwndDesktop = UserGetDesktopWindow();
625  if (!pwndDesktop) return;
626 // pDesk = pwndDesktop->head.rpdesk;
627 
628  /* Check if the mouse is captured */
629  Msg->hwnd = IntGetCaptureWindow();
630  if (Msg->hwnd != NULL)
631  {
632  pwnd = UserGetWindowObject(Msg->hwnd);
633  }
634  else
635  {
636  pwnd = IntTopLevelWindowFromPoint(Msg->pt.x, Msg->pt.y);
637  if (pwnd) Msg->hwnd = pwnd->head.h;
638  }
639 
640  hdcScreen = IntGetScreenDC();
641  CurInfo = IntGetSysCursorInfo();
642 
643  /* Check if we found a window */
644  if (Msg->hwnd != NULL && pwnd != NULL)
645  {
646  pti = pwnd->head.pti;
647  MessageQueue = pti->MessageQueue;
648 
649  if (MessageQueue->QF_flags & QF_INDESTROY)
650  {
651  ERR("Mouse is over a Window with a Dead Message Queue!\n");
652  return;
653  }
654 
655  // Check to see if this is attached.
656  if ( pti != MessageQueue->ptiMouse &&
657  MessageQueue->cThreads > 1 )
658  {
659  // Set the send pti to the message queue mouse pti.
660  pti = MessageQueue->ptiMouse;
661  }
662 
663  if (Msg->message == WM_MOUSEMOVE)
664  {
665  /* Check if cursor should be visible */
666  if(hdcScreen &&
667  MessageQueue->CursorObject &&
668  MessageQueue->iCursorLevel >= 0)
669  {
670  /* Check if shape has changed */
671  if(CurInfo->CurrentCursorObject != MessageQueue->CursorObject)
672  {
673  /* Call GDI to set the new screen cursor */
674  GreSetPointerShape(hdcScreen,
675  MessageQueue->CursorObject->hbmAlpha ?
676  NULL : MessageQueue->CursorObject->hbmMask,
677  MessageQueue->CursorObject->hbmAlpha ?
678  MessageQueue->CursorObject->hbmAlpha : MessageQueue->CursorObject->hbmColor,
679  MessageQueue->CursorObject->xHotspot,
680  MessageQueue->CursorObject->yHotspot,
681  gpsi->ptCursor.x,
682  gpsi->ptCursor.y,
683  MessageQueue->CursorObject->hbmAlpha ? SPS_ALPHA : 0);
684 
685  } else
686  GreMovePointer(hdcScreen, Msg->pt.x, Msg->pt.y);
687  }
688  /* Check if we have to hide cursor */
689  else if (CurInfo->ShowingCursor >= 0)
690  GreMovePointer(hdcScreen, -1, -1);
691 
692  /* Update global cursor info */
693  CurInfo->ShowingCursor = MessageQueue->iCursorLevel;
694  CurInfo->CurrentCursorObject = MessageQueue->CursorObject;
695  gpqCursor = MessageQueue;
696 
697  /* Mouse move is a special case */
698  MessageQueue->QF_flags |= QF_MOUSEMOVED;
699  gdwMouseMoveExtraInfo = dwExtraInfo;
700  gdwMouseMoveTimeStamp = Msg->time;
702  }
703  else
704  {
705  if (!IntGetCaptureWindow())
706  {
707  // ERR("ptiLastInput is set\n");
708  // ptiLastInput = pti; // Once this is set during Reboot or Shutdown, this prevents the exit window having foreground.
709  // Find all the Move Mouse calls and fix mouse set active focus issues......
710  }
711 
712  // Post mouse move before posting mouse buttons, keep it in sync.
713  if (pti->MessageQueue->QF_flags & QF_MOUSEMOVED)
714  {
716  }
717 
718  TRACE("Posting mouse message to hwnd=%p!\n", UserHMGetHandle(pwnd));
719  MsqPostMessage(pti, Msg, TRUE, QS_MOUSEBUTTON, 0, dwExtraInfo);
720  }
721  }
722  else if (hdcScreen)
723  {
724  /* always show cursor on background; FIXME: set default pointer */
725  GreMovePointer(hdcScreen, Msg->pt.x, Msg->pt.y);
726  CurInfo->ShowingCursor = 0;
727  }
728 }
VOID FASTCALL MsqWakeQueue(PTHREADINFO pti, DWORD MessageBits, BOOL KeyEvent)
Definition: msgqueue.c:412
#define TRUE
Definition: types.h:120
ULONG NTAPI GreSetPointerShape(_In_ HDC hdc, _In_opt_ HBITMAP hbmMask, _In_opt_ HBITMAP hbmColor, _In_ LONG xHot, _In_ LONG yHot, _In_ LONG x, _In_ LONG y, _In_ FLONG fl)
Definition: mouse.c:671
long y
Definition: polytest.cpp:48
HDC FASTCALL IntGetScreenDC(VOID)
Definition: winsta.c:347
HBITMAP hbmColor
Definition: cursoricon.h:20
long x
Definition: polytest.cpp:48
ULONG_PTR dwExtraInfo
Definition: winuser.h:3796
#define EngGetTickCount32()
Definition: eng.h:43
#define WM_MOUSEWHEEL
Definition: treelist.c:96
static HDC
Definition: imagelist.c:92
ULONG_PTR gdwMouseMoveExtraInfo
Definition: msgqueue.c:21
HWND FASTCALL IntGetCaptureWindow(VOID)
Definition: focus.c:32
PSERVERINFO gpsi
Definition: main.c:27
#define SPS_ALPHA
Definition: winddi.h:4039
#define WH_MOUSE_LL
Definition: winuser.h:44
PCURICON_OBJECT CurrentCursorObject
Definition: cursoricon.h:74
THRDESKHEAD head
Definition: ntuser.h:659
#define MAKELONG(a, b)
Definition: typedefs.h:248
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define QF_INDESTROY
Definition: msgqueue.h:103
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
#define TRACE(s)
Definition: solgame.cpp:4
VOID NTAPI GreMovePointer(_In_ HDC hdc, _In_ LONG x, _In_ LONG y)
Definition: mouse.c:767
PUSER_MESSAGE_QUEUE gpqCursor
Definition: msgqueue.c:20
PSYSTEM_CURSORINFO IntGetSysCursorInfo(VOID)
Definition: cursoricon.c:187
VOID FASTCALL MsqPostMessage(PTHREADINFO pti, MSG *Msg, BOOLEAN HardwareMessage, DWORD MessageBits, DWORD dwQEvent, LONG_PTR ExtraInfo)
Definition: msgqueue.c:1338
GLbitfield flags
Definition: glext.h:7161
VOID FASTCALL IntCoalesceMouseMove(PTHREADINFO pti)
Definition: msgqueue.c:551
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1103
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1349
#define QS_MOUSEMOVE
Definition: winuser.h:886
PCURICON_OBJECT CursorObject
Definition: msgqueue.h:89
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:88
#define HC_ACTION
Definition: winuser.h:48
#define WM_MOUSEMOVE
Definition: winuser.h:1757
#define QS_MOUSEBUTTON
Definition: winuser.h:885
HBITMAP hbmMask
Definition: cursoricon.h:19
HBITMAP hbmAlpha
Definition: cursoricon.h:21
PWND FASTCALL IntTopLevelWindowFromPoint(INT x, INT y)
Definition: msgqueue.c:61
struct @1587 Msg[]
#define HIWORD(l)
Definition: typedefs.h:246
PTHREADINFO ptiMouse
Definition: msgqueue.h:55
#define QF_MOUSEMOVED
Definition: msgqueue.h:99
#define LOWORD(l)
Definition: pedump.c:82
DWORD gdwMouseMoveTimeStamp
Definition: msgqueue.c:22

Referenced by co_UserDestroyWindow(), co_WinPosSetWindowPos(), IntDeactivateWindow(), UserAttachThreadInput(), UserSendMouseInput(), and UserSetCursorPos().

◆ co_MsqPeekHardwareMessage()

BOOL APIENTRY co_MsqPeekHardwareMessage ( IN PTHREADINFO  pti,
IN BOOL  Remove,
IN PWND  Window,
IN UINT  MsgFilterLow,
IN UINT  MsgFilterHigh,
IN UINT  QSflags,
OUT MSG pMsg 
)

Definition at line 1996 of file msgqueue.c.

2003 {
2004  BOOL AcceptMessage, NotForUs;
2005  PUSER_MESSAGE CurrentMessage;
2006  PLIST_ENTRY ListHead;
2007  MSG msg;
2008  ULONG_PTR idSave;
2009  DWORD QS_Flags;
2010  LONG_PTR ExtraInfo;
2011  BOOL Ret = FALSE;
2012  PUSER_MESSAGE_QUEUE MessageQueue = pti->MessageQueue;
2013 
2014  if (!filter_contains_hw_range( MsgFilterLow, MsgFilterHigh )) return FALSE;
2015 
2016  ListHead = MessageQueue->HardwareMessagesListHead.Flink;
2017 
2018  if (IsListEmpty(ListHead)) return FALSE;
2019 
2020  if (!MessageQueue->ptiSysLock)
2021  {
2022  MessageQueue->ptiSysLock = pti;
2023  pti->pcti->CTI_flags |= CTI_THREADSYSLOCK;
2024  }
2025 
2026  if (MessageQueue->ptiSysLock != pti)
2027  {
2028  ERR("Thread Q is locked to ptiSysLock 0x%p pti 0x%p\n",MessageQueue->ptiSysLock,pti);
2029  return FALSE;
2030  }
2031 
2032  while (ListHead != &MessageQueue->HardwareMessagesListHead)
2033  {
2034  CurrentMessage = CONTAINING_RECORD(ListHead, USER_MESSAGE, ListEntry);
2035  ListHead = ListHead->Flink;
2036 
2037  if (MessageQueue->idSysPeek == (ULONG_PTR)CurrentMessage)
2038  {
2039  TRACE("Skip this message due to it is in play!\n");
2040  continue;
2041  }
2042 /*
2043  MSDN:
2044  1: any window that belongs to the current thread, and any messages on the current thread's message queue whose hwnd value is NULL.
2045  2: retrieves only messages on the current thread's message queue whose hwnd value is NULL.
2046  3: handle to the window whose messages are to be retrieved.
2047  */
2048  if ( ( !Window || // 1
2049  ( Window == PWND_BOTTOM && CurrentMessage->Msg.hwnd == NULL ) || // 2
2050  ( Window != PWND_BOTTOM && Window->head.h == CurrentMessage->Msg.hwnd ) || // 3
2051  ( is_mouse_message(CurrentMessage->Msg.message) ) ) && // Null window for anything mouse.
2052  ( ( ( MsgFilterLow == 0 && MsgFilterHigh == 0 ) && CurrentMessage->QS_Flags & QSflags ) ||
2053  ( MsgFilterLow <= CurrentMessage->Msg.message && MsgFilterHigh >= CurrentMessage->Msg.message ) ) )
2054  {
2055  idSave = MessageQueue->idSysPeek;
2056  MessageQueue->idSysPeek = (ULONG_PTR)CurrentMessage;
2057 
2058  msg = CurrentMessage->Msg;
2059  ExtraInfo = CurrentMessage->ExtraInfo;
2060  QS_Flags = CurrentMessage->QS_Flags;
2061 
2062  NotForUs = FALSE;
2063 
2064  UpdateKeyStateFromMsg(MessageQueue, &msg);
2065  AcceptMessage = co_IntProcessHardwareMessage(&msg, &Remove, &NotForUs, ExtraInfo, MsgFilterLow, MsgFilterHigh);
2066 
2067  if (Remove)
2068  {
2069  if (CurrentMessage->pti != NULL && (MessageQueue->idSysPeek == (ULONG_PTR)CurrentMessage))
2070  {
2071  MsqDestroyMessage(CurrentMessage);
2072  }
2073  ClearMsgBitsMask(pti, QS_Flags);
2074  }
2075 
2076  MessageQueue->idSysPeek = idSave;
2077 
2078  if (NotForUs)
2079  {
2080  Ret = FALSE;
2081  break;
2082  }
2083 
2084  if (AcceptMessage)
2085  {
2086  *pMsg = msg;
2087  // Fix all but one wine win:test_GetMessagePos WM_TIMER tests. See PostTimerMessages.
2088  if (!RtlEqualMemory(&pti->ptLast, &msg.pt, sizeof(POINT)))
2089  {
2090  pti->TIF_flags |= TIF_MSGPOSCHANGED;
2091  }
2092  pti->timeLast = msg.time;
2093  pti->ptLast = msg.pt;
2094  MessageQueue->ExtraInfo = ExtraInfo;
2095  Ret = TRUE;
2096  break;
2097  }
2098  }
2099  }
2100 
2101  MessageQueue->ptiSysLock = NULL;
2102  pti->pcti->CTI_flags &= ~CTI_THREADSYSLOCK;
2103  return Ret;
2104 }
static VOID UpdateKeyStateFromMsg(PUSER_MESSAGE_QUEUE MessageQueue, MSG *msg)
Definition: msgqueue.c:265
#define TRUE
Definition: types.h:120
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define PWND_BOTTOM
Definition: ntuser.h:731
static INT FASTCALL filter_contains_hw_range(UINT first, UINT last)
Definition: msgqueue.c:1970
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
uint32_t ULONG_PTR
Definition: typedefs.h:63
VOID FASTCALL MsqDestroyMessage(PUSER_MESSAGE Message)
Definition: msgqueue.c:748
Definition: window.c:28
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
BOOL co_IntProcessHardwareMessage(MSG *Msg, BOOL *RemoveMessages, BOOL *NotForUs, LONG_PTR ExtraInfo, UINT first, UINT last)
Definition: msgqueue.c:1954
_In_ BOOLEAN Remove
Definition: psfuncs.h:110
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:90
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define TRACE(s)
Definition: solgame.cpp:4
#define CTI_THREADSYSLOCK
Definition: ntuser.h:160
VOID FASTCALL ClearMsgBitsMask(PTHREADINFO pti, UINT MessageBits)
Definition: msgqueue.c:445
NTSYSAPI ULONG NTAPI RtlEqualMemory(CONST VOID *Source1, CONST VOID *Source2, ULONG Length)
unsigned long DWORD
Definition: ntddk_ex.h:95
PTHREADINFO ptiSysLock
Definition: msgqueue.h:52
ULONG_PTR idSysPeek
Definition: msgqueue.h:54
Definition: typedefs.h:117
#define TIF_MSGPOSCHANGED
Definition: ntuser.h:260
#define ERR(fmt,...)
Definition: debug.h:109
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define msg(x)
Definition: auth_time.c:54
struct @1587 Msg[]
#define ULONG_PTR
Definition: config.h:101
static BOOL is_mouse_message(UINT message)
Definition: msgqueue.c:1986
LIST_ENTRY HardwareMessagesListHead
Definition: msgqueue.h:59

Referenced by co_IntPeekMessage().

◆ co_MsqReplyMessage()

BOOL FASTCALL co_MsqReplyMessage ( LRESULT  )

Definition at line 2529 of file msgqueue.c.

2530 {
2532  PTHREADINFO pti;
2533 
2535  Message = pti->pusmCurrent;
2536 
2537  if (!Message) return FALSE;
2538 
2539  if (Message->QS_Flags & QS_SMRESULT) return FALSE;
2540 
2541  // SendMessageXxx || Callback msg and not a notify msg
2542  if (Message->ptiSender || Message->CompletionCallback)
2543  {
2544  Message->lResult = lResult;
2545  Message->QS_Flags |= QS_SMRESULT;
2546  // See co_MsqDispatchOneSentMessage, change bits already accounted for and cleared and this msg is going away..
2547  }
2548  return TRUE;
2549 }
#define TRUE
Definition: types.h:120
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
#define QS_SMRESULT
Definition: undocuser.h:93
struct _USER_SENT_MESSAGE * pusmCurrent
Definition: win32.h:97
CHAR Message[80]
Definition: alive.c:5

Referenced by NtUserCallOneParam().

◆ co_MsqSendMessage()

NTSTATUS FASTCALL co_MsqSendMessage ( PTHREADINFO  ptirec,
HWND  Wnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam,
UINT  uTimeout,
BOOL  Block,
INT  HookMessage,
ULONG_PTR uResult 
)

Definition at line 1057 of file msgqueue.c.

1066 {
1067  PTHREADINFO pti;
1068  PUSER_SENT_MESSAGE SaveMsg, Message;
1069  NTSTATUS WaitStatus;
1072  PWND pWnd;
1073  BOOLEAN SwapStateEnabled;
1074  LRESULT Result = 0;
1075 
1077  ASSERT(pti != ptirec);
1078  ASSERT(ptirec->pcti); // Send must have a client side to receive it!!!!
1079 
1080  /* Don't send from or to a dying thread */
1081  if (pti->TIF_flags & TIF_INCLEANUP || ptirec->TIF_flags & TIF_INCLEANUP)
1082  {
1083  // Unless we are dying and need to tell our parents.
1084  if (pti->TIF_flags & TIF_INCLEANUP && !(ptirec->TIF_flags & TIF_INCLEANUP))
1085  {
1086  // Parent notify is the big one. Fire and forget!
1087  TRACE("Send message from dying thread %u\n", Msg);
1088  co_MsqSendMessageAsync(ptirec, Wnd, Msg, wParam, lParam, NULL, 0, FALSE, HookMessage);
1089  }
1090  if (uResult) *uResult = -1;
1091  TRACE("MsqSM: Msg %u Current pti %lu or Rec pti %lu\n", Msg, pti->TIF_flags & TIF_INCLEANUP, ptirec->TIF_flags & TIF_INCLEANUP);
1092  return STATUS_UNSUCCESSFUL;
1093  }
1094 
1095  if (IsThreadSuspended(ptirec))
1096  {
1097  ERR("Sending to Suspended Thread Msg %lx\n",Msg);
1098  if (uResult) *uResult = -1;
1099  return STATUS_UNSUCCESSFUL;
1100  }
1101 
1102  // Should we do the same for No Wait?
1103  if ( HookMessage == MSQ_NORMAL )
1104  {
1105  pWnd = ValidateHwndNoErr(Wnd);
1106 
1107  // These can not cross International Border lines!
1108  if ( pti->ppi != ptirec->ppi && pWnd )
1109  {
1110  switch(Msg)
1111  {
1112  // Handle the special case when working with password transfers across bordering processes.
1113  case EM_GETLINE:
1114  case EM_SETPASSWORDCHAR:
1115  case WM_GETTEXT:
1116  // Look for edit controls setup for passwords.
1117  if ( gpsi->atomSysClass[ICLS_EDIT] == pWnd->pcls->atomClassName && // Use atomNVClassName.
1118  pWnd->style & ES_PASSWORD )
1119  {
1120  if (uResult) *uResult = -1;
1121  ERR("Running across the border without a passport!\n");
1123  return STATUS_UNSUCCESSFUL;
1124  }
1125  break;
1126  case WM_NOTIFY:
1127  if (uResult) *uResult = -1;
1128  ERR("Running across the border without a passport!\n");
1129  return STATUS_UNSUCCESSFUL;
1130  }
1131  }
1132 
1133  // These can not cross State lines!
1134  if ( Msg == WM_CREATE || Msg == WM_NCCREATE )
1135  {
1136  if (uResult) *uResult = -1;
1137  ERR("Can not tell the other State we have Create!\n");
1138  return STATUS_UNSUCCESSFUL;
1139  }
1140  }
1141 
1142  if(!(Message = AllocateUserMessage(TRUE)))
1143  {
1144  ERR("MsqSendMessage(): Not enough memory to allocate a message\n");
1145  if (uResult) *uResult = -1;
1147  }
1148 
1149  Timeout.QuadPart = Int32x32To64(-10000,uTimeout); // Pass SMTO test with a TO of 0x80000000.
1150  TRACE("Timeout val %lld\n",Timeout.QuadPart);
1151 
1152  Message->Msg.hwnd = Wnd;
1153  Message->Msg.message = Msg;
1154  Message->Msg.wParam = wParam;
1155  Message->Msg.lParam = lParam;
1156  Message->ptiReceiver = ptirec;
1157  Message->ptiSender = pti;
1158  Message->HookMessage = HookMessage;
1159  Message->QS_Flags = QS_SENDMESSAGE;
1160 
1161  SaveMsg = pti->pusmSent;
1162  pti->pusmSent = Message;
1163 
1164  /* Queue it in the destination's message queue */
1165  InsertTailList(&ptirec->SentMessagesListHead, &Message->ListEntry);
1166 
1167  MsqWakeQueue(ptirec, QS_SENDMESSAGE, TRUE);
1168 
1169  // First time in, turn off swapping of the stack.
1170  if (pti->cEnterCount == 0)
1171  {
1172  SwapStateEnabled = KeSetKernelStackSwapEnable(FALSE);
1173  }
1174  pti->cEnterCount++;
1175 
1176  if (Block)
1177  {
1178  PVOID WaitObjects[2];
1179 
1180  WaitObjects[0] = Message->pkCompletionEvent; // Wait 0
1181  WaitObjects[1] = ptirec->pEThread; // Wait 1
1182 
1183  UserLeaveCo();
1184 
1185  WaitStatus = KeWaitForMultipleObjects( 2,
1186  WaitObjects,
1187  WaitAny,
1188  UserRequest,
1189  UserMode,
1190  FALSE,
1191  (uTimeout ? &Timeout : NULL),
1192  NULL );
1193 
1194  UserEnterCo();
1195 
1196  if (WaitStatus == STATUS_TIMEOUT)
1197  {
1198  /* Look up if the message has not yet dispatched, if so
1199  make sure it can't pass a result and it must not set the completion event anymore */
1200  Entry = ptirec->SentMessagesListHead.Flink;
1201  while (Entry != &ptirec->SentMessagesListHead)
1202  {
1203  if (CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, ListEntry) == Message)
1204  {
1205  Message->pkCompletionEvent = NULL;
1206  RemoveEntryList(&Message->ListEntry);
1207  ClearMsgBitsMask(ptirec, Message->QS_Flags);
1208  InsertTailList(&usmList, &Message->ListEntry);
1209  break;
1210  }
1211  Entry = Entry->Flink;
1212  }
1213 
1214  ERR("MsqSendMessage (blocked) timed out 1 Status %lx\n", WaitStatus);
1215  }
1216  // Receiving thread passed on and left us hanging with issues still pending.
1217  else if (WaitStatus == STATUS_WAIT_1)
1218  {
1219  ERR("Bk Receiving Thread woken up dead!\n");
1220  Message->flags |= SMF_RECEIVERDIED;
1221  }
1222 
1223  while (co_MsqDispatchOneSentMessage(pti))
1224  ;
1225  }
1226  else
1227  {
1228  PVOID WaitObjects[3];
1229 
1230  WaitObjects[0] = Message->pkCompletionEvent; // Wait 0
1231  WaitObjects[1] = pti->pEventQueueServer; // Wait 1
1232  WaitObjects[2] = ptirec->pEThread; // Wait 2
1233 
1234  do
1235  {
1236  UserLeaveCo();
1237 
1238  WaitStatus = KeWaitForMultipleObjects( 3,
1239  WaitObjects,
1240  WaitAny,
1241  UserRequest,
1242  UserMode,
1243  FALSE,
1244  (uTimeout ? &Timeout : NULL),
1245  NULL);
1246 
1247  UserEnterCo();
1248 
1249  if (WaitStatus == STATUS_TIMEOUT)
1250  {
1251  /* Look up if the message has not yet been dispatched, if so
1252  make sure it can't pass a result and it must not set the completion event anymore */
1253  Entry = ptirec->SentMessagesListHead.Flink;
1254  while (Entry != &ptirec->SentMessagesListHead)
1255  {
1256  if (CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, ListEntry) == Message)
1257  {
1258  Message->pkCompletionEvent = NULL;
1259  RemoveEntryList(&Message->ListEntry);
1260  ClearMsgBitsMask(ptirec, Message->QS_Flags);
1261  InsertTailList(&usmList, &Message->ListEntry);
1262  break;
1263  }
1264  Entry = Entry->Flink;
1265  }
1266 
1267  ERR("MsqSendMessage timed out 2 Status %lx\n", WaitStatus);
1268  break;
1269  }
1270  // Receiving thread passed on and left us hanging with issues still pending.
1271  else if (WaitStatus == STATUS_WAIT_2)
1272  {
1273  ERR("NB Receiving Thread woken up dead!\n");
1274  Message->flags |= SMF_RECEIVERDIED;
1275  break;
1276  }
1277 
1278  if (WaitStatus == STATUS_USER_APC) break;
1279 
1280  while (co_MsqDispatchOneSentMessage(pti))
1281  ;
1282  } while (WaitStatus == STATUS_WAIT_1);
1283  }
1284 
1285  // Count is nil, restore swapping of the stack.
1286  if (--pti->cEnterCount == 0 )
1287  {
1288  KeSetKernelStackSwapEnable(SwapStateEnabled);
1289  }
1290 
1291  // Handle User APC
1292  if (WaitStatus == STATUS_USER_APC)
1293  {
1294  // The current thread is dying!
1295  TRACE("User APC\n");
1296 
1297  // The Message will be on the Trouble list until Thread cleanup.
1298  Message->flags |= SMF_SENDERDIED;
1299 
1301  ERR("User APC Returned\n"); // Should not see this message.
1302  }
1303 
1304  // Force this thread to wake up for the next go around.
1306 
1307  Result = Message->lResult;
1308 
1309  // Determine whether this message is being processed or not.
1311  {
1312  Message->flags |= SMF_RECEIVERFREE;
1313  }
1314 
1315  if (!(Message->flags & SMF_RECEIVERFREE))
1316  {
1317  TRACE("Sender Freeing Message %p ptirec %p bit %d list empty %d\n",Message,ptirec,!!(ptirec->pcti->fsChangeBits & QS_SENDMESSAGE),IsListEmpty(&ptirec->SentMessagesListHead));
1318  // Make it to this point, the message was received.
1320  }
1321 
1322  pti->pusmSent = SaveMsg;
1323 
1324  TRACE("MSM Allocation Count %d Status %lx Result %d\n",SendMsgCount,WaitStatus,Result);
1325 
1326  if (WaitStatus != STATUS_TIMEOUT)
1327  {
1328  if (uResult)
1329  {
1330  *uResult = (STATUS_WAIT_0 == WaitStatus ? Result : 0);
1331  }
1332  }
1333 
1334  return WaitStatus;
1335 }
VOID FASTCALL MsqWakeQueue(PTHREADINFO pti, DWORD MessageBits, BOOL KeyEvent)
Definition: msgqueue.c:412
#define TRUE
Definition: types.h:120
struct _USER_SENT_MESSAGE * pusmSent
Definition: win32.h:96
PWND FASTCALL ValidateHwndNoErr(HWND hWnd)
Definition: window.c:96
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct _Entry Entry
Definition: kefuncs.h:627
BOOLEAN FASTCALL co_MsqDispatchOneSentMessage(_In_ PTHREADINFO pti)
Definition: msgqueue.c:873
FLONG TIF_flags
Definition: win32.h:94
#define WM_GETTEXT
Definition: winuser.h:1600
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
LONG NTSTATUS
Definition: precomp.h:26
#define ICLS_EDIT
Definition: ntuser.h:874
#define SMF_SENDERDIED
Definition: msgqueue.h:39
#define InsertTailList(ListHead, Entry)
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define WM_NCCREATE
Definition: winuser.h:1665
RTL_ATOM atomClassName
Definition: ntuser.h:536
PSERVERINFO gpsi
Definition: main.c:27
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
WPARAM wParam
Definition: combotst.c:138
PPROCESSINFO ppi
Definition: win32.h:87
INT SendMsgCount
Definition: msgqueue.c:19
#define ES_PASSWORD
Definition: pedump.c:670
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
#define STATUS_WAIT_2
Definition: ntstatus.h:72
#define STATUS_WAIT_1
Definition: ntstatus.h:71
BOOL FASTCALL co_MsqSendMessageAsync(PTHREADINFO ptiReceiver, HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam, SENDASYNCPROC CompletionCallback, ULONG_PTR CompletionCallbackContext, BOOL HasPackedLParam, INT HookMessage)
Definition: msgqueue.c:1014
VOID FASTCALL co_IntDeliverUserAPC(VOID)
Definition: callback.c:1146
#define STATUS_WAIT_0
Definition: ntstatus.h:223
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
LIST_ENTRY SentMessagesListHead
Definition: win32.h:99
#define UserLeaveCo
Definition: ntuser.h:10
#define SMF_RECEIVERFREE
Definition: msgqueue.h:40
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define QS_SENDMESSAGE
Definition: winuser.h:892
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:90
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define SMF_RECEIVERBUSY
Definition: msgqueue.h:42
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define TRACE(s)
Definition: solgame.cpp:4
VOID FASTCALL ClearMsgBitsMask(PTHREADINFO pti, UINT MessageBits)
Definition: msgqueue.c:445
#define EM_SETPASSWORDCHAR
Definition: winuser.h:1996
PKEVENT pEventQueueServer
Definition: win32.h:124
VOID FASTCALL FreeUserMessage(PUSER_SENT_MESSAGE Message)
Definition: msgqueue.c:786
#define UserEnterCo
Definition: ntuser.h:9
NTSTATUS NTAPI KeWaitForMultipleObjects(IN ULONG Count, IN PVOID Object[], IN WAIT_TYPE WaitType, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL, OUT PKWAIT_BLOCK WaitBlockArray OPTIONAL)
Definition: wait.c:586
#define SMF_RECEIVERDIED
Definition: msgqueue.h:38
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
CHAR Message[80]
Definition: alive.c:5
PUSER_SENT_MESSAGE FASTCALL AllocateUserMessage(BOOL KEvent)
Definition: msgqueue.c:763
Definition: typedefs.h:117
#define STATUS_USER_APC
Definition: ntstatus.h:78
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
#define MSQ_NORMAL
Definition: msgqueue.h:4
static ULONG Timeout
Definition: ping.c:61
BOOL FASTCALL IsThreadSuspended(PTHREADINFO pti)
Definition: msgqueue.c:2225
struct @1587 Msg[]
#define WM_CREATE
Definition: winuser.h:1590
#define EM_GETLINE
Definition: winuser.h:1973
#define IO_NO_INCREMENT
Definition: iotypes.h:566
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139
INT cEnterCount
Definition: win32.h:130
#define TIF_INCLEANUP
Definition: ntuser.h:240
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
base of all file and directory entries
Definition: entries.h:82
#define Int32x32To64(a, b)
#define WM_NOTIFY
Definition: richedit.h:61
#define SMF_RECEIVEDMESSAGE
Definition: msgqueue.h:41
BOOLEAN NTAPI KeSetKernelStackSwapEnable(IN BOOLEAN Enable)
Definition: thrdobj.c:997
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1013
LIST_ENTRY usmList
Definition: msgqueue.c:23
PCLS pcls
Definition: ntuser.h:684
DWORD style
Definition: ntuser.h:670

Referenced by co_IntCallLowLevelHook(), and co_IntSendMessageTimeoutSingle().

◆ co_MsqSendMessageAsync()

BOOL FASTCALL co_MsqSendMessageAsync ( PTHREADINFO  ptiReceiver,
HWND  hwnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam,
SENDASYNCPROC  CompletionCallback,
ULONG_PTR  CompletionCallbackContext,
BOOL  HasPackedLParam,
INT  HookMessage 
)

Definition at line 1014 of file msgqueue.c.

1023 {
1024 
1025  PTHREADINFO ptiSender;
1027 
1029  {
1030  ERR("MsqSendMessageAsync(): Not enough memory to allocate a message");
1031  return FALSE;
1032  }
1033 
1034  ptiSender = PsGetCurrentThreadWin32Thread();
1035 
1036  Message->Msg.hwnd = hwnd;
1037  Message->Msg.message = Msg;
1038  Message->Msg.wParam = wParam;
1039  Message->Msg.lParam = lParam;
1040  Message->pkCompletionEvent = NULL; // No event needed.
1041  Message->ptiReceiver = ptiReceiver;
1042  Message->ptiCallBackSender = ptiSender;
1043  Message->CompletionCallback = CompletionCallback;
1044  Message->CompletionCallbackContext = CompletionCallbackContext;
1045  Message->HookMessage = HookMessage;
1046  Message->HasPackedLParam = HasPackedLParam;
1047  Message->QS_Flags = QS_SENDMESSAGE;
1048  Message->flags = SMF_RECEIVERFREE;
1049 
1050  InsertTailList(&ptiReceiver->SentMessagesListHead, &Message->ListEntry);
1051  MsqWakeQueue(ptiReceiver, QS_SENDMESSAGE, TRUE);
1052 
1053  return TRUE;
1054 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
VOID FASTCALL MsqWakeQueue(PTHREADINFO pti, DWORD MessageBits, BOOL KeyEvent)
Definition: msgqueue.c:412
#define TRUE
Definition: types.h:120
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
#define InsertTailList(ListHead, Entry)
WPARAM wParam
Definition: combotst.c:138
LIST_ENTRY SentMessagesListHead
Definition: win32.h:99
#define SMF_RECEIVERFREE
Definition: msgqueue.h:40
smooth NULL
Definition: ftsmooth.c:416
#define QS_SENDMESSAGE
Definition: winuser.h:892
CHAR Message[80]
Definition: alive.c:5
PUSER_SENT_MESSAGE FASTCALL AllocateUserMessage(BOOL KEvent)
Definition: msgqueue.c:763
#define ERR(fmt,...)
Definition: debug.h:109
struct @1587 Msg[]
const TCHAR * CompletionCallback(unsigned __int64 &rnIndex, const BOOL *pblnForward, const TCHAR *pszContext, const TCHAR *pszBegin)
Definition: Completion.cpp:439
LPARAM lParam
Definition: combotst.c:139

Referenced by co_MsqSendMessage(), IntHookModuleUnloaded(), and UserRegisterUserApiHook().

◆ co_MsqWaitForNewMessages()

NTSTATUS FASTCALL co_MsqWaitForNewMessages ( PTHREADINFO  pti,
PWND  WndFilter,
UINT  MsgFilterMin,
UINT  MsgFilterMax 
)

Definition at line 2164 of file msgqueue.c.

2166 {
2168 
2169  // Post mouse moves before waiting for messages.
2170  if (pti->MessageQueue->QF_flags & QF_MOUSEMOVED)
2171  {
2172  IntCoalesceMouseMove(pti);
2173  }
2174 
2175  UserLeaveCo();
2176 
2177  ZwYieldExecution(); // Let someone else run!
2178 
2180  UserRequest,
2181  UserMode,
2182  FALSE,
2183  NULL );
2184  UserEnterCo();
2185  if ( ret == STATUS_USER_APC )
2186  {
2187  TRACE("MWFNW User APC\n");
2189  }
2190  return ret;
2191 }
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
VOID FASTCALL co_IntDeliverUserAPC(VOID)
Definition: callback.c:1146
#define UserLeaveCo
Definition: ntuser.h:10
NTSYSAPI NTSTATUS NTAPI ZwYieldExecution(VOID)
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
PKEVENT pEventQueueServer
Definition: win32.h:124
#define UserEnterCo
Definition: ntuser.h:9
VOID FASTCALL IntCoalesceMouseMove(PTHREADINFO pti)
Definition: msgqueue.c:551
int ret
#define STATUS_USER_APC
Definition: ntstatus.h:78
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:88
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define QF_MOUSEMOVED
Definition: msgqueue.h:99

Referenced by co_IntGetPeekMessage(), and co_IntWaitMessage().

◆ FreeUserMessage()

VOID FASTCALL FreeUserMessage ( PUSER_SENT_MESSAGE  )

Definition at line 786 of file msgqueue.c.

787 {
788  Message->pkCompletionEvent = NULL;
789 
790  /* Remove it from the list */
791  RemoveEntryList(&Message->ListEntry);
792 
793  ExFreeToPagedLookasideList(pgSendMsgLookasideList, Message);
794  SendMsgCount--;
795 }
INT SendMsgCount
Definition: msgqueue.c:19
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
smooth NULL
Definition: ftsmooth.c:416
CHAR Message[80]
Definition: alive.c:5
static PPAGED_LOOKASIDE_LIST pgSendMsgLookasideList
Definition: msgqueue.c:17

Referenced by co_MsqDispatchOneSentMessage(), co_MsqSendMessage(), MsqCleanupThreadMsgs(), and MsqRemoveWindowMessagesFromQueue().

◆ HungAppSysTimerProc()

VOID CALLBACK HungAppSysTimerProc ( HWND  ,
UINT  ,
UINT_PTR  ,
DWORD   
)

Definition at line 2238 of file msgqueue.c.

2239 {
2240  DoTheScreenSaver();
2241  TRACE("HungAppSysTimerProc\n");
2242  // Process list of windows that are hung and waiting.
2243 }
#define TRACE(s)
Definition: solgame.cpp:4
VOID FASTCALL DoTheScreenSaver(VOID)
Definition: input.c:48

Referenced by StartTheTimers().

◆ IdlePing()

VOID FASTCALL IdlePing ( VOID  )

Definition at line 515 of file message.c.

516 {
518  PTHREADINFO pti;
519 
521 
522  if ( pti )
523  {
524  pti->pClientInfo->cSpins = 0; // Reset spins.
525 
526  if ( pti->pDeskInfo && pti == gptiForeground )
527  {
529  pti->pDeskInfo->fsHooks & HOOKID_TO_FLAG(WH_FOREGROUNDIDLE) )
530  {
532  }
533  }
534  }
535 
536  TRACE("IdlePing ppi %p\n", ppi);
537  if ( ppi && ppi->InputIdleEvent )
538  {
539  TRACE("InputIdleEvent\n");
540  KeSetEvent( ppi->InputIdleEvent, IO_NO_INCREMENT, FALSE);
541  }
542 }
#define HOOKID_TO_FLAG(HookId)
Definition: hook.h:5
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define WH_FOREGROUNDIDLE
Definition: winuser.h:41
PTHREADINFO gptiForeground
Definition: focus.c:14
#define TRACE(s)
Definition: solgame.cpp:4
ULONG fsHooks
Definition: win32.h:116
struct _CLIENTINFO * pClientInfo
Definition: win32.h:93
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1103
#define HC_ACTION
Definition: winuser.h:48
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
#define IO_NO_INCREMENT
Definition: iotypes.h:566
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:92

Referenced by co_IntGetPeekMessage(), and IntMsqSetWakeMask().

◆ IdlePong()

VOID FASTCALL IdlePong ( VOID  )

Definition at line 545 of file message.c.

546 {
548 
549  TRACE("IdlePong ppi %p\n", ppi);
550  if ( ppi && ppi->InputIdleEvent )
551  {
552  KeClearEvent(ppi->InputIdleEvent);
553  }
554 }
#define TRACE(s)
Definition: solgame.cpp:4
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22

Referenced by co_IntGetPeekMessage(), co_IntPeekMessage(), and IntMsqClearWakeMask().

◆ IntCallMsgFilter()

BOOL FASTCALL IntCallMsgFilter ( LPMSG  ,
INT   
)

Definition at line 1975 of file message.c.

1976 {
1977  BOOL Ret = FALSE;
1978 
1979  if ( co_HOOK_CallHooks( WH_SYSMSGFILTER, code, 0, (LPARAM)lpmsg))
1980  {
1981  Ret = TRUE;
1982  }
1983  else
1984  {
1985  Ret = co_HOOK_CallHooks( WH_MSGFILTER, code, 0, (LPARAM)lpmsg);
1986  }
1987  return Ret;
1988 }
#define TRUE
Definition: types.h:120
#define WH_MSGFILTER
Definition: winuser.h:29
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG_PTR LPARAM
Definition: windef.h:208
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1103
#define WH_SYSMSGFILTER
Definition: winuser.h:36

Referenced by DefWndDoSizeMove(), DefWndStartSizeMove(), MENU_TrackMenu(), NC_DoButton(), and NC_HandleNCRButtonDown().

◆ IntCoalesceMouseMove()

VOID FASTCALL IntCoalesceMouseMove ( PTHREADINFO  )

Definition at line 551 of file msgqueue.c.

552 {
553  MSG Msg;
554 
555  // Force time stamp to update, keeping message time in sync.
556  if (gdwMouseMoveTimeStamp == 0)
557  {
559  }
560 
561  // Build mouse move message.
562  Msg.hwnd = NULL;
563  Msg.message = WM_MOUSEMOVE;
564  Msg.wParam = 0;
565  Msg.lParam = MAKELONG(gpsi->ptCursor.x, gpsi->ptCursor.y);
566  Msg.time = gdwMouseMoveTimeStamp;
567  Msg.pt = gpsi->ptCursor;
568 
569  // Post the move.
571 
572  // Zero the time stamp.
574 
575  // Clear flag since the move was posted.
576  pti->MessageQueue->QF_flags &= ~QF_MOUSEMOVED;
577 }
#define EngGetTickCount32()
Definition: eng.h:43
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
ULONG_PTR gdwMouseMoveExtraInfo
Definition: msgqueue.c:21
PSERVERINFO gpsi
Definition: main.c:27
#define MAKELONG(a, b)
Definition: typedefs.h:248
smooth NULL
Definition: ftsmooth.c:416
VOID FASTCALL MsqPostMouseMove(PTHREADINFO pti, MSG *Msg, LONG_PTR ExtraInfo)
Definition: msgqueue.c:518
#define WM_MOUSEMOVE
Definition: winuser.h:1757
struct @1587 Msg[]
#define QF_MOUSEMOVED
Definition: msgqueue.h:99
DWORD gdwMouseMoveTimeStamp
Definition: msgqueue.c:22

Referenced by co_IntPeekMessage(), co_MsqInsertMouseMessage(), co_MsqWaitForNewMessages(), and ProcessKeyEvent().

◆ IntDispatchMessage()

LRESULT FASTCALL IntDispatchMessage ( MSG Msg)

◆ IntGetQueueStatus()

DWORD APIENTRY IntGetQueueStatus ( DWORD  )

Definition at line 1924 of file message.c.

1925 {
1926  PTHREADINFO pti;
1927  DWORD Result;
1928 
1930 // wine:
1932 
1933  /* High word, types of messages currently in the queue.
1934  Low word, types of messages that have been added to the queue and that
1935  are still in the queue
1936  */
1937  Result = MAKELONG(pti->pcti->fsChangeBits & Changes, pti->pcti->fsWakeBits & Changes);
1938 
1939  pti->pcti->fsChangeBits &= ~Changes;
1940 
1941  return Result;
1942 }
#define QS_ALLPOSTMESSAGE
Definition: winuser.h:876
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
#define QS_SMRESULT
Definition: undocuser.h:93
#define MAKELONG(a, b)
Definition: typedefs.h:248
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:90
unsigned long DWORD
Definition: ntddk_ex.h:95
#define QS_ALLINPUT
Definition: winuser.h:874

Referenced by NtUserCallOneParam(), and NtUserGetThreadState().

◆ IntInitMessagePumpHook()

BOOL APIENTRY IntInitMessagePumpHook ( VOID  )

Definition at line 1945 of file message.c.

1946 {
1948 
1949  if (pti->pcti)
1950  {
1951  pti->pcti->dwcPumpHook++;
1952  return TRUE;
1953  }
1954  return FALSE;
1955 }
#define TRUE
Definition: types.h:120
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:90

Referenced by NtUserCallNoParam().

◆ IntMsqClearWakeMask()

BOOL FASTCALL IntMsqClearWakeMask ( VOID  )

Definition at line 392 of file msgqueue.c.

393 {
394  PTHREADINFO Win32Thread;
395 
396  Win32Thread = PsGetCurrentThreadWin32Thread();
397  if (Win32Thread == NULL || Win32Thread->MessageQueue == NULL)
398  return FALSE;
399  // Very hacky, but that is what they do.
400  Win32Thread->pcti->fsWakeBits = 0;
401 
402  IdlePong();
403 
404  return TRUE;
405 }
#define TRUE
Definition: types.h:120
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
smooth NULL
Definition: ftsmooth.c:416
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:90
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:88
VOID FASTCALL IdlePong(VOID)
Definition: message.c:545

Referenced by NtUserCallNoParam().

◆ IntMsqSetWakeMask()

HANDLE FASTCALL IntMsqSetWakeMask ( DWORD  WakeMask)

Definition at line 362 of file msgqueue.c.

363 {
364  PTHREADINFO Win32Thread;
365  HANDLE MessageEventHandle;
366  DWORD dwFlags = HIWORD(WakeMask);
367 
368  Win32Thread = PsGetCurrentThreadWin32Thread();
369  if (Win32Thread == NULL || Win32Thread->MessageQueue == NULL)
370  return 0;
371 
372 // Win32Thread->pEventQueueServer; IntMsqSetWakeMask returns Win32Thread->hEventQueueClient
373  MessageEventHandle = Win32Thread->hEventQueueClient;
374 
375  if (Win32Thread->pcti)
376  {
377  if ( (Win32Thread->pcti->fsChangeBits & LOWORD(WakeMask)) ||
378  ( (dwFlags & MWMO_INPUTAVAILABLE) && (Win32Thread->pcti->fsWakeBits & LOWORD(WakeMask)) ) )
379  {
380  ERR("Chg 0x%x Wake 0x%x Mask 0x%x\n",Win32Thread->pcti->fsChangeBits, Win32Thread->pcti->fsWakeBits, WakeMask);
381  KeSetEvent(Win32Thread->pEventQueueServer, IO_NO_INCREMENT, FALSE); // Wake it up!
382  return MessageEventHandle;
383  }
384  }
385 
386  IdlePing();
387 
388  return MessageEventHandle;
389 }
#define MWMO_INPUTAVAILABLE
Definition: winuser.h:900
VOID FASTCALL IdlePing(VOID)
Definition: message.c:515
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
smooth NULL
Definition: ftsmooth.c:416
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:90
PKEVENT pEventQueueServer
Definition: win32.h:124
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define ERR(fmt,...)
Definition: debug.h:109
HANDLE hEventQueueClient
Definition: win32.h:122
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:88
#define HIWORD(l)
Definition: typedefs.h:246
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define LOWORD(l)
Definition: pedump.c:82

Referenced by NtUserCallOneParam().

◆ IntTranslateKbdMessage()

BOOL FASTCALL IntTranslateKbdMessage ( LPMSG  lpMsg,
UINT  flags 
)

Definition at line 1136 of file keyboard.c.

1138 {
1139  PTHREADINFO pti;
1140  INT cch = 0, i;
1141  WCHAR wch[3] = { 0 };
1142  MSG NewMsg = { 0 };
1143  PKBDTABLES pKbdTbl;
1144  BOOL bResult = FALSE;
1145 
1146  switch(lpMsg->message)
1147  {
1148  case WM_KEYDOWN:
1149  case WM_KEYUP:
1150  case WM_SYSKEYDOWN:
1151  case WM_SYSKEYUP:
1152  break;
1153  default:
1154  return FALSE;
1155  }
1156 
1158 
1159  if (!pti->KeyboardLayout)
1160  {
1162  pti->pClientInfo->hKL = pti->KeyboardLayout ? pti->KeyboardLayout->hkl : NULL;
1163  pKbdTbl = pti->KeyboardLayout ? pti->KeyboardLayout->spkf->pKbdTbl : NULL;
1164  }
1165  else
1166  pKbdTbl = pti->KeyboardLayout->spkf->pKbdTbl;
1167  if (!pKbdTbl)
1168  return FALSE;
1169 
1170  if (lpMsg->message != WM_KEYDOWN && lpMsg->message != WM_SYSKEYDOWN)
1171  return FALSE;
1172 
1173  /* Init pt, hwnd and time msg fields */
1174  NewMsg.pt = gpsi->ptCursor;
1175  NewMsg.hwnd = lpMsg->hwnd;
1176  NewMsg.time = EngGetTickCount32();
1177 
1178  TRACE("Enter IntTranslateKbdMessage msg %s, vk %x\n",
1179  lpMsg->message == WM_SYSKEYDOWN ? "WM_SYSKEYDOWN" : "WM_KEYDOWN", lpMsg->wParam);
1180 
1181  if (lpMsg->wParam == VK_PACKET)
1182  {
1183  NewMsg.message = (lpMsg->message == WM_KEYDOWN) ? WM_CHAR : WM_SYSCHAR;
1184  NewMsg.wParam = HIWORD(lpMsg->lParam);
1185  NewMsg.lParam = LOWORD(lpMsg->lParam);
1186  MsqPostMessage(pti, &NewMsg, FALSE, QS_KEY, 0, 0);
1187  return TRUE;
1188  }
1189 
1190  cch = IntToUnicodeEx(lpMsg->wParam,
1191  HIWORD(lpMsg->lParam) & 0xFF,
1192  pti->MessageQueue->afKeyState,
1193  wch,
1194  sizeof(wch) / sizeof(wch[0]),
1195  0,
1196  pKbdTbl);
1197 
1198  if (cch)
1199  {
1200  if (cch > 0) /* Normal characters */
1201  NewMsg.message = (lpMsg->message == WM_KEYDOWN) ? WM_CHAR : WM_SYSCHAR;
1202  else /* Dead character */
1203  {
1204  cch = -cch;
1205  NewMsg.message =
1206  (lpMsg->message == WM_KEYDOWN) ? WM_DEADCHAR : WM_SYSDEADCHAR;
1207  }
1208  NewMsg.lParam = lpMsg->lParam;
1209 
1210  /* Send all characters */
1211  for (i = 0; i < cch; ++i)
1212  {
1213  TRACE("Msg: %x '%lc' (%04x) %08x\n", NewMsg.message, wch[i], wch[i], NewMsg.lParam);
1214  NewMsg.wParam = wch[i];
1215  MsqPostMessage(pti, &NewMsg, FALSE, QS_KEY, 0, 0);
1216  }
1217  bResult = TRUE;
1218  }
1219 
1220  TRACE("Leave IntTranslateKbdMessage ret %d, cch %d, msg %x, wch %x\n",
1221  bResult, cch, NewMsg.message, NewMsg.wParam);
1222  return bResult;
1223 }
#define TRUE
Definition: types.h:120
#define WM_CHAR
Definition: winuser.h:1699
#define EngGetTickCount32()
Definition: eng.h:43
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
WPARAM wParam
Definition: winuser.h:3091
PSERVERINFO gpsi
Definition: main.c:27
int32_t INT
Definition: typedefs.h:56
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WM_SYSCHAR
Definition: winuser.h:1703
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:201
smooth NULL
Definition: ftsmooth.c:416
#define WM_KEYDOWN
Definition: winuser.h:1697
LPARAM lParam
Definition: winuser.h:3092
#define WM_DEADCHAR
Definition: winuser.h:1700
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: kbd.h:95
#define WM_KEYUP
Definition: winuser.h:1698
static int APIENTRY IntToUnicodeEx(UINT wVirtKey, UINT wScanCode, PBYTE pKeyState, LPWSTR pwszBuff, int cchBuff, UINT wFlags, PKBDTABLES pKbdTbl)
Definition: keyboard.c:432
VOID FASTCALL MsqPostMessage(PTHREADINFO pti, MSG *Msg, BOOLEAN HardwareMessage, DWORD MessageBits, DWORD dwQEvent, LONG_PTR ExtraInfo)
Definition: msgqueue.c:1338
struct _CLIENTINFO * pClientInfo
Definition: win32.h:93
struct tagKL * KeyboardLayout
Definition: win32.h:89
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:88
#define WM_SYSDEADCHAR
Definition: winuser.h:1704
#define WM_SYSKEYUP
Definition: winuser.h:1702
PKL W32kGetDefaultKeyLayout(VOID)
Definition: kbdlayout.c:343
HWND hwnd
Definition: winuser.h:3089
#define WM_SYSKEYDOWN
Definition: winuser.h:1701
#define HIWORD(l)
Definition: typedefs.h:246
#define QS_KEY
Definition: winuser.h:883
UINT message
Definition: winuser.h:3090
#define LOWORD(l)
Definition: pedump.c:82

Referenced by DefWndDoSizeMove(), DefWndStartSizeMove(), MENU_TrackMenu(), and NtUserTranslateMessage().

◆ IntUninitMessagePumpHook()

BOOL APIENTRY IntUninitMessagePumpHook ( VOID  )

Definition at line 1958 of file message.c.

1959 {
1961 
1962  if (pti->pcti)
1963  {
1964  if (pti->pcti->dwcPumpHook <= 0)
1965  {
1966  return FALSE;
1967  }
1968  pti->pcti->dwcPumpHook--;
1969  return TRUE;
1970  }
1971  return FALSE;
1972 }
#define TRUE
Definition: types.h:120
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:90

Referenced by NtUserCallNoParam().

◆ IsThreadSuspended()

BOOL FASTCALL IsThreadSuspended ( PTHREADINFO  )

Definition at line 2225 of file msgqueue.c.

2226 {
2227  if (pti->pEThread)
2228  {
2229  BOOL Ret = TRUE;
2230  if (!(pti->pEThread->Tcb.SuspendCount) && !PsGetThreadFreezeCount(pti->pEThread)) Ret = FALSE;
2231  return Ret;
2232  }
2233  return FALSE;
2234 }
#define TRUE
Definition: types.h:120
unsigned int BOOL
Definition: ntddk_ex.h:94
ULONG NTAPI PsGetThreadFreezeCount(IN PETHREAD Thread)
Definition: thread.c:685

Referenced by co_MsqSendMessage(), and UpdateThreadWindows().

◆ lParamMemorySize()

UINT lParamMemorySize ( UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 243 of file message.c.

244 {
245  PMSGMEMORY MsgMemoryEntry = FindMsgMemory(Msg);
246  if(MsgMemoryEntry == NULL) return 0;
247  return MsgMemorySize(MsgMemoryEntry, wParam, lParam);
248 }
static PMSGMEMORY FASTCALL FindMsgMemory(UINT Msg)
Definition: message.c:145
WPARAM wParam
Definition: combotst.c:138
smooth NULL
Definition: ftsmooth.c:416
static UINT FASTCALL MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam)
Definition: message.c:164
struct @1587 Msg[]
LPARAM lParam
Definition: combotst.c:139

Referenced by co_IntCallHookProc().

◆ MsqCleanupThreadMsgs()

VOID FASTCALL MsqCleanupThreadMsgs ( PTHREADINFO  )

Definition at line 2266 of file msgqueue.c.

2267 {
2268  PLIST_ENTRY CurrentEntry;
2269  PUSER_MESSAGE CurrentMessage;
2270  PUSER_SENT_MESSAGE CurrentSentMessage;
2271 
2272  TRACE("MsqCleanupThreadMsgs %p\n",pti);
2273 
2274  // Clear it all out.
2275  if (pti->pcti)
2276  {
2277  pti->pcti->fsWakeBits = 0;
2278  pti->pcti->fsChangeBits = 0;
2279  }
2280 
2281  pti->nCntsQBits[QSRosKey] = 0;
2282  pti->nCntsQBits[QSRosMouseMove] = 0;
2283  pti->nCntsQBits[QSRosMouseButton] = 0;
2284  pti->nCntsQBits[QSRosPostMessage] = 0;
2285  pti->nCntsQBits[QSRosSendMessage] = 0;
2286  pti->nCntsQBits[QSRosHotKey] = 0;
2287  pti->nCntsQBits[QSRosEvent] = 0;
2288 
2289  /* cleanup posted messages */
2290  while (!IsListEmpty(&pti->PostedMessagesListHead))
2291  {
2292  CurrentEntry = pti->PostedMessagesListHead.Flink;
2293  CurrentMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, ListEntry);
2294  ERR("Thread Cleanup Post Messages %p\n",CurrentMessage);
2295  if (CurrentMessage->dwQEvent)
2296  {
2297  if (CurrentMessage->dwQEvent == POSTEVENT_NWE)
2298  {
2299  ExFreePoolWithTag( (PVOID)CurrentMessage->ExtraInfo, TAG_HOOK);
2300  }
2301  }
2302  MsqDestroyMessage(CurrentMessage);
2303  }
2304 
2305  /* remove the messages that have not yet been dispatched */
2306  while (!IsListEmpty(&pti->SentMessagesListHead))
2307  {
2308  CurrentEntry = pti->SentMessagesListHead.Flink;
2309  CurrentSentMessage = CONTAINING_RECORD(CurrentEntry, USER_SENT_MESSAGE, ListEntry);
2310 
2311  ERR("Thread Cleanup Sent Messages %p\n",CurrentSentMessage);
2312 
2313  /* wake the sender's thread */
2314  if (CurrentSentMessage->pkCompletionEvent != NULL)
2315  {
2316  KeSetEvent(CurrentSentMessage->pkCompletionEvent, IO_NO_INCREMENT, FALSE);
2317  }
2318 
2319  if (CurrentSentMessage->HasPackedLParam)
2320  {
2321  if (CurrentSentMessage->Msg.lParam)
2322  ExFreePool((PVOID)CurrentSentMessage->Msg.lParam);
2323  }
2324 
2325  /* free the message */
2326  FreeUserMessage(CurrentSentMessage);
2327  }
2328 
2329  // Process Trouble Message List
2330  if (!IsListEmpty(&usmList))
2331  {
2332  CurrentEntry = usmList.Flink;
2333  while (CurrentEntry != &usmList)
2334  {
2335  CurrentSentMessage = CONTAINING_RECORD(CurrentEntry, USER_SENT_MESSAGE, ListEntry);
2336  CurrentEntry = CurrentEntry->Flink;
2337 
2338  TRACE("Found troubled messages %p on the list\n",CurrentSentMessage);
2339 
2340  if ( pti == CurrentSentMessage->ptiReceiver )
2341  {
2342  if (CurrentSentMessage->HasPackedLParam)
2343  {
2344  if (CurrentSentMessage->Msg.lParam)
2345  ExFreePool((PVOID)CurrentSentMessage->Msg.lParam);
2346  }
2347 
2348  /* free the message */
2349  FreeUserMessage(CurrentSentMessage);
2350  }
2351  else if ( pti == CurrentSentMessage->ptiSender ||
2352  pti == CurrentSentMessage->ptiCallBackSender )
2353  {
2354  // Determine whether this message is being processed or not.
2355  if ((CurrentSentMessage->flags & (SMF_RECEIVERBUSY|SMF_RECEIVEDMESSAGE)) != SMF_RECEIVEDMESSAGE)
2356  {
2357  CurrentSentMessage->flags |= SMF_RECEIVERFREE;
2358  }
2359 
2360  if (!(CurrentSentMessage->flags & SMF_RECEIVERFREE))
2361  {
2362 
2363  if (CurrentSentMessage->HasPackedLParam)
2364  {
2365  if (CurrentSentMessage->Msg.lParam)
2366  ExFreePool((PVOID)CurrentSentMessage->Msg.lParam);
2367  }
2368 
2369  /* free the message */
2370  FreeUserMessage(CurrentSentMessage);
2371  }
2372  }
2373  }
2374  }
2375 }
PTHREADINFO ptiSender
Definition: msgqueue.h:28
PKEVENT pkCompletionEvent
Definition: msgqueue.h:25
#define TAG_HOOK
Definition: tags.h:5
LONG_PTR ExtraInfo
Definition: msgqueue.h:13
Definition: win32.h:40
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
VOID FASTCALL MsqDestroyMessage(PUSER_MESSAGE Message)
Definition: msgqueue.c:748
#define SMF_RECEIVERFREE
Definition: msgqueue.h:40
PTHREADINFO ptiReceiver
Definition: msgqueue.h:29
smooth NULL
Definition: ftsmooth.c:416
DWORD dwQEvent
Definition: msgqueue.h:14
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define SMF_RECEIVERBUSY
Definition: msgqueue.h:42
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define TRACE(s)
Definition: solgame.cpp:4
VOID FASTCALL FreeUserMessage(PUSER_SENT_MESSAGE Message)
Definition: msgqueue.c:786
#define POSTEVENT_NWE
Definition: msgqueue.h:125
BOOL HasPackedLParam
Definition: msgqueue.h:34
PTHREADINFO ptiCallBackSender
Definition: msgqueue.h:31
Definition: typedefs.h:117
#define ERR(fmt,...)
Definition: debug.h:109
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define SMF_RECEIVEDMESSAGE
Definition: msgqueue.h:41
LIST_ENTRY usmList
Definition: msgqueue.c:23

Referenced by UserDeleteW32Thread().

◆ MsqCreateMessage()

PUSER_MESSAGE FASTCALL MsqCreateMessage ( LPMSG  Msg)

Definition at line 731 of file msgqueue.c.

732 {
734 
735  Message = ExAllocateFromPagedLookasideList(pgMessageLookasideList);
736  if (!Message)
737  {
738  return NULL;
739  }
740 
741  RtlZeroMemory(Message, sizeof(*Message));
742  RtlMoveMemory(&Message->Msg, Msg, sizeof(MSG));
743  PostMsgCount++;
744  return Message;
745 }
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
smooth NULL
Definition: ftsmooth.c:416
CHAR Message[80]
Definition: alive.c:5
struct @1587 Msg[]
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
INT PostMsgCount
Definition: msgqueue.c:18
static PPAGED_LOOKASIDE_LIST pgMessageLookasideList
Definition: msgqueue.c:16

Referenced by MsqPostMessage().

◆ MsqCreateMessageQueue()

PUSER_MESSAGE_QUEUE FASTCALL MsqCreateMessageQueue ( PTHREADINFO  )

Definition at line 2441 of file msgqueue.c.

2442 {
2443  PUSER_MESSAGE_QUEUE MessageQueue;
2444 
2445  MessageQueue = ExAllocatePoolWithTag(NonPagedPool,
2446  sizeof(*MessageQueue),
2447  USERTAG_Q);
2448 
2449  if (!MessageQueue)
2450  {
2451  return NULL;
2452  }
2453 
2454  RtlZeroMemory(MessageQueue, sizeof(*MessageQueue));
2455  /* hold at least one reference until it'll be destroyed */
2456  IntReferenceMessageQueue(MessageQueue);
2457  /* initialize the queue */
2458  if (!MsqInitializeMessageQueue(pti, MessageQueue))
2459  {
2460  IntDereferenceMessageQueue(MessageQueue);
2461  return NULL;
2462  }
2463 
2464  return MessageQueue;
2465 }
#define USERTAG_Q
Definition: tags.h:268
#define IntReferenceMessageQueue(MsgQueue)
Definition: msgqueue.h:217
smooth NULL
Definition: ftsmooth.c:416
#define IntDereferenceMessageQueue(MsgQueue)
Definition: msgqueue.h:220
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
BOOLEAN FASTCALL MsqInitializeMessageQueue(PTHREADINFO pti, PUSER_MESSAGE_QUEUE MessageQueue)
Definition: msgqueue.c:2246

Referenced by InitThreadCallback(), and UserAttachThreadInput().

◆ MsqDecPaintCountQueue()

VOID FASTCALL MsqDecPaintCountQueue ( PTHREADINFO  )

Definition at line 508 of file msgqueue.c.

509 {
511 }
VOID FASTCALL ClearMsgBitsMask(PTHREADINFO pti, UINT MessageBits)
Definition: msgqueue.c:445
#define QS_PAINT
Definition: winuser.h:887

Referenced by co_IntUpdateWindows(), co_UserFreeWindow(), IntBeginPaint(), IntGetNCUpdateRgn(), IntGetPaintMessage(), and IntInvalidateWindows().

◆ MsqDestroyMessage()

VOID FASTCALL MsqDestroyMessage ( PUSER_MESSAGE  Message)

Definition at line 748 of file msgqueue.c.

749 {
750  TRACE("Post Destroy %d\n",PostMsgCount);
751  if (Message->pti == NULL)
752  {
753  ERR("Double Free Message\n");
754  return;
755  }
756  RemoveEntryList(&Message->ListEntry);
757  Message->pti = NULL;
758  ExFreeToPagedLookasideList(pgMessageLookasideList, Message);
759  PostMsgCount--;
760 }
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
CHAR Message[80]
Definition: alive.c:5
#define ERR(fmt,...)
Definition: debug.h:109
INT PostMsgCount
Definition: msgqueue.c:18
static PPAGED_LOOKASIDE_LIST pgMessageLookasideList
Definition: msgqueue.c:16

Referenced by co_MsqPeekHardwareMessage(), FindRemoveEventMsg(), MsqCleanupMessageQueue(), MsqCleanupThreadMsgs(), MsqPeekMessage(), and MsqRemoveWindowMessagesFromQueue().

◆ MsqDestroyMessageQueue()

VOID FASTCALL MsqDestroyMessageQueue ( _In_ PTHREADINFO  pti)

Definition at line 2468 of file msgqueue.c.

2469 {
2470  PDESKTOP desk;
2471  PUSER_MESSAGE_QUEUE MessageQueue = pti->MessageQueue;
2472 
2473  NT_ASSERT(MessageQueue != NULL);
2474  MessageQueue->QF_flags |= QF_INDESTROY;
2475 
2476  /* remove the message queue from any desktops */
2477  if ((desk = InterlockedExchangePointer((PVOID*)&MessageQueue->Desktop, 0)))
2478  {
2480  IntDereferenceMessageQueue(MessageQueue);
2481  }
2482 
2483  /* clean it up */
2485 
2486  /* decrease the reference counter, if it hits zero, the queue will be freed */
2488  IntDereferenceMessageQueue(MessageQueue);
2489 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
VOID FASTCALL MsqCleanupMessageQueue(PTHREADINFO pti)
Definition: msgqueue.c:2378
struct _USER_MESSAGE_QUEUE * ActiveMessageQueue
Definition: desktop.h:38
smooth NULL
Definition: ftsmooth.c:416
#define QF_INDESTROY
Definition: msgqueue.h:103
#define IntDereferenceMessageQueue(MsgQueue)
Definition: msgqueue.h:220
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
#define __WARNING_USING_UNINIT_VAR
Definition: suppress.h:31
struct _DESKTOP * Desktop
Definition: msgqueue.h:50
#define _PRAGMA_WARNING_SUPPRESS(x)
Definition: suppress.h:28
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by UserAttachThreadInput(), and UserDeleteW32Thread().

◆ MsqGetDownKeyState()

WPARAM FASTCALL MsqGetDownKeyState ( PUSER_MESSAGE_QUEUE  )

Definition at line 338 of file msgqueue.c.

339 {
340  WPARAM ret = 0;
341 
342  if (gspv.bMouseBtnSwap)
343  {
344  if (IS_KEY_DOWN(MessageQueue->afKeyState, VK_RBUTTON)) ret |= MK_LBUTTON;
345  if (IS_KEY_DOWN(MessageQueue->afKeyState, VK_LBUTTON)) ret |= MK_RBUTTON;
346  }
347  else
348  {
349  if (IS_KEY_DOWN(MessageQueue->afKeyState, VK_LBUTTON)) ret |= MK_LBUTTON;
350  if (IS_KEY_DOWN(MessageQueue->afKeyState, VK_RBUTTON)) ret |= MK_RBUTTON;
351  }
352 
353  if (IS_KEY_DOWN(MessageQueue->afKeyState, VK_MBUTTON)) ret |= MK_MBUTTON;
354  if (IS_KEY_DOWN(MessageQueue->afKeyState, VK_SHIFT)) ret |= MK_SHIFT;
355  if (IS_KEY_DOWN(MessageQueue->afKeyState, VK_CONTROL)) ret |= MK_CONTROL;
356  if (IS_KEY_DOWN(MessageQueue->afKeyState, VK_XBUTTON1)) ret |= MK_XBUTTON1;
357  if (IS_KEY_DOWN(MessageQueue->afKeyState, VK_XBUTTON2)) ret |= MK_XBUTTON2;
358  return ret;
359 }
#define MK_SHIFT
Definition: winuser.h:2344
#define MK_LBUTTON
Definition: winuser.h:2342
#define VK_LBUTTON
Definition: winuser.h:2165
BOOL bMouseBtnSwap
Definition: sysparams.h:82
#define MK_MBUTTON
Definition: winuser.h:2346
UINT_PTR WPARAM
Definition: windef.h:207
#define VK_RBUTTON
Definition: winuser.h:2166
#define VK_SHIFT
Definition: winuser.h:2177
#define MK_RBUTTON
Definition: winuser.h:2343
SPIVALUES gspv
Definition: sysparams.c:17
int ret
#define MK_CONTROL
Definition: winuser.h:2345
#define VK_CONTROL
Definition: winuser.h:2178
#define IS_KEY_DOWN(ks, vk)
Definition: input.h:98
#define VK_MBUTTON
Definition: winuser.h:2168

Referenced by co_IntProcessMouseMessage(), and SystemTimerProc().

◆ MsqGetMessageExtraInfo()

LPARAM FASTCALL MsqGetMessageExtraInfo ( VOID  )

Definition at line 2512 of file msgqueue.c.

2513 {
2514  PTHREADINFO pti;
2515  PUSER_MESSAGE_QUEUE MessageQueue;
2516 
2518  MessageQueue = pti->MessageQueue;
2519  if(!MessageQueue)
2520  {
2521  return 0;
2522  }
2523 
2524  return MessageQueue->ExtraInfo;
2525 }
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:88

Referenced by NtUserGetThreadState().

◆ MsqIncPaintCountQueue()

VOID FASTCALL MsqIncPaintCountQueue ( PTHREADINFO  )

Definition at line 501 of file msgqueue.c.

502 {
503  pti->cPaintsReady++;
504  MsqWakeQueue(pti, QS_PAINT, TRUE);
505 }
VOID FASTCALL MsqWakeQueue(PTHREADINFO pti, DWORD MessageBits, BOOL KeyEvent)
Definition: msgqueue.c:412
#define TRUE
Definition: types.h:120
#define QS_PAINT
Definition: winuser.h:887

Referenced by IntInvalidateWindows().

◆ MsqInitializeImpl()

INIT_FUNCTION NTSTATUS NTAPI MsqInitializeImpl ( VOID  )

Definition at line 30 of file msgqueue.c.

31 {
32  // Setup Post Messages
35  return STATUS_NO_MEMORY;
37  NULL,
38  NULL,
39  0,
40  sizeof(USER_MESSAGE),
41  TAG_USRMSG,
42  256);
43  // Setup Send Messages
46  return STATUS_NO_MEMORY;
48  NULL,
49  NULL,
50  0,
51  sizeof(USER_SENT_MESSAGE),
52  TAG_USRMSG,
53  16);
54 
56 
57  return(STATUS_SUCCESS);
58 }
VOID NTAPI ExInitializePagedLookasideList(IN PPAGED_LOOKASIDE_LIST Lookaside, IN PALLOCATE_FUNCTION Allocate OPTIONAL, IN PFREE_FUNCTION Free OPTIONAL, IN ULONG Flags, IN SIZE_T Size, IN ULONG Tag, IN USHORT Depth)
Definition: lookas.c:274
#define TAG_USRMSG
Definition: tags.h:8
smooth NULL
Definition: ftsmooth.c:416
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
struct LOOKASIDE_ALIGN _PAGED_LOOKASIDE_LIST PAGED_LOOKASIDE_LIST
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
static PPAGED_LOOKASIDE_LIST pgSendMsgLookasideList
Definition: msgqueue.c:17
return STATUS_SUCCESS
Definition: btrfs.c:2938
LIST_ENTRY usmList
Definition: msgqueue.c:23
static PPAGED_LOOKASIDE_LIST pgMessageLookasideList
Definition: msgqueue.c:16

Referenced by DriverEntry().

◆ MsqInitializeMessageQueue()

BOOLEAN FASTCALL MsqInitializeMessageQueue ( PTHREADINFO  ,
PUSER_MESSAGE_QUEUE   
)

Definition at line 2246 of file msgqueue.c.

2247 {
2248  InitializeListHead(&MessageQueue->HardwareMessagesListHead); // Keep here!
2249  MessageQueue->spwndFocus = NULL;
2250  MessageQueue->iCursorLevel = 0;
2251  MessageQueue->CursorObject = SYSTEMCUR(WAIT); // See test_initial_cursor.
2252  if (MessageQueue->CursorObject)
2253  {
2254  TRACE("Default cursor hcur %p\n",UserHMGetHandle(MessageQueue->CursorObject));
2255  UserReferenceObject(MessageQueue->CursorObject);
2256  }
2257  RtlCopyMemory(MessageQueue->afKeyState, gafAsyncKeyState, sizeof(gafAsyncKeyState));
2258  MessageQueue->ptiMouse = pti;
2259  MessageQueue->ptiKeyboard = pti;
2260  MessageQueue->cThreads++;
2261 
2262  return TRUE;
2263 }
BYTE gafAsyncKeyState[256 *2/8]
Definition: keyboard.c:13
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
smooth NULL
Definition: ftsmooth.c:416
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
#define WAIT
Definition: listbox.c:36
#define TRACE(s)
Definition: solgame.cpp:4
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define SYSTEMCUR(func)
Definition: cursoricon.h:129
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:697

Referenced by MsqCreateMessageQueue().

◆ MsqIsClkLck()

BOOL FASTCALL MsqIsClkLck ( LPMSG  Msg,
BOOL  Remove 
)

◆ MsqIsDblClk()

BOOL FASTCALL MsqIsDblClk ( LPMSG  Msg,
BOOL  Remove 
)

◆ MsqIsHung()

BOOL FASTCALL MsqIsHung ( PTHREADINFO  pti,
DWORD  TimeOut 
)

Definition at line 2194 of file msgqueue.c.

2195 {
2196  DWORD dwTimeStamp = EngGetTickCount32();
2197  if (dwTimeStamp - pti->pcti->timeLastRead > TimeOut &&
2198  !(pti->pcti->fsWakeMask & QS_INPUT) &&
2199  !PsGetThreadFreezeCount(pti->pEThread) &&
2200  !(pti->ppi->W32PF_flags & W32PF_APPSTARTING))
2201  {
2202  ERR("\nMsqIsHung(pti %p, TimeOut %lu)\n"
2203  "pEThread %p, ThreadsProcess %p, ImageFileName '%s'\n"
2204  "dwTimeStamp = %lu\n"
2205  "pti->pcti->timeLastRead = %lu\n"
2206  "pti->timeLast = %lu\n"
2207  "PsGetThreadFreezeCount(pti->pEThread) = %lu\n",
2208  pti, TimeOut,
2209  pti->pEThread,
2210  pti->pEThread ? pti->pEThread->ThreadsProcess : NULL,
2211  (pti->pEThread && pti->pEThread->ThreadsProcess)
2212  ? pti->pEThread->ThreadsProcess->ImageFileName : "(None)",
2213  dwTimeStamp,
2214  pti->pcti->timeLastRead,
2215  pti->timeLast,
2216  PsGetThreadFreezeCount(pti->pEThread));
2217 
2218  return TRUE;
2219  }
2220 
2221  return FALSE;
2222 }
#define TRUE
Definition: types.h:120
#define EngGetTickCount32()
Definition: eng.h:43
PPROCESSINFO ppi
Definition: win32.h:87
smooth NULL
Definition: ftsmooth.c:416
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:90
#define QS_INPUT
Definition: winuser.h:881
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG timeLast
Definition: win32.h:101
#define ERR(fmt,...)
Definition: debug.h:109
ULONG NTAPI PsGetThreadFreezeCount(IN PETHREAD Thread)
Definition: thread.c:685
#define W32PF_APPSTARTING
Definition: win32.h:10

Referenced by co_IntSendMessageTimeoutSingle(), IntMakeHungWindowGhosted(), NtUserCallTwoParam(), NtUserQueryWindow(), and UpdateThreadWindows().

◆ MsqPeekMessage()

BOOLEAN APIENTRY MsqPeekMessage ( IN PTHREADINFO  pti,
IN BOOLEAN  Remove,
IN PWND  Window,
IN UINT  MsgFilterLow,
IN UINT  MsgFilterHigh,
IN UINT  QSflags,
OUT LONG_PTR ExtraInfo,
OUT DWORD dwQEvent,
OUT PMSG  Message 
)

Definition at line 2107 of file msgqueue.c.

2116 {
2117  PUSER_MESSAGE CurrentMessage;
2118  PLIST_ENTRY ListHead;
2119  DWORD QS_Flags;
2120  BOOL Ret = FALSE;
2121 
2122  ListHead = pti->PostedMessagesListHead.Flink;
2123 
2124  if (IsListEmpty(ListHead)) return FALSE;
2125 
2126  while(ListHead != &pti->PostedMessagesListHead)
2127  {
2128  CurrentMessage = CONTAINING_RECORD(ListHead, USER_MESSAGE, ListEntry);
2129  ListHead = ListHead->Flink;
2130 /*
2131  MSDN:
2132  1: any window that belongs to the current thread, and any messages on the current thread's message queue whose hwnd value is NULL.
2133  2: retrieves only messages on the current thread's message queue whose hwnd value is NULL.
2134  3: handle to the window whose messages are to be retrieved.
2135  */
2136  if ( ( !Window || // 1
2137  ( Window == PWND_BOTTOM && CurrentMessage->Msg.hwnd == NULL ) || // 2
2138  ( Window != PWND_BOTTOM && Window->head.h == CurrentMessage->Msg.hwnd ) ) && // 3
2139  ( ( ( MsgFilterLow == 0 && MsgFilterHigh == 0 ) && CurrentMessage->QS_Flags & QSflags ) ||
2140  ( MsgFilterLow <= CurrentMessage->Msg.message && MsgFilterHigh >= CurrentMessage->Msg.message ) ) )
2141  {
2142  *Message = CurrentMessage->Msg;
2143  *ExtraInfo = CurrentMessage->ExtraInfo;
2144  QS_Flags = CurrentMessage->QS_Flags;
2145  if (dwQEvent) *dwQEvent = CurrentMessage->dwQEvent;
2146 
2147  if (Remove)
2148  {
2149  if (CurrentMessage->pti != NULL)
2150  {
2151  MsqDestroyMessage(CurrentMessage);
2152  }
2153  ClearMsgBitsMask(pti, QS_Flags);
2154  }
2155  Ret = TRUE;
2156  break;
2157  }
2158  }
2159 
2160  return Ret;
2161 }
#define TRUE
Definition: types.h:120
#define PWND_BOTTOM
Definition: ntuser.h:731
PTHREADINFO pti
Definition: msgqueue.h:15
LONG_PTR ExtraInfo
Definition: msgqueue.h:13
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
VOID FASTCALL MsqDestroyMessage(PUSER_MESSAGE Message)
Definition: msgqueue.c:748
Definition: window.c:28
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
DWORD QS_Flags
Definition: msgqueue.h:12
_In_ BOOLEAN Remove
Definition: psfuncs.h:110
DWORD dwQEvent
Definition: msgqueue.h:14
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
VOID FASTCALL ClearMsgBitsMask(PTHREADINFO pti, UINT MessageBits)
Definition: msgqueue.c:445
unsigned long DWORD
Definition: ntddk_ex.h:95
CHAR Message[80]
Definition: alive.c:5
Definition: typedefs.h:117
struct @1587 Msg[]

Referenced by co_IntPeekMessage().

◆ MsqPostMessage()

VOID FASTCALL MsqPostMessage ( PTHREADINFO  ,
MSG ,
BOOLEAN  ,
DWORD  ,
DWORD  ,
LONG_PTR   
)

Definition at line 1338 of file msgqueue.c.

1344 {
1346  PUSER_MESSAGE_QUEUE MessageQueue;
1347 
1348  if ( pti->TIF_flags & TIF_INCLEANUP || pti->MessageQueue->QF_flags & QF_INDESTROY )
1349  {
1350  ERR("Post Msg; Thread or Q is Dead!\n");
1351  return;
1352  }
1353 
1354  if(!(Message = MsqCreateMessage(Msg)))
1355  {
1356  return;
1357  }
1358 
1359  MessageQueue = pti->MessageQueue;
1360 
1361  if (!HardwareMessage)
1362  {
1363  InsertTailList(&pti->PostedMessagesListHead, &Message->ListEntry);
1364  }
1365  else
1366  {
1367  InsertTailList(&MessageQueue->HardwareMessagesListHead, &Message->ListEntry);
1368  }
1369 
1370  if (Msg->message == WM_HOTKEY) MessageBits |= QS_HOTKEY; // Justin Case, just set it.
1371  Message->dwQEvent = dwQEvent;
1372  Message->ExtraInfo = ExtraInfo;
1373  Message->QS_Flags = MessageBits;
1374  Message->pti = pti;
1375  MsqWakeQueue(pti, MessageBits, TRUE);
1376  TRACE("Post Message %d\n",PostMsgCount);
1377 }
VOID FASTCALL MsqWakeQueue(PTHREADINFO pti, DWORD MessageBits, BOOL KeyEvent)
Definition: msgqueue.c:412
#define TRUE
Definition: types.h:120
#define WM_HOTKEY
Definition: winuser.h:1861
#define InsertTailList(ListHead, Entry)
#define QS_HOTKEY
Definition: winuser.h:877
#define QF_INDESTROY
Definition: msgqueue.h:103
#define TRACE(s)
Definition: solgame.cpp:4
CHAR Message[80]
Definition: alive.c:5
PUSER_MESSAGE FASTCALL MsqCreateMessage(LPMSG Msg)
Definition: msgqueue.c:731
#define ERR(fmt,...)
Definition: debug.h:109
struct @1587 Msg[]
INT PostMsgCount
Definition: msgqueue.c:18
LIST_ENTRY HardwareMessagesListHead
Definition: msgqueue.h:59
#define TIF_INCLEANUP
Definition: ntuser.h:240

Referenced by co_IntSetForegroundAndFocusWindow(), co_IntSetForegroundMessageQueue(), co_MsqInsertMouseMessage(), IntCallLowLevelEvent(), IntTranslateKbdMessage(), MsqPostMouseMove(), PostTimerMessages(), ProcessKeyEvent(), UserPostMessage(), and UserPostThreadMessage().

◆ MsqPostQuitMessage()

VOID FASTCALL MsqPostQuitMessage ( PTHREADINFO  pti,
ULONG  ExitCode 
)

Definition at line 1380 of file msgqueue.c.

1381 {
1382  pti->QuitPosted = TRUE;
1383  pti->exitCode = ExitCode;
1385 }
VOID FASTCALL MsqWakeQueue(PTHREADINFO pti, DWORD MessageBits, BOOL KeyEvent)
Definition: msgqueue.c:412
#define TRUE
Definition: types.h:120
#define QS_ALLPOSTMESSAGE
Definition: winuser.h:876
BOOLEAN QuitPosted
Definition: win32.h:104
INT exitCode
Definition: win32.h:106
#define QS_POSTMESSAGE
Definition: winuser.h:888

Referenced by NtUserCallOneParam().

◆ MsqRemoveWindowMessagesFromQueue()

VOID APIENTRY MsqRemoveWindowMessagesFromQueue ( PWND  pWindow)

Definition at line 798 of file msgqueue.c.

799 {
800  PTHREADINFO pti;
801  PUSER_SENT_MESSAGE SentMessage;
802  PUSER_MESSAGE PostedMessage;
803  PLIST_ENTRY CurrentEntry, ListHead;
804 
805  ASSERT(Window);
806 
807  pti = Window->head.pti;
808 
809  /* remove the posted messages for this window */
810  CurrentEntry = pti->PostedMessagesListHead.Flink;
811  ListHead = &pti->PostedMessagesListHead;
812  while (CurrentEntry != ListHead)
813  {
814  PostedMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, ListEntry);
815 
816  if (PostedMessage->Msg.hwnd == Window->head.h)
817  {
818  if (PostedMessage->Msg.message == WM_QUIT && pti->QuitPosted == 0)
819  {
820  pti->QuitPosted = 1;
821  pti->exitCode = PostedMessage->Msg.wParam;
822  }
823  ClearMsgBitsMask(pti, PostedMessage->QS_Flags);
824  MsqDestroyMessage(PostedMessage);
825  CurrentEntry = pti->PostedMessagesListHead.Flink;
826  }
827  else
828  {
829  CurrentEntry = CurrentEntry->Flink;
830  }
831  }
832 
833  /* remove the sent messages for this window */
834  CurrentEntry = pti->SentMessagesListHead.Flink;
835  ListHead = &pti->SentMessagesListHead;
836  while (CurrentEntry != ListHead)
837  {
838  SentMessage = CONTAINING_RECORD(CurrentEntry, USER_SENT_MESSAGE, ListEntry);
839 
840  if(SentMessage->Msg.hwnd == Window->head.h)
841  {
842  ERR("Remove Window Messages %p From Sent Queue\n",SentMessage);
843 #if 0 // Should mark these as invalid and allow the rest clean up, so far no harm by just commenting out. See CORE-9210.
844  ClearMsgBitsMask(pti, SentMessage->QS_Flags);
845 
846  /* wake the sender's thread */
847  if (SentMessage->pkCompletionEvent != NULL)
848  {
850  }
851 
852  if (SentMessage->HasPackedLParam)
853  {
854  if (SentMessage->Msg.lParam)
855  ExFreePool((PVOID)SentMessage->Msg.lParam);
856  }
857 
858  /* free the message */
859  FreeUserMessage(SentMessage);
860 
861  CurrentEntry = pti->SentMessagesListHead.Flink;
862 #endif
863  CurrentEntry = CurrentEntry->Flink;
864  }
865  else
866  {
867  CurrentEntry = CurrentEntry->Flink;
868  }
869  }
870 }
PKEVENT pkCompletionEvent
Definition: msgqueue.h:25
#define WM_QUIT
Definition: winuser.h:1605
BOOLEAN QuitPosted
Definition: win32.h:104
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
VOID FASTCALL MsqDestroyMessage(PUSER_MESSAGE Message)
Definition: msgqueue.c:748
Definition: window.c:28
LIST_ENTRY SentMessagesListHead
Definition: win32.h:99
smooth NULL
Definition: ftsmooth.c:416
INT exitCode
Definition: win32.h:106
DWORD QS_Flags
Definition: msgqueue.h:12
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
VOID FASTCALL ClearMsgBitsMask(PTHREADINFO pti, UINT MessageBits)
Definition: msgqueue.c:445
VOID FASTCALL FreeUserMessage(PUSER_SENT_MESSAGE Message)
Definition: msgqueue.c:786
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOL HasPackedLParam
Definition: msgqueue.h:34
Definition: typedefs.h:117
#define ERR(fmt,...)
Definition: debug.h:109
LIST_ENTRY PostedMessagesListHead
Definition: win32.h:132
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by co_UserFreeWindow().

◆ MsqSetMessageExtraInfo()

LPARAM FASTCALL MsqSetMessageExtraInfo ( LPARAM  lParam)

Definition at line 2492 of file msgqueue.c.

2493 {
2494  LPARAM Ret;
2495  PTHREADINFO pti;
2496  PUSER_MESSAGE_QUEUE MessageQueue;
2497 
2499  MessageQueue = pti->MessageQueue;
2500  if(!MessageQueue)
2501  {
2502  return 0;
2503  }
2504 
2505  Ret = MessageQueue->ExtraInfo;
2506  MessageQueue->ExtraInfo = lParam;
2507 
2508  return Ret;
2509 }
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
LONG_PTR LPARAM
Definition: windef.h:208
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:88
LPARAM lParam
Definition: combotst.c:139

Referenced by NtUserCallOneParam().

◆ MsqSetStateWindow()

HWND FASTCALL MsqSetStateWindow ( PTHREADINFO  pti,
ULONG  Type,
HWND  hWnd 
)

Definition at line 2552 of file msgqueue.c.

2553 {
2554  HWND Prev;
2555  PUSER_MESSAGE_QUEUE MessageQueue;
2556 
2557  MessageQueue = pti->MessageQueue;
2558 
2559  switch(Type)
2560  {
2561  case MSQ_STATE_CAPTURE:
2562  Prev = MessageQueue->spwndCapture ? UserHMGetHandle(MessageQueue->spwndCapture) : 0;
2563  MessageQueue->spwndCapture = ValidateHwndNoErr(hWnd);
2564  return Prev;
2565  case MSQ_STATE_ACTIVE:
2566  Prev = MessageQueue->spwndActive ? UserHMGetHandle(MessageQueue->spwndActive) : 0;
2567  MessageQueue->spwndActive = ValidateHwndNoErr(hWnd);
2568  return Prev;
2569  case MSQ_STATE_FOCUS:
2570  Prev = MessageQueue->spwndFocus ? UserHMGetHandle(MessageQueue->spwndFocus) : 0;
2571  MessageQueue->spwndFocus = ValidateHwndNoErr(hWnd);
2572  return Prev;
2573  case MSQ_STATE_MENUOWNER:
2574  Prev = MessageQueue->MenuOwner;
2575  MessageQueue->MenuOwner = hWnd;
2576  return Prev;
2577  case MSQ_STATE_MOVESIZE:
2578  Prev = MessageQueue->MoveSize;
2579  MessageQueue->MoveSize = hWnd;
2580  return Prev;
2581  case MSQ_STATE_CARET:
2582  Prev = MessageQueue->CaretInfo.hWnd;
2583  MessageQueue->CaretInfo.hWnd = hWnd;
2584  return Prev;
2585  }
2586 
2587  return NULL;
2588 }
#define MSQ_STATE_ACTIVE
Definition: ntuser.h:3545
#define MSQ_STATE_MOVESIZE
Definition: ntuser.h:3548
PWND FASTCALL ValidateHwndNoErr(HWND hWnd)
Definition: window.c:96
Type
Definition: Type.h:6
HWND hWnd
Definition: settings.c:17
#define MSQ_STATE_FOCUS
Definition: ntuser.h:3546
smooth NULL
Definition: ftsmooth.c:416
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
THRDCARETINFO CaretInfo
Definition: msgqueue.h:92
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:88
#define MSQ_STATE_CAPTURE
Definition: ntuser.h:3544
#define MSQ_STATE_CARET
Definition: ntuser.h:3549
#define MSQ_STATE_MENUOWNER
Definition: ntuser.h:3547

Referenced by co_UserSetCapture(), DefWndDoSizeMove(), IntTrackPopupMenuEx(), MENU_DoNextMenu(), MENU_InitTracking(), MENU_TrackMenu(), and NtUserCallTwoParam().

◆ MsqWakeQueue()

VOID FASTCALL MsqWakeQueue ( PTHREADINFO  ,
DWORD  ,
BOOL   
)

Definition at line 412 of file msgqueue.c.

413 {
414  PUSER_MESSAGE_QUEUE Queue;
415 
416  Queue = pti->MessageQueue;
417 
418  if (Queue->QF_flags & QF_INDESTROY)
419  {
420  ERR("This Message Queue is in Destroy!\n");
421  }
422  pti->pcti->fsWakeBits |= MessageBits;
423  pti->pcti->fsChangeBits |= MessageBits;
424 
425  // Start bit accounting to help clear the main set of bits.
426  if (MessageBits & QS_KEY)
427  {
428  pti->nCntsQBits[QSRosKey]++;
429  }
430  if (MessageBits & QS_MOUSE)
431  {
432  if (MessageBits & QS_MOUSEMOVE) pti->nCntsQBits[QSRosMouseMove]++;
433  if (MessageBits & QS_MOUSEBUTTON) pti->nCntsQBits[QSRosMouseButton]++;
434  }
435  if (MessageBits & QS_POSTMESSAGE) pti->nCntsQBits[QSRosPostMessage]++;
436  if (MessageBits & QS_SENDMESSAGE) pti->nCntsQBits[QSRosSendMessage]++;
437  if (MessageBits & QS_HOTKEY) pti->nCntsQBits[QSRosHotKey]++;
438  if (MessageBits & QS_EVENT) pti->nCntsQBits[QSRosEvent]++;
439 
440  if (KeyEvent)
441  KeSetEvent(pti->pEventQueueServer, IO_NO_INCREMENT, FALSE);
442 }
Definition: win32.h:40
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define QS_HOTKEY
Definition: winuser.h:877
#define QS_SENDMESSAGE
Definition: winuser.h:892
#define QF_INDESTROY
Definition: msgqueue.h:103
#define QS_EVENT
Definition: undocuser.h:95
#define QS_MOUSEMOVE
Definition: winuser.h:886
#define ERR(fmt,...)
Definition: debug.h:109
#define QS_POSTMESSAGE
Definition: winuser.h:888
#define QS_MOUSEBUTTON
Definition: winuser.h:885
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define QS_MOUSE
Definition: winuser.h:884
#define QS_KEY
Definition: winuser.h:883

Referenced by co_IntSendMessageWithCallBack(), co_MsqDispatchOneSentMessage(), co_MsqInsertMouseMessage(), co_MsqSendMessage(), co_MsqSendMessageAsync(), MsqIncPaintCountQueue(), MsqPostMessage(), MsqPostMouseMove(), MsqPostQuitMessage(), and ProcessTimers().

◆ UserPostThreadMessage()

BOOL FASTCALL UserPostThreadMessage ( PTHREADINFO  pti,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1147 of file message.c.

1151 {
1152  MSG Message;
1153 
1154  if (is_pointer_message(Msg))
1155  {
1157  return FALSE;
1158  }
1159  Message.hwnd = NULL;
1160  Message.message = Msg;
1161  Message.wParam = wParam;
1162  Message.lParam = lParam;
1163  Message.pt = gpsi->ptCursor;
1164  Message.time = EngGetTickCount32();
1165  MsqPostMessage(pti, &Message, FALSE, QS_POSTMESSAGE, 0, 0);
1166  return TRUE;
1167 }
#define TRUE
Definition: types.h:120
#define EngGetTickCount32()
Definition: eng.h:43
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
PSERVERINFO gpsi
Definition: main.c:27
WPARAM wParam
Definition: combotst.c:138
smooth NULL
Definition: ftsmooth.c:416
VOID FASTCALL MsqPostMessage(PTHREADINFO pti, MSG *Msg, BOOLEAN HardwareMessage, DWORD MessageBits, DWORD dwQEvent, LONG_PTR ExtraInfo)
Definition: msgqueue.c:1338
CHAR Message[80]
Definition: alive.c:5
static int is_pointer_message(UINT message)
Definition: message.c:99
#define ERROR_MESSAGE_SYNC_ONLY
Definition: winerror.h:681
#define QS_POSTMESSAGE
Definition: winuser.h:888
struct @1587 Msg[]
LPARAM lParam
Definition: combotst.c:139
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by co_UserProcessHotKeys(), NtUserPostThreadMessage(), and UserPostMessage().

◆ UserSendNotifyMessage()

BOOL FASTCALL UserSendNotifyMessage ( HWND  hWnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1875 of file message.c.

1879 {
1880  BOOL Ret = TRUE;
1881 
1882  if (is_pointer_message(Msg))
1883  {
1885  return FALSE;
1886  }
1887 
1888  // Basicly the same as IntPostOrSendMessage
1889  if (hWnd == HWND_BROADCAST) // Handle Broadcast
1890  {
1891  HWND *List;
1893  ULONG i;
1894 
1897 
1898  if (List != NULL)
1899  {
1901  for (i = 0; List[i]; i++)
1902  {
1903  PWND pwnd = UserGetWindowObject(List[i]);
1904  if (!pwnd) continue;
1905 
1906  if ( pwnd->fnid == FNID_MENU ||
1908  continue;
1909 
1911  }
1913  }
1914  }
1915  else
1916  {
1918  }
1919  return Ret;
1920 }
#define TRUE
Definition: types.h:120
#define FNID_MENU
Definition: ntuser.h:823
BOOL FASTCALL UserSendNotifyMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1875
HWND hWnd
Definition: settings.c:17
RTL_ATOM atomClassName
Definition: ntuser.h:536
PSERVERINFO gpsi
Definition: main.c:27
WPARAM wParam
Definition: combotst.c:138
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DWORD fnid
Definition: ntuser.h:673
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
LIST_ENTRY List
Definition: psmgr.c:57
Implementation of the Explorer desktop window.
Definition: desktop.h:51
#define ICLS_SWITCH
Definition: ntuser.h:893
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1349
HWND *FASTCALL IntWinListChildren(PWND Window)
Definition: window.c:255
Definition: ntuser.h:657
static int is_pointer_message(UINT message)
Definition: message.c:99
#define ERROR_MESSAGE_SYNC_ONLY
Definition: winerror.h:681
LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1548
struct @1587 Msg[]
unsigned int ULONG
Definition: retypes.h:1
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define USERTAG_WINDOWLIST
Definition: tags.h:297
#define HWND_BROADCAST
Definition: winuser.h:1190
LPARAM lParam
Definition: combotst.c:139
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1013
PCLS pcls
Definition: ntuser.h:684

Referenced by co_IntSendActivateMessages(), NtUserMessageCall(), NtUserSetSysColors(), UserChangeDisplaySettings(), UserRealizePalette(), and UserSendNotifyMessage().

◆ UserSetCursor()

PCURICON_OBJECT FASTCALL UserSetCursor ( PCURICON_OBJECT  NewCursor,
BOOL  ForceChange 
)

Definition at line 93 of file msgqueue.c.

96 {
97  PCURICON_OBJECT OldCursor;
98  HDC hdcScreen;
99  PTHREADINFO pti;
100  PUSER_MESSAGE_QUEUE MessageQueue;
101  PWND pWnd;
102 
104  MessageQueue = pti->MessageQueue;
105 
106  OldCursor = MessageQueue->CursorObject;
107 
108  /* Check if cursors are different */
109  if (OldCursor == NewCursor)
110  return OldCursor;
111 
112  /* Update cursor for this message queue */
113  MessageQueue->CursorObject = NewCursor;
114 
115  /* If cursor is not visible we have nothing to do */
116  if (MessageQueue->iCursorLevel < 0)
117  return OldCursor;
118 
119  // Fixes the error message "Not the same cursor!".
120  if (gpqCursor == NULL)
121  {
122  gpqCursor = MessageQueue;
123  }
124 
125  /* Update cursor if this message queue controls it */
126  pWnd = IntTopLevelWindowFromPoint(gpsi->ptCursor.x, gpsi->ptCursor.y);
127  if (pWnd && pWnd->head.pti->MessageQueue == MessageQueue)
128  {
129  /* Get the screen DC */
130  if (!(hdcScreen = IntGetScreenDC()))
131  {
132  return NULL;
133  }
134 
135  if (NewCursor)
136  {
137  /* Call GDI to set the new screen cursor */
138  PCURICON_OBJECT CursorFrame = NewCursor;
139  if(NewCursor->CURSORF_flags & CURSORF_ACON)
140  {
141  FIXME("Should animate the cursor, using only the first frame now.\n");
142  CursorFrame = ((PACON)NewCursor)->aspcur[0];
143  }
144  GreSetPointerShape(hdcScreen,
145  CursorFrame->hbmAlpha ? NULL : NewCursor->hbmMask,
146  CursorFrame->hbmAlpha ? NewCursor->hbmAlpha : NewCursor->hbmColor,
147  CursorFrame->xHotspot,
148  CursorFrame->yHotspot,
149  gpsi->ptCursor.x,
150  gpsi->ptCursor.y,
151  CursorFrame->hbmAlpha ? SPS_ALPHA : 0);
152  }
153  else /* Note: OldCursor != NewCursor so we have to hide cursor */
154  {
155  /* Remove the cursor