ReactOS 0.4.15-dev-5667-ged97270
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)
 
 CODE_SEG ("INIT") 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 InterlockedDecrement
Definition: armddk.h:52
#define USERTAG_Q
Definition: tags.h:269

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: inflate.c:139
Definition: tftpd.h:60

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:
#define WM_NCMOUSEFIRST
Definition: msgqueue.h:239
#define WM_NCMOUSELAST
Definition: msgqueue.h:240
#define WM_MOUSEFIRST
Definition: winuser.h:1764
#define WM_MOUSELAST
Definition: winuser.h:1791

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.

116{
117 WM_ASYNC_SHOWWINDOW = 0x80000000,
121};
@ WM_ASYNC_SETACTIVEWINDOW
Definition: msgqueue.h:119
@ WM_ASYNC_SHOWWINDOW
Definition: msgqueue.h:117
@ WM_ASYNC_SETWINDOWPOS
Definition: msgqueue.h:118
@ WM_ASYNC_DESTROYWINDOW
Definition: msgqueue.h:120

Function Documentation

◆ AllocateUserMessage()

PUSER_SENT_MESSAGE FASTCALL AllocateUserMessage ( BOOL  KEvent)

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\n");
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}
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
static const WCHAR Message[]
Definition: register.c:74
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
static PPAGED_LOOKASIDE_LIST pgSendMsgLookasideList
Definition: msgqueue.c:17
INT SendMsgCount
Definition: msgqueue.c:19
@ NotificationEvent
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
#define TRACE(s)
Definition: solgame.cpp:4
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

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

◆ ClearMsgBitsMask()

VOID FASTCALL ClearMsgBitsMask ( PTHREADINFO  pti,
UINT  MessageBits 
)

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}
unsigned int UINT
Definition: ndis.h:50
DWORD nCntsQBits[QSIDCOUNTS]
Definition: win32.h:153
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:91
UINT cTimersReady
Definition: win32.h:110
UINT cPaintsReady
Definition: win32.h:109
#define QS_EVENT
Definition: undocuser.h:97
@ QSRosMouseMove
Definition: win32.h:42
@ QSRosKey
Definition: win32.h:41
@ QSRosEvent
Definition: win32.h:47
@ QSRosHotKey
Definition: win32.h:46
@ QSRosSendMessage
Definition: win32.h:45
@ QSRosPostMessage
Definition: win32.h:44
@ QSRosMouseButton
Definition: win32.h:43
#define QS_KEY
Definition: winuser.h:868
#define QS_MOUSEMOVE
Definition: winuser.h:869
#define QS_SENDMESSAGE
Definition: winuser.h:874
#define QS_TIMER
Definition: winuser.h:872
#define QS_HOTKEY
Definition: winuser.h:875
#define QS_MOUSEBUTTON
Definition: winuser.h:870
#define QS_POSTMESSAGE
Definition: winuser.h:871
#define QS_PAINT
Definition: winuser.h:873

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 1177 of file message.c.

1183{
1184 PWND Window;
1185 PTHREADINFO pti;
1186 BOOL Present = FALSE;
1188 LONG_PTR ExtraInfo = 0;
1189
1190 if ( hWnd == HWND_TOPMOST || hWnd == HWND_BROADCAST )
1191 hWnd = HWND_BOTTOM;
1192
1193 /* Validate input */
1194 if (hWnd && hWnd != HWND_BOTTOM)
1195 {
1197 {
1198 if (bGMSG)
1199 return -1;
1200 else
1201 return FALSE;
1202 }
1203 }
1204 else
1205 {
1206 Window = (PWND)hWnd;
1207 }
1208
1209 if (MsgFilterMax < MsgFilterMin)
1210 {
1211 MsgFilterMin = 0;
1212 MsgFilterMax = 0;
1213 }
1214
1215 if (bGMSG)
1216 {
1217 RemoveMsg |= ((GetWakeMask( MsgFilterMin, MsgFilterMax ))<< 16);
1218 }
1219
1221 pti->pClientInfo->cSpins++; // Bump up the spin count.
1222
1223 do
1224 {
1225 Present = co_IntPeekMessage( pMsg,
1226 Window,
1227 MsgFilterMin,
1228 MsgFilterMax,
1229 RemoveMsg,
1230 &ExtraInfo,
1231 bGMSG );
1232 if (Present)
1233 {
1234 if ( pMsg->message != WM_DEVICECHANGE || (pMsg->wParam & 0x8000) )
1235 {
1236 /* GetMessage or PostMessage must never get messages that contain pointers */
1237 ASSERT(FindMsgMemory(pMsg->message) == NULL);
1238 }
1239
1240 if ( pMsg->message >= WM_DDE_FIRST && pMsg->message <= WM_DDE_LAST )
1241 {
1242 if (!IntDdeGetMessageHook(pMsg, ExtraInfo))
1243 {
1244 TRACE("DDE Get return ERROR\n");
1245 continue;
1246 }
1247 }
1248
1249 if (pMsg->message != WM_PAINT && pMsg->message != WM_QUIT)
1250 {
1251 if (!RtlEqualMemory(&pti->ptLast, &pMsg->pt, sizeof(POINT)))
1252 {
1254 }
1255 pti->timeLast = pMsg->time;
1256 pti->ptLast = pMsg->pt;
1257 }
1258
1259 // The WH_GETMESSAGE hook enables an application to monitor messages about to
1260 // be returned by the GetMessage or PeekMessage function.
1261
1263
1264 if ( bGMSG || pMsg->message == WM_PAINT) break;
1265 }
1266
1267 if ( bGMSG )
1268 {
1270 Window,
1271 MsgFilterMin,
1272 MsgFilterMax);
1273 if ( !NT_SUCCESS(Status) ||
1276 {
1277 Present = -1;
1278 break;
1279 }
1280 }
1281 else
1282 {
1283 if (!(RemoveMsg & PM_NOYIELD))
1284 {
1285 IdlePing();
1286 // Yield this thread!
1287 UserLeave();
1290 // Fall through to exit.
1291 IdlePong();
1292 }
1293 break;
1294 }
1295 }
1296 while( bGMSG && !Present );
1297
1298 // Been spinning, time to swap vinyl...
1299 if (pti->pClientInfo->cSpins >= 100)
1300 {
1301 // Clear the spin cycle to fix the mix.
1302 pti->pClientInfo->cSpins = 0;
1303 //if (!(pti->TIF_flags & TIF_SPINNING)) // FIXME: Need to swap vinyl...
1304 }
1305 return Present;
1306}
HWND hWnd
Definition: settings.c:17
LONG NTSTATUS
Definition: precomp.h:26
#define WM_DDE_FIRST
Definition: dde.h:47
#define WM_DDE_LAST
Definition: dde.h:46
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned int BOOL
Definition: ntddk_ex.h:94
Status
Definition: gdiplustypes.h:25
struct _WND * PWND
#define TIF_MSGPOSCHANGED
Definition: ntuser.h:282
#define RtlEqualMemory(a, b, c)
Definition: kdvm.h:18
#define ASSERT(a)
Definition: mode.c:44
NTSTATUS FASTCALL co_MsqWaitForNewMessages(PTHREADINFO pti, PWND WndFilter, UINT MsgFilterMin, UINT MsgFilterMax)
Definition: msgqueue.c:2163
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
NTSYSAPI NTSTATUS NTAPI ZwYieldExecution(VOID)
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
#define STATUS_USER_APC
Definition: ntstatus.h:78
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1103
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:254
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:245
Definition: window.c:28
POINT ptLast
Definition: win32.h:129
struct _CLIENTINFO * pClientInfo
Definition: win32.h:94
LONG timeLast
Definition: win32.h:102
FLONG TIF_flags
Definition: win32.h:95
Definition: ntuser.h:689
UINT message
Definition: winuser.h:3105
DWORD time
Definition: winuser.h:3108
WPARAM wParam
Definition: winuser.h:3106
POINT pt
Definition: winuser.h:3109
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:134
BOOL APIENTRY IntDdeGetMessageHook(PMSG pMsg, LONG_PTR ExtraInfo)
Definition: dde.c:326
UINT FASTCALL GetWakeMask(UINT first, UINT last)
Definition: message.c:574
VOID FASTCALL IdlePing(VOID)
Definition: message.c:527
VOID FASTCALL IdlePong(VOID)
Definition: message.c:557
BOOL APIENTRY co_IntPeekMessage(PMSG Msg, PWND Window, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg, LONG_PTR *ExtraInfo, BOOL bGMSG)
Definition: message.c:965
static PMSGMEMORY FASTCALL FindMsgMemory(UINT Msg)
Definition: message.c:147
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_PAINT
Definition: winuser.h:1610
#define WM_QUIT
Definition: winuser.h:1613
#define HWND_TOPMOST
Definition: winuser.h:1198
#define HWND_BROADCAST
Definition: winuser.h:1194
#define HC_ACTION
Definition: winuser.h:48
#define WM_DEVICECHANGE
Definition: winuser.h:1801
#define PM_NOYIELD
Definition: winuser.h:1187
#define PM_REMOVE
Definition: winuser.h:1186
#define WH_GETMESSAGE
Definition: winuser.h:33
#define HWND_BOTTOM
Definition: winuser.h:1195

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 1446 of file message.c.

1450{
1451 ULONG_PTR Result = 0;
1452
1454 {
1455 return (LRESULT)Result;
1456 }
1457 return 0;
1458}
WPARAM wParam
Definition: combotst.c:138
struct @1609 Msg[]
LPARAM lParam
Definition: combotst.c:139
uint32_t ULONG_PTR
Definition: typedefs.h:65
LRESULT FASTCALL co_IntSendMessageTimeout(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult)
Definition: message.c:1654
LONG_PTR LRESULT
Definition: windef.h:209
#define SMTO_NORMAL
Definition: winuser.h:1215
_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

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_UserActivateKeyboardLayout(), 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(), IntCheckImeShowStatus(), IntClientShutdown(), IntDeactivateWindow(), IntDefWindowProc(), IntEnableWindow(), IntFlashWindowEx(), IntFocusSetInputContext(), IntImmActivateLayout(), IntScrollWindowEx(), IntSendDestroyMsg(), IntSendFocusMessages(), IntSendMessageToUI(), IntSendNCPaint(), IntSendOpenStatusNotify(), 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 1710 of file message.c.

1714{
1715 ULONG_PTR Result = 0;
1717 Msg,
1718 wParam,
1719 lParam,
1720 NULL,
1721 0,
1722 &Result);
1723}
LRESULT FASTCALL co_IntSendMessageWithCallBack(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, SENDASYNCPROC CompletionCallback, ULONG_PTR CompletionCallbackContext, ULONG_PTR *uResult)
Definition: message.c:1732

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 1654 of file message.c.

1661{
1663 HWND *Children;
1664 HWND *Child;
1665
1666 if (hWnd != HWND_BROADCAST && hWnd != HWND_TOPMOST)
1667 {
1668 return co_IntSendMessageTimeoutSingle(hWnd, Msg, wParam, lParam, uFlags, uTimeout, uResult);
1669 }
1670
1671 if (!is_message_broadcastable(Msg)) return TRUE;
1672
1674 if (NULL == DesktopWindow)
1675 {
1677 return 0;
1678 }
1679
1680 if (hWnd != HWND_TOPMOST)
1681 {
1682 /* Send message to the desktop window too! */
1683 co_IntSendMessageTimeoutSingle(DesktopWindow->head.h, Msg, wParam, lParam, uFlags, uTimeout, uResult);
1684 }
1685
1687 if (NULL == Children)
1688 {
1689 return 0;
1690 }
1691
1692 for (Child = Children; NULL != *Child; Child++)
1693 {
1695 if (!pwnd) continue;
1696
1697 if ( pwnd->fnid == FNID_MENU ||
1699 continue;
1700
1702 }
1703
1705
1706 return (LRESULT) TRUE;
1707}
#define TRUE
Definition: types.h:120
UINT uFlags
Definition: api.c:59
PSERVERINFO gpsi
Definition: imm.c:18
#define ICLS_SWITCH
Definition: ntuser.h:927
#define FNID_MENU
Definition: ntuser.h:856
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
Implementation of the Explorer desktop window.
Definition: desktop.h:52
RTL_ATOM atomClassName
Definition: ntuser.h:563
PCLS pcls
Definition: ntuser.h:715
DWORD fnid
Definition: ntuser.h:704
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1055
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1386
static LRESULT FASTCALL co_IntSendMessageTimeoutSingle(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult)
Definition: message.c:1461
static BOOL is_message_broadcastable(UINT msg)
Definition: message.c:568
#define USERTAG_WINDOWLIST
Definition: tags.h:298
HWND *FASTCALL IntWinListChildren(PWND Window)
Definition: window.c:286
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28
#define ERROR_INTERNAL_ERROR
Definition: winerror.h:840

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 1732 of file message.c.

1739{
1741 PWND Window = NULL;
1742 PMSGMEMORY MsgMemoryEntry;
1743 INT lParamBufferSize;
1744 LPARAM lParamPacked;
1745 PTHREADINFO Win32Thread, ptiSendTo = NULL;
1749 BOOL DoCallBack = TRUE;
1750
1752 {
1753 TRACE("SendMessageWithCallBack: Invalid handle 0x%p!\n",hWnd);
1754 RETURN(FALSE);
1755 }
1756
1757 UserRefObjectCo(Window, &Ref);
1758
1759 if (Window->state & WNDS_DESTROYED)
1760 {
1761 /* FIXME: last error? */
1762 ERR("Attempted to send message to window %p that is being destroyed!\n", hWnd);
1763 RETURN(FALSE);
1764 }
1765
1766 Win32Thread = PsGetCurrentThreadWin32Thread();
1767
1768 if (Win32Thread == NULL ||
1769 Win32Thread->TIF_flags & TIF_INCLEANUP)
1770 {
1771 RETURN(FALSE);
1772 }
1773
1774 ptiSendTo = IntSendTo(Window, Win32Thread, Msg);
1775
1776 if (Msg & 0x80000000 &&
1777 !ptiSendTo)
1778 {
1779 if (Win32Thread->TIF_flags & TIF_INCLEANUP) RETURN( FALSE);
1780
1781 TRACE("SMWCB: Internal Message!\n");
1783 if (uResult) *uResult = Result;
1784 RETURN( TRUE);
1785 }
1786
1787 /* See if this message type is present in the table */
1788 MsgMemoryEntry = FindMsgMemory(Msg);
1789 if (NULL == MsgMemoryEntry)
1790 {
1791 lParamBufferSize = -1;
1792 }
1793 else
1794 {
1795 lParamBufferSize = MsgMemorySize(MsgMemoryEntry, wParam, lParam);
1796 if (!lParamBufferSize) lParamBufferSize = -1;
1797 }
1798
1799 if (! NT_SUCCESS(PackParam(&lParamPacked, Msg, wParam, lParam, !!ptiSendTo)))
1800 {
1801 ERR("Failed to pack message parameters\n");
1802 RETURN( FALSE);
1803 }
1804
1805 /* If it can be sent now, then send it. */
1806 if ( !ptiSendTo )
1807 {
1808 if (Win32Thread->TIF_flags & TIF_INCLEANUP)
1809 {
1810 UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE);
1811 /* Never send messages to exiting threads */
1812 RETURN(FALSE);
1813 }
1814
1816
1817 if ( Window->state & WNDS_SERVERSIDEWINDOWPROC )
1818 {
1819 TRACE("SMWCB: Server Side Window Procedure\n");
1820 switch(Window->fnid)
1821 {
1822 case FNID_DESKTOP:
1823 DoCallBack = !DesktopWindowProc(Window, Msg, wParam, lParamPacked, (LRESULT*)&Result);
1824 break;
1825 case FNID_MESSAGEWND:
1827 break;
1828 case FNID_MENU:
1829 DoCallBack = !PopupMenuWndProc( Window, Msg, wParam, lParam,(LRESULT*)&Result);
1830 break;
1831 }
1832 }
1833
1834 if (DoCallBack)
1836 !Window->Unicode,
1837 hWnd,
1838 Msg,
1839 wParam,
1840 lParamPacked,
1841 lParamBufferSize );
1842 if(uResult)
1843 {
1844 *uResult = Result;
1845 }
1846
1848
1850 {
1852 hWnd,
1853 Msg,
1854 CompletionCallbackContext,
1855 Result);
1856 }
1857 }
1858
1859 if ( !ptiSendTo)
1860 {
1861 if (! NT_SUCCESS(UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE)))
1862 {
1863 ERR("Failed to unpack message parameters\n");
1864 }
1865 RETURN(TRUE);
1866 }
1867
1869 {
1870 ERR("MsqSendMessage(): Not enough memory to allocate a message\n");
1871 RETURN(FALSE);
1872 }
1873
1874 Message->Msg.hwnd = hWnd;
1875 Message->Msg.message = Msg;
1876 Message->Msg.wParam = wParam;
1877 Message->Msg.lParam = lParamPacked;
1878 Message->pkCompletionEvent = NULL; // No event needed.
1879 Message->lResult = 0;
1880 Message->QS_Flags = 0;
1881 Message->ptiReceiver = ptiSendTo;
1882 Message->ptiSender = NULL; // mjmartin, you are right! This is null.
1883 Message->ptiCallBackSender = Win32Thread;
1884 Message->CompletionCallback = CompletionCallback;
1885 Message->CompletionCallbackContext = CompletionCallbackContext;
1886 Message->HookMessage = MSQ_NORMAL;
1887 Message->HasPackedLParam = (lParamBufferSize > 0);
1888 Message->QS_Flags = QS_SENDMESSAGE;
1889 Message->flags = SMF_RECEIVERFREE;
1890
1891 if (Msg & 0x80000000) // Higher priority event message!
1892 InsertHeadList(&ptiSendTo->SentMessagesListHead, &Message->ListEntry);
1893 else
1894 InsertTailList(&ptiSendTo->SentMessagesListHead, &Message->ListEntry);
1895 MsqWakeQueue(ptiSendTo, QS_SENDMESSAGE, TRUE);
1896
1897 RETURN(TRUE);
1898
1899CLEANUP:
1902}
#define RETURN(x)
const TCHAR * CompletionCallback(unsigned __int64 &rnIndex, const BOOL *pblnForward, const TCHAR *pszContext, const TCHAR *pszBegin)
Definition: Completion.cpp:439
#define ULONG_PTR
Definition: config.h:101
#define InsertTailList(ListHead, Entry)
#define InsertHeadList(ListHead, Entry)
#define TIF_INCLEANUP
Definition: ntuser.h:262
#define FNID_DESKTOP
Definition: ntuser.h:857
#define WNDS_DESTROYED
Definition: ntuser.h:631
#define WNDS_SERVERSIDEWINDOWPROC
Definition: ntuser.h:618
#define FNID_MESSAGEWND
Definition: ntuser.h:859
VOID FASTCALL MsqWakeQueue(PTHREADINFO pti, DWORD MessageBits, BOOL KeyEvent)
Definition: msgqueue.c:412
PUSER_SENT_MESSAGE FASTCALL AllocateUserMessage(BOOL KEvent)
Definition: msgqueue.c:763
#define MSQ_NORMAL
Definition: msgqueue.h:4
#define SMF_RECEIVERFREE
Definition: msgqueue.h:40
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:40
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:27
LIST_ENTRY SentMessagesListHead
Definition: win32.h:100
Definition: object.h:4
int32_t INT
Definition: typedefs.h:58
#define CLEANUP
Definition: ntuser.h:5
#define DECLARE_RETURN(type)
Definition: ntuser.h:3
#define END_CLEANUP
Definition: ntuser.h:6
VOID APIENTRY co_IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback, HWND hWnd, UINT Msg, ULONG_PTR CompletionCallbackContext, LRESULT Result)
Definition: callback.c:238
LRESULT APIENTRY co_IntCallWindowProc(WNDPROC Proc, BOOLEAN IsAnsiProc, HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, INT lParamBufferSize)
Definition: callback.c:282
BOOL FASTCALL DesktopWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: desktop.c:1439
BOOL FASTCALL UserMessageWindowProc(PWND pwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: desktop.c:1525
BOOL WINAPI PopupMenuWndProc(PWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: menu.c:4631
static VOID FASTCALL IntCallWndProcRet(PWND Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *uResult)
Definition: message.c:741
static UINT FASTCALL MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam)
Definition: message.c:166
PTHREADINFO FASTCALL IntSendTo(PWND Window, PTHREADINFO ptiCur, UINT Msg)
Definition: message.c:1332
static NTSTATUS PackParam(LPARAM *lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL NonPagedPoolNeeded)
Definition: message.c:263
static VOID FASTCALL IntCallWndProc(PWND Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:707
static LRESULT handle_internal_message(PWND pWnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: message.c:772
static NTSTATUS UnpackParam(LPARAM lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL NonPagedPoolUsed)
Definition: message.c:381

Referenced by co_IntSendMessageNoWait(), IntFocusSetInputContext(), and NtUserMessageCall().

◆ co_IntWaitMessage()

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

Definition at line 1131 of file message.c.

1134{
1135 PTHREADINFO pti;
1137 MSG Msg;
1138 LONG_PTR ExtraInfo = 0;
1139
1141
1142 do
1143 {
1144 if ( co_IntPeekMessage( &Msg, // Dont reenter!
1145 Window,
1146 MsgFilterMin,
1147 MsgFilterMax,
1148 MAKELONG( PM_NOREMOVE, GetWakeMask( MsgFilterMin, MsgFilterMax)),
1149 &ExtraInfo,
1150 TRUE ) ) // act like GetMessage.
1151 {
1152 return TRUE;
1153 }
1154
1155 /* Nothing found. Wait for new messages. */
1157 Window,
1158 MsgFilterMin,
1159 MsgFilterMax);
1160 if (!NT_SUCCESS(Status))
1161 {
1163 ERR("Exit co_IntWaitMessage on error!\n");
1164 return FALSE;
1165 }
1167 {
1168 return FALSE;
1169 }
1170 }
1171 while ( TRUE );
1172
1173 return FALSE;
1174}
#define STATUS_SUCCESS
Definition: shellext.h:65
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define MAKELONG(a, b)
Definition: typedefs.h:249
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:37
#define PM_NOREMOVE
Definition: winuser.h:1185

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{
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;
1005Exit:
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}
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
#define CTI_INSENDMESSAGE
Definition: ntuser.h:162
VOID FASTCALL ClearMsgBitsMask(PTHREADINFO pti, UINT MessageBits)
Definition: msgqueue.c:445
VOID FASTCALL FreeUserMessage(PUSER_SENT_MESSAGE Message)
Definition: msgqueue.c:786
LIST_ENTRY usmList
Definition: msgqueue.c:23
#define MSQ_ISHOOK
Definition: msgqueue.h:5
#define SMF_RECEIVEDMESSAGE
Definition: msgqueue.h:41
#define MSQ_INJECTMODULE
Definition: msgqueue.h:6
#define SMF_RECEIVERBUSY
Definition: msgqueue.h:42
LRESULT APIENTRY co_CallHook(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:322
BOOL IntLoadHookModule(int iHookID, HHOOK hHook, BOOL Unload)
Definition: hook.c:31
static void Exit(void)
Definition: sock.c:1330
base of all file and directory entries
Definition: entries.h:83
Definition: typedefs.h:120
int32_t INT_PTR
Definition: typedefs.h:64
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define QS_SMRESULT
Definition: undocuser.h:95
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
#define IO_NO_INCREMENT
Definition: iotypes.h:598

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;
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}
#define EngGetTickCount32()
Definition: eng.h:43
HWND FASTCALL IntGetCaptureWindow(VOID)
Definition: focus.c:34
GLbitfield flags
Definition: glext.h:7161
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
static HDC
Definition: imagelist.c:92
VOID FASTCALL IntCoalesceMouseMove(PTHREADINFO pti)
Definition: msgqueue.c:551
VOID FASTCALL MsqPostMessage(PTHREADINFO pti, MSG *Msg, BOOLEAN HardwareMessage, DWORD MessageBits, DWORD dwQEvent, LONG_PTR ExtraInfo)
Definition: msgqueue.c:1337
PWND FASTCALL IntTopLevelWindowFromPoint(INT x, INT y)
Definition: msgqueue.c:61
ULONG_PTR gdwMouseMoveExtraInfo
Definition: msgqueue.c:21
PUSER_MESSAGE_QUEUE gpqCursor
Definition: msgqueue.c:20
DWORD gdwMouseMoveTimeStamp
Definition: msgqueue.c:22
#define QF_INDESTROY
Definition: msgqueue.h:103
#define QF_MOUSEMOVED
Definition: msgqueue.h:99
#define LOWORD(l)
Definition: pedump.c:82
HBITMAP hbmColor
Definition: cursoricon.h:20
HBITMAP hbmMask
Definition: cursoricon.h:19
HBITMAP hbmAlpha
Definition: cursoricon.h:21
PCURICON_OBJECT CurrentCursorObject
Definition: cursoricon.h:74
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:89
PTHREADINFO ptiMouse
Definition: msgqueue.h:55
PCURICON_OBJECT CursorObject
Definition: msgqueue.h:89
THRDESKHEAD head
Definition: ntuser.h:690
ULONG_PTR dwExtraInfo
Definition: winuser.h:3811
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define WM_MOUSEWHEEL
Definition: treelist.c:96
#define HIWORD(l)
Definition: typedefs.h:247
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:703
VOID NTAPI GreMovePointer(_In_ HDC hdc, _In_ LONG x, _In_ LONG y)
Definition: mouse.c:799
PSYSTEM_CURSORINFO IntGetSysCursorInfo(VOID)
Definition: cursoricon.c:187
HDC FASTCALL IntGetScreenDC(VOID)
Definition: winsta.c:371
#define SPS_ALPHA
Definition: winddi.h:4039
#define WM_MOUSEMOVE
Definition: winuser.h:1765
#define WH_MOUSE_LL
Definition: winuser.h:44

Referenced by co_UserDestroyWindow(), co_WinPosSetWindowPos(), IntDeactivateWindow(), UserAttachThreadInput(), UserDeleteW32Thread(), 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 1995 of file msgqueue.c.

2002{
2003 BOOL AcceptMessage, NotForUs;
2004 PUSER_MESSAGE CurrentMessage;
2005 PLIST_ENTRY ListHead;
2006 MSG msg;
2007 ULONG_PTR idSave;
2008 DWORD QS_Flags;
2009 LONG_PTR ExtraInfo;
2010 BOOL Ret = FALSE;
2011 PUSER_MESSAGE_QUEUE MessageQueue = pti->MessageQueue;
2012
2013 if (!filter_contains_hw_range( MsgFilterLow, MsgFilterHigh )) return FALSE;
2014
2015 ListHead = MessageQueue->HardwareMessagesListHead.Flink;
2016
2017 if (IsListEmpty(ListHead)) return FALSE;
2018
2019 if (!MessageQueue->ptiSysLock)
2020 {
2021 MessageQueue->ptiSysLock = pti;
2022 pti->pcti->CTI_flags |= CTI_THREADSYSLOCK;
2023 }
2024
2025 if (MessageQueue->ptiSysLock != pti)
2026 {
2027 ERR("Thread Q is locked to ptiSysLock 0x%p pti 0x%p\n",MessageQueue->ptiSysLock,pti);
2028 return FALSE;
2029 }
2030
2031 while (ListHead != &MessageQueue->HardwareMessagesListHead)
2032 {
2033 CurrentMessage = CONTAINING_RECORD(ListHead, USER_MESSAGE, ListEntry);
2034 ListHead = ListHead->Flink;
2035
2036 if (MessageQueue->idSysPeek == (ULONG_PTR)CurrentMessage)
2037 {
2038 TRACE("Skip this message due to it is in play!\n");
2039 continue;
2040 }
2041/*
2042 MSDN:
2043 1: any window that belongs to the current thread, and any messages on the current thread's message queue whose hwnd value is NULL.
2044 2: retrieves only messages on the current thread's message queue whose hwnd value is NULL.
2045 3: handle to the window whose messages are to be retrieved.
2046 */
2047 if ( ( !Window || // 1
2048 ( Window == PWND_BOTTOM && CurrentMessage->Msg.hwnd == NULL ) || // 2
2049 ( Window != PWND_BOTTOM && Window->head.h == CurrentMessage->Msg.hwnd ) || // 3
2050 ( is_mouse_message(CurrentMessage->Msg.message) ) ) && // Null window for anything mouse.
2051 ( ( ( MsgFilterLow == 0 && MsgFilterHigh == 0 ) && CurrentMessage->QS_Flags & QSflags ) ||
2052 ( MsgFilterLow <= CurrentMessage->Msg.message && MsgFilterHigh >= CurrentMessage->Msg.message ) ) )
2053 {
2054 idSave = MessageQueue->idSysPeek;
2055 MessageQueue->idSysPeek = (ULONG_PTR)CurrentMessage;
2056
2057 msg = CurrentMessage->Msg;
2058 ExtraInfo = CurrentMessage->ExtraInfo;
2059 QS_Flags = CurrentMessage->QS_Flags;
2060
2061 NotForUs = FALSE;
2062
2063 UpdateKeyStateFromMsg(MessageQueue, &msg);
2064 AcceptMessage = co_IntProcessHardwareMessage(&msg, &Remove, &NotForUs, ExtraInfo, MsgFilterLow, MsgFilterHigh);
2065
2066 if (Remove)
2067 {
2068 if (CurrentMessage->pti != NULL && (MessageQueue->idSysPeek == (ULONG_PTR)CurrentMessage))
2069 {
2070 MsqDestroyMessage(CurrentMessage);
2071 }
2072 ClearMsgBitsMask(pti, QS_Flags);
2073 }
2074
2075 MessageQueue->idSysPeek = idSave;
2076
2077 if (NotForUs)
2078 {
2079 Ret = FALSE;
2080 break;
2081 }
2082
2083 if (AcceptMessage)
2084 {
2085 *pMsg = msg;
2086 // Fix all but one wine win:test_GetMessagePos WM_TIMER tests. See PostTimerMessages.
2087 if (!RtlEqualMemory(&pti->ptLast, &msg.pt, sizeof(POINT)))
2088 {
2089 pti->TIF_flags |= TIF_MSGPOSCHANGED;
2090 }
2091 pti->timeLast = msg.time;
2092 pti->ptLast = msg.pt;
2093 MessageQueue->ExtraInfo = ExtraInfo;
2094 Ret = TRUE;
2095 break;
2096 }
2097 }
2098 }
2099
2100 MessageQueue->ptiSysLock = NULL;
2101 pti->pcti->CTI_flags &= ~CTI_THREADSYSLOCK;
2102 return Ret;
2103}
#define msg(x)
Definition: auth_time.c:54
unsigned long DWORD
Definition: ntddk_ex.h:95
#define PWND_BOTTOM
Definition: ntuser.h:764
#define CTI_THREADSYSLOCK
Definition: ntuser.h:161
VOID FASTCALL MsqDestroyMessage(PUSER_MESSAGE Message)
Definition: msgqueue.c:748
static BOOL is_mouse_message(UINT message)
Definition: msgqueue.c:1985
static VOID UpdateKeyStateFromMsg(PUSER_MESSAGE_QUEUE MessageQueue, MSG *msg)
Definition: msgqueue.c:265
static INT FASTCALL filter_contains_hw_range(UINT first, UINT last)
Definition: msgqueue.c:1969
BOOL co_IntProcessHardwareMessage(MSG *Msg, BOOL *RemoveMessages, BOOL *NotForUs, LONG_PTR ExtraInfo, UINT first, UINT last)
Definition: msgqueue.c:1953
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
ULONG_PTR idSysPeek
Definition: msgqueue.h:54
PTHREADINFO ptiSysLock
Definition: msgqueue.h:52
LIST_ENTRY HardwareMessagesListHead
Definition: msgqueue.h:59
_In_ BOOLEAN Remove
Definition: psfuncs.h:110

Referenced by co_IntPeekMessage().

◆ co_MsqReplyMessage()

BOOL FASTCALL co_MsqReplyMessage ( LRESULT  lResult)

Definition at line 2528 of file msgqueue.c.

2529{
2531 PTHREADINFO pti;
2532
2534 Message = pti->pusmCurrent;
2535
2536 if (!Message) return FALSE;
2537
2538 if (Message->QS_Flags & QS_SMRESULT) return FALSE;
2539
2540 // SendMessageXxx || Callback msg and not a notify msg
2541 if (Message->ptiSender || Message->CompletionCallback)
2542 {
2543 Message->lResult = lResult;
2544 Message->QS_Flags |= QS_SMRESULT;
2545 // See co_MsqDispatchOneSentMessage, change bits already accounted for and cleared and this msg is going away..
2546 }
2547 return TRUE;
2548}
struct _USER_SENT_MESSAGE * pusmCurrent
Definition: win32.h:98

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 1056 of file msgqueue.c.

1065{
1066 PTHREADINFO pti;
1067 PUSER_SENT_MESSAGE SaveMsg, Message;
1068 NTSTATUS WaitStatus;
1071 PWND pWnd;
1072 BOOLEAN SwapStateEnabled;
1073 LRESULT Result = 0;
1074
1076 ASSERT(pti != ptirec);
1077 ASSERT(ptirec->pcti); // Send must have a client side to receive it!!!!
1078
1079 /* Don't send from or to a dying thread */
1080 if (pti->TIF_flags & TIF_INCLEANUP || ptirec->TIF_flags & TIF_INCLEANUP)
1081 {
1082 // Unless we are dying and need to tell our parents.
1083 if (pti->TIF_flags & TIF_INCLEANUP && !(ptirec->TIF_flags & TIF_INCLEANUP))
1084 {
1085 // Parent notify is the big one. Fire and forget!
1086 TRACE("Send message from dying thread %u\n", Msg);
1087 co_MsqSendMessageAsync(ptirec, Wnd, Msg, wParam, lParam, NULL, 0, FALSE, HookMessage);
1088 }
1089 if (uResult) *uResult = -1;
1090 TRACE("MsqSM: Msg %u Current pti %lu or Rec pti %lu\n", Msg, pti->TIF_flags & TIF_INCLEANUP, ptirec->TIF_flags & TIF_INCLEANUP);
1091 return STATUS_UNSUCCESSFUL;
1092 }
1093
1094 if (IsThreadSuspended(ptirec))
1095 {
1096 ERR("Sending to Suspended Thread Msg %lx\n",Msg);
1097 if (uResult) *uResult = -1;
1098 return STATUS_UNSUCCESSFUL;
1099 }
1100
1101 // Should we do the same for No Wait?
1102 if ( HookMessage == MSQ_NORMAL )
1103 {
1104 pWnd = ValidateHwndNoErr(Wnd);
1105
1106 // These can not cross International Border lines!
1107 if ( pti->ppi != ptirec->ppi && pWnd )
1108 {
1109 switch(Msg)
1110 {
1111 // Handle the special case when working with password transfers across bordering processes.
1112 case EM_GETLINE:
1113 case EM_SETPASSWORDCHAR:
1114 case WM_GETTEXT:
1115 // Look for edit controls setup for passwords.
1116 if ( gpsi->atomSysClass[ICLS_EDIT] == pWnd->pcls->atomClassName && // Use atomNVClassName.
1117 pWnd->style & ES_PASSWORD )
1118 {
1119 if (uResult) *uResult = -1;
1120 ERR("Running across the border without a passport!\n");
1122 return STATUS_UNSUCCESSFUL;
1123 }
1124 break;
1125 case WM_NOTIFY:
1126 if (uResult) *uResult = -1;
1127 ERR("Running across the border without a passport!\n");
1128 return STATUS_UNSUCCESSFUL;
1129 }
1130 }
1131
1132 // These can not cross State lines!
1133 if ( Msg == WM_CREATE || Msg == WM_NCCREATE )
1134 {
1135 if (uResult) *uResult = -1;
1136 ERR("Can not tell the other State we have Create!\n");
1137 return STATUS_UNSUCCESSFUL;
1138 }
1139 }
1140
1142 {
1143 ERR("MsqSendMessage(): Not enough memory to allocate a message\n");
1144 if (uResult) *uResult = -1;
1146 }
1147
1148 Timeout.QuadPart = Int32x32To64(-10000,uTimeout); // Pass SMTO test with a TO of 0x80000000.
1149 TRACE("Timeout val %lld\n",Timeout.QuadPart);
1150
1151 Message->Msg.hwnd = Wnd;
1152 Message->Msg.message = Msg;
1153 Message->Msg.wParam = wParam;
1154 Message->Msg.lParam = lParam;
1155 Message->ptiReceiver = ptirec;
1156 Message->ptiSender = pti;
1157 Message->HookMessage = HookMessage;
1158 Message->QS_Flags = QS_SENDMESSAGE;
1159
1160 SaveMsg = pti->pusmSent;
1161 pti->pusmSent = Message;
1162
1163 /* Queue it in the destination's message queue */
1164 InsertTailList(&ptirec->SentMessagesListHead, &Message->ListEntry);
1165
1167
1168 // First time in, turn off swapping of the stack.
1169 if (pti->cEnterCount == 0)
1170 {
1171 SwapStateEnabled = KeSetKernelStackSwapEnable(FALSE);
1172 }
1173 pti->cEnterCount++;
1174
1175 if (Block)
1176 {
1177 PVOID WaitObjects[2];
1178
1179 WaitObjects[0] = Message->pkCompletionEvent; // Wait 0
1180 WaitObjects[1] = ptirec->pEThread; // Wait 1
1181
1182 UserLeaveCo();
1183
1184 WaitStatus = KeWaitForMultipleObjects( 2,
1185 WaitObjects,
1186 WaitAny,
1188 UserMode,
1189 FALSE,
1190 (uTimeout ? &Timeout : NULL),
1191 NULL );
1192
1193 UserEnterCo();
1194
1195 if (WaitStatus == STATUS_TIMEOUT)
1196 {
1197 /* Look up if the message has not yet dispatched, if so
1198 make sure it can't pass a result and it must not set the completion event anymore */
1200 while (Entry != &ptirec->SentMessagesListHead)
1201 {
1203 {
1204 Message->pkCompletionEvent = NULL;
1205 RemoveEntryList(&Message->ListEntry);
1206 ClearMsgBitsMask(ptirec, Message->QS_Flags);
1207 InsertTailList(&usmList, &Message->ListEntry);
1208 break;
1209 }
1210 Entry = Entry->Flink;
1211 }
1212
1213 ERR("MsqSendMessage (blocked) timed out 1 Status %lx\n", WaitStatus);
1214 }
1215 // Receiving thread passed on and left us hanging with issues still pending.
1216 else if (WaitStatus == STATUS_WAIT_1)
1217 {
1218 ERR("Bk Receiving Thread woken up dead!\n");
1219 Message->flags |= SMF_RECEIVERDIED;
1220 }
1221
1222 while (co_MsqDispatchOneSentMessage(pti))
1223 ;
1224 }
1225 else
1226 {
1227 PVOID WaitObjects[3];
1228
1229 WaitObjects[0] = Message->pkCompletionEvent; // Wait 0
1230 WaitObjects[1] = pti->pEventQueueServer; // Wait 1
1231 WaitObjects[2] = ptirec->pEThread; // Wait 2
1232
1233 do
1234 {
1235 UserLeaveCo();
1236
1237 WaitStatus = KeWaitForMultipleObjects( 3,
1238 WaitObjects,
1239 WaitAny,
1241 UserMode,
1242 FALSE,
1243 (uTimeout ? &Timeout : NULL),
1244 NULL);
1245
1246 UserEnterCo();
1247
1248 if (WaitStatus == STATUS_TIMEOUT)
1249 {
1250 /* Look up if the message has not yet been dispatched, if so
1251 make sure it can't pass a result and it must not set the completion event anymore */
1253 while (Entry != &ptirec->SentMessagesListHead)
1254 {
1256 {
1257 Message->pkCompletionEvent = NULL;
1258 RemoveEntryList(&Message->ListEntry);
1259 ClearMsgBitsMask(ptirec, Message->QS_Flags);
1260 InsertTailList(&usmList, &Message->ListEntry);
1261 break;
1262 }
1263 Entry = Entry->Flink;
1264 }
1265
1266 ERR("MsqSendMessage timed out 2 Status %lx\n", WaitStatus);
1267 break;
1268 }
1269 // Receiving thread passed on and left us hanging with issues still pending.
1270 else if (WaitStatus == STATUS_WAIT_2)
1271 {
1272 ERR("NB Receiving Thread woken up dead!\n");
1273 Message->flags |= SMF_RECEIVERDIED;
1274 break;
1275 }
1276
1277 if (WaitStatus == STATUS_USER_APC) break;
1278
1279 while (co_MsqDispatchOneSentMessage(pti))
1280 ;
1281 } while (WaitStatus == STATUS_WAIT_1);
1282 }
1283
1284 // Count is nil, restore swapping of the stack.
1285 if (--pti->cEnterCount == 0 )
1286 {
1287 KeSetKernelStackSwapEnable(SwapStateEnabled);
1288 }
1289
1290 // Handle User APC
1291 if (WaitStatus == STATUS_USER_APC)
1292 {
1293 // The current thread is dying!
1294 TRACE("User APC\n");
1295
1296 // The Message will be on the Trouble list until Thread cleanup.
1297 Message->flags |= SMF_SENDERDIED;
1298
1300 ERR("User APC Returned\n"); // Should not see this message.
1301 }
1302
1303 // Force this thread to wake up for the next go around.
1305
1306 Result = Message->lResult;
1307
1308 // Determine whether this message is being processed or not.
1310 {
1311 Message->flags |= SMF_RECEIVERFREE;
1312 }
1313
1314 if (!(Message->flags & SMF_RECEIVERFREE))
1315 {
1316 TRACE("Sender Freeing Message %p ptirec %p bit %d list empty %d\n",Message,ptirec,!!(ptirec->pcti->fsChangeBits & QS_SENDMESSAGE),IsListEmpty(&ptirec->SentMessagesListHead));
1317 // Make it to this point, the message was received.
1319 }
1320
1321 pti->pusmSent = SaveMsg;
1322
1323 TRACE("MSM Allocation Count %d Status %lx Result %d\n",SendMsgCount,WaitStatus,Result);
1324
1325 if (WaitStatus != STATUS_TIMEOUT)
1326 {
1327 if (uResult)
1328 {
1329 *uResult = (STATUS_WAIT_0 == WaitStatus ? Result : 0);
1330 }
1331 }
1332
1333 return WaitStatus;
1334}
unsigned char BOOLEAN
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
#define ICLS_EDIT
Definition: ntuser.h:908
BOOLEAN FASTCALL co_MsqDispatchOneSentMessage(_In_ PTHREADINFO pti)
Definition: msgqueue.c:873
BOOL FASTCALL IsThreadSuspended(PTHREADINFO pti)
Definition: msgqueue.c:2224
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
#define SMF_SENDERDIED
Definition: msgqueue.h:39
#define SMF_RECEIVERDIED
Definition: msgqueue.h:38
#define UserMode
Definition: asm.h:35
#define Int32x32To64(a, b)
@ WaitAny
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 STATUS_WAIT_0
Definition: ntstatus.h:237
#define STATUS_WAIT_1
Definition: ntstatus.h:71
#define STATUS_WAIT_2
Definition: ntstatus.h:72
#define ES_PASSWORD
Definition: pedump.c:670
static ULONG Timeout
Definition: ping.c:61
#define WM_NOTIFY
Definition: richedit.h:61
PPROCESSINFO ppi
Definition: win32.h:88
INT cEnterCount
Definition: win32.h:135
struct _USER_SENT_MESSAGE * pusmSent
Definition: win32.h:97
PKEVENT pEventQueueServer
Definition: win32.h:125
DWORD style
Definition: ntuser.h:701
BOOLEAN NTAPI KeSetKernelStackSwapEnable(IN BOOLEAN Enable)
Definition: thrdobj.c:997
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define UserEnterCo
Definition: ntuser.h:8
#define UserLeaveCo
Definition: ntuser.h:9
VOID FASTCALL co_IntDeliverUserAPC(VOID)
Definition: callback.c:1157
#define WM_CREATE
Definition: winuser.h:1598
#define EM_SETPASSWORDCHAR
Definition: winuser.h:2004
#define WM_GETTEXT
Definition: winuser.h:1608
#define WM_NCCREATE
Definition: winuser.h:1673
#define EM_GETLINE
Definition: winuser.h:1981
@ UserRequest
Definition: ketypes.h:409

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 PTHREADINFO ptiSender;
1026
1028 {
1029 ERR("MsqSendMessageAsync(): Not enough memory to allocate a message\n");
1030 return FALSE;
1031 }
1032
1033 ptiSender = PsGetCurrentThreadWin32Thread();
1034
1035 Message->Msg.hwnd = hwnd;
1036 Message->Msg.message = Msg;
1037 Message->Msg.wParam = wParam;
1038 Message->Msg.lParam = lParam;
1039 Message->pkCompletionEvent = NULL; // No event needed.
1040 Message->ptiReceiver = ptiReceiver;
1041 Message->ptiCallBackSender = ptiSender;
1042 Message->CompletionCallback = CompletionCallback;
1043 Message->CompletionCallbackContext = CompletionCallbackContext;
1044 Message->HookMessage = HookMessage;
1045 Message->HasPackedLParam = HasPackedLParam;
1046 Message->QS_Flags = QS_SENDMESSAGE;
1047 Message->flags = SMF_RECEIVERFREE;
1048
1049 InsertTailList(&ptiReceiver->SentMessagesListHead, &Message->ListEntry);
1050 MsqWakeQueue(ptiReceiver, QS_SENDMESSAGE, TRUE);
1051
1052 return TRUE;
1053}
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

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

◆ co_MsqWaitForNewMessages()

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

Definition at line 2163 of file msgqueue.c.

2165{
2167
2168 // Post mouse moves before waiting for messages.
2169 if (pti->MessageQueue->QF_flags & QF_MOUSEMOVED)
2170 {
2172 }
2173
2174 UserLeaveCo();
2175
2176 ZwYieldExecution(); // Let someone else run!
2177
2180 UserMode,
2181 FALSE,
2182 NULL );
2183 UserEnterCo();
2184 if ( ret == STATUS_USER_APC )
2185 {
2186 TRACE("MWFNW User APC\n");
2188 }
2189 return ret;
2190}
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
int ret

Referenced by co_IntGetPeekMessage(), and co_IntWaitMessage().

◆ CODE_SEG()

CODE_SEG ( "INIT"  )

Definition at line 1810 of file Interface.c.

1817{
1818 UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\FileSystem\\Filters\\"DRIVER_NAME);
1819 PDEVICE_OBJECT RawDeviceObject;
1821 PFILE_OBJECT RawFileObject;
1823 UNICODE_STRING SymLink;
1824
1826
1829
1830 /* Save the registry key for this driver */
1834 RegistryPath->MaximumLength,
1838
1839 /* Do some initialization */
1841
1842 /* Create the main filter manager device object */
1844 0,
1845 &DeviceName,
1848 FALSE,
1849 &DeviceObject);
1850 if (!NT_SUCCESS(Status))
1851 {
1852 DPRINT1("fltmgr IoCreateDevice failed. Status = %X\n", Status);
1853 goto Cleanup;
1854 }
1855
1856 /* Store a global reference so we can access from callbacks */
1858
1859 /* Generate the symbolic link name */
1860 RtlInitUnicodeString(&SymLink, L"\\??\\"DRIVER_NAME);
1862 if (!NT_SUCCESS(Status)) goto Cleanup;
1863
1864 /* Create the callbacks for the dispatch table, FastIo and FS callbacks */
1866 if (!NT_SUCCESS(Status)) goto Cleanup;
1867
1868 /* Initialize the comms objects */
1870 if (!NT_SUCCESS(Status)) goto Cleanup;
1871
1872 /* Register for notifications when a new file system is loaded. This also enumerates any existing file systems */
1874 FLT_ASSERT(Status != STATUS_DEVICE_ALREADY_ATTACHED); // Windows checks for this, I'm not sure how it can happen. Needs investigation??
1875 if (!NT_SUCCESS(Status)) goto Cleanup;
1876
1879
1880 /* IoRegisterFsRegistrationChange isn't notified about the raw file systems, so we attach to them manually */
1881 RtlInitUnicodeString(&ObjectName, L"\\Device\\RawDisk");
1884 &RawFileObject,
1885 &RawDeviceObject);
1886 if (NT_SUCCESS(Status))
1887 {
1888 FltpFsNotification(RawDeviceObject, TRUE);
1889 ObDereferenceObject(RawFileObject);
1890 }
1891
1892 RtlInitUnicodeString(&ObjectName, L"\\Device\\RawCdRom");
1895 &RawFileObject,
1896 &RawDeviceObject);
1897 if (NT_SUCCESS(Status))
1898 {
1899 FltpFsNotification(RawDeviceObject, TRUE);
1900 ObDereferenceObject(RawFileObject);
1901 }
1902
1903 /* We're done, clear the initializing flag */
1906
1907Cleanup:
1908
1909 if (!NT_SUCCESS(Status))
1910 {
1912 {
1913 DriverObject->FastIoDispatch = NULL;
1915 }
1916
1917 IoDeleteSymbolicLink(&SymLink);
1918
1919 if (DeviceObject)
1921
1924 }
1925
1926 return Status;
1927}
LIST_ENTRY FilterList
Definition: Filter.c:24
DRIVER_FS_NOTIFICATION FltpFsNotification
Definition: Interface.c:1699
ERESOURCE FilterListLock
Definition: Filter.c:25
static NTSTATUS SetupDispatchAndCallbacksTables(_In_ PDRIVER_OBJECT DriverObject)
Definition: Interface.c:1739
DRIVER_DATA DriverData
Definition: Interface.c:35
#define DPRINT1
Definition: precomp.h:8
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
static const WCHAR Cleanup[]
Definition: register.c:80
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define ClearFlag(_F, _SF)
Definition: ext2fs.h:191
#define DRIVER_NAME
Definition: ext2fs.h:136
#define FLT_ASSERT(_e)
Definition: fltkernel.h:49
#define FM_TAG_REGISTRY_DATA
Definition: fltmgr.h:18
#define FM_TAG_DISPATCH_TABLE
Definition: fltmgr.h:17
NTSTATUS FltpSetupCommunicationObjects(_In_ PDRIVER_OBJECT DriverObject)
Definition: Messaging.c:377
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1435
NTSTATUS NTAPI IoRegisterFsRegistrationChange(IN PDRIVER_OBJECT DriverObject, IN PDRIVER_FS_NOTIFICATION DriverNotificationRoutine)
Definition: volume.c:1089
#define STATUS_DEVICE_ALREADY_ATTACHED
Definition: ntstatus.h:292
#define L(x)
Definition: ntvdm.h:50
#define FILE_DEVICE_DISK_FILE_SYSTEM
Definition: winioctl.h:114
PDRIVER_OBJECT DriverObject
Definition: fltmgr.h:31
UNICODE_STRING ServiceKey
Definition: fltmgr.h:33
PFAST_IO_DISPATCH FastIoDispatch
Definition: fltmgr.h:37
FAST_MUTEX FilterAttachLock
Definition: fltmgr.h:39
PDEVICE_OBJECT DeviceObject
Definition: fltmgr.h:32
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
uint16_t * PWCHAR
Definition: typedefs.h:56
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_In_ PVOID _Out_opt_ PULONG_PTR _Outptr_opt_ PCUNICODE_STRING * ObjectName
Definition: cmfuncs.h:64
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
* PFILE_OBJECT
Definition: iotypes.h:1998
#define ObDereferenceObject
Definition: obfuncs.h:203

◆ FreeUserMessage()

VOID FASTCALL FreeUserMessage ( PUSER_SENT_MESSAGE  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}

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

◆ HungAppSysTimerProc()

VOID CALLBACK HungAppSysTimerProc ( HWND  hwnd,
UINT  uMsg,
UINT_PTR  idEvent,
DWORD  dwTime 
)

Definition at line 2237 of file msgqueue.c.

2238{
2240 TRACE("HungAppSysTimerProc\n");
2241 // Process list of windows that are hung and waiting.
2242}
VOID FASTCALL DoTheScreenSaver(VOID)
Definition: input.c:48

Referenced by StartTheTimers().

◆ IdlePing()

VOID FASTCALL IdlePing ( VOID  )

Definition at line 527 of file message.c.

528{
530 PTHREADINFO pti;
531
533
534 if ( pti )
535 {
536 pti->pClientInfo->cSpins = 0; // Reset spins.
537
538 if ( pti->pDeskInfo && pti == gptiForeground )
539 {
542 {
544 }
545 }
546 }
547
548 TRACE("IdlePing ppi %p\n", ppi);
549 if ( ppi && ppi->InputIdleEvent )
550 {
551 TRACE("InputIdleEvent\n");
552 KeSetEvent( ppi->InputIdleEvent, IO_NO_INCREMENT, FALSE);
553 }
554}
#define HOOKID_TO_FLAG(HookId)
Definition: hook.h:5
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:93
ULONG fsHooks
Definition: win32.h:117
PTHREADINFO gptiForeground
Definition: focus.c:15
#define WH_FOREGROUNDIDLE
Definition: winuser.h:41

Referenced by co_IntGetPeekMessage(), and IntMsqSetWakeMask().

◆ IdlePong()

VOID FASTCALL IdlePong ( VOID  )

Definition at line 557 of file message.c.

558{
560
561 TRACE("IdlePong ppi %p\n", ppi);
562 if ( ppi && ppi->InputIdleEvent )
563 {
564 KeClearEvent(ppi->InputIdleEvent);
565 }
566}
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22

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

◆ IntCallMsgFilter()

BOOL FASTCALL IntCallMsgFilter ( LPMSG  lpmsg,
INT  code 
)

Definition at line 2137 of file message.c.

2138{
2139 BOOL Ret = FALSE;
2140
2141 if ( co_HOOK_CallHooks( WH_SYSMSGFILTER, code, 0, (LPARAM)lpmsg))
2142 {
2143 Ret = TRUE;
2144 }
2145 else
2146 {
2147 Ret = co_HOOK_CallHooks( WH_MSGFILTER, code, 0, (LPARAM)lpmsg);
2148 }
2149 return Ret;
2150}
#define WH_MSGFILTER
Definition: winuser.h:29
#define WH_SYSMSGFILTER
Definition: winuser.h:36

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

◆ IntCoalesceMouseMove()

VOID FASTCALL IntCoalesceMouseMove ( PTHREADINFO  pti)

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);
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}
VOID FASTCALL MsqPostMouseMove(PTHREADINFO pti, MSG *Msg, LONG_PTR ExtraInfo)
Definition: msgqueue.c:518

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

◆ IntDispatchMessage()

LRESULT FASTCALL IntDispatchMessage ( MSG Msg)

◆ IntGetQueueStatus()

DWORD APIENTRY IntGetQueueStatus ( DWORD  Changes)

Definition at line 2086 of file message.c.

2087{
2088 PTHREADINFO pti;
2089 DWORD Result;
2090
2092// wine:
2094
2095 /* High word, types of messages currently in the queue.
2096 Low word, types of messages that have been added to the queue and that
2097 are still in the queue
2098 */
2099 Result = MAKELONG(pti->pcti->fsChangeBits & Changes, pti->pcti->fsWakeBits & Changes);
2100
2101 pti->pcti->fsChangeBits &= ~Changes;
2102
2103 return Result;
2104}
#define QS_ALLPOSTMESSAGE
Definition: winuser.h:876
#define QS_ALLINPUT
Definition: winuser.h:897

Referenced by NtUserCallOneParam(), and NtUserGetThreadState().

◆ IntInitMessagePumpHook()

BOOL APIENTRY IntInitMessagePumpHook ( VOID  )

Definition at line 2107 of file message.c.

2108{
2110
2111 if (pti->pcti)
2112 {
2113 pti->pcti->dwcPumpHook++;
2114 return TRUE;
2115 }
2116 return FALSE;
2117}

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}

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}
HANDLE hEventQueueClient
Definition: win32.h:123
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define MWMO_INPUTAVAILABLE
Definition: winuser.h:904

Referenced by NtUserCallOneParam().

◆ IntTranslateKbdMessage()

BOOL FASTCALL IntTranslateKbdMessage ( LPMSG  lpMsg,
UINT  flags 
)

Definition at line 1152 of file keyboard.c.

1154{
1155 PTHREADINFO pti;
1156 INT cch = 0, i;
1157 WCHAR wch[3] = { 0 };
1158 MSG NewMsg = { 0 };
1159 PKBDTABLES pKbdTbl;
1160 BOOL bResult = FALSE;
1161
1162 switch(lpMsg->message)
1163 {
1164 case WM_KEYDOWN:
1165 case WM_KEYUP:
1166 case WM_SYSKEYDOWN:
1167 case WM_SYSKEYUP:
1168 break;
1169 default:
1170 return FALSE;
1171 }
1172
1174
1175 if (!pti->KeyboardLayout)
1176 {
1177 PKL pDefKL = W32kGetDefaultKeyLayout();
1178 UserAssignmentLock((PVOID*)&(pti->KeyboardLayout), pDefKL);
1179 if (pDefKL)
1180 {
1181 pti->pClientInfo->hKL = pDefKL->hkl;
1182 pKbdTbl = pDefKL->spkf->pKbdTbl;
1183 }
1184 else
1185 {
1186 pti->pClientInfo->hKL = NULL;
1187 pKbdTbl = NULL;
1188 }
1189 }
1190 else
1191 pKbdTbl = pti->KeyboardLayout->spkf->pKbdTbl;
1192 if (!pKbdTbl)
1193 return FALSE;
1194
1195 if (lpMsg->message != WM_KEYDOWN && lpMsg->message != WM_SYSKEYDOWN)
1196 return FALSE;
1197
1198 /* Init pt, hwnd and time msg fields */
1199 NewMsg.pt = gpsi->ptCursor;
1200 NewMsg.hwnd = lpMsg->hwnd;
1201 NewMsg.time = EngGetTickCount32();
1202
1203 TRACE("Enter IntTranslateKbdMessage msg %s, vk %x\n",
1204 lpMsg->message == WM_SYSKEYDOWN ? "WM_SYSKEYDOWN" : "WM_KEYDOWN", lpMsg->wParam);
1205
1206 if (lpMsg->wParam == VK_PACKET)
1207 {
1208 NewMsg.message = (lpMsg->message == WM_KEYDOWN) ? WM_CHAR : WM_SYSCHAR;
1209 NewMsg.wParam = HIWORD(lpMsg->lParam);
1210 NewMsg.lParam = LOWORD(lpMsg->lParam);
1211 MsqPostMessage(pti, &NewMsg, FALSE, QS_KEY, 0, 0);
1212 return TRUE;
1213 }
1214
1215 cch = IntToUnicodeEx(lpMsg->wParam,
1216 HIWORD(lpMsg->lParam) & 0xFF,
1217 pti->MessageQueue->afKeyState,
1218 wch,
1219 sizeof(wch) / sizeof(wch[0]),
1220 0,
1221 pKbdTbl);
1222
1223 if (cch)
1224 {
1225 if (cch > 0) /* Normal characters */
1226 NewMsg.message = (lpMsg->message == WM_KEYDOWN) ? WM_CHAR : WM_SYSCHAR;
1227 else /* Dead character */
1228 {
1229 cch = -cch;
1230 NewMsg.message =
1232 }
1233 NewMsg.lParam = lpMsg->lParam;
1234
1235 /* Send all characters */
1236 for (i = 0; i < cch; ++i)
1237 {
1238 TRACE("Msg: %x '%lc' (%04x) %08x\n", NewMsg.message, wch[i], wch[i], NewMsg.lParam);
1239 NewMsg.wParam = wch[i];
1240 MsqPostMessage(pti, &NewMsg, FALSE, QS_KEY, 0, 0);
1241 }
1242 bResult = TRUE;
1243 }
1244
1245 TRACE("Leave IntTranslateKbdMessage ret %d, cch %d, msg %x, wch %x\n",
1246 bResult, cch, NewMsg.message, NewMsg.wParam);
1247 return bResult;
1248}
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
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
Definition: kbd.h:95
struct tagKL * KeyboardLayout
Definition: win32.h:90
struct _KBDTABLES * pKbdTbl
Definition: input.h:21
Definition: input.h:27
PKBDFILE spkf
Definition: input.h:33
HKL hkl
Definition: input.h:32
HWND hwnd
Definition: winuser.h:3104
LPARAM lParam
Definition: winuser.h:3107
PKL W32kGetDefaultKeyLayout(VOID)
Definition: kbdlayout.c:514
static int APIENTRY IntToUnicodeEx(UINT wVirtKey, UINT wScanCode, PBYTE pKeyState, LPWSTR pwszBuff, int cchBuff, UINT wFlags, PKBDTABLES pKbdTbl)
Definition: keyboard.c:432
PVOID FASTCALL UserAssignmentLock(PVOID *ppvObj, PVOID pvNew)
Definition: object.c:840
#define WM_KEYUP
Definition: winuser.h:1706
#define WM_SYSCHAR
Definition: winuser.h:1711
#define WM_SYSDEADCHAR
Definition: winuser.h:1712
#define WM_SYSKEYUP
Definition: winuser.h:1710
#define WM_CHAR
Definition: winuser.h:1707
#define WM_KEYDOWN
Definition: winuser.h:1705
#define WM_DEADCHAR
Definition: winuser.h:1708
#define WM_SYSKEYDOWN
Definition: winuser.h:1709
__wchar_t WCHAR
Definition: xmlstorage.h:180

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

◆ IntUninitMessagePumpHook()

BOOL APIENTRY IntUninitMessagePumpHook ( VOID  )

Definition at line 2120 of file message.c.

2121{
2123
2124 if (pti->pcti)
2125 {
2126 if (pti->pcti->dwcPumpHook <= 0)
2127 {
2128 return FALSE;
2129 }
2130 pti->pcti->dwcPumpHook--;
2131 return TRUE;
2132 }
2133 return FALSE;
2134}

Referenced by NtUserCallNoParam().

◆ IsThreadSuspended()

BOOL FASTCALL IsThreadSuspended ( PTHREADINFO  pti)

Definition at line 2224 of file msgqueue.c.

2225{
2226 if (pti->pEThread)
2227 {
2228 BOOL Ret = TRUE;
2229 if (!(pti->pEThread->Tcb.SuspendCount) && !PsGetThreadFreezeCount(pti->pEThread)) Ret = FALSE;
2230 return Ret;
2231 }
2232 return FALSE;
2233}
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 255 of file message.c.

256{
257 PMSGMEMORY MsgMemoryEntry = FindMsgMemory(Msg);
258 if(MsgMemoryEntry == NULL) return 0;
259 return MsgMemorySize(MsgMemoryEntry, wParam, lParam);
260}

Referenced by co_IntCallHookProc().

◆ MsqCleanupThreadMsgs()

VOID FASTCALL MsqCleanupThreadMsgs ( PTHREADINFO  pti)

Definition at line 2265 of file msgqueue.c.

2266{
2267 PLIST_ENTRY CurrentEntry;
2268 PUSER_MESSAGE CurrentMessage;
2269 PUSER_SENT_MESSAGE CurrentSentMessage;
2270
2271 TRACE("MsqCleanupThreadMsgs %p\n",pti);
2272
2273 // Clear it all out.
2274 if (pti->pcti)
2275 {
2276 pti->pcti->fsWakeBits = 0;
2277 pti->pcti->fsChangeBits = 0;
2278 }
2279
2280 pti->nCntsQBits[QSRosKey] = 0;
2281 pti->nCntsQBits[QSRosMouseMove] = 0;
2282 pti->nCntsQBits[QSRosMouseButton] = 0;
2283 pti->nCntsQBits[QSRosPostMessage] = 0;
2284 pti->nCntsQBits[QSRosSendMessage] = 0;
2285 pti->nCntsQBits[QSRosHotKey] = 0;
2286 pti->nCntsQBits[QSRosEvent] = 0;
2287
2288 /* cleanup posted messages */
2289 while (!IsListEmpty(&pti->PostedMessagesListHead))
2290 {
2291 CurrentEntry = pti->PostedMessagesListHead.Flink;
2292 CurrentMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, ListEntry);
2293 ERR("Thread Cleanup Post Messages %p\n",CurrentMessage);
2294 if (CurrentMessage->dwQEvent)
2295 {
2296 if (CurrentMessage->dwQEvent == POSTEVENT_NWE)
2297 {
2298 ExFreePoolWithTag( (PVOID)CurrentMessage->ExtraInfo, TAG_HOOK);
2299 }
2300 }
2301 MsqDestroyMessage(CurrentMessage);
2302 }
2303
2304 /* remove the messages that have not yet been dispatched */
2305 while (!IsListEmpty(&pti->SentMessagesListHead))
2306 {
2307 CurrentEntry = pti->SentMessagesListHead.Flink;
2308 CurrentSentMessage = CONTAINING_RECORD(CurrentEntry, USER_SENT_MESSAGE, ListEntry);
2309
2310 ERR("Thread Cleanup Sent Messages %p\n",CurrentSentMessage);
2311
2312 /* wake the sender's thread */
2313 if (CurrentSentMessage->pkCompletionEvent != NULL)
2314 {
2315 KeSetEvent(CurrentSentMessage->pkCompletionEvent, IO_NO_INCREMENT, FALSE);
2316 }
2317
2318 if (CurrentSentMessage->HasPackedLParam)
2319 {
2320 if (CurrentSentMessage->Msg.lParam)
2321 ExFreePool((PVOID)CurrentSentMessage->Msg.lParam);
2322 }
2323
2324 /* free the message */
2325 FreeUserMessage(CurrentSentMessage);
2326 }
2327
2328 // Process Trouble Message List
2329 if (!IsListEmpty(&usmList))
2330 {
2331 CurrentEntry = usmList.Flink;
2332 while (CurrentEntry != &usmList)
2333 {
2334 CurrentSentMessage = CONTAINING_RECORD(CurrentEntry, USER_SENT_MESSAGE, ListEntry);
2335 CurrentEntry = CurrentEntry->Flink;
2336
2337 TRACE("Found troubled messages %p on the list\n",CurrentSentMessage);
2338
2339 if ( pti == CurrentSentMessage->ptiReceiver )
2340 {
2341 if (CurrentSentMessage->HasPackedLParam)
2342 {
2343 if (CurrentSentMessage->Msg.lParam)
2344 ExFreePool((PVOID)CurrentSentMessage->Msg.lParam);
2345 }
2346
2347 /* free the message */
2348 FreeUserMessage(CurrentSentMessage);
2349 }
2350 else if ( pti == CurrentSentMessage->ptiSender ||
2351 pti == CurrentSentMessage->ptiCallBackSender )
2352 {
2353 // Determine whether this message is being processed or not.
2354 if ((CurrentSentMessage->flags & (SMF_RECEIVERBUSY|SMF_RECEIVEDMESSAGE)) != SMF_RECEIVEDMESSAGE)
2355 {
2356 CurrentSentMessage->flags |= SMF_RECEIVERFREE;
2357 }
2358
2359 if (!(CurrentSentMessage->flags & SMF_RECEIVERFREE))
2360 {
2361
2362 if (CurrentSentMessage->HasPackedLParam)
2363 {
2364 if (CurrentSentMessage->Msg.lParam)
2365 ExFreePool((PVOID)CurrentSentMessage->Msg.lParam);
2366 }
2367
2368 /* free the message */
2369 FreeUserMessage(CurrentSentMessage);
2370 }
2371 }
2372 }
2373 }
2374}
#define POSTEVENT_NWE
Definition: msgqueue.h:125
LIST_ENTRY PostedMessagesListHead
Definition: win32.h:137
LONG_PTR ExtraInfo
Definition: msgqueue.h:13
DWORD dwQEvent
Definition: msgqueue.h:14
BOOL HasPackedLParam
Definition: msgqueue.h:34
PTHREADINFO ptiReceiver
Definition: msgqueue.h:29
PTHREADINFO ptiCallBackSender
Definition: msgqueue.h:31
PKEVENT pkCompletionEvent
Definition: msgqueue.h:25
PTHREADINFO ptiSender
Definition: msgqueue.h:28
#define TAG_HOOK
Definition: tags.h:5

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}
INT PostMsgCount
Definition: msgqueue.c:18
static PPAGED_LOOKASIDE_LIST pgMessageLookasideList
Definition: msgqueue.c:16
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264

Referenced by MsqPostMessage().

◆ MsqCreateMessageQueue()

PUSER_MESSAGE_QUEUE FASTCALL MsqCreateMessageQueue ( PTHREADINFO  pti)

Definition at line 2440 of file msgqueue.c.

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

Referenced by InitThreadCallback(), and UserAttachThreadInput().

◆ MsqDecPaintCountQueue()

VOID FASTCALL MsqDecPaintCountQueue ( PTHREADINFO  pti)

◆ 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}

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

◆ MsqDestroyMessageQueue()

VOID FASTCALL MsqDestroyMessageQueue ( _In_ PTHREADINFO  pti)

Definition at line 2467 of file msgqueue.c.

2468{
2469 PDESKTOP desk;
2470 PUSER_MESSAGE_QUEUE MessageQueue = pti->MessageQueue;
2471
2472 NT_ASSERT(MessageQueue != NULL);
2473 MessageQueue->QF_flags |= QF_INDESTROY;
2474
2475 /* remove the message queue from any desktops */
2476 if ((desk = InterlockedExchangePointer((PVOID*)&MessageQueue->Desktop, 0)))
2477 {
2479 IntDereferenceMessageQueue(MessageQueue);
2480 }
2481
2482 /* clean it up */
2484
2485 /* decrease the reference counter, if it hits zero, the queue will be freed */
2487 IntDereferenceMessageQueue(MessageQueue);
2488}
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
VOID FASTCALL MsqCleanupMessageQueue(PTHREADINFO pti)
Definition: msgqueue.c:2377
struct _USER_MESSAGE_QUEUE * ActiveMessageQueue
Definition: desktop.h:38
struct _DESKTOP * Desktop
Definition: msgqueue.h:50
#define _PRAGMA_WARNING_SUPPRESS(x)
Definition: suppress.h:28
#define __WARNING_USING_UNINIT_VAR
Definition: suppress.h:31
#define NT_ASSERT
Definition: rtlfuncs.h:3310

Referenced by UserAttachThreadInput(), and UserDeleteW32Thread().

◆ MsqGetDownKeyState()

WPARAM FASTCALL MsqGetDownKeyState ( PUSER_MESSAGE_QUEUE  MessageQueue)

Definition at line 338 of file msgqueue.c.

339{
340 WPARAM ret = 0;
341
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}
BOOL bMouseBtnSwap
Definition: sysparams.h:82
BYTE afKeyState[256 *2/8]
Definition: msgqueue.h:84
#define IS_KEY_DOWN(ks, vk)
Definition: input.h:99
SPIVALUES gspv
Definition: sysparams.c:17
UINT_PTR WPARAM
Definition: windef.h:207
#define MK_RBUTTON
Definition: winuser.h:2358
#define MK_SHIFT
Definition: winuser.h:2359
#define VK_RBUTTON
Definition: winuser.h:2181
#define VK_CONTROL
Definition: winuser.h:2193
#define VK_MBUTTON
Definition: winuser.h:2183
#define MK_MBUTTON
Definition: winuser.h:2361
#define MK_CONTROL
Definition: winuser.h:2360
#define MK_LBUTTON
Definition: winuser.h:2357
#define VK_SHIFT
Definition: winuser.h:2192
#define VK_LBUTTON
Definition: winuser.h:2180

Referenced by co_IntProcessMouseMessage(), and SystemTimerProc().

◆ MsqGetMessageExtraInfo()

LPARAM FASTCALL MsqGetMessageExtraInfo ( VOID  )

Definition at line 2511 of file msgqueue.c.

2512{
2513 PTHREADINFO pti;
2514 PUSER_MESSAGE_QUEUE MessageQueue;
2515
2517 MessageQueue = pti->MessageQueue;
2518 if(!MessageQueue)
2519 {
2520 return 0;
2521 }
2522
2523 return MessageQueue->ExtraInfo;
2524}

Referenced by NtUserGetThreadState().

◆ MsqIncPaintCountQueue()

VOID FASTCALL MsqIncPaintCountQueue ( PTHREADINFO  pti)

Definition at line 501 of file msgqueue.c.

502{
503 pti->cPaintsReady++;
505}

Referenced by IntInvalidateWindows().

◆ MsqInitializeMessageQueue()

BOOLEAN FASTCALL MsqInitializeMessageQueue ( PTHREADINFO  pti,
PUSER_MESSAGE_QUEUE  MessageQueue 
)

Definition at line 2245 of file msgqueue.c.

2246{
2247 InitializeListHead(&MessageQueue->HardwareMessagesListHead); // Keep here!
2248 MessageQueue->spwndFocus = NULL;
2249 MessageQueue->iCursorLevel = 0;
2250 MessageQueue->CursorObject = SYSTEMCUR(WAIT); // See test_initial_cursor.
2251 if (MessageQueue->CursorObject)
2252 {
2253 TRACE("Default cursor hcur %p\n",UserHMGetHandle(MessageQueue->CursorObject));
2254 UserReferenceObject(MessageQueue->CursorObject);
2255 }
2257 MessageQueue->ptiMouse = pti;
2258 MessageQueue->ptiKeyboard = pti;
2259 MessageQueue->cThreads++;
2260
2261 return TRUE;
2262}
#define SYSTEMCUR(func)
Definition: cursoricon.h:129
#define WAIT
Definition: listbox.c:36
PTHREADINFO ptiKeyboard
Definition: msgqueue.h:56
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
BYTE gafAsyncKeyState[256 *2/8]
Definition: keyboard.c:13
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:731

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 2193 of file msgqueue.c.

2194{
2195 DWORD dwTimeStamp = EngGetTickCount32();
2196 if (dwTimeStamp - pti->pcti->timeLastRead > TimeOut &&
2197 !(pti->pcti->fsWakeMask & QS_INPUT) &&
2198 !PsGetThreadFreezeCount(pti->pEThread) &&
2199 !(pti->ppi->W32PF_flags & W32PF_APPSTARTING))
2200 {
2201 TRACE("\nMsqIsHung(pti %p, TimeOut %lu)\n"
2202 "pEThread %p, ThreadsProcess %p, ImageFileName '%s'\n"
2203 "dwTimeStamp = %lu\n"
2204 "pti->pcti->timeLastRead = %lu\n"
2205 "pti->timeLast = %lu\n"
2206 "PsGetThreadFreezeCount(pti->pEThread) = %lu\n",
2207 pti, TimeOut,
2208 pti->pEThread,
2209 pti->pEThread ? pti->pEThread->ThreadsProcess : NULL,
2210 (pti->pEThread && pti->pEThread->ThreadsProcess)
2211 ? pti->pEThread->ThreadsProcess->ImageFileName : "(None)",
2212 dwTimeStamp,
2213 pti->pcti->timeLastRead,
2214 pti->timeLast,
2215 PsGetThreadFreezeCount(pti->pEThread));
2216
2217 return TRUE;
2218 }
2219
2220 return FALSE;
2221}
#define W32PF_APPSTARTING
Definition: win32.h:10
#define QS_INPUT
Definition: winuser.h:893

Referenced by co_IntSendMessageTimeoutSingle(), IntMakeHungWindowGhosted(), 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 2106 of file msgqueue.c.

2115{
2116 PUSER_MESSAGE CurrentMessage;
2117 PLIST_ENTRY ListHead;
2118 DWORD QS_Flags;
2119 BOOL Ret = FALSE;
2120
2121 ListHead = pti->PostedMessagesListHead.Flink;
2122
2123 if (IsListEmpty(ListHead)) return FALSE;
2124
2125 while(ListHead != &pti->PostedMessagesListHead)
2126 {
2127 CurrentMessage = CONTAINING_RECORD(ListHead, USER_MESSAGE, ListEntry);
2128 ListHead = ListHead->Flink;
2129/*
2130 MSDN:
2131 1: any window that belongs to the current thread, and any messages on the current thread's message queue whose hwnd value is NULL.
2132 2: retrieves only messages on the current thread's message queue whose hwnd value is NULL.
2133 3: handle to the window whose messages are to be retrieved.
2134 */
2135 if ( ( !Window || // 1
2136 ( Window == PWND_BOTTOM && CurrentMessage->Msg.hwnd == NULL ) || // 2
2137 ( Window != PWND_BOTTOM && Window->head.h == CurrentMessage->Msg.hwnd ) ) && // 3
2138 ( ( ( MsgFilterLow == 0 && MsgFilterHigh == 0 ) && CurrentMessage->QS_Flags & QSflags ) ||
2139 ( MsgFilterLow <= CurrentMessage->Msg.message && MsgFilterHigh >= CurrentMessage->Msg.message ) ) )
2140 {
2141 *Message = CurrentMessage->Msg;
2142 *ExtraInfo = CurrentMessage->ExtraInfo;
2143 QS_Flags = CurrentMessage->QS_Flags;
2144 if (dwQEvent) *dwQEvent = CurrentMessage->dwQEvent;
2145
2146 if (Remove)
2147 {
2148 if (CurrentMessage->pti != NULL)
2149 {
2150 MsqDestroyMessage(CurrentMessage);
2151 }
2152 ClearMsgBitsMask(pti, QS_Flags);
2153 }
2154 Ret = TRUE;
2155 break;
2156 }
2157 }
2158
2159 return Ret;
2160}
PTHREADINFO pti
Definition: msgqueue.h:15
DWORD QS_Flags
Definition: msgqueue.h:12

Referenced by co_IntPeekMessage().

◆ MsqPostMessage()

VOID FASTCALL MsqPostMessage ( PTHREADINFO  pti,
MSG Msg,
BOOLEAN  HardwareMessage,
DWORD  MessageBits,
DWORD  dwQEvent,
LONG_PTR  ExtraInfo 
)

Definition at line 1337 of file msgqueue.c.

1343{
1345 PUSER_MESSAGE_QUEUE MessageQueue;
1346
1347 if ( pti->TIF_flags & TIF_INCLEANUP || pti->MessageQueue->QF_flags & QF_INDESTROY )
1348 {
1349 ERR("Post Msg; Thread or Q is Dead!\n");
1350 return;
1351 }
1352
1353 if(!(Message = MsqCreateMessage(Msg)))
1354 {
1355 return;
1356 }
1357
1358 MessageQueue = pti->MessageQueue;
1359
1360 if (!HardwareMessage)
1361 {
1362 InsertTailList(&pti->PostedMessagesListHead, &Message->ListEntry);
1363 }
1364 else
1365 {
1366 InsertTailList(&MessageQueue->HardwareMessagesListHead, &Message->ListEntry);
1367 }
1368
1369 if (Msg->message == WM_HOTKEY) MessageBits |= QS_HOTKEY; // Justin Case, just set it.
1370 Message->dwQEvent = dwQEvent;
1371 Message->ExtraInfo = ExtraInfo;
1372 Message->QS_Flags = MessageBits;
1373 Message->pti = pti;
1374 MsqWakeQueue(pti, MessageBits, TRUE);
1375 TRACE("Post Message %d\n",PostMsgCount);
1376}
PUSER_MESSAGE FASTCALL MsqCreateMessage(LPMSG Msg)
Definition: msgqueue.c:731
#define WM_HOTKEY
Definition: winuser.h:1869

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

◆ MsqPostQuitMessage()

VOID FASTCALL MsqPostQuitMessage ( PTHREADINFO  pti,
ULONG  ExitCode 
)

Definition at line 1379 of file msgqueue.c.

1380{
1381 pti->QuitPosted = TRUE;
1382 pti->exitCode = ExitCode;
1384}
INT exitCode
Definition: win32.h:107
BOOLEAN QuitPosted
Definition: win32.h:105

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}

Referenced by co_UserFreeWindow().

◆ MsqSetMessageExtraInfo()

LPARAM FASTCALL MsqSetMessageExtraInfo ( LPARAM  lParam)

Definition at line 2491 of file msgqueue.c.

2492{
2493 LPARAM Ret;
2494 PTHREADINFO pti;
2495 PUSER_MESSAGE_QUEUE MessageQueue;
2496
2498 MessageQueue = pti->MessageQueue;
2499 if(!MessageQueue)
2500 {
2501 return 0;
2502 }
2503
2504 Ret = MessageQueue->ExtraInfo;
2505 MessageQueue->ExtraInfo = lParam;
2506
2507 return Ret;
2508}

Referenced by NtUserCallOneParam().

◆ MsqSetStateWindow()

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

Definition at line 2551 of file msgqueue.c.

2552{
2553 HWND Prev;
2554 PUSER_MESSAGE_QUEUE MessageQueue;
2555
2556 MessageQueue = pti->MessageQueue;
2557
2558 switch(Type)
2559 {
2560 case MSQ_STATE_CAPTURE:
2561 Prev = MessageQueue->spwndCapture ? UserHMGetHandle(MessageQueue->spwndCapture) : 0;
2562 MessageQueue->spwndCapture = ValidateHwndNoErr(hWnd);
2563 return Prev;
2564 case MSQ_STATE_ACTIVE:
2565 Prev = MessageQueue->spwndActive ? UserHMGetHandle(MessageQueue->spwndActive) : 0;
2566 MessageQueue->spwndActive = ValidateHwndNoErr(hWnd);
2567 return Prev;
2568 case MSQ_STATE_FOCUS:
2569 Prev = MessageQueue->spwndFocus ? UserHMGetHandle(MessageQueue->spwndFocus) : 0;
2570 MessageQueue->spwndFocus = ValidateHwndNoErr(hWnd);
2571 return Prev;
2573 Prev = MessageQueue->MenuOwner;
2574 MessageQueue->MenuOwner = hWnd;
2575 return Prev;
2576 case MSQ_STATE_MOVESIZE:
2577 Prev = MessageQueue->MoveSize;
2578 MessageQueue->MoveSize = hWnd;
2579 return Prev;
2580 case MSQ_STATE_CARET:
2581 Prev = MessageQueue->CaretInfo.hWnd;
2582 MessageQueue->CaretInfo.hWnd = hWnd;
2583 return Prev;
2584 }
2585
2586 return NULL;
2587}
Type
Definition: Type.h:7
#define MSQ_STATE_CARET
Definition: ntuser.h:3704
#define MSQ_STATE_MOVESIZE
Definition: ntuser.h:3703
#define MSQ_STATE_CAPTURE
Definition: ntuser.h:3699
#define MSQ_STATE_FOCUS
Definition: ntuser.h:3701
#define MSQ_STATE_ACTIVE
Definition: ntuser.h:3700
#define MSQ_STATE_MENUOWNER
Definition: ntuser.h:3702
THRDCARETINFO CaretInfo
Definition: msgqueue.h:92

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

◆ MsqWakeQueue()

VOID FASTCALL MsqWakeQueue ( PTHREADINFO  pti,
DWORD  MessageBits,
BOOL  KeyEvent 
)

Definition at line 412 of file msgqueue.c.

413{
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)
442}
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2225
#define QS_MOUSE
Definition: winuser.h:886

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 1309 of file message.c.

1313{
1314 MSG Message;
1315
1317 {
1319 return FALSE;
1320 }
1321 Message.hwnd = NULL;
1322 Message.message = Msg;
1323 Message.wParam = wParam;
1324 Message.lParam = lParam;
1325 Message.pt = gpsi->ptCursor;
1326 Message.time = EngGetTickCount32();
1328 return TRUE;
1329}
static int is_pointer_message(UINT message, WPARAM wparam)
Definition: message.c:99
#define ERROR_MESSAGE_SYNC_ONLY
Definition: winerror.h:681

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

◆ UserSendNotifyMessage()

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

Definition at line 2037 of file message.c.

2041{
2042 BOOL Ret = TRUE;
2043
2045 {
2047 return FALSE;
2048 }
2049
2050 // Basicly the same as IntPostOrSendMessage
2051 if (hWnd == HWND_BROADCAST) // Handle Broadcast
2052 {
2053 HWND *List;
2055 ULONG i;
2056
2059
2060 if (List != NULL)
2061 {
2063 for (i = 0; List[i]; i++)
2064 {
2065 PWND pwnd = UserGetWindowObject(List[i]);
2066 if (!pwnd) continue;
2067
2068 if ( pwnd->fnid == FNID_MENU ||
2070 continue;
2071
2073 }
2075 }
2076 }
2077 else
2078 {
2080 }
2081 return Ret;
2082}
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1710
BOOL FASTCALL UserSendNotifyMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:2037

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 */
156 GreMovePointer(hdcScreen, -1, -1);
157 TRACE("Removing pointer!\n");
158 }
160 }
161
162 /* Return the old cursor */
163 return OldCursor;
164}
#define FIXME(fmt,...)
Definition: debug.h:111
struct tagACON * PACON
#define CURSORF_ACON
Definition: ntuser.h:1197
ULONG CURSORF_flags
Definition: cursoricon.h:16

Referenced by DefWndDoSizeMove(), DesktopWindowProc(), IntSystemSetCursor(), NtUserSetCursor(), and UserChangeDisplaySettings().

◆ UserShowCursor()

int UserShowCursor ( BOOL  bShow)

Definition at line 168 of file msgqueue.c.

169{
170 HDC hdcScreen;
171 PTHREADINFO pti;
172 PUSER_MESSAGE_QUEUE MessageQueue;
173 PWND pWnd;
174
175 if (!(hdcScreen = IntGetScreenDC()))
176 {
177 return -1; /* No mouse */
178 }
179
181 MessageQueue = pti->MessageQueue;
182
183 /* Update counter */
184 MessageQueue->iCursorLevel += bShow ? 1 : -1;
185 pti->iCursorLevel += bShow ? 1 : -1;
186
187 /* Check for trivial cases */
188 if ((bShow && MessageQueue->iCursorLevel != 0) ||
189 (!bShow && MessageQueue->iCursorLevel != -1))
190 {
191 /* Note: w don't update global info here because it is used only
192 internally to check if cursor is visible */
193 return MessageQueue->iCursorLevel;
194 }
195
196 /* Check if cursor is above window owned by this MessageQueue */
197 pWnd = IntTopLevelWindowFromPoint(gpsi->ptCursor.x, gpsi->ptCursor.y);
198 if (pWnd && pWnd->head.pti->MessageQueue == MessageQueue)
199 {
200 if (bShow)
201 {
202 /* Show the pointer */
203 GreMovePointer(hdcScreen, gpsi->ptCursor.x, gpsi->ptCursor.y);
204 TRACE("Showing pointer!\n");
205 }
206 else
207 {
208 /* Remove the pointer */
209 GreMovePointer(hdcScreen, -1, -1);
210 TRACE("Removing pointer!\n");
211 }
212
213 /* Update global info */
215 }
216
217 return MessageQueue->iCursorLevel;
218}
INT iCursorLevel
Definition: win32.h:127

Referenced by DefWndDoSizeMove(), and NtUserCallOneParam().

Variable Documentation

◆ usmList