ReactOS 0.4.17-dev-1133-gc25e4fd
message.c File Reference
#include <win32k.h>
#include <dde.h>
Include dependency graph for message.c:

Go to the source code of this file.

Classes

struct  tagMSGMEMORY
 

Macros

#define PM_BADMSGFLAGS   ~(PM_QS_SENDMESSAGE|PM_QS_PAINT|PM_QS_POSTMESSAGE|PM_QS_INPUT|PM_NOYIELD|PM_REMOVE)
 
#define SET(msg)   (1 << ((msg) & 31))
 
#define MMS_SIZE_WPARAM   -1
 
#define MMS_SIZE_WPARAMWCHAR   -2
 
#define MMS_SIZE_LPARAMSZ   -3
 
#define MMS_SIZE_SPECIAL   -4
 
#define MMS_FLAG_READ   0x01
 
#define MMS_FLAG_WRITE   0x02
 
#define MMS_FLAG_READWRITE   (MMS_FLAG_READ | MMS_FLAG_WRITE)
 
#define INFINITE   0xFFFFFFFF
 
#define WAIT_FAILED   ((DWORD)0xFFFFFFFF)
 

Typedefs

typedef struct tagMSGMEMORY MSGMEMORY
 
typedef struct tagMSGMEMORY * PMSGMEMORY
 

Functions

 DBG_DEFAULT_CHANNEL (UserMsg)
 
static INT PosInArray (_In_ PCWSTR String)
 
NTSTATUS FASTCALL IntInitMessageImpl (VOID)
 
NTSTATUS FASTCALL IntCleanupMessageImpl (VOID)
 
static int is_pointer_message (UINT message, WPARAM wparam)
 
static PMSGMEMORY FASTCALL FindMsgMemory (UINT Msg)
 
static UINT FASTCALL MsgMemorySize (PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam)
 
UINT lParamMemorySize (UINT Msg, WPARAM wParam, LPARAM lParam)
 
static NTSTATUS PackParam (LPARAM *lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL NonPagedPoolNeeded)
 
static NTSTATUS UnpackParam (LPARAM lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL NonPagedPoolUsed)
 
static NTSTATUS FASTCALL CopyMsgToKernelMem (MSG *KernelModeMsg, MSG *UserModeMsg, PMSGMEMORY MsgMemoryEntry)
 
static NTSTATUS FASTCALL CopyMsgToUserMem (MSG *UserModeMsg, MSG *KernelModeMsg)
 
VOID FASTCALL IdlePing (VOID)
 
VOID FASTCALL IdlePong (VOID)
 
static BOOL is_message_broadcastable (UINT msg)
 
UINT FASTCALL GetWakeMask (UINT first, UINT last)
 
BOOL FASTCALL IntMsgCreateStructW (PWND Window, CREATESTRUCTW *pCsw, CREATESTRUCTW *Cs, PVOID *ppszClass, PVOID *ppszName)
 
static VOID FASTCALL IntCallWndProc (PWND Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
static VOID FASTCALL IntCallWndProcRet (PWND Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *uResult)
 
static LRESULT handle_internal_message (PWND pWnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static LRESULT handle_internal_events (PTHREADINFO pti, PWND pWnd, DWORD dwQEvent, LONG_PTR ExtraInfo, PMSG pMsg)
 
LRESULT FASTCALL IntDispatchMessage (PMSG pMsg)
 
BOOL APIENTRY co_IntPeekMessage (PMSG Msg, PWND Window, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg, LONG_PTR *ExtraInfo, BOOL bGMSG)
 
BOOL FASTCALL co_IntWaitMessage (PWND Window, UINT MsgFilterMin, UINT MsgFilterMax)
 
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)
 
PTHREADINFO FASTCALL IntSendTo (PWND Window, PTHREADINFO ptiCur, UINT Msg)
 
BOOL FASTCALL UserPostMessage (HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
LRESULT FASTCALL co_IntSendMessage (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
static LRESULT FASTCALL co_IntSendMessageTimeoutSingle (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult)
 
LRESULT FASTCALL co_IntSendMessageTimeout (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult)
 
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)
 
static LRESULT FASTCALL co_IntDoSendMessage (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, PDOSENDMESSAGE dsm)
 
BOOL FASTCALL UserSendNotifyMessage (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
DWORD APIENTRY IntGetQueueStatus (DWORD Changes)
 
BOOL APIENTRY IntInitMessagePumpHook (VOID)
 
BOOL APIENTRY IntUninitMessagePumpHook (VOID)
 
BOOL FASTCALL IntCallMsgFilter (LPMSG lpmsg, INT code)
 
BOOL APIENTRY NtUserDragDetect (HWND hWnd, POINT pt)
 
BOOL APIENTRY NtUserPostMessage (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
BOOL APIENTRY NtUserPostThreadMessage (DWORD idThread, UINT Msg, WPARAM wParam, LPARAM lParam)
 
BOOL APIENTRY NtUserWaitMessage (VOID)
 
BOOL APIENTRY NtUserGetMessage (PMSG pMsg, HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax)
 
BOOL APIENTRY NtUserPeekMessage (PMSG pMsg, HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg)
 
BOOL APIENTRY NtUserCallMsgFilter (LPMSG lpmsg, INT code)
 
LRESULT APIENTRY NtUserDispatchMessage (PMSG UnsafeMsgInfo)
 
BOOL APIENTRY NtUserTranslateMessage (LPMSG lpMsg, UINT flags)
 
LRESULT APIENTRY ScrollBarWndProc (HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
BOOL APIENTRY NtUserMessageCall (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ResultInfo, DWORD dwType, BOOL Ansi)
 
DWORD APIENTRY NtUserWaitForInputIdle (IN HANDLE hProcess, IN DWORD dwMilliseconds, IN BOOL bSharedWow)
 

Variables

WCHAR StrUserKernel [3][20] = {{L"intl"}, {L"Environment"}, {L"Policy"}}
 
static const unsigned int message_pointer_flags []
 
static MSGMEMORY g_MsgMemory []
 

Macro Definition Documentation

◆ INFINITE

#define INFINITE   0xFFFFFFFF

Definition at line 3100 of file message.c.

◆ MMS_FLAG_READ

#define MMS_FLAG_READ   0x01

Definition at line 132 of file message.c.

◆ MMS_FLAG_READWRITE

#define MMS_FLAG_READWRITE   (MMS_FLAG_READ | MMS_FLAG_WRITE)

Definition at line 134 of file message.c.

◆ MMS_FLAG_WRITE

#define MMS_FLAG_WRITE   0x02

Definition at line 133 of file message.c.

◆ MMS_SIZE_LPARAMSZ

#define MMS_SIZE_LPARAMSZ   -3

Definition at line 130 of file message.c.

◆ MMS_SIZE_SPECIAL

#define MMS_SIZE_SPECIAL   -4

Definition at line 131 of file message.c.

◆ MMS_SIZE_WPARAM

#define MMS_SIZE_WPARAM   -1

Definition at line 128 of file message.c.

◆ MMS_SIZE_WPARAMWCHAR

#define MMS_SIZE_WPARAMWCHAR   -2

Definition at line 129 of file message.c.

◆ PM_BADMSGFLAGS

#define PM_BADMSGFLAGS   ~(PM_QS_SENDMESSAGE|PM_QS_PAINT|PM_QS_POSTMESSAGE|PM_QS_INPUT|PM_NOYIELD|PM_REMOVE)

Definition at line 14 of file message.c.

◆ SET

#define SET (   msg)    (1 << ((msg) & 31))

Definition at line 56 of file message.c.

◆ WAIT_FAILED

#define WAIT_FAILED   ((DWORD)0xFFFFFFFF)

Definition at line 3101 of file message.c.

Typedef Documentation

◆ MSGMEMORY

◆ PMSGMEMORY

Function Documentation

◆ co_IntDoSendMessage()

static LRESULT FASTCALL co_IntDoSendMessage ( HWND  hWnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam,
PDOSENDMESSAGE  dsm 
)
static

Definition at line 2006 of file message.c.

2011{
2014 PWND Window = NULL;
2015 MSG UserModeMsg, KernelModeMsg;
2016 PMSGMEMORY MsgMemoryEntry;
2017 PTHREADINFO ptiSendTo;
2018
2019 if (hWnd != HWND_BROADCAST && hWnd != HWND_TOPMOST)
2020 {
2022 if ( !Window )
2023 {
2024 return 0;
2025 }
2026 }
2027
2028 /* Check for an exiting window. */
2029 if (Window && Window->state & WNDS_DESTROYED)
2030 {
2031 ERR("co_IntDoSendMessage Window Exiting!\n");
2032 }
2033
2034 /* See if the current thread can handle this message */
2035 ptiSendTo = IntSendTo(Window, gptiCurrent, Msg);
2036
2037 // If broadcasting or sending to another thread, save the users data.
2038 if (!Window || ptiSendTo )
2039 {
2040 UserModeMsg.hwnd = hWnd;
2041 UserModeMsg.message = Msg;
2042 UserModeMsg.wParam = wParam;
2043 UserModeMsg.lParam = lParam;
2044 MsgMemoryEntry = FindMsgMemory(UserModeMsg.message);
2045 Status = CopyMsgToKernelMem(&KernelModeMsg, &UserModeMsg, MsgMemoryEntry);
2046 if (!NT_SUCCESS(Status))
2047 {
2049 return (dsm ? 0 : -1);
2050 }
2051 }
2052 else
2053 {
2054 KernelModeMsg.hwnd = hWnd;
2055 KernelModeMsg.message = Msg;
2056 KernelModeMsg.wParam = wParam;
2057 KernelModeMsg.lParam = lParam;
2058 }
2059
2060 if (!dsm)
2061 {
2062 Result = co_IntSendMessage( KernelModeMsg.hwnd,
2063 KernelModeMsg.message,
2064 KernelModeMsg.wParam,
2065 KernelModeMsg.lParam );
2066 }
2067 else
2068 {
2069 Result = co_IntSendMessageTimeout( KernelModeMsg.hwnd,
2070 KernelModeMsg.message,
2071 KernelModeMsg.wParam,
2072 KernelModeMsg.lParam,
2073 dsm->uFlags,
2074 dsm->uTimeout,
2075 &dsm->Result );
2076 }
2077
2078 if (!Window || ptiSendTo )
2079 {
2080 Status = CopyMsgToUserMem(&UserModeMsg, &KernelModeMsg);
2081 if (!NT_SUCCESS(Status))
2082 {
2084 return(dsm ? 0 : -1);
2085 }
2086 }
2087
2088 return (LRESULT)Result;
2089}
HWND hWnd
Definition: settings.c:17
LONG NTSTATUS
Definition: precomp.h:26
#define ERR(fmt,...)
Definition: precomp.h:57
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
struct @1897 Msg[]
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
Status
Definition: gdiplustypes.h:24
#define WNDS_DESTROYED
Definition: ntuser.h:640
LONG_PTR LRESULT
Definition: minwindef.h:176
PTHREADINFO gptiCurrent
Definition: ntuser.c:15
#define HWND_TOPMOST
Definition: winuser.h:1219
#define HWND_BROADCAST
Definition: winuser.h:1215
Definition: window.c:29
Definition: ntuser.h:698
ULONG_PTR Result
Definition: ntuser.h:2671
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:123
static NTSTATUS FASTCALL CopyMsgToKernelMem(MSG *KernelModeMsg, MSG *UserModeMsg, PMSGMEMORY MsgMemoryEntry)
Definition: message.c:451
PTHREADINFO FASTCALL IntSendTo(PWND Window, PTHREADINFO ptiCur, UINT Msg)
Definition: message.c:1383
LRESULT FASTCALL co_IntSendMessageTimeout(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult)
Definition: message.c:1709
static PMSGMEMORY FASTCALL FindMsgMemory(UINT Msg)
Definition: message.c:168
static NTSTATUS FASTCALL CopyMsgToUserMem(MSG *UserModeMsg, MSG *KernelModeMsg)
Definition: message.c:536
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1497
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:21
_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:409

Referenced by NtUserMessageCall().

◆ co_IntGetPeekMessage()

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

Definition at line 1228 of file message.c.

1234{
1235 PWND Window;
1236 PTHREADINFO pti;
1237 BOOL Present = FALSE;
1239 LONG_PTR ExtraInfo = 0;
1240
1241 if ( hWnd == HWND_TOPMOST || hWnd == HWND_BROADCAST )
1242 hWnd = HWND_BOTTOM;
1243
1244 /* Validate input */
1245 if (hWnd && hWnd != HWND_BOTTOM)
1246 {
1248 {
1249 if (bGMSG)
1250 return -1;
1251 else
1252 return FALSE;
1253 }
1254 }
1255 else
1256 {
1257 Window = (PWND)hWnd;
1258 }
1259
1260 if (MsgFilterMax < MsgFilterMin)
1261 {
1262 MsgFilterMin = 0;
1263 MsgFilterMax = 0;
1264 }
1265
1266 if (bGMSG)
1267 {
1268 RemoveMsg |= ((GetWakeMask( MsgFilterMin, MsgFilterMax ))<< 16);
1269 }
1270
1272 pti->pClientInfo->cSpins++; // Bump up the spin count.
1273
1274 do
1275 {
1276 Present = co_IntPeekMessage( pMsg,
1277 Window,
1278 MsgFilterMin,
1279 MsgFilterMax,
1280 RemoveMsg,
1281 &ExtraInfo,
1282 bGMSG );
1283 if (Present)
1284 {
1285 if ( pMsg->message != WM_DEVICECHANGE || (pMsg->wParam & 0x8000) )
1286 {
1287 /* GetMessage or PostMessage must never get messages that contain pointers */
1288 ASSERT(FindMsgMemory(pMsg->message) == NULL);
1289 }
1290
1291 if ( pMsg->message >= WM_DDE_FIRST && pMsg->message <= WM_DDE_LAST )
1292 {
1293 if (!IntDdeGetMessageHook(pMsg, ExtraInfo))
1294 {
1295 TRACE("DDE Get return ERROR\n");
1296 continue;
1297 }
1298 }
1299
1300 if (pMsg->message != WM_PAINT && pMsg->message != WM_QUIT)
1301 {
1302 if (!RtlEqualMemory(&pti->ptLast, &pMsg->pt, sizeof(POINT)))
1303 {
1305 }
1306 pti->timeLast = pMsg->time;
1307 pti->ptLast = pMsg->pt;
1308 }
1309
1310 // The WH_GETMESSAGE hook enables an application to monitor messages about to
1311 // be returned by the GetMessage or PeekMessage function.
1312
1314
1315 if ( bGMSG || pMsg->message == WM_PAINT) break;
1316 }
1317
1318 if ( bGMSG )
1319 {
1321 Window,
1322 MsgFilterMin,
1323 MsgFilterMax);
1324 if ( !NT_SUCCESS(Status) ||
1327 {
1328 Present = -1;
1329 break;
1330 }
1331 }
1332 else
1333 {
1334 if (!(RemoveMsg & PM_NOYIELD))
1335 {
1336 IdlePing();
1337 // Yield this thread!
1338 UserLeave();
1341 // Fall through to exit.
1342 IdlePong();
1343 }
1344 break;
1345 }
1346 }
1347 while( bGMSG && !Present );
1348
1349 // Been spinning, time to swap vinyl...
1350 if (pti->pClientInfo->cSpins >= 100)
1351 {
1352 // Clear the spin cycle to fix the mix.
1353 pti->pClientInfo->cSpins = 0;
1354 //if (!(pti->TIF_flags & TIF_SPINNING)) // FIXME: Need to swap vinyl...
1355 }
1356 return Present;
1357}
#define STATUS_TIMEOUT
Definition: d3dkmdt.h:49
#define WM_DDE_FIRST
Definition: dde.h:47
#define WM_DDE_LAST
Definition: dde.h:46
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _WND * PWND
#define TIF_MSGPOSCHANGED
Definition: ntuser.h:286
#define RtlEqualMemory(dst, src, len)
Definition: kdvm.h:18
LONG_PTR LPARAM
Definition: minwindef.h:175
#define ASSERT(a)
Definition: mode.c:44
NTSTATUS FASTCALL co_MsqWaitForNewMessages(PTHREADINFO pti, PWND WndFilter, UINT MsgFilterMin, UINT MsgFilterMax)
Definition: msgqueue.c:2120
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
NTSYSAPI NTSTATUS NTAPI ZwYieldExecution(VOID)
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:829
#define STATUS_USER_APC
Definition: ntstatus.h:130
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1102
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
#define WM_PAINT
Definition: winuser.h:1648
#define WM_QUIT
Definition: winuser.h:1651
#define HC_ACTION
Definition: winuser.h:48
#define WM_DEVICECHANGE
Definition: winuser.h:1839
#define PM_NOYIELD
Definition: winuser.h:1208
#define PM_REMOVE
Definition: winuser.h:1207
#define WH_GETMESSAGE
Definition: winuser.h:33
#define HWND_BOTTOM
Definition: winuser.h:1216
#define TRACE(s)
Definition: solgame.cpp:4
POINT ptLast
Definition: win32.h:130
struct _CLIENTINFO * pClientInfo
Definition: win32.h:95
LONG timeLast
Definition: win32.h:103
FLONG TIF_flags
Definition: win32.h:96
UINT message
Definition: winuser.h:3223
DWORD time
Definition: winuser.h:3226
WPARAM wParam
Definition: winuser.h:3224
POINT pt
Definition: winuser.h:3227
BOOL APIENTRY IntDdeGetMessageHook(PMSG pMsg, LONG_PTR ExtraInfo)
Definition: dde.c:326
UINT FASTCALL GetWakeMask(UINT first, UINT last)
Definition: message.c:623
VOID FASTCALL IdlePing(VOID)
Definition: message.c:576
VOID FASTCALL IdlePong(VOID)
Definition: message.c:606
BOOL APIENTRY co_IntPeekMessage(PMSG Msg, PWND Window, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg, LONG_PTR *ExtraInfo, BOOL bGMSG)
Definition: message.c:1014

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

◆ co_IntPeekMessage()

BOOL APIENTRY co_IntPeekMessage ( PMSG  Msg,
PWND  Window,
UINT  MsgFilterMin,
UINT  MsgFilterMax,
UINT  RemoveMsg,
LONG_PTR *  ExtraInfo,
BOOL  bGMSG 
)

Definition at line 1014 of file message.c.

1021{
1022 PTHREADINFO pti;
1023 BOOL RemoveMessages;
1024 UINT ProcessMask;
1025 BOOL Hit = FALSE;
1026
1028
1029 RemoveMessages = RemoveMsg & PM_REMOVE;
1030 ProcessMask = HIWORD(RemoveMsg);
1031
1032 /* Hint, "If wMsgFilterMin and wMsgFilterMax are both zero, PeekMessage returns
1033 all available messages (that is, no range filtering is performed)". */
1034 if (!ProcessMask) ProcessMask = (QS_ALLPOSTMESSAGE|QS_ALLINPUT);
1035
1036 IdlePong();
1037
1038 do
1039 {
1040 /* Update the last message-queue access time */
1041 pti->pcti->timeLastRead = EngGetTickCount32();
1042
1043 // Post mouse moves while looping through peek messages.
1044 if (pti->MessageQueue->QF_flags & QF_MOUSEMOVED)
1045 {
1047 }
1048
1049 /* Dispatch sent messages here. */
1050 while ( co_MsqDispatchOneSentMessage(pti) )
1051 {
1052 /* if some PM_QS* flags were specified, only handle sent messages from now on */
1053 if (HIWORD(RemoveMsg) && !bGMSG) Hit = TRUE; // wine does this; ProcessMask = QS_SENDMESSAGE;
1054 }
1055 if (Hit) return FALSE;
1056
1057 /* Clear changed bits so we can wait on them if we don't find a message */
1058 if (ProcessMask & QS_POSTMESSAGE)
1059 {
1060 pti->pcti->fsChangeBits &= ~(QS_POSTMESSAGE | QS_HOTKEY | QS_TIMER);
1061 if (MsgFilterMin == 0 && MsgFilterMax == 0) // Wine hack does this; ~0U)
1062 {
1063 pti->pcti->fsChangeBits &= ~QS_ALLPOSTMESSAGE;
1064 }
1065 }
1066
1067 if (ProcessMask & QS_INPUT)
1068 {
1069 pti->pcti->fsChangeBits &= ~QS_INPUT;
1070 }
1071
1072 /* Now check for normal messages. */
1073 if (( (ProcessMask & QS_POSTMESSAGE) ||
1074 (ProcessMask & QS_HOTKEY) ) &&
1075 MsqPeekMessage( pti,
1076 RemoveMessages,
1077 Window,
1078 MsgFilterMin,
1079 MsgFilterMax,
1080 ProcessMask,
1081 ExtraInfo,
1082 0,
1083 Msg ))
1084 {
1085 goto GotMessage;
1086 }
1087
1088 /* Only check for quit messages if not posted messages pending. */
1089 if (ProcessMask & QS_POSTMESSAGE && pti->QuitPosted)
1090 {
1091 /* According to the PSDK, WM_QUIT messages are always returned, regardless
1092 of the filter specified */
1093 Msg->hwnd = NULL;
1094 Msg->message = WM_QUIT;
1095 Msg->wParam = pti->exitCode;
1096 Msg->lParam = 0;
1097 if (RemoveMessages)
1098 {
1099 pti->QuitPosted = FALSE;
1101 pti->pcti->fsWakeBits &= ~QS_ALLPOSTMESSAGE;
1102 pti->pcti->fsChangeBits &= ~QS_ALLPOSTMESSAGE;
1103 }
1104 goto GotMessage;
1105 }
1106
1107 /* Check for hardware events. */
1108 if ((ProcessMask & QS_INPUT || ProcessMask & QS_RAWINPUT) &&
1110 RemoveMessages,
1111 Window,
1112 MsgFilterMin,
1113 MsgFilterMax,
1114 ProcessMask,
1115 Msg))
1116 {
1117 goto GotMessage;
1118 }
1119
1120 /* Now check for System Event messages. */
1121 {
1122 LONG_PTR eExtraInfo;
1123 MSG eMsg;
1124 DWORD dwQEvent;
1125 if (MsqPeekMessage( pti,
1126 TRUE,
1127 Window,
1128 0,
1129 0,
1130 QS_EVENT,
1131 &eExtraInfo,
1132 &dwQEvent,
1133 &eMsg ))
1134 {
1135 handle_internal_events( pti, Window, dwQEvent, eExtraInfo, &eMsg);
1136 continue;
1137 }
1138 }
1139
1140 /* Check for sent messages again. */
1141 while ( co_MsqDispatchOneSentMessage(pti) )
1142 {
1143 if (HIWORD(RemoveMsg) && !bGMSG) Hit = TRUE;
1144 }
1145 if (Hit) return FALSE;
1146
1147 /* Check for paint messages. */
1148 if ((ProcessMask & QS_PAINT) &&
1149 pti->cPaintsReady &&
1151 MsgFilterMin,
1152 MsgFilterMax,
1153 pti,
1154 Msg,
1155 RemoveMessages))
1156 {
1157 goto GotMessage;
1158 }
1159
1160 /* This is correct, check for the current threads timers waiting to be
1161 posted to this threads message queue. If any we loop again.
1162 */
1163 if ((ProcessMask & QS_TIMER) &&
1165 {
1166 continue;
1167 }
1168
1169 return FALSE;
1170 }
1171 while (TRUE);
1172
1173GotMessage:
1174 /* Update the last message-queue access time */
1175 pti->pcti->timeLastRead = EngGetTickCount32();
1176 if (RemoveMessages)
1178 return TRUE;
1179}
#define EngGetTickCount32()
Definition: eng.h:43
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned int UINT
Definition: sysinfo.c:13
VOID FASTCALL ClearMsgBitsMask(PTHREADINFO pti, UINT MessageBits)
Definition: msgqueue.c:445
BOOLEAN FASTCALL co_MsqDispatchOneSentMessage(_In_ PTHREADINFO pti)
Definition: msgqueue.c:873
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: msgqueue.c:1940
VOID FASTCALL IntCoalesceMouseMove(PTHREADINFO pti)
Definition: msgqueue.c:551
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: msgqueue.c:2063
#define QF_MOUSEMOVED
Definition: msgqueue.h:102
#define QS_TIMER
Definition: winuser.h:889
#define QS_ALLPOSTMESSAGE
Definition: winuser.h:893
#define QS_ALLINPUT
Definition: winuser.h:914
#define QS_HOTKEY
Definition: winuser.h:892
#define QS_INPUT
Definition: winuser.h:910
#define QS_POSTMESSAGE
Definition: winuser.h:888
#define QS_PAINT
Definition: winuser.h:890
INT exitCode
Definition: win32.h:108
BOOLEAN QuitPosted
Definition: win32.h:106
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:92
UINT cPaintsReady
Definition: win32.h:110
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:90
#define HIWORD(l)
Definition: typedefs.h:247
#define QS_EVENT
Definition: undocuser.h:98
BOOL FASTCALL IntGetPaintMessage(PWND Window, UINT MsgFilterMin, UINT MsgFilterMax, PTHREADINFO Thread, MSG *Message, BOOL Remove)
Definition: painting.c:1193
VOID FASTCALL UserUpdatePrevRawInput(PTHREADINFO pti, CONST MSG *pMsg)
Definition: rawinput.c:379
static LRESULT handle_internal_events(PTHREADINFO pti, PWND pWnd, DWORD dwQEvent, LONG_PTR ExtraInfo, PMSG pMsg)
Definition: message.c:862
BOOL FASTCALL PostTimerMessages(PWND Window)
Definition: timer.c:401

Referenced by co_IntGetPeekMessage(), and co_IntWaitMessage().

◆ co_IntSendMessage()

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

Definition at line 1497 of file message.c.

1501{
1502 ULONG_PTR Result = 0;
1503
1505 {
1506 return (LRESULT)Result;
1507 }
1508 return 0;
1509}
#define SMTO_NORMAL
Definition: winuser.h:1236
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by co_IntDoSendMessage(), co_IntPaintWindows(), co_IntProcessKeyboardMessage(), co_IntProcessMouseMessage(), co_IntSendActivateMessages(), co_IntSendDeactivateMessages(), co_IntSetForegroundMessageQueue(), co_IntSetWindowLongPtr(), co_IntSnapWindow(), co_IntTranslateAccelerator(), co_IntUpdateWindows(), co_MsqDispatchOneSentMessage(), 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(), IntImeWindowPosChanged(), 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 1765 of file message.c.

1769{
1770 ULONG_PTR Result = 0;
1772 Msg,
1773 wParam,
1774 lParam,
1775 NULL,
1776 0,
1777 &Result);
1778}
LRESULT FASTCALL co_IntSendMessageWithCallBack(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, SENDASYNCPROC CompletionCallback, ULONG_PTR CompletionCallbackContext, ULONG_PTR *uResult)
Definition: message.c:1787

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

1716{
1717 PWND DesktopWindow;
1718 HWND *Children;
1719 HWND *Child;
1720
1721 if (hWnd != HWND_BROADCAST && hWnd != HWND_TOPMOST)
1722 {
1723 return co_IntSendMessageTimeoutSingle(hWnd, Msg, wParam, lParam, uFlags, uTimeout, uResult);
1724 }
1725
1726 if (!is_message_broadcastable(Msg)) return TRUE;
1727
1728 DesktopWindow = UserGetDesktopWindow();
1729 if (NULL == DesktopWindow)
1730 {
1732 return 0;
1733 }
1734
1735 if (hWnd != HWND_TOPMOST)
1736 {
1737 /* Send message to the desktop window too! */
1738 co_IntSendMessageTimeoutSingle(UserHMGetHandle(DesktopWindow), Msg, wParam, lParam, uFlags, uTimeout, uResult);
1739 }
1740
1741 Children = IntWinListChildren(DesktopWindow);
1742 if (NULL == Children)
1743 {
1744 return 0;
1745 }
1746
1747 for (Child = Children; NULL != *Child; Child++)
1748 {
1750 if (!pwnd) continue;
1751
1752 if ( pwnd->fnid == FNID_MENU ||
1754 continue;
1755
1757 }
1758
1760
1761 return (LRESULT) TRUE;
1762}
UINT uFlags
Definition: api.c:59
PSERVERINFO gpsi
Definition: imm.c:18
#define UserHMGetHandle(obj)
Definition: ntuser.h:233
#define ICLS_SWITCH
Definition: ntuser.h:936
#define FNID_MENU
Definition: ntuser.h:865
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
RTL_ATOM atomClassName
Definition: ntuser.h:572
PCLS pcls
Definition: ntuser.h:724
DWORD fnid
Definition: ntuser.h:713
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1064
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1413
static LRESULT FASTCALL co_IntSendMessageTimeoutSingle(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult)
Definition: message.c:1512
static BOOL is_message_broadcastable(UINT msg)
Definition: message.c:617
#define USERTAG_WINDOWLIST
Definition: tags.h:298
HWND *FASTCALL IntWinListChildren(PWND Window)
Definition: window.c:275
#define ERROR_INTERNAL_ERROR
Definition: winerror.h:1185

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

◆ co_IntSendMessageTimeoutSingle()

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

Definition at line 1512 of file message.c.

1519{
1521 PWND Window;
1522 PMSGMEMORY MsgMemoryEntry;
1523 INT lParamBufferSize;
1524 LPARAM lParamPacked;
1525 PTHREADINFO Win32Thread, ptiSendTo = NULL;
1526 ULONG_PTR Result = 0;
1527 LRESULT Ret = FALSE;
1529 BOOL DoCallBack = TRUE;
1530
1532 {
1533 TRACE("SendMessageTimeoutSingle: Invalid handle 0x%p!\n",hWnd);
1534 return FALSE;
1535 }
1536
1537 UserRefObjectCo(Window, &Ref);
1538
1539 Win32Thread = PsGetCurrentThreadWin32Thread();
1540
1541 ptiSendTo = IntSendTo(Window, Win32Thread, Msg);
1542
1543 if ( Msg >= WM_DDE_FIRST && Msg <= WM_DDE_LAST )
1544 {
1546 {
1547 ERR("Sending Exit DDE 0x%x\n",Msg);
1548 goto Cleanup; // Return FALSE
1549 }
1550 }
1551
1552 if ( !ptiSendTo )
1553 {
1554 if (Win32Thread->TIF_flags & TIF_INCLEANUP)
1555 {
1556 /* Never send messages to exiting threads */
1557 goto Cleanup; // Return FALSE
1558 }
1559
1560 if (Msg & 0x80000000)
1561 {
1562 TRACE("SMTS: Internal Message!\n");
1564 if (uResult) *uResult = Result;
1565 Ret = TRUE;
1566 goto Cleanup;
1567 }
1568
1569 // Only happens when calling the client!
1571
1572 if ( Window->state & WNDS_SERVERSIDEWINDOWPROC )
1573 {
1574 TRACE("SMT: Server Side Window Procedure\n");
1575 // Handle it here. Safeguard against excessive recursions.
1576 if (IoGetRemainingStackSize() < PAGE_SIZE)
1577 {
1578 ERR("Server Callback Exceeded Stack!\n");
1579 goto Cleanup; // Return FALSE
1580 }
1581 /* Return after server side call, IntCallWndProcRet will not be called. */
1582 switch(Window->fnid)
1583 {
1584 case FNID_DESKTOP:
1585 DoCallBack = !DesktopWindowProc(Window, Msg, wParam, lParam,(LRESULT*)&Result);
1586 break;
1587 case FNID_MESSAGEWND:
1589 break;
1590 case FNID_MENU:
1591 DoCallBack = !PopupMenuWndProc( Window, Msg, wParam, lParam,(LRESULT*)&Result);
1592 break;
1593 }
1594 if (!DoCallBack)
1595 {
1596 if (uResult) *uResult = Result;
1597 Ret = TRUE;
1598 goto Cleanup;
1599 }
1600 }
1601 /* See if this message type is present in the table */
1602 MsgMemoryEntry = FindMsgMemory(Msg);
1603 if (NULL == MsgMemoryEntry)
1604 {
1605 lParamBufferSize = -1;
1606 }
1607 else
1608 {
1609 lParamBufferSize = MsgMemorySize(MsgMemoryEntry, wParam, lParam);
1610 // If zero, do not allow callback on client side to allocate a buffer!!!!! See CORE-7695.
1611 if (!lParamBufferSize) lParamBufferSize = -1;
1612 }
1613
1614 if (! NT_SUCCESS(PackParam(&lParamPacked, Msg, wParam, lParam, FALSE)))
1615 {
1616 ERR("Failed to pack message parameters\n");
1617 goto Cleanup; // Return FALSE
1618 }
1619
1621 !Window->Unicode,
1622 hWnd,
1623 Msg,
1624 wParam,
1625 lParamPacked,
1626 lParamBufferSize );
1627 if (uResult)
1628 {
1629 *uResult = Result;
1630 }
1631
1632 if (! NT_SUCCESS(UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE)))
1633 {
1634 ERR("Failed to unpack message parameters\n");
1635 Ret = TRUE;
1636 goto Cleanup;
1637 }
1638
1639 // Only happens when calling the client!
1641
1642 Ret = TRUE;
1643 goto Cleanup;
1644 }
1645
1646 if (Window->state & WNDS_DESTROYED)
1647 {
1648 /* FIXME: Last error? */
1649 ERR("Attempted to send message to window %p that is being destroyed!\n", hWnd);
1650 goto Cleanup; // Return FALSE
1651 }
1652
1653 if ((uFlags & SMTO_ABORTIFHUNG) && MsqIsHung(ptiSendTo, 4 * MSQ_HUNG))
1654 {
1655 // FIXME: Set window hung and add to a list.
1656 /* FIXME: Set a LastError? */
1657 ERR("Window %p (%p) (pti %p) is hung!\n", hWnd, Window, ptiSendTo);
1658 goto Cleanup; // Return FALSE
1659 }
1660
1661 do
1662 {
1663 Status = co_MsqSendMessage( ptiSendTo,
1664 hWnd,
1665 Msg,
1666 wParam,
1667 lParam,
1668 uTimeout,
1669 (uFlags & SMTO_BLOCK),
1670 MSQ_NORMAL,
1671 uResult );
1672 }
1673 while ((Status == STATUS_TIMEOUT) &&
1674 (uFlags & SMTO_NOTIMEOUTIFNOTHUNG) &&
1675 !MsqIsHung(ptiSendTo, MSQ_HUNG)); // FIXME: Set window hung and add to a list.
1676
1677 if (Status == STATUS_TIMEOUT)
1678 {
1679 if (0 && MsqIsHung(ptiSendTo, MSQ_HUNG))
1680 {
1681 TRACE("Let's go Ghost!\n");
1683 }
1684/*
1685 * MSDN says:
1686 * Microsoft Windows 2000: If GetLastError returns zero, then the function
1687 * timed out.
1688 * XP+ : If the function fails or times out, the return value is zero.
1689 * To get extended error information, call GetLastError. If GetLastError
1690 * returns ERROR_TIMEOUT, then the function timed out.
1691 */
1693 goto Cleanup; // Return FALSE
1694 }
1695 else if (!NT_SUCCESS(Status))
1696 {
1698 goto Cleanup; // Return FALSE
1699 }
1700
1701 Ret = TRUE;
1702
1703Cleanup:
1705 return Ret;
1706}
static const WCHAR Cleanup[]
Definition: register.c:80
#define ULONG_PTR
Definition: config.h:101
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define TIF_INCLEANUP
Definition: ntuser.h:266
#define FNID_DESKTOP
Definition: ntuser.h:866
#define WNDS_SERVERSIDEWINDOWPROC
Definition: ntuser.h:627
#define FNID_MESSAGEWND
Definition: ntuser.h:868
NTSTATUS FASTCALL co_MsqSendMessage(PTHREADINFO ptirec, HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uTimeout, BOOL Block, INT HookMessage, ULONG_PTR *uResult)
Definition: msgqueue.c:1056
BOOL FASTCALL MsqIsHung(PTHREADINFO pti, DWORD TimeOut)
Definition: msgqueue.c:2150
#define MSQ_NORMAL
Definition: msgqueue.h:4
#define MSQ_HUNG
Definition: msgqueue.h:3
BOOL FASTCALL IntMakeHungWindowGhosted(HWND hwndHung)
Definition: ghost.c:156
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:44
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:28
#define SMTO_BLOCK
Definition: winuser.h:1235
#define SMTO_ABORTIFHUNG
Definition: winuser.h:1234
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: object.h:4
int32_t INT
Definition: typedefs.h:58
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:30
LRESULT APIENTRY co_IntCallWindowProc(WNDPROC Proc, BOOLEAN IsAnsiProc, HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, INT lParamBufferSize)
Definition: callback.c:282
BOOL FASTCALL IntDdeSendMessageHook(PWND pWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: dde.c:386
BOOL FASTCALL DesktopWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: desktop.c:1462
BOOL FASTCALL UserMessageWindowProc(PWND pwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: desktop.c:1545
BOOL WINAPI PopupMenuWndProc(PWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: menu.c:4657
static VOID FASTCALL IntCallWndProcRet(PWND Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *uResult)
Definition: message.c:790
static UINT FASTCALL MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam)
Definition: message.c:187
static NTSTATUS PackParam(LPARAM *lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL NonPagedPoolNeeded)
Definition: message.c:284
static VOID FASTCALL IntCallWndProc(PWND Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:756
static LRESULT handle_internal_message(PWND pWnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: message.c:821
static NTSTATUS UnpackParam(LPARAM lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL NonPagedPoolUsed)
Definition: message.c:402
#define ERROR_TIMEOUT
Definition: winerror.h:1286

Referenced by co_IntSendMessageTimeout().

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

1794{
1796 PWND Window;
1797 PMSGMEMORY MsgMemoryEntry;
1798 INT lParamBufferSize;
1799 LPARAM lParamPacked;
1800 PTHREADINFO Win32Thread, ptiSendTo = NULL;
1801 LRESULT Ret = FALSE;
1804 BOOL DoCallBack = TRUE;
1805
1807 {
1808 TRACE("SendMessageWithCallBack: Invalid handle 0x%p\n",hWnd);
1809 return FALSE;
1810 }
1811
1812 UserRefObjectCo(Window, &Ref);
1813
1814 if (Window->state & WNDS_DESTROYED)
1815 {
1816 /* FIXME: last error? */
1817 ERR("Attempted to send message to window %p that is being destroyed\n", hWnd);
1818 goto Cleanup; // Return FALSE
1819 }
1820
1821 Win32Thread = PsGetCurrentThreadWin32Thread();
1822
1823 if (Win32Thread == NULL || Win32Thread->TIF_flags & TIF_INCLEANUP)
1824 goto Cleanup; // Return FALSE
1825
1826 ptiSendTo = IntSendTo(Window, Win32Thread, Msg);
1827
1828 if (Msg & 0x80000000 &&
1829 !ptiSendTo)
1830 {
1831 if (Win32Thread->TIF_flags & TIF_INCLEANUP)
1832 goto Cleanup; // Return FALSE
1833
1834 TRACE("SMWCB: Internal Message\n");
1836 if (uResult) *uResult = Result;
1837 Ret = TRUE;
1838 goto Cleanup;
1839 }
1840
1841 /* See if this message type is present in the table */
1842 MsgMemoryEntry = FindMsgMemory(Msg);
1843 if (NULL == MsgMemoryEntry)
1844 {
1845 lParamBufferSize = -1;
1846 }
1847 else
1848 {
1849 lParamBufferSize = MsgMemorySize(MsgMemoryEntry, wParam, lParam);
1850 if (!lParamBufferSize) lParamBufferSize = -1;
1851 }
1852
1853 if (!NT_SUCCESS(PackParam(&lParamPacked, Msg, wParam, lParam, !!ptiSendTo)))
1854 {
1855 ERR("Failed to pack message parameters\n");
1856 goto Cleanup; // Return FALSE
1857 }
1858
1859 /* If it can be sent now, then send it. */
1860 if (!ptiSendTo)
1861 {
1862 if (Win32Thread->TIF_flags & TIF_INCLEANUP)
1863 {
1864 UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE);
1865 /* Never send messages to exiting threads */
1866 goto Cleanup; // Return FALSE
1867 }
1868
1870
1871 if (Window->state & WNDS_SERVERSIDEWINDOWPROC)
1872 {
1873 TRACE("SMWCB: Server Side Window Procedure\n");
1874 switch(Window->fnid)
1875 {
1876 case FNID_DESKTOP:
1877 DoCallBack = !DesktopWindowProc(Window, Msg, wParam, lParamPacked, (LRESULT*)&Result);
1878 break;
1879 case FNID_MESSAGEWND:
1881 break;
1882 case FNID_MENU:
1883 DoCallBack = !PopupMenuWndProc(Window, Msg, wParam, lParam, (LRESULT*)&Result);
1884 break;
1885 }
1886 }
1887
1888 if (DoCallBack)
1890 !Window->Unicode,
1891 hWnd,
1892 Msg,
1893 wParam,
1894 lParamPacked,
1895 lParamBufferSize);
1896 if(uResult)
1897 {
1898 *uResult = Result;
1899 }
1900
1902
1904 {
1906 hWnd,
1907 Msg,
1908 CompletionCallbackContext,
1909 Result);
1910 }
1911 }
1912
1913 if (!ptiSendTo)
1914 {
1915 if (!NT_SUCCESS(UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE)))
1916 {
1917 ERR("Failed to unpack message parameters\n");
1918 }
1919 Ret = TRUE;
1920 goto Cleanup;
1921 }
1922
1924 {
1925 ERR("Failed to allocate message\n");
1926 goto Cleanup; // Return FALSE
1927 }
1928
1929 Message->Msg.hwnd = hWnd;
1930 Message->Msg.message = Msg;
1931 Message->Msg.wParam = wParam;
1932 Message->Msg.lParam = lParamPacked;
1933 Message->pkCompletionEvent = NULL; // No event needed.
1934 Message->lResult = 0;
1935 Message->QS_Flags = 0;
1936 Message->ptiReceiver = ptiSendTo;
1937 Message->ptiSender = NULL;
1938 Message->ptiCallBackSender = Win32Thread;
1939 Message->CompletionCallback = CompletionCallback;
1940 Message->CompletionCallbackContext = CompletionCallbackContext;
1941 Message->HookMessage = MSQ_NORMAL;
1942 Message->HasPackedLParam = (lParamBufferSize > 0);
1943 Message->QS_Flags = QS_SENDMESSAGE;
1944 Message->flags = SMF_RECEIVERFREE;
1945
1946 if (Msg & 0x80000000) // Higher priority event message!
1947 InsertHeadList(&ptiSendTo->SentMessagesListHead, &Message->ListEntry);
1948 else
1949 InsertTailList(&ptiSendTo->SentMessagesListHead, &Message->ListEntry);
1950 MsqWakeQueue(ptiSendTo, QS_SENDMESSAGE, TRUE);
1951
1952 Ret = TRUE;
1953
1954Cleanup:
1956 return Ret;
1957}
const TCHAR * CompletionCallback(unsigned __int64 &rnIndex, const BOOL *pblnForward, const TCHAR *pszContext, const TCHAR *pszBegin)
Definition: Completion.cpp:439
static const WCHAR Message[]
Definition: register.c:74
#define InsertTailList(ListHead, Entry)
#define InsertHeadList(ListHead, Entry)
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 SMF_RECEIVERFREE
Definition: msgqueue.h:40
#define QS_SENDMESSAGE
Definition: winuser.h:891
LIST_ENTRY SentMessagesListHead
Definition: win32.h:101
VOID APIENTRY co_IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback, HWND hWnd, UINT Msg, ULONG_PTR CompletionCallbackContext, LRESULT Result)
Definition: callback.c:238

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

◆ co_IntWaitMessage()

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

Definition at line 1182 of file message.c.

1185{
1186 PTHREADINFO pti;
1188 MSG Msg;
1189 LONG_PTR ExtraInfo = 0;
1190
1192
1193 do
1194 {
1195 if ( co_IntPeekMessage( &Msg, // Dont reenter!
1196 Window,
1197 MsgFilterMin,
1198 MsgFilterMax,
1199 MAKELONG( PM_NOREMOVE, GetWakeMask( MsgFilterMin, MsgFilterMax)),
1200 &ExtraInfo,
1201 TRUE ) ) // act like GetMessage.
1202 {
1203 return TRUE;
1204 }
1205
1206 /* Nothing found. Wait for new messages. */
1208 Window,
1209 MsgFilterMin,
1210 MsgFilterMax);
1211 if (!NT_SUCCESS(Status))
1212 {
1214 ERR("Exit co_IntWaitMessage on error!\n");
1215 return FALSE;
1216 }
1218 {
1219 return FALSE;
1220 }
1221 }
1222 while ( TRUE );
1223
1224 return FALSE;
1225}
#define PM_NOREMOVE
Definition: winuser.h:1206
#define MAKELONG(a, b)
Definition: typedefs.h:249

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

◆ CopyMsgToKernelMem()

static NTSTATUS FASTCALL CopyMsgToKernelMem ( MSG *  KernelModeMsg,
MSG *  UserModeMsg,
PMSGMEMORY  MsgMemoryEntry 
)
static

Definition at line 451 of file message.c.

452{
454
455 PVOID KernelMem;
456 UINT Size;
457
458 *KernelModeMsg = *UserModeMsg;
459
460 /* See if this message type is present in the table */
461 if (NULL == MsgMemoryEntry)
462 {
463 /* Not present, no copying needed */
464 return STATUS_SUCCESS;
465 }
466
467 /* Determine required size */
468 Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, UserModeMsg->lParam);
469
470 if (0 != Size)
471 {
472 /* Allocate kernel mem */
474 if (NULL == KernelMem)
475 {
476 ERR("Not enough memory to copy message to kernel mem\n");
477 return STATUS_NO_MEMORY;
478 }
479 KernelModeMsg->lParam = (LPARAM) KernelMem;
480
481 /* Copy data if required */
482 if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_READ))
483 {
484 TRACE("Copy Message %u from usermode buffer\n", KernelModeMsg->message);
485 /* Don't do extra testing for 1 word messages. For examples see
486 * https://wiki.winehq.org/List_Of_Windows_Messages and
487 * we are just handling WM_WININICHANGE here. */
488 if (Size > 1 && UserModeMsg->lParam &&
489 KernelModeMsg->message == WM_WININICHANGE)
490 {
491 WCHAR lParamMsg[_countof(StrUserKernel[0]) + 1] = { 0 };
493 {
494 RtlCopyMemory(lParamMsg, (WCHAR*)UserModeMsg->lParam, sizeof(lParamMsg));
495 }
497 {
499 }
500 _SEH2_END;
501
502 /* Make sure that we have a UNICODE_NULL within lParamMsg */
503 lParamMsg[ARRAYSIZE(lParamMsg) - 1] = UNICODE_NULL;
504
505 if (!UserModeMsg->wParam && PosInArray(lParamMsg) >= 0)
506 {
507 TRACE("Copy String '%S' from usermode buffer\n", lParamMsg);
508 wcscpy(KernelMem, lParamMsg);
509 return STATUS_SUCCESS;
510 }
511 }
512
513 Status = MmCopyFromCaller(KernelMem, (PVOID)UserModeMsg->lParam, Size);
514 if (!NT_SUCCESS(Status))
515 {
516 ERR("Failed to copy message to kernel: invalid usermode lParam buffer\n");
517 ExFreePoolWithTag(KernelMem, TAG_MSG);
518 return Status;
519 }
520 }
521 else
522 {
523 /* Make sure we don't pass any secrets to usermode */
524 RtlZeroMemory(KernelMem, Size);
525 }
526 }
527 else
528 {
529 KernelModeMsg->lParam = 0;
530 }
531
532 return STATUS_SUCCESS;
533}
#define ARRAYSIZE(a)
Definition: cat.c:25
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define STATUS_ACCESS_VIOLATION
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define UNICODE_NULL
short WCHAR
Definition: pedump.c:58
#define MmCopyFromCaller
Definition: polytest.cpp:29
#define WM_WININICHANGE
Definition: winuser.h:1658
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:104
#define _SEH2_END
Definition: pseh2_64.h:194
#define _SEH2_TRY
Definition: pseh2_64.h:93
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:207
wcscpy
#define _countof(array)
Definition: sndvol32.h:70
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
#define MMS_FLAG_READ
Definition: message.c:132
WCHAR StrUserKernel[3][20]
Definition: message.c:18
static INT PosInArray(_In_ PCWSTR String)
Definition: message.c:28
#define TAG_MSG
Definition: tags.h:7

Referenced by co_IntDoSendMessage().

◆ CopyMsgToUserMem()

static NTSTATUS FASTCALL CopyMsgToUserMem ( MSG *  UserModeMsg,
MSG *  KernelModeMsg 
)
static

Definition at line 536 of file message.c.

537{
539 PMSGMEMORY MsgMemoryEntry;
540 UINT Size;
541
542 /* See if this message type is present in the table */
543 MsgMemoryEntry = FindMsgMemory(UserModeMsg->message);
544 if (NULL == MsgMemoryEntry)
545 {
546 /* Not present, no copying needed */
547 return STATUS_SUCCESS;
548 }
549
550 /* Determine required size */
551 Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, UserModeMsg->lParam);
552
553 if (0 != Size)
554 {
555 /* Copy data if required */
556 if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_WRITE))
557 {
558 Status = MmCopyToCaller((PVOID) UserModeMsg->lParam, (PVOID) KernelModeMsg->lParam, Size);
559 if (! NT_SUCCESS(Status))
560 {
561 ERR("Failed to copy message from kernel: invalid usermode lParam buffer\n");
562 ExFreePool((PVOID) KernelModeMsg->lParam);
563 return Status;
564 }
565 }
566 ExFreePool((PVOID) KernelModeMsg->lParam);
567 }
568
569 return STATUS_SUCCESS;
570}
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define MmCopyToCaller(x, y, z)
Definition: mmcopy.h:19
#define MMS_FLAG_WRITE
Definition: message.c:133

Referenced by co_IntDoSendMessage().

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserMsg  )

◆ FindMsgMemory()

static PMSGMEMORY FASTCALL FindMsgMemory ( UINT  Msg)
static

Definition at line 168 of file message.c.

169{
170 PMSGMEMORY MsgMemoryEntry;
171
172 /* See if this message type is present in the table */
173 for (MsgMemoryEntry = g_MsgMemory;
174 MsgMemoryEntry < g_MsgMemory + sizeof(g_MsgMemory) / sizeof(MSGMEMORY);
175 MsgMemoryEntry++)
176 {
177 if (Msg == MsgMemoryEntry->Message)
178 {
179 return MsgMemoryEntry;
180 }
181 }
182
183 return NULL;
184}
UINT Message
Definition: message.c:137
static MSGMEMORY g_MsgMemory[]
Definition: message.c:143

Referenced by co_IntDoSendMessage(), co_IntGetPeekMessage(), co_IntSendMessageTimeoutSingle(), co_IntSendMessageWithCallBack(), CopyMsgToUserMem(), lParamMemorySize(), PackParam(), and UnpackParam().

◆ GetWakeMask()

UINT FASTCALL GetWakeMask ( UINT  first,
UINT  last 
)

Definition at line 623 of file message.c.

624{
625 UINT mask = QS_POSTMESSAGE | QS_SENDMESSAGE; /* Always selected */
626
627 if (first || last)
628 {
629 if ((first <= WM_KEYLAST) && (last >= WM_KEYFIRST)) mask |= QS_KEY;
630 if ( ((first <= WM_MOUSELAST) && (last >= WM_MOUSEFIRST)) ||
632 if ((first <= WM_TIMER) && (last >= WM_TIMER)) mask |= QS_TIMER;
633 if ((first <= WM_SYSTIMER) && (last >= WM_SYSTIMER)) mask |= QS_TIMER;
634 if ((first <= WM_PAINT) && (last >= WM_PAINT)) mask |= QS_PAINT;
635 }
636 else mask = QS_ALLINPUT;
637
638 return mask;
639}
#define WM_SYSTIMER
Definition: comctl32.h:125
GLenum GLint GLuint mask
Definition: glext.h:6028
const GLint * first
Definition: glext.h:5794
static const LARGE_INTEGER *static const HANDLE const LARGE_INTEGER *static PSLIST_ENTRY PSLIST_ENTRY last
Definition: sync.c:64
#define WM_NCMOUSEFIRST
Definition: msgqueue.h:242
#define WM_NCMOUSELAST
Definition: msgqueue.h:243
#define QS_KEY
Definition: winuser.h:885
#define WM_MOUSEFIRST
Definition: winuser.h:1802
#define WM_MOUSELAST
Definition: winuser.h:1829
#define WM_KEYFIRST
Definition: winuser.h:1742
#define WM_TIMER
Definition: winuser.h:1770
#define QS_MOUSE
Definition: winuser.h:903
#define WM_KEYLAST
Definition: winuser.h:1756

Referenced by co_IntGetPeekMessage(), and co_IntWaitMessage().

◆ handle_internal_events()

static LRESULT handle_internal_events ( PTHREADINFO  pti,
PWND  pWnd,
DWORD  dwQEvent,
LONG_PTR  ExtraInfo,
PMSG  pMsg 
)
static

Definition at line 862 of file message.c.

863{
864 LRESULT Result = 0;
865
866 switch(dwQEvent)
867 {
868 case POSTEVENT_NWE:
869 {
870 co_EVENT_CallEvents( pMsg->message, pMsg->hwnd, pMsg->wParam, ExtraInfo);
871 }
872 break;
873 case POSTEVENT_SAW:
874 {
875 //ERR("HIE : SAW : pti 0x%p hWnd 0x%p\n",pti,pMsg->hwnd);
876 IntActivateWindow((PWND)pMsg->wParam, pti, (HANDLE)pMsg->lParam, (DWORD)ExtraInfo);
877 }
878 break;
879 case POSTEVENT_DAW:
880 {
881 //ERR("HIE : DAW : pti 0x%p tid 0x%p hWndPrev 0x%p\n",pti,ExtraInfo,pMsg->hwnd);
882 IntDeactivateWindow(pti, (HANDLE)ExtraInfo);
883 }
884 break;
885 }
886 return Result;
887}
BOOL FASTCALL IntDeactivateWindow(PTHREADINFO pti, HANDLE tid)
Definition: focus.c:188
VOID FASTCALL IntActivateWindow(PWND Wnd, PTHREADINFO pti, HANDLE tid, DWORD Type)
Definition: focus.c:357
#define POSTEVENT_NWE
Definition: msgqueue.h:128
#define POSTEVENT_SAW
Definition: msgqueue.h:127
#define POSTEVENT_DAW
Definition: msgqueue.h:126
HWND hwnd
Definition: winuser.h:3222
LPARAM lParam
Definition: winuser.h:3225
LRESULT APIENTRY co_EVENT_CallEvents(DWORD event, HWND hwnd, UINT_PTR idObject, LONG_PTR idChild)
Definition: event.c:150

Referenced by co_IntPeekMessage().

◆ handle_internal_message()

static LRESULT handle_internal_message ( PWND  pWnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 821 of file message.c.

822{
823 LRESULT lRes;
824// USER_REFERENCE_ENTRY Ref;
825// PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
826
827 if (!pWnd || UserIsDesktopWindow(pWnd) || UserIsMessageWindow(pWnd))
828 return 0;
829
830 TRACE("Internal Event Msg 0x%x hWnd 0x%p\n", msg, UserHMGetHandle(pWnd));
831
832 switch(msg)
833 {
835 return co_WinPosShowWindow( pWnd, wparam );
837 {
838 PWINDOWPOS winpos = (PWINDOWPOS)lparam;
839 if (!winpos) return 0;
840 lRes = co_WinPosSetWindowPos( pWnd,
841 winpos->hwndInsertAfter,
842 winpos->x,
843 winpos->y,
844 winpos->cx,
845 winpos->cy,
846 winpos->flags);
848 return lRes;
849 }
851 {
852 TRACE("WM_ASYNC_DESTROYWINDOW\n");
853 if (pWnd->style & WS_CHILD)
855 else
857 }
858 }
859 return 0;
860}
@ lparam
Definition: SystemMenu.c:31
@ wparam
Definition: SystemMenu.c:30
#define msg(x)
Definition: auth_time.c:54
#define UserIsMessageWindow(pWnd)
Definition: desktop.h:199
#define UserIsDesktopWindow(pWnd)
Definition: desktop.h:196
@ WM_ASYNC_SHOWWINDOW
Definition: msgqueue.h:120
@ WM_ASYNC_SETWINDOWPOS
Definition: msgqueue.h:121
@ WM_ASYNC_DESTROYWINDOW
Definition: msgqueue.h:123
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1223
BOOLEAN FASTCALL co_WinPosSetWindowPos(PWND Window, HWND WndInsertAfter, INT x, INT y, INT cx, INT cy, UINT flags)
Definition: winpos.c:1792
BOOLEAN FASTCALL co_WinPosShowWindow(PWND Wnd, INT Cmd)
Definition: winpos.c:2635
#define WS_CHILD
Definition: pedump.c:617
struct _WINDOWPOS * PWINDOWPOS
UINT flags
Definition: winuser.h:3702
HWND hwndInsertAfter
Definition: winuser.h:3697
DWORD style
Definition: ntuser.h:710
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2857
#define USERTAG_SWP
Definition: tags.h:281
LRESULT co_UserFreeWindow(PWND Window, PPROCESSINFO ProcessData, PTHREADINFO ThreadData, BOOLEAN SendMessages)
Definition: window.c:575

Referenced by co_IntSendMessageTimeoutSingle(), and co_IntSendMessageWithCallBack().

◆ IdlePing()

VOID FASTCALL IdlePing ( VOID  )

Definition at line 576 of file message.c.

577{
579 PTHREADINFO pti;
580
582
583 if ( pti )
584 {
585 pti->pClientInfo->cSpins = 0; // Reset spins.
586
587 if ( pti->pDeskInfo && pti == gptiForeground )
588 {
591 {
593 }
594 }
595 }
596
597 TRACE("IdlePing ppi %p\n", ppi);
598 if ( ppi && ppi->InputIdleEvent )
599 {
600 TRACE("InputIdleEvent\n");
601 KeSetEvent( ppi->InputIdleEvent, IO_NO_INCREMENT, FALSE);
602 }
603}
PTHREADINFO gptiForeground
Definition: focus.c:15
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define HOOKID_TO_FLAG(HookId)
Definition: hook.h:5
#define WH_FOREGROUNDIDLE
Definition: winuser.h:41
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:94
ULONG fsHooks
Definition: win32.h:118
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Referenced by co_IntGetPeekMessage(), and IntMsqSetWakeMask().

◆ IdlePong()

VOID FASTCALL IdlePong ( VOID  )

Definition at line 606 of file message.c.

607{
609
610 TRACE("IdlePong ppi %p\n", ppi);
611 if ( ppi && ppi->InputIdleEvent )
612 {
613 KeClearEvent(ppi->InputIdleEvent);
614 }
615}
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 2192 of file message.c.

2193{
2194 BOOL Ret;
2195
2196 Ret = co_HOOK_CallHooks(WH_SYSMSGFILTER, code, 0, (LPARAM)lpmsg);
2197 if (!Ret)
2198 Ret = co_HOOK_CallHooks(WH_MSGFILTER, code, 0, (LPARAM)lpmsg);
2199
2200 return Ret;
2201}
#define WH_MSGFILTER
Definition: winuser.h:29
#define WH_SYSMSGFILTER
Definition: winuser.h:36
Definition: inflate.c:139

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

◆ IntCallWndProc()

static VOID FASTCALL IntCallWndProc ( PWND  Window,
HWND  hWnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 756 of file message.c.

757{
758 BOOL SameThread = FALSE;
759 CWPSTRUCT CWP;
760 PVOID pszClass = NULL, pszName = NULL;
761 CREATESTRUCTW Csw;
762
764 if ( !ISITHOOKED(WH_CALLWNDPROC) && !(Window->head.rpdesk->pDeskInfo->fsHooks & HOOKID_TO_FLAG(WH_CALLWNDPROC)) )
765 return;
766
768 SameThread = TRUE;
769
770 if ( Msg == WM_CREATE || Msg == WM_NCCREATE )
771 { //
772 // String pointers are in user heap space, like WH_CBT HCBT_CREATEWND.
773 //
774 if (!IntMsgCreateStructW( Window, &Csw, (CREATESTRUCTW *)lParam, &pszClass, &pszName ))
775 return;
776 lParam = (LPARAM)&Csw;
777 }
778
779 CWP.hwnd = hWnd;
780 CWP.message = Msg;
781 CWP.wParam = wParam;
782 CWP.lParam = lParam;
783 co_HOOK_CallHooks( WH_CALLWNDPROC, HC_ACTION, SameThread, (LPARAM)&CWP );
784
785 if (pszName) UserHeapFree(pszName);
786 if (pszClass) UserHeapFree(pszClass);
787}
#define ISITHOOKED(HookId)
Definition: hook.h:6
#define WM_CREATE
Definition: winuser.h:1636
#define WM_NCCREATE
Definition: winuser.h:1711
#define WH_CALLWNDPROC
Definition: winuser.h:34
LPARAM lParam
Definition: winuser.h:3133
WPARAM wParam
Definition: winuser.h:3134
UINT message
Definition: winuser.h:3135
static __inline BOOL UserHeapFree(PVOID lpMem)
Definition: usrheap.h:44
BOOL FASTCALL IntMsgCreateStructW(PWND Window, CREATESTRUCTW *pCsw, CREATESTRUCTW *Cs, PVOID *ppszClass, PVOID *ppszName)
Definition: message.c:646

Referenced by co_IntSendMessageTimeoutSingle(), and co_IntSendMessageWithCallBack().

◆ IntCallWndProcRet()

static VOID FASTCALL IntCallWndProcRet ( PWND  Window,
HWND  hWnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam,
LRESULT *  uResult 
)
static

Definition at line 790 of file message.c.

791{
792 BOOL SameThread = FALSE;
793 CWPRETSTRUCT CWPR;
794 PVOID pszClass = NULL, pszName = NULL;
795 CREATESTRUCTW Csw;
796
797 if ( !ISITHOOKED(WH_CALLWNDPROCRET) && !(Window->head.rpdesk->pDeskInfo->fsHooks & HOOKID_TO_FLAG(WH_CALLWNDPROCRET)) )
798 return;
799
801 SameThread = TRUE;
802
803 if ( Msg == WM_CREATE || Msg == WM_NCCREATE )
804 {
805 if (!IntMsgCreateStructW( Window, &Csw, (CREATESTRUCTW *)lParam, &pszClass, &pszName ))
806 return;
807 lParam = (LPARAM)&Csw;
808 }
809
810 CWPR.hwnd = hWnd;
811 CWPR.message = Msg;
812 CWPR.wParam = wParam;
813 CWPR.lParam = lParam;
814 CWPR.lResult = uResult ? (*uResult) : 0;
815 co_HOOK_CallHooks( WH_CALLWNDPROCRET, HC_ACTION, SameThread, (LPARAM)&CWPR );
816
817 if (pszName) UserHeapFree(pszName);
818 if (pszClass) UserHeapFree(pszClass);
819}
#define WH_CALLWNDPROCRET
Definition: winuser.h:42
WPARAM wParam
Definition: winuser.h:3127
LRESULT lResult
Definition: winuser.h:3125
LPARAM lParam
Definition: winuser.h:3126

Referenced by co_IntSendMessageTimeoutSingle(), and co_IntSendMessageWithCallBack().

◆ IntCleanupMessageImpl()

NTSTATUS FASTCALL IntCleanupMessageImpl ( VOID  )

Definition at line 47 of file message.c.

48{
49 return STATUS_SUCCESS;
50}

◆ IntDispatchMessage()

LRESULT FASTCALL IntDispatchMessage ( PMSG  pMsg)

Definition at line 890 of file message.c.

891{
892 LONG Time;
893 LRESULT retval = 0;
894 PTHREADINFO pti;
895 PWND Window = NULL;
896 BOOL DoCallBack = TRUE;
897
898 if (pMsg->hwnd)
899 {
901 if (!Window) return 0;
902 }
903
905
906 if ( Window && Window->head.pti != pti)
907 {
909 return 0;
910 }
911
912 if (((pMsg->message == WM_SYSTIMER) ||
913 (pMsg->message == WM_TIMER)) &&
914 (pMsg->lParam) )
915 {
916 if (pMsg->message == WM_TIMER)
917 {
918 if (ValidateTimerCallback(pti,pMsg->lParam))
919 {
922 TRUE,
923 pMsg->hwnd,
924 WM_TIMER,
925 pMsg->wParam,
926 (LPARAM)Time,
927 -1);
928 }
929 return retval;
930 }
931 else
932 {
933 PTIMER pTimer = FindSystemTimer(pMsg);
934 if (pTimer && pTimer->pfn)
935 {
937 pTimer->pfn(pMsg->hwnd, WM_SYSTIMER, (UINT)pMsg->wParam, Time);
938 }
939 return 0;
940 }
941 }
942 // Need a window!
943 if ( !Window ) return 0;
944
945 if (pMsg->message == WM_PAINT) Window->state |= WNDS_PAINTNOTPROCESSED;
946
947 if ( Window->state & WNDS_SERVERSIDEWINDOWPROC )
948 {
949 TRACE("Dispatch: Server Side Window Procedure\n");
950 switch(Window->fnid)
951 {
952 case FNID_DESKTOP:
953 DoCallBack = !DesktopWindowProc( Window,
954 pMsg->message,
955 pMsg->wParam,
956 pMsg->lParam,
957 &retval);
958 break;
959 case FNID_MESSAGEWND:
960 DoCallBack = !UserMessageWindowProc( Window,
961 pMsg->message,
962 pMsg->wParam,
963 pMsg->lParam,
964 &retval);
965 break;
966 case FNID_MENU:
967 DoCallBack = !PopupMenuWndProc( Window,
968 pMsg->message,
969 pMsg->wParam,
970 pMsg->lParam,
971 &retval);
972 break;
973 }
974 }
975
976 /* Since we are doing a callback on the same thread right away, there is
977 no need to copy the lparam to kernel mode and then back to usermode.
978 We just pretend it isn't a pointer */
979
980 if (DoCallBack)
981 retval = co_IntCallWindowProc( Window->lpfnWndProc,
982 !Window->Unicode,
983 pMsg->hwnd,
984 pMsg->message,
985 pMsg->wParam,
986 pMsg->lParam,
987 -1);
988
989 if ( pMsg->message == WM_PAINT &&
990 VerifyWnd(Window) &&
991 Window->state & WNDS_PAINTNOTPROCESSED ) // <--- Cleared, paint was already processed!
992 {
993 Window->state2 &= ~WNDS2_WMPAINTSENT;
994 /* send a WM_ERASEBKGND if the non-client area is still invalid */
995 ERR("Message WM_PAINT count %d Internal Paint Set? %s\n",Window->head.pti->cPaintsReady, Window->state & WNDS_INTERNALPAINT ? "TRUE" : "FALSE");
997 }
998
999 return retval;
1000}
#define WNDS_INTERNALPAINT
Definition: ntuser.h:621
#define WNDS_PAINTNOTPROCESSED
Definition: ntuser.h:631
static PLARGE_INTEGER Time
Definition: time.c:37
long LONG
Definition: pedump.c:60
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:3014
Definition: timer.h:4
TIMERPROC pfn
Definition: timer.h:13
VOID FASTCALL IntPaintWindow(PWND Window)
Definition: painting.c:1186
int retval
Definition: wcstombs.cpp:91
BOOL FASTCALL ValidateTimerCallback(PTHREADINFO pti, LPARAM lParam)
Definition: timer.c:155
PTIMER FASTCALL FindSystemTimer(PMSG pMsg)
Definition: timer.c:131
PWND FASTCALL VerifyWnd(PWND pWnd)
Definition: window.c:88
#define ERROR_MESSAGE_SYNC_ONLY
Definition: winerror.h:1005

Referenced by DefWndDoSizeMove(), DefWndStartSizeMove(), DesktopThreadMain(), MENU_TrackMenu(), and NtUserDispatchMessage().

◆ IntGetQueueStatus()

DWORD APIENTRY IntGetQueueStatus ( DWORD  Changes)

Definition at line 2141 of file message.c.

2142{
2143 PTHREADINFO pti;
2144 DWORD Result;
2145
2147// wine:
2149
2150 /* High word, types of messages currently in the queue.
2151 Low word, types of messages that have been added to the queue and that
2152 are still in the queue
2153 */
2154 Result = MAKELONG(pti->pcti->fsChangeBits & Changes, pti->pcti->fsWakeBits & Changes);
2155
2156 pti->pcti->fsChangeBits &= ~Changes;
2157
2158 return Result;
2159}
#define QS_SMRESULT
Definition: undocuser.h:96

Referenced by NtUserCallOneParam(), and NtUserGetThreadState().

◆ IntInitMessageImpl()

NTSTATUS FASTCALL IntInitMessageImpl ( VOID  )

Definition at line 41 of file message.c.

42{
43 return STATUS_SUCCESS;
44}

◆ IntInitMessagePumpHook()

BOOL APIENTRY IntInitMessagePumpHook ( VOID  )

Definition at line 2162 of file message.c.

2163{
2165
2166 if (pti->pcti)
2167 {
2168 pti->pcti->dwcPumpHook++;
2169 return TRUE;
2170 }
2171 return FALSE;
2172}

Referenced by NtUserCallNoParam().

◆ IntMsgCreateStructW()

BOOL FASTCALL IntMsgCreateStructW ( PWND  Window,
CREATESTRUCTW *  pCsw,
CREATESTRUCTW *  Cs,
PVOID *  ppszClass,
PVOID *  ppszName 
)

Definition at line 646 of file message.c.

652{
653 PLARGE_STRING WindowName;
654 PUNICODE_STRING ClassName;
655 PVOID pszClass = NULL, pszName = NULL;
656
657 /* Fill the new CREATESTRUCTW */
658 RtlCopyMemory(pCsw, Cs, sizeof(CREATESTRUCTW));
659 pCsw->style = Window->style; /* HCBT_CREATEWND needs the real window style */
660
661 WindowName = (PLARGE_STRING) Cs->lpszName;
662 ClassName = (PUNICODE_STRING) Cs->lpszClass;
663
664 // Based on the assumption this is from "unicode source" user32, ReactOS, answer is yes.
665 if (!IS_ATOM(ClassName->Buffer))
666 {
667 if (ClassName->Length)
668 {
669 if (Window->state & WNDS_ANSICREATOR)
670 {
672 AnsiString.MaximumLength = (USHORT)RtlUnicodeStringToAnsiSize(ClassName)+sizeof(CHAR);
673 pszClass = UserHeapAlloc(AnsiString.MaximumLength);
674 if (!pszClass)
675 {
676 ERR("UserHeapAlloc() failed!\n");
677 return FALSE;
678 }
679 RtlZeroMemory(pszClass, AnsiString.MaximumLength);
680 AnsiString.Buffer = (PCHAR)pszClass;
682 }
683 else
684 {
686 UnicodeString.MaximumLength = ClassName->Length + sizeof(UNICODE_NULL);
688 if (!pszClass)
689 {
690 ERR("UserHeapAlloc() failed!\n");
691 return FALSE;
692 }
694 UnicodeString.Buffer = (PWSTR)pszClass;
696 }
697 *ppszClass = pszClass;
698 pCsw->lpszClass = UserHeapAddressToUser(pszClass);
699 }
700 else
701 {
702 pCsw->lpszClass = NULL;
703 }
704 }
705 else
706 {
707 pCsw->lpszClass = ClassName->Buffer;
708 }
709 if (WindowName->Length)
710 {
712 Name.Buffer = WindowName->Buffer;
713 Name.Length = (USHORT)min(WindowName->Length, MAXUSHORT); // FIXME: LARGE_STRING truncated
714 Name.MaximumLength = (USHORT)min(WindowName->MaximumLength, MAXUSHORT);
715
716 if (Window->state & WNDS_ANSICREATOR)
717 {
719 AnsiString.MaximumLength = (USHORT)RtlUnicodeStringToAnsiSize(&Name) + sizeof(CHAR);
720 pszName = UserHeapAlloc(AnsiString.MaximumLength);
721 if (!pszName)
722 {
723 ERR("UserHeapAlloc() failed!\n");
724 return FALSE;
725 }
726 RtlZeroMemory(pszName, AnsiString.MaximumLength);
727 AnsiString.Buffer = (PCHAR)pszName;
729 }
730 else
731 {
733 UnicodeString.MaximumLength = Name.Length + sizeof(UNICODE_NULL);
735 if (!pszName)
736 {
737 ERR("UserHeapAlloc() failed!\n");
738 return FALSE;
739 }
741 UnicodeString.Buffer = (PWSTR)pszName;
743 }
744 *ppszName = pszName;
745 pCsw->lpszName = UserHeapAddressToUser(pszName);
746 }
747 else
748 {
749 pCsw->lpszName = NULL;
750 }
751
752 return TRUE;
753}
#define CHAR(Char)
#define IS_ATOM(x)
Definition: class.h:3
LPWSTR Name
Definition: desk.c:124
@ AnsiString
Definition: dnslib.h:19
struct _LARGE_STRING * PLARGE_STRING
#define WNDS_ANSICREATOR
Definition: ntuser.h:638
#define PCHAR
Definition: match.c:90
#define min(a, b)
Definition: monoChain.cc:55
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
unsigned short USHORT
Definition: pedump.c:61
SIGDN PWSTR * ppszName
Definition: shobjidl.idl:651
ULONG Length
Definition: ntuser.h:94
ULONG MaximumLength
Definition: ntuser.h:95
PVOID Buffer
Definition: ntuser.h:97
USHORT MaximumLength
Definition: env_spec_w32.h:370
LPCWSTR lpszClass
Definition: winuser.h:3073
LPCWSTR lpszName
Definition: winuser.h:3072
uint16_t * PWSTR
Definition: typedefs.h:56
#define MAXUSHORT
Definition: typedefs.h:83
static __inline PVOID UserHeapAlloc(SIZE_T Bytes)
Definition: usrheap.h:34
static __inline PVOID UserHeapAddressToUser(PVOID lpMem)
Definition: usrheap.h:99
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_opt_ PCUNICODE_STRING UnicodeString
Definition: wdfstring.h:64
#define RtlUnicodeStringToAnsiSize(String)
Definition: rtlfuncs.h:1022

Referenced by co_UserCreateWindowEx(), IntCallWndProc(), and IntCallWndProcRet().

◆ IntSendTo()

PTHREADINFO FASTCALL IntSendTo ( PWND  Window,
PTHREADINFO  ptiCur,
UINT  Msg 
)

Definition at line 1383 of file message.c.

1384{
1385 if ( ptiCur )
1386 {
1387 if (!Window ||
1388 Window->head.pti == ptiCur )
1389 {
1390 return NULL;
1391 }
1392 }
1393 return Window ? Window->head.pti : NULL;
1394}

Referenced by co_IntDoSendMessage(), co_IntSendMessageTimeoutSingle(), and co_IntSendMessageWithCallBack().

◆ IntUninitMessagePumpHook()

BOOL APIENTRY IntUninitMessagePumpHook ( VOID  )

Definition at line 2175 of file message.c.

2176{
2178
2179 if (pti->pcti)
2180 {
2181 if (pti->pcti->dwcPumpHook <= 0)
2182 {
2183 return FALSE;
2184 }
2185 pti->pcti->dwcPumpHook--;
2186 return TRUE;
2187 }
2188 return FALSE;
2189}

Referenced by NtUserCallNoParam().

◆ is_message_broadcastable()

static BOOL is_message_broadcastable ( UINT  msg)
static

Definition at line 617 of file message.c.

618{
619 return msg < WM_USER || msg >= 0xc000;
620}

Referenced by co_IntSendMessageTimeout(), and UserPostMessage().

◆ is_pointer_message()

static int is_pointer_message ( UINT  message,
WPARAM  wparam 
)
inlinestatic

Definition at line 120 of file message.c.

121{
122 if (message >= 8*sizeof(message_pointer_flags)) return FALSE;
123 if (message == WM_DEVICECHANGE && !(wparam & 0x8000)) return FALSE;
124 return (message_pointer_flags[message / 32] & SET(message)) != 0;
125}
Definition: tftpd.h:60
static const unsigned int message_pointer_flags[]
Definition: message.c:58
#define SET(msg)
Definition: message.c:56

Referenced by DispatchMessageA(), DispatchMessageW(), NtUserMessageCall(), SendMessageCallbackA(), SendMessageCallbackW(), SendNotifyMessageA(), SendNotifyMessageW(), UserPostMessage(), UserPostThreadMessage(), and UserSendNotifyMessage().

◆ lParamMemorySize()

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

Definition at line 276 of file message.c.

277{
278 PMSGMEMORY MsgMemoryEntry = FindMsgMemory(Msg);
279 if(MsgMemoryEntry == NULL) return 0;
280 return MsgMemorySize(MsgMemoryEntry, wParam, lParam);
281}

Referenced by co_IntCallHookProc().

◆ MsgMemorySize()

static UINT FASTCALL MsgMemorySize ( PMSGMEMORY  MsgMemoryEntry,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 187 of file message.c.

188{
189 CREATESTRUCTW *Cs;
190 PLARGE_STRING WindowName;
191 PUNICODE_STRING ClassName;
192 UINT Size = 0;
193
195 {
196 if (MMS_SIZE_WPARAM == MsgMemoryEntry->Size)
197 {
198 Size = (UINT)wParam;
199 }
200 else if (MMS_SIZE_WPARAMWCHAR == MsgMemoryEntry->Size)
201 {
202 Size = (UINT) (wParam * sizeof(WCHAR));
203 }
204 else if (MMS_SIZE_LPARAMSZ == MsgMemoryEntry->Size)
205 {
206 // WM_SETTEXT and WM_SETTINGCHANGE can be null!
207 if (!lParam)
208 {
209 TRACE("lParam is NULL!\n");
210 Size = 0;
211 }
212 else
213 Size = (UINT) ((wcslen((PWSTR) lParam) + 1) * sizeof(WCHAR));
214 }
215 else if (MMS_SIZE_SPECIAL == MsgMemoryEntry->Size)
216 {
217 switch(MsgMemoryEntry->Message)
218 {
219 case WM_CREATE:
220 case WM_NCCREATE:
221 Cs = (CREATESTRUCTW *) lParam;
222 WindowName = (PLARGE_STRING) Cs->lpszName;
223 ClassName = (PUNICODE_STRING) Cs->lpszClass;
224 Size = sizeof(CREATESTRUCTW) + WindowName->Length + sizeof(WCHAR);
225 if (IS_ATOM(ClassName->Buffer))
226 {
227 Size += sizeof(WCHAR) + sizeof(ATOM);
228 }
229 else
230 {
231 Size += sizeof(WCHAR) + ClassName->Length + sizeof(WCHAR);
232 }
233 break;
234
235 case WM_NCCALCSIZE:
236 Size = wParam ? sizeof(NCCALCSIZE_PARAMS) + sizeof(WINDOWPOS) : sizeof(RECT);
237 break;
238
239 case WM_COPYDATA:
240 {
242 Size = sizeof(COPYDATASTRUCT) + cds->cbData;
243 }
244 break;
245
246 case WM_DEVICECHANGE:
247 {
248 if ( lParam && (wParam & 0x8000) )
249 {
251 Size = header->dbch_size;
252 }
253 }
254 break;
255
256 default:
257 ASSERT(FALSE);
258 Size = 0;
259 break;
260 }
261 }
262 else
263 {
264 Size = MsgMemoryEntry->Size;
265 }
266 }
268 {
269 ERR("Exception caught in MsgMemorySize()! Status: 0x%x\n", _SEH2_GetExceptionCode());
270 Size = 0;
271 }
272 _SEH2_END;
273 return Size;
274}
WORD ATOM
Definition: dimm.idl:113
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
struct tagNCCALCSIZE_PARAMS NCCALCSIZE_PARAMS
struct tagCREATESTRUCTW CREATESTRUCTW
struct tagCOPYDATASTRUCT COPYDATASTRUCT
#define WM_COPYDATA
Definition: winuser.h:1692
#define WM_NCCALCSIZE
Definition: winuser.h:1713
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:204
#define UINT
Definition: utils.c:29
Definition: dcommon.idl:28
UINT Size
Definition: message.c:138
#define MMS_SIZE_LPARAMSZ
Definition: message.c:130
#define MMS_SIZE_WPARAMWCHAR
Definition: message.c:129
#define MMS_SIZE_SPECIAL
Definition: message.c:131
#define MMS_SIZE_WPARAM
Definition: message.c:128
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by co_IntSendMessageTimeoutSingle(), co_IntSendMessageWithCallBack(), CopyMsgToKernelMem(), CopyMsgToUserMem(), lParamMemorySize(), and PackParam().

◆ NtUserCallMsgFilter()

BOOL APIENTRY NtUserCallMsgFilter ( LPMSG  lpmsg,
INT  code 
)

Definition at line 2431 of file message.c.

2432{
2433 BOOL Ret = FALSE;
2434 MSG Msg;
2435
2436 _SEH2_TRY
2437 {
2438 ProbeForRead(lpmsg, sizeof(MSG), 1);
2439 RtlCopyMemory( &Msg, lpmsg, sizeof(MSG));
2440 }
2442 {
2443 _SEH2_YIELD(return FALSE);
2444 }
2445 _SEH2_END;
2446
2448 Ret = IntCallMsgFilter(&Msg, code);
2449 UserLeave();
2450
2451 _SEH2_TRY
2452 {
2453 ProbeForWrite(lpmsg, sizeof(MSG), 1);
2454 RtlCopyMemory(lpmsg, &Msg, sizeof(MSG));
2455 }
2457 {
2458 Ret = FALSE;
2459 }
2460 _SEH2_END;
2461
2462 return Ret;
2463}
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
BOOL FASTCALL IntCallMsgFilter(LPMSG lpmsg, INT code)
Definition: message.c:2192

Referenced by CallMsgFilterA(), and CallMsgFilterW().

◆ NtUserDispatchMessage()

LRESULT APIENTRY NtUserDispatchMessage ( PMSG  UnsafeMsgInfo)

Definition at line 2466 of file message.c.

2467{
2468 LRESULT Res = 0;
2469 MSG SafeMsg;
2470
2471 _SEH2_TRY
2472 {
2473 ProbeForRead(UnsafeMsgInfo, sizeof(MSG), 1);
2474 RtlCopyMemory(&SafeMsg, UnsafeMsgInfo, sizeof(MSG));
2475 }
2477 {
2479 _SEH2_YIELD(return FALSE);
2480 }
2481 _SEH2_END;
2482
2484
2485 Res = IntDispatchMessage(&SafeMsg);
2486
2487 UserLeave();
2488 return Res;
2489}
LRESULT FASTCALL IntDispatchMessage(PMSG pMsg)
Definition: message.c:890

Referenced by DispatchMessageA(), and DispatchMessageW().

◆ NtUserDragDetect()

BOOL APIENTRY NtUserDragDetect ( HWND  hWnd,
POINT  pt 
)

Functions

Definition at line 2207 of file message.c.

2210{
2211 MSG msg;
2212 RECT rect;
2213 ULONG wDragWidth, wDragHeight;
2214 BOOL Ret = FALSE;
2215
2216 TRACE("Enter NtUserDragDetect(%p)\n", hWnd);
2218
2219 wDragWidth = UserGetSystemMetrics(SM_CXDRAG);
2220 wDragHeight= UserGetSystemMetrics(SM_CYDRAG);
2221
2222 rect.left = pt.x - wDragWidth;
2223 rect.right = pt.x + wDragWidth;
2224
2225 rect.top = pt.y - wDragHeight;
2226 rect.bottom = pt.y + wDragHeight;
2227
2229
2230 for (;;)
2231 {
2235 {
2236 if ( msg.message == WM_LBUTTONUP )
2237 {
2239 goto Exit; // Return FALSE
2240 }
2241 if ( msg.message == WM_MOUSEMOVE )
2242 {
2243 POINT tmp;
2244 tmp.x = (short)LOWORD(msg.lParam);
2245 tmp.y = (short)HIWORD(msg.lParam);
2246 if( !RECTL_bPointInRect( &rect, tmp.x, tmp.y ) )
2247 {
2249 Ret = TRUE;
2250 goto Exit;
2251 }
2252 }
2253 if ( msg.message == WM_KEYDOWN )
2254 {
2255 if ( msg.wParam == VK_ESCAPE )
2256 {
2258 Ret = TRUE;
2259 goto Exit;
2260 }
2261 }
2262 if ( msg.message == WM_QUEUESYNC )
2263 {
2265 }
2266 }
2267 co_IntWaitMessage(NULL, 0, 0);
2268 }
2269
2270Exit:
2271 TRACE("Leave NtUserDragDetect, ret=%i\n", Ret);
2272 UserLeave();
2273 return Ret;
2274}
RECT rect
Definition: combotst.c:67
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define pt(x, y)
Definition: drawing.c:79
HWND FASTCALL co_UserSetCapture(HWND hWnd)
Definition: focus.c:1453
#define LOWORD(l)
Definition: pedump.c:82
#define SM_CXDRAG
Definition: winuser.h:1039
#define WM_MOUSEMOVE
Definition: winuser.h:1803
#define WH_CBT
Definition: winuser.h:35
#define WM_QUEUESYNC
Definition: winuser.h:1667
#define HCBT_QS
Definition: winuser.h:57
#define WM_LBUTTONUP
Definition: winuser.h:1805
#define WM_KEYDOWN
Definition: winuser.h:1743
#define SM_CYDRAG
Definition: winuser.h:1040
#define VK_ESCAPE
Definition: winuser.h:2250
static void Exit(void)
Definition: sock.c:1330
long y
Definition: dcommon.idl:24
long x
Definition: dcommon.idl:24
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
uint32_t ULONG
Definition: typedefs.h:59
FORCEINLINE BOOL RECTL_bPointInRect(_In_ const RECTL *prcl, _In_ INT x, _In_ INT y)
Definition: rect.h:52
BOOL FASTCALL co_IntWaitMessage(PWND Window, UINT MsgFilterMin, UINT MsgFilterMax)
Definition: message.c:1182
BOOL APIENTRY co_IntGetPeekMessage(PMSG pMsg, HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg, BOOL bGMSG)
Definition: message.c:1228
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:209

Referenced by DragDetect().

◆ NtUserGetMessage()

BOOL APIENTRY NtUserGetMessage ( PMSG  pMsg,
HWND  hWnd,
UINT  MsgFilterMin,
UINT  MsgFilterMax 
)

Definition at line 2345 of file message.c.

2349{
2350 MSG Msg;
2351 BOOL Ret;
2352
2353 if ( (MsgFilterMin|MsgFilterMax) & ~WM_MAXIMUM )
2354 {
2356 return FALSE;
2357 }
2358
2360
2361 RtlZeroMemory(&Msg, sizeof(MSG));
2362
2363 Ret = co_IntGetPeekMessage(&Msg, hWnd, MsgFilterMin, MsgFilterMax, PM_REMOVE, TRUE);
2364
2365 UserLeave();
2366
2367 if (Ret)
2368 {
2369 _SEH2_TRY
2370 {
2371 ProbeForWrite(pMsg, sizeof(MSG), 1);
2372 RtlCopyMemory(pMsg, &Msg, sizeof(MSG));
2373 }
2375 {
2377 Ret = FALSE;
2378 }
2379 _SEH2_END;
2380 }
2381
2382 if ((INT)Ret != -1)
2383 Ret = Ret ? (WM_QUIT != pMsg->message) : FALSE;
2384
2385 return Ret;
2386}
#define WM_MAXIMUM
Definition: undocuser.h:65

Referenced by GetMessageA(), and GetMessageW().

◆ NtUserMessageCall()

BOOL APIENTRY NtUserMessageCall ( HWND  hWnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam,
ULONG_PTR  ResultInfo,
DWORD  dwType,
BOOL  Ansi 
)

Definition at line 2529 of file message.c.

2536{
2537 LRESULT lResult = 0;
2538 BOOL Ret = FALSE;
2539 PWND Window = NULL;
2541
2543
2544 switch(dwType)
2545 {
2546 case FNID_SCROLLBAR:
2547 {
2548 lResult = ScrollBarWndProc(hWnd, Msg, wParam, lParam);
2549 break;
2550 }
2551 case FNID_DESKTOP:
2552 {
2554 if (Window)
2555 {
2556 //ERR("FNID_DESKTOP IN\n");
2557 Ret = DesktopWindowProc(Window, Msg, wParam, lParam, &lResult);
2558 //ERR("FNID_DESKTOP OUT\n");
2559 }
2560 break;
2561 }
2562 case FNID_MENU:
2563 {
2565 if (Window)
2566 {
2567 Ret = PopupMenuWndProc( Window, Msg, wParam, lParam, &lResult);
2568 }
2569 break;
2570 }
2571 case FNID_MESSAGEWND:
2572 {
2574 if (Window)
2575 {
2576 Ret = !UserMessageWindowProc(Window, Msg, wParam, lParam, &lResult);
2577 }
2578 break;
2579 }
2580 case FNID_DEFWINDOWPROC:
2581 /* Validate input */
2582 if (hWnd)
2583 {
2585 if (!Window)
2586 {
2587 UserLeave();
2588 return FALSE;
2589 }
2590 UserRefObjectCo(Window, &Ref);
2591 }
2592 lResult = IntDefWindowProc(Window, Msg, wParam, lParam, Ansi);
2593 Ret = TRUE;
2594 if (hWnd)
2596 break;
2599 break;
2601 {
2602 BROADCASTPARM parm, *retparam;
2603 DWORD_PTR RetVal = 0;
2604
2605 if (ResultInfo)
2606 {
2607 _SEH2_TRY
2608 {
2609 ProbeForWrite((PVOID)ResultInfo, sizeof(BROADCASTPARM), 1);
2610 RtlCopyMemory(&parm, (PVOID)ResultInfo, sizeof(BROADCASTPARM));
2611 }
2613 {
2614 _SEH2_YIELD(break);
2615 }
2616 _SEH2_END;
2617 }
2618 else
2619 break;
2620
2621 if ( parm.recipients & BSM_ALLDESKTOPS ||
2623 {
2624 PLIST_ENTRY DesktopEntry;
2625 PDESKTOP rpdesk;
2626 HWND *List, hwndDenied = NULL;
2627 HDESK hDesk = NULL;
2628 PWND pwnd, pwndDesk;
2629 ULONG i;
2630 UINT fuFlags;
2631
2632 for (DesktopEntry = InputWindowStation->DesktopListHead.Flink;
2633 DesktopEntry != &InputWindowStation->DesktopListHead;
2634 DesktopEntry = DesktopEntry->Flink)
2635 {
2636 rpdesk = CONTAINING_RECORD(DesktopEntry, DESKTOP, ListEntry);
2637 pwndDesk = rpdesk->pDeskInfo->spwnd;
2638 List = IntWinListChildren(pwndDesk);
2639
2640 if (parm.flags & BSF_QUERY)
2641 {
2642 if (List != NULL)
2643 {
2644 if (parm.flags & BSF_FORCEIFHUNG || parm.flags & BSF_NOHANG)
2645 {
2646 fuFlags = SMTO_ABORTIFHUNG;
2647 }
2648 else if (parm.flags & BSF_NOTIMEOUTIFNOTHUNG)
2649 {
2650 fuFlags = SMTO_NOTIMEOUTIFNOTHUNG;
2651 }
2652 else
2653 {
2654 fuFlags = SMTO_NORMAL;
2655 }
2657 Msg,
2658 wParam,
2659 lParam,
2660 fuFlags,
2661 2000,
2662 &RetVal);
2663 Ret = TRUE;
2664 for (i = 0; List[i]; i++)
2665 {
2666 pwnd = UserGetWindowObject(List[i]);
2667 if (!pwnd) continue;
2668
2669 if ( pwnd->fnid == FNID_MENU ||
2671 continue;
2672
2673 if ( parm.flags & BSF_IGNORECURRENTTASK )
2674 {
2675 if ( pwnd->head.pti == gptiCurrent )
2676 continue;
2677 }
2679 Msg,
2680 wParam,
2681 lParam,
2682 fuFlags,
2683 2000,
2684 &RetVal);
2685
2686 if (!RetVal && EngGetLastError() == ERROR_TIMEOUT)
2687 {
2688 if (!(parm.flags & BSF_FORCEIFHUNG))
2689 Ret = FALSE;
2690 }
2691 if (RetVal == BROADCAST_QUERY_DENY)
2692 {
2693 hwndDenied = List[i];
2694 hDesk = UserHMGetHandle(pwndDesk);
2695 Ret = FALSE;
2696 }
2697 }
2699 _SEH2_TRY
2700 {
2701 retparam = (PBROADCASTPARM) ResultInfo;
2702 retparam->hDesk = hDesk;
2703 retparam->hWnd = hwndDenied;
2704 }
2706 {
2707 _SEH2_YIELD(break);
2708 }
2709 _SEH2_END;
2710 if (!Ret) break; // Have a hit! Let everyone know!
2711 }
2712 }
2713 else if (parm.flags & BSF_POSTMESSAGE)
2714 {
2715 if (List != NULL)
2716 {
2718
2719 for (i = 0; List[i]; i++)
2720 {
2721 pwnd = UserGetWindowObject(List[i]);
2722 if (!pwnd) continue;
2723
2724 if ( pwnd->fnid == FNID_MENU ||
2726 continue;
2727
2728 if ( parm.flags & BSF_IGNORECURRENTTASK )
2729 {
2730 if ( pwnd->head.pti == gptiCurrent )
2731 continue;
2732 }
2734 }
2736 }
2737 Ret = TRUE;
2738 }
2739 else
2740 {
2741 if (List != NULL)
2742 {
2744
2745 for (i = 0; List[i]; i++)
2746 {
2747 pwnd = UserGetWindowObject(List[i]);
2748 if (!pwnd) continue;
2749
2750 if ( pwnd->fnid == FNID_MENU ||
2752 continue;
2753
2754 if ( parm.flags & BSF_IGNORECURRENTTASK )
2755 {
2756 if ( pwnd->head.pti == gptiCurrent )
2757 continue;
2758 }
2760 }
2762 }
2763 if (lParam && !wParam && _wcsicmp((WCHAR*)lParam, L"Environment") == 0)
2764 {
2765 /* Handle Broadcast of WM_SETTINGCHAGE for Environment */
2767 0, (LPARAM)L"Environment", 0);
2768 }
2769 Ret = TRUE;
2770 }
2771 }
2772 }
2773 else if (parm.recipients & BSM_APPLICATIONS)
2774 {
2775 HWND *List, hwndDenied = NULL;
2776 HDESK hDesk = NULL;
2777 PWND pwnd, pwndDesk;
2778 ULONG i;
2779 UINT fuFlags;
2780
2781 pwndDesk = UserGetDesktopWindow();
2782 List = IntWinListChildren(pwndDesk);
2783
2784 if (parm.flags & BSF_QUERY)
2785 {
2786 if (List != NULL)
2787 {
2788 if (parm.flags & BSF_FORCEIFHUNG || parm.flags & BSF_NOHANG)
2789 {
2790 fuFlags = SMTO_ABORTIFHUNG;
2791 }
2792 else if (parm.flags & BSF_NOTIMEOUTIFNOTHUNG)
2793 {
2794 fuFlags = SMTO_NOTIMEOUTIFNOTHUNG;
2795 }
2796 else
2797 {
2798 fuFlags = SMTO_NORMAL;
2799 }
2801 Msg,
2802 wParam,
2803 lParam,
2804 fuFlags,
2805 2000,
2806 &RetVal);
2807 Ret = TRUE;
2808 for (i = 0; List[i]; i++)
2809 {
2810 pwnd = UserGetWindowObject(List[i]);
2811 if (!pwnd) continue;
2812
2813 if ( pwnd->fnid == FNID_MENU ||
2815 continue;
2816
2817 if ( parm.flags & BSF_IGNORECURRENTTASK )
2818 {
2819 if ( pwnd->head.pti == gptiCurrent )
2820 continue;
2821 }
2823 Msg,
2824 wParam,
2825 lParam,
2826 fuFlags,
2827 2000,
2828 &RetVal);
2829
2830 if (!RetVal && EngGetLastError() == ERROR_TIMEOUT)
2831 {
2832 if (!(parm.flags & BSF_FORCEIFHUNG))
2833 Ret = FALSE;
2834 }
2835 if (RetVal == BROADCAST_QUERY_DENY)
2836 {
2837 hwndDenied = List[i];
2838 hDesk = UserHMGetHandle(pwndDesk);
2839 Ret = FALSE;
2840 }
2841 }
2843 _SEH2_TRY
2844 {
2845 retparam = (PBROADCASTPARM) ResultInfo;
2846 retparam->hDesk = hDesk;
2847 retparam->hWnd = hwndDenied;
2848 }
2850 {
2851 _SEH2_YIELD(break);
2852 }
2853 _SEH2_END;
2854 }
2855 }
2856 else if (parm.flags & BSF_POSTMESSAGE)
2857 {
2858 if (List != NULL)
2859 {
2861
2862 for (i = 0; List[i]; i++)
2863 {
2864 pwnd = UserGetWindowObject(List[i]);
2865 if (!pwnd) continue;
2866
2867 if ( pwnd->fnid == FNID_MENU ||
2869 continue;
2870
2871 if ( parm.flags & BSF_IGNORECURRENTTASK )
2872 {
2873 if ( pwnd->head.pti == gptiCurrent )
2874 continue;
2875 }
2877 }
2879 }
2880 Ret = TRUE;
2881 }
2882 else
2883 {
2884 if (List != NULL)
2885 {
2887
2888 for (i = 0; List[i]; i++)
2889 {
2890 pwnd = UserGetWindowObject(List[i]);
2891 if (!pwnd) continue;
2892
2893 if ( pwnd->fnid == FNID_MENU ||
2895 continue;
2896
2897 if ( parm.flags & BSF_IGNORECURRENTTASK )
2898 {
2899 if ( pwnd->head.pti == gptiCurrent )
2900 continue;
2901 }
2903 }
2905 }
2906 Ret = TRUE;
2907 }
2908 }
2909 }
2910 break;
2912 {
2913 CALL_BACK_INFO CallBackInfo;
2914 ULONG_PTR uResult;
2915
2916 _SEH2_TRY
2917 {
2918 ProbeForRead((PVOID)ResultInfo, sizeof(CALL_BACK_INFO), 1);
2919 RtlCopyMemory(&CallBackInfo, (PVOID)ResultInfo, sizeof(CALL_BACK_INFO));
2920 }
2922 {
2923 _SEH2_YIELD(break);
2924 }
2925 _SEH2_END;
2926
2928 {
2930 break;
2931 }
2932
2934 CallBackInfo.CallBack, CallBackInfo.Context, &uResult)))
2935 {
2936 ERR("Callback failure!\n");
2937 }
2938 }
2939 break;
2940 case FNID_SENDMESSAGE:
2941 {
2942 lResult = co_IntDoSendMessage(hWnd, Msg, wParam, lParam, 0);
2943 Ret = TRUE;
2944
2945 if (ResultInfo)
2946 {
2947 _SEH2_TRY
2948 {
2949 ProbeForWrite((PVOID)ResultInfo, sizeof(ULONG_PTR), 1);
2950 RtlCopyMemory((PVOID)ResultInfo, &lResult, sizeof(ULONG_PTR));
2951 }
2953 {
2954 Ret = FALSE;
2955 _SEH2_YIELD(break);
2956 }
2957 _SEH2_END;
2958 }
2959 break;
2960 }
2961 case FNID_SENDMESSAGEFF:
2963 {
2964 DOSENDMESSAGE dsm, *pdsm = (PDOSENDMESSAGE)ResultInfo;
2965 if (ResultInfo)
2966 {
2967 _SEH2_TRY
2968 {
2969 ProbeForRead(pdsm, sizeof(DOSENDMESSAGE), 1);
2970 RtlCopyMemory(&dsm, pdsm, sizeof(DOSENDMESSAGE));
2971 }
2973 {
2974 _SEH2_YIELD(break);
2975 }
2976 _SEH2_END;
2977 }
2978
2979 Ret = co_IntDoSendMessage( hWnd, Msg, wParam, lParam, pdsm ? &dsm : NULL );
2980
2981 if (pdsm)
2982 {
2983 _SEH2_TRY
2984 {
2985 ProbeForWrite(pdsm, sizeof(DOSENDMESSAGE), 1);
2986 RtlCopyMemory(pdsm, &dsm, sizeof(DOSENDMESSAGE));
2987 }
2989 {
2990 Ret = FALSE;
2991 _SEH2_YIELD(break);
2992 }
2993 _SEH2_END;
2994 }
2995 break;
2996 }
2997 // CallNextHook bypass.
2998 case FNID_CALLWNDPROC:
3000 {
3001 PTHREADINFO pti;
3003 PHOOK NextObj, Hook;
3004
3005 pti = GetW32ThreadInfo();
3006
3007 Hook = pti->sphkCurrent;
3008
3009 if (!Hook) break;
3010
3011 NextObj = Hook->phkNext;
3012 ClientInfo = pti->pClientInfo;
3013 _SEH2_TRY
3014 {
3015 ClientInfo->phkCurrent = NextObj;
3016 }
3018 {
3019 ClientInfo = NULL;
3020 }
3021 _SEH2_END;
3022
3023 if (!ClientInfo || !NextObj) break;
3024
3025 NextObj->phkNext = IntGetNextHook(NextObj);
3026
3027 if ( Hook->HookId == WH_CALLWNDPROC)
3028 {
3029 CWPSTRUCT CWP;
3030 CWP.hwnd = hWnd;
3031 CWP.message = Msg;
3032 CWP.wParam = wParam;
3033 CWP.lParam = lParam;
3034 TRACE("WH_CALLWNDPROC: Hook %p NextHook %p\n", Hook, NextObj);
3035
3036 lResult = co_IntCallHookProc( Hook->HookId,
3037 HC_ACTION,
3038 ((ClientInfo->CI_flags & CI_CURTHPRHOOK) ? 1 : 0),
3039 (LPARAM)&CWP,
3040 Hook->Proc,
3041 Hook->ihmod,
3042 Hook->offPfn,
3043 Hook->Ansi,
3044 &Hook->ModuleName);
3045 }
3046 else
3047 {
3048 CWPRETSTRUCT CWPR;
3049 CWPR.hwnd = hWnd;
3050 CWPR.message = Msg;
3051 CWPR.wParam = wParam;
3052 CWPR.lParam = lParam;
3053 CWPR.lResult = ClientInfo->dwHookData;
3054
3055 lResult = co_IntCallHookProc( Hook->HookId,
3056 HC_ACTION,
3057 ((ClientInfo->CI_flags & CI_CURTHPRHOOK) ? 1 : 0),
3058 (LPARAM)&CWPR,
3059 Hook->Proc,
3060 Hook->ihmod,
3061 Hook->offPfn,
3062 Hook->Ansi,
3063 &Hook->ModuleName);
3064 }
3065 }
3066 break;
3067 }
3068
3069 switch(dwType)
3070 {
3071 case FNID_DEFWINDOWPROC:
3072 case FNID_CALLWNDPROC:
3074 case FNID_SCROLLBAR:
3075 case FNID_DESKTOP:
3076 case FNID_MENU:
3077 if (ResultInfo)
3078 {
3079 _SEH2_TRY
3080 {
3081 ProbeForWrite((PVOID)ResultInfo, sizeof(LRESULT), 1);
3082 RtlCopyMemory((PVOID)ResultInfo, &lResult, sizeof(LRESULT));
3083 }
3085 {
3086 Ret = FALSE;
3087 }
3088 _SEH2_END;
3089 }
3090 break;
3091 default:
3092 break;
3093 }
3094
3095 UserLeave();
3096
3097 return Ret;
3098}
#define BSF_POSTMESSAGE
Definition: dbt.h:58
#define BSF_NOTIMEOUTIFNOTHUNG
Definition: dbt.h:57
#define BSF_NOHANG
Definition: dbt.h:56
#define BSF_IGNORECURRENTTASK
Definition: dbt.h:55
#define BSF_QUERY
Definition: dbt.h:59
#define BSM_APPLICATIONS
Definition: dbt.h:48
#define BSF_FORCEIFHUNG
Definition: dbt.h:54
#define BSM_ALLDESKTOPS
Definition: dbt.h:49
#define BSM_ALLCOMPONENTS
Definition: dbt.h:47
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:164
#define L(x)
Definition: resources.c:13
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
#define FNID_SENDMESSAGEFF
Definition: ntuser.h:887
#define FNID_SCROLLBAR
Definition: ntuser.h:863
#define FNID_DEFWINDOWPROC
Definition: ntuser.h:867
#define FNID_SENDMESSAGECALLBACK
Definition: ntuser.h:894
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:806
#define FNID_SENDMESSAGEWTOOPTION
Definition: ntuser.h:889
#define FNID_CALLWNDPROCRET
Definition: ntuser.h:881
#define FNID_CALLWNDPROC
Definition: ntuser.h:880
#define CI_CURTHPRHOOK
Definition: ntuser.h:308
struct tagDOSENDMESSAGE * PDOSENDMESSAGE
#define FNID_SENDMESSAGE
Definition: ntuser.h:886
struct _BROADCASTPARM * PBROADCASTPARM
#define FNID_BROADCASTSYSTEMMESSAGE
Definition: ntuser.h:891
#define FNID_SENDNOTIFYMESSAGE
Definition: ntuser.h:893
CLIENT_DATA ClientInfo
LRESULT FASTCALL IntDefWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Ansi)
Definition: defwnd.c:633
PHOOK FASTCALL IntGetNextHook(PHOOK Hook)
Definition: hook.c:995
PWINSTATION_OBJECT InputWindowStation
Definition: winsta.c:21
#define WM_SETTINGCHANGE
Definition: winuser.h:1657
#define BROADCAST_QUERY_DENY
Definition: winuser.h:178
DWORD recipients
Definition: ntuser.h:1113
DWORD flags
Definition: ntuser.h:1112
HDESK hDesk
Definition: ntuser.h:1114
SENDASYNCPROC CallBack
Definition: callback.h:45
ULONG_PTR Context
Definition: callback.h:46
struct _WND * spwnd
Definition: ntuser.h:140
PDESKTOPINFO pDeskInfo
Definition: desktop.h:8
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
struct tagHOOK * sphkCurrent
Definition: win32.h:119
LIST_ENTRY DesktopListHead
Definition: winsta.h:19
THRDESKHEAD head
Definition: ntuser.h:699
INT_PTR ihmod
Definition: ntuser.h:248
struct tagHOOK * phkNext
Definition: ntuser.h:244
HOOKPROC Proc
Definition: ntuser.h:253
ULONG_PTR offPfn
Definition: ntuser.h:246
int HookId
Definition: ntuser.h:245
BOOLEAN Ansi
Definition: ntuser.h:254
UNICODE_STRING ModuleName
Definition: ntuser.h:255
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
LRESULT APIENTRY co_IntCallHookProc(INT HookId, INT Code, WPARAM wParam, LPARAM lParam, HOOKPROC Proc, INT Mod, ULONG_PTR offPfn, BOOLEAN Ansi, PUNICODE_STRING ModuleName)
Definition: callback.c:508
static int is_pointer_message(UINT message, WPARAM wparam)
Definition: message.c:120
static LRESULT FASTCALL co_IntDoSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, PDOSENDMESSAGE dsm)
Definition: message.c:2006
BOOL FASTCALL UserSendNotifyMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:2092
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1397
LRESULT APIENTRY ScrollBarWndProc(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: scrollbar.c:1134
ENGAPI ULONG APIENTRY EngGetLastError(VOID)
Definition: error.c:9

Referenced by CallNextHookEx(), DefWndHandleSysCommand(), DesktopWndProcW(), IntBroadcastSystemMessage(), IntScrollCreateScrollBar(), MenuWindowProcA(), MenuWindowProcW(), PopupMenuWndProcW(), SendMessageA(), SendMessageCallbackA(), SendMessageCallbackW(), SendMessageTimeoutA(), SendMessageTimeoutW(), SendMessageW(), SendNotifyMessageW(), and User32DefWindowProc().

◆ NtUserPeekMessage()

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

Definition at line 2389 of file message.c.

2394{
2395 MSG Msg;
2396 BOOL Ret;
2397
2398 if ( RemoveMsg & PM_BADMSGFLAGS )
2399 {
2401 return FALSE;
2402 }
2403
2405
2406 RtlZeroMemory(&Msg, sizeof(MSG));
2407
2408 Ret = co_IntGetPeekMessage(&Msg, hWnd, MsgFilterMin, MsgFilterMax, RemoveMsg, FALSE);
2409
2410 UserLeave();
2411
2412 if (Ret)
2413 {
2414 _SEH2_TRY
2415 {
2416 ProbeForWrite(pMsg, sizeof(MSG), 1);
2417 RtlCopyMemory(pMsg, &Msg, sizeof(MSG));
2418 }
2420 {
2422 Ret = FALSE;
2423 }
2424 _SEH2_END;
2425 }
2426
2427 return Ret;
2428}
#define PM_BADMSGFLAGS
Definition: message.c:14
#define ERROR_INVALID_FLAGS
Definition: winerror.h:907

Referenced by PeekMessageWorker().

◆ NtUserPostMessage()

BOOL APIENTRY NtUserPostMessage ( HWND  hWnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 2277 of file message.c.

2281{
2282 BOOL ret;
2283
2285
2287
2288 UserLeave();
2289
2290 return ret;
2291}
return ret
Definition: mutex.c:147

Referenced by PostMessageA(), and PostMessageW().

◆ NtUserPostThreadMessage()

BOOL APIENTRY NtUserPostThreadMessage ( DWORD  idThread,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 2294 of file message.c.

2298{
2299 BOOL ret = FALSE;
2300 PETHREAD peThread;
2301 PTHREADINFO pThread;
2303
2305
2306 Status = PsLookupThreadByThreadId(UlongToHandle(idThread), &peThread);
2307
2308 if ( Status == STATUS_SUCCESS )
2309 {
2310 pThread = (PTHREADINFO)peThread->Tcb.Win32Thread;
2311 if( !pThread ||
2312 !pThread->MessageQueue ||
2313 (pThread->TIF_flags & TIF_INCLEANUP))
2314 {
2315 ObDereferenceObject( peThread );
2316 goto exit;
2317 }
2318 ret = UserPostThreadMessage( pThread, Msg, wParam, lParam);
2319 ObDereferenceObject( peThread );
2320 }
2321 else
2322 {
2324 }
2325exit:
2326 UserLeave();
2327 return ret;
2328}
#define UlongToHandle(ul)
Definition: basetsd.h:91
NTSTATUS NTAPI PsLookupThreadByThreadId(IN HANDLE ThreadId, OUT PETHREAD *Thread)
Definition: thread.c:667
struct _THREADINFO * PTHREADINFO
Definition: ntwin32.h:6
#define exit(n)
Definition: config.h:202
KTHREAD Tcb
Definition: pstypes.h:1296
PVOID Win32Thread
Definition: ketypes.h:2013
BOOL FASTCALL UserPostThreadMessage(PTHREADINFO pti, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1360
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by PostThreadMessageA(), and PostThreadMessageW().

◆ NtUserTranslateMessage()

BOOL APIENTRY NtUserTranslateMessage ( LPMSG  lpMsg,
UINT  flags 
)

Definition at line 2492 of file message.c.

2493{
2494 MSG SafeMsg;
2495 BOOL Ret;
2496 PWND pWnd;
2497
2498 _SEH2_TRY
2499 {
2500 ProbeForRead(lpMsg, sizeof(MSG), 1);
2501 RtlCopyMemory(&SafeMsg, lpMsg, sizeof(MSG));
2502 }
2504 {
2506 _SEH2_YIELD(return FALSE);
2507 }
2508 _SEH2_END;
2509
2511 pWnd = UserGetWindowObject(SafeMsg.hwnd);
2512 if (pWnd) // Must have a window!
2513 {
2514 Ret = IntTranslateKbdMessage(&SafeMsg, flags);
2515 }
2516 else
2517 {
2518 TRACE("No Window for Translate. hwnd 0x%p Msg %u\n", SafeMsg.hwnd, SafeMsg.message);
2519 Ret = FALSE;
2520 }
2521 UserLeave();
2522
2523 return Ret;
2524}
GLbitfield flags
Definition: glext.h:7161
BOOL FASTCALL IntTranslateKbdMessage(LPMSG lpMsg, UINT flags)
Definition: keyboard.c:1563

Referenced by TranslateMessageEx().

◆ NtUserWaitForInputIdle()

DWORD APIENTRY NtUserWaitForInputIdle ( IN HANDLE  hProcess,
IN DWORD  dwMilliseconds,
IN BOOL  bSharedWow 
)

Definition at line 3105 of file message.c.

3108{
3110 PPROCESSINFO W32Process;
3111 PTHREADINFO pti;
3113 HANDLE Handles[3];
3116
3118
3122 UserMode,
3123 (PVOID*)&Process,
3124 NULL);
3125
3126 if (!NT_SUCCESS(Status))
3127 {
3128 UserLeave();
3130 return WAIT_FAILED;
3131 }
3132
3134
3135 W32Process = (PPROCESSINFO)Process->Win32Process;
3136
3138 !W32Process ||
3139 pti->ppi == W32Process)
3140 {
3142 UserLeave();
3144 return WAIT_FAILED;
3145 }
3146
3147 Handles[0] = Process;
3148 Handles[1] = W32Process->InputIdleEvent;
3149 Handles[2] = pti->pEventQueueServer; // IntMsqSetWakeMask returns hEventQueueClient
3150
3151 if (!Handles[1])
3152 {
3154 UserLeave();
3155 return STATUS_SUCCESS; /* no event to wait on */
3156 }
3157
3158 if (dwMilliseconds != INFINITE)
3159 Timeout.QuadPart = (LONGLONG) dwMilliseconds * (LONGLONG) -10000;
3160
3162 W32Process->W32PF_flags |= W32PF_WAITFORINPUTIDLE;
3163 for (pti = W32Process->ptiList; pti; pti = pti->ptiSibling)
3164 {
3166 pti->pClientInfo->dwTIFlags = pti->TIF_flags;
3167 }
3169
3170 TRACE("WFII: ppi %p\n", W32Process);
3171 TRACE("WFII: waiting for %p\n", Handles[1] );
3172
3173 /*
3174 * We must add a refcount to our current PROCESSINFO,
3175 * because anything could happen (including process death) we're leaving win32k
3176 */
3177 IntReferenceProcessInfo(W32Process);
3178
3179 do
3180 {
3181 UserLeave();
3183 Handles,
3184 WaitAny,
3186 UserMode,
3187 FALSE,
3188 dwMilliseconds == INFINITE ? NULL : &Timeout,
3189 NULL);
3191
3192 if (!NT_SUCCESS(Status))
3193 {
3196 goto WaitExit;
3197 }
3198
3199 switch (Status)
3200 {
3201 case STATUS_WAIT_0:
3202 goto WaitExit;
3203
3204 case STATUS_WAIT_2:
3205 {
3206 MSG Msg;
3207 co_IntGetPeekMessage( &Msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE, FALSE);
3208 ERR("WFII: WAIT 2\n");
3209 }
3210 break;
3211
3212 case STATUS_TIMEOUT:
3213 ERR("WFII: timeout\n");
3214 case WAIT_FAILED:
3215 goto WaitExit;
3216
3217 default:
3218 ERR("WFII: finished\n");
3220 goto WaitExit;
3221 }
3222 }
3223 while (TRUE);
3224
3225WaitExit:
3227 for (pti = W32Process->ptiList; pti; pti = pti->ptiSibling)
3228 {
3229 pti->TIF_flags &= ~TIF_WAITFORINPUTIDLE;
3230 pti->pClientInfo->dwTIFlags = pti->TIF_flags;
3231 }
3232 W32Process->W32PF_flags &= ~W32PF_WAITFORINPUTIDLE;
3234
3235 IntDereferenceProcessInfo(W32Process);
3237 UserLeave();
3238 return Status;
3239}
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:162
#define TIF_WAITFORINPUTIDLE
Definition: ntuser.h:280
if(dx< 0)
Definition: linetemp.h:194
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#define UserMode
Definition: asm.h:39
@ WaitAny
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1751
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:599
BOOLEAN NTAPI PsGetProcessExitProcessCalled(PEPROCESS Process)
Definition: process.c:1083
POBJECT_TYPE PsProcessType
Definition: process.c:20
#define STATUS_WAIT_0
Definition: ntstatus.h:330
#define STATUS_WAIT_2
Definition: ntstatus.h:124
struct _PROCESSINFO * PPROCESSINFO
Definition: ntwin32.h:5
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:493
static ULONG Timeout
Definition: ping.c:61
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:704
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:756
PTHREADINFO ptiList
Definition: win32.h:260
PPROCESSINFO ppi
Definition: win32.h:89
PTHREADINFO ptiSibling
Definition: win32.h:117
PKEVENT pEventQueueServer
Definition: win32.h:126
int64_t LONGLONG
Definition: typedefs.h:68
#define IntReferenceProcessInfo(ppi)
Definition: win32.h:185
#define W32PF_WAITFORINPUTIDLE
Definition: win32.h:22
#define IntDereferenceProcessInfo(ppi)
Definition: win32.h:190
#define INFINITE
Definition: message.c:3100
#define WAIT_FAILED
Definition: message.c:3101
@ UserRequest
Definition: ketypes.h:473
KAPC_STATE
Definition: ketypes.h:1727

Referenced by WaitForInputIdle().

◆ NtUserWaitMessage()

BOOL APIENTRY NtUserWaitMessage ( VOID  )

Definition at line 2331 of file message.c.

2332{
2333 BOOL ret;
2334
2336 TRACE("NtUserWaitMessage Enter\n");
2337 ret = co_IntWaitMessage(NULL, 0, 0);
2338 TRACE("NtUserWaitMessage Leave\n");
2339 UserLeave();
2340
2341 return ret;
2342}

Referenced by WaitMessage().

◆ PackParam()

static NTSTATUS PackParam ( LPARAM *  lParamPacked,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam,
BOOL  NonPagedPoolNeeded 
)
static

Definition at line 284 of file message.c.

285{
286 NCCALCSIZE_PARAMS *UnpackedNcCalcsize;
287 NCCALCSIZE_PARAMS *PackedNcCalcsize;
288 CREATESTRUCTW *UnpackedCs;
289 CREATESTRUCTW *PackedCs;
290 PLARGE_STRING WindowName;
291 PUNICODE_STRING ClassName;
293 UINT Size;
294 PCHAR CsData;
295
296 *lParamPacked = lParam;
297
298 if (NonPagedPoolNeeded)
300 else
302
303 if (WM_NCCALCSIZE == Msg && wParam)
304 {
305
306 UnpackedNcCalcsize = (NCCALCSIZE_PARAMS *) lParam;
307 PackedNcCalcsize = ExAllocatePoolWithTag(PoolType,
308 sizeof(NCCALCSIZE_PARAMS) + sizeof(WINDOWPOS),
309 TAG_MSG);
310
311 if (NULL == PackedNcCalcsize)
312 {
313 ERR("Not enough memory to pack lParam\n");
314 return STATUS_NO_MEMORY;
315 }
316 RtlCopyMemory(PackedNcCalcsize, UnpackedNcCalcsize, sizeof(NCCALCSIZE_PARAMS));
317 PackedNcCalcsize->lppos = (PWINDOWPOS) (PackedNcCalcsize + 1);
318 RtlCopyMemory(PackedNcCalcsize->lppos, UnpackedNcCalcsize->lppos, sizeof(WINDOWPOS));
319 *lParamPacked = (LPARAM) PackedNcCalcsize;
320 }
321 else if (WM_CREATE == Msg || WM_NCCREATE == Msg)
322 {
323 UnpackedCs = (CREATESTRUCTW *) lParam;
324 WindowName = (PLARGE_STRING) UnpackedCs->lpszName;
325 ClassName = (PUNICODE_STRING) UnpackedCs->lpszClass;
326 Size = sizeof(CREATESTRUCTW) + WindowName->Length + sizeof(WCHAR);
327 if (IS_ATOM(ClassName->Buffer))
328 {
329 Size += sizeof(WCHAR) + sizeof(ATOM);
330 }
331 else
332 {
333 Size += sizeof(WCHAR) + ClassName->Length + sizeof(WCHAR);
334 }
336 if (NULL == PackedCs)
337 {
338 ERR("Not enough memory to pack lParam\n");
339 return STATUS_NO_MEMORY;
340 }
341 RtlCopyMemory(PackedCs, UnpackedCs, sizeof(CREATESTRUCTW));
342 CsData = (PCHAR) (PackedCs + 1);
343 PackedCs->lpszName = (LPCWSTR) (CsData - (PCHAR) PackedCs);
344 RtlCopyMemory(CsData, WindowName->Buffer, WindowName->Length);
345 CsData += WindowName->Length;
346 *((WCHAR *) CsData) = L'\0';
347 CsData += sizeof(WCHAR);
348 PackedCs->lpszClass = (LPCWSTR) (CsData - (PCHAR) PackedCs);
349 if (IS_ATOM(ClassName->Buffer))
350 {
351 *((WCHAR *) CsData) = L'A';
352 CsData += sizeof(WCHAR);
353 *((ATOM *) CsData) = (ATOM)(DWORD_PTR) ClassName->Buffer;
354 CsData += sizeof(ATOM);
355 }
356 else
357 {
358 NT_ASSERT(ClassName->Buffer != NULL);
359 *((WCHAR *) CsData) = L'S';
360 CsData += sizeof(WCHAR);
361 RtlCopyMemory(CsData, ClassName->Buffer, ClassName->Length);
362 CsData += ClassName->Length;
363 *((WCHAR *) CsData) = L'\0';
364 CsData += sizeof(WCHAR);
365 }
366 ASSERT(CsData == (PCHAR) PackedCs + Size);
367 *lParamPacked = (LPARAM) PackedCs;
368 }
369 else if (PoolType == NonPagedPool)
370 {
371 PMSGMEMORY MsgMemoryEntry;
372 PVOID PackedData;
373 SIZE_T size;
374
375 MsgMemoryEntry = FindMsgMemory(Msg);
376
377 if (!MsgMemoryEntry)
378 {
379 /* Keep previous behavior */
380 return STATUS_SUCCESS;
381 }
382 size = MsgMemorySize(MsgMemoryEntry, wParam, lParam);
383 if (!size)
384 {
385 ERR("No size for lParamPacked\n");
386 return STATUS_SUCCESS;
387 }
389 if (PackedData == NULL)
390 {
391 ERR("Not enough memory to pack lParam\n");
392 return STATUS_NO_MEMORY;
393 }
394 RtlCopyMemory(PackedData, (PVOID)lParam, MsgMemorySize(MsgMemoryEntry, wParam, lParam));
395 *lParamPacked = (LPARAM)PackedData;
396 }
397
398 return STATUS_SUCCESS;
399}
#define NonPagedPool
Definition: env_spec_w32.h:307
GLsizeiptr size
Definition: glext.h:5919
PWINDOWPOS lppos
Definition: winuser.h:3707
const uint16_t * LPCWSTR
Definition: typedefs.h:57
INT POOL_TYPE
Definition: typedefs.h:78
ULONG_PTR SIZE_T
Definition: typedefs.h:80
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3821
#define NT_ASSERT
Definition: rtlfuncs.h:3334

Referenced by co_IntSendMessageTimeoutSingle(), and co_IntSendMessageWithCallBack().

◆ PosInArray()

static INT PosInArray ( _In_ PCWSTR  String)
static

Definition at line 28 of file message.c.

29{
30 INT i;
31
32 for (i = 0; i < ARRAYSIZE(StrUserKernel); ++i)
33 {
35 return i;
36 }
37 return -1;
38}
_ACRTIMP int __cdecl wcsncmp(const wchar_t *, const wchar_t *, size_t)
Definition: wcs.c:523
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2439

Referenced by CopyMsgToKernelMem().

◆ ScrollBarWndProc()

LRESULT APIENTRY ScrollBarWndProc ( HWND  Wnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1134 of file scrollbar.c.

1135{
1136 LRESULT lResult = 0;
1137 PWND pWnd;
1138 pWnd = UserGetWindowObject(hWnd);
1139 if (!pWnd) return 0;
1140
1141 switch(Msg)
1142 {
1143 case WM_ENABLE:
1144 if (pWnd->pSBInfo)
1146 break;
1147 }
1148 return lResult;
1149}
#define WM_ENABLE
Definition: winuser.h:1643
#define ESB_DISABLE_BOTH
Definition: winuser.h:556
#define ESB_ENABLE_BOTH
Definition: winuser.h:563
PSBINFO pSBInfo
Definition: ntuser.h:730
INT WSBflags
Definition: ntuser.h:517

Referenced by NtUserMessageCall().

◆ UnpackParam()

static NTSTATUS UnpackParam ( LPARAM  lParamPacked,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam,
BOOL  NonPagedPoolUsed 
)
static

Definition at line 402 of file message.c.

403{
404 NCCALCSIZE_PARAMS *UnpackedParams;
405 NCCALCSIZE_PARAMS *PackedParams;
406 PWINDOWPOS UnpackedWindowPos;
407
408 if (lParamPacked == lParam)
409 {
410 return STATUS_SUCCESS;
411 }
412
413 if (WM_NCCALCSIZE == Msg && wParam)
414 {
415 PackedParams = (NCCALCSIZE_PARAMS *) lParamPacked;
416 UnpackedParams = (NCCALCSIZE_PARAMS *) lParam;
417 UnpackedWindowPos = UnpackedParams->lppos;
418 RtlCopyMemory(UnpackedParams, PackedParams, sizeof(NCCALCSIZE_PARAMS));
419 UnpackedParams->lppos = UnpackedWindowPos;
420 RtlCopyMemory(UnpackedWindowPos, PackedParams + 1, sizeof(WINDOWPOS));
421 ExFreePool((PVOID) lParamPacked);
422
423 return STATUS_SUCCESS;
424 }
425 else if (WM_CREATE == Msg || WM_NCCREATE == Msg)
426 {
427 ExFreePool((PVOID) lParamPacked);
428
429 return STATUS_SUCCESS;
430 }
431 else if (NonPagedPoolUsed)
432 {
433 PMSGMEMORY MsgMemoryEntry;
434 MsgMemoryEntry = FindMsgMemory(Msg);
435 ASSERT(MsgMemoryEntry);
436
437 if (MsgMemoryEntry->Flags == MMS_FLAG_READWRITE)
438 {
439 //RtlCopyMemory((PVOID)lParam, (PVOID)lParamPacked, MsgMemoryEntry->Size);
440 }
441 ExFreePool((PVOID) lParamPacked);
442 return STATUS_SUCCESS;
443 }
444
445 ASSERT(FALSE);
446
448}
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define MMS_FLAG_READWRITE
Definition: message.c:134

Referenced by co_IntSendMessageTimeoutSingle(), and co_IntSendMessageWithCallBack().

◆ UserPostMessage()

BOOL FASTCALL UserPostMessage ( HWND  Wnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1397 of file message.c.

1401{
1402 PTHREADINFO pti;
1403 MSG Message;
1404 LONG_PTR ExtraInfo = 0;
1405
1406 Message.hwnd = Wnd;
1407 Message.message = Msg;
1408 Message.wParam = wParam;
1409 Message.lParam = lParam;
1410 Message.pt = gpsi->ptCursor;
1411 Message.time = EngGetTickCount32();
1412
1413 if (is_pointer_message(Message.message, Message.wParam))
1414 {
1416 return FALSE;
1417 }
1418
1419 if (Wnd == HWND_BROADCAST || Wnd == HWND_TOPMOST)
1420 {
1421 HWND *List;
1422 PWND DesktopWindow;
1423 ULONG i;
1424
1425 if (!is_message_broadcastable(Msg)) return TRUE;
1426
1427 DesktopWindow = UserGetDesktopWindow();
1428 List = IntWinListChildren(DesktopWindow);
1429
1430 if (List != NULL)
1431 {
1432 UserPostMessage(UserHMGetHandle(DesktopWindow), Msg, wParam, lParam);
1433 for (i = 0; List[i]; i++)
1434 {
1435 PWND pwnd = UserGetWindowObject(List[i]);
1436 if (!pwnd) continue;
1437
1438 if ( pwnd->fnid == FNID_MENU || // Also need pwnd->pcls->atomClassName == gaOleMainThreadWndClass
1440 continue;
1441
1443 }
1445 }
1446 }
1447 else
1448 {
1449 PWND Window;
1450
1451 if (!Wnd)
1452 {
1454 Msg,
1455 wParam,
1456 lParam);
1457 }
1458
1460 if ( !Window )
1461 {
1462 ERR("UserPostMessage: Invalid handle 0x%p Msg 0x%x!\n", Wnd, Msg);
1463 return FALSE;
1464 }
1465
1466 pti = Window->head.pti;
1467
1468 if ( pti->TIF_flags & TIF_INCLEANUP )
1469 {
1470 ERR("Attempted to post message to window %p when the thread is in cleanup!\n", Wnd);
1471 return FALSE;
1472 }
1473
1474 if ( Window->state & WNDS_DESTROYED )
1475 {
1476 ERR("Attempted to post message to window %p that is being destroyed!\n", Wnd);
1478 return FALSE;
1479 }
1480
1481 if ( Msg >= WM_DDE_FIRST && Msg <= WM_DDE_LAST )
1482 {
1483 if (!IntDdePostMessageHook(Window, Msg, wParam, &lParam, &ExtraInfo))
1484 {
1485 TRACE("Posting Exit DDE 0x%x\n",Msg);
1486 return FALSE;
1487 }
1488 Message.lParam = lParam;
1489 }
1490
1491 MsqPostMessage(pti, &Message, FALSE, QS_POSTMESSAGE, 0, ExtraInfo);
1492 }
1493 return TRUE;
1494}
BOOL FASTCALL MsqPostMessage(PTHREADINFO pti, MSG *Msg, BOOLEAN HardwareMessage, DWORD MessageBits, DWORD dwQEvent, LONG_PTR ExtraInfo)
Definition: msgqueue.c:1337
BOOL APIENTRY IntDdePostMessageHook(IN PWND pWnd, IN UINT Msg, IN WPARAM wParam, IN OUT LPARAM *lParam, IN OUT LONG_PTR *ExtraInfo)
Definition: dde.c:172
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:1226

Referenced by co_IntProcessKeyboardMessage(), co_IntShellHookNotify(), co_UserProcessHotKeys(), DefWndHandleSetCursor(), DefWndHandleSysCommand(), DoTheScreenSaver(), ExitThreadCallback(), IntDefWindowProc(), IntImmProcessKey(), IntLanguageToggle(), IntRemoveTrackMouseEvent(), IntTrackMouseEvent(), IntTrackMouseMove(), MENU_EndMenu(), MENU_ExecFocusedItem(), MENU_TrackKbdMenuBar(), MENU_TrackMenu(), NotifyLogon(), NtUserCallOneParam(), NtUserEndMenu(), NtUserLockWorkStation(), NtUserMessageCall(), NtUserPostMessage(), SystemTimerProc(), and UserPostMessage().

◆ UserPostThreadMessage()

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

Definition at line 1360 of file message.c.

1364{
1365 MSG Message;
1366
1368 {
1370 return FALSE;
1371 }
1372 Message.hwnd = NULL;
1373 Message.message = Msg;
1374 Message.wParam = wParam;
1375 Message.lParam = lParam;
1376 Message.pt = gpsi->ptCursor;
1377 Message.time = EngGetTickCount32();
1379 return TRUE;
1380}

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

◆ UserSendNotifyMessage()

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

Definition at line 2092 of file message.c.

2096{
2097 BOOL Ret = TRUE;
2098
2100 {
2102 return FALSE;
2103 }
2104
2105 // Basicly the same as IntPostOrSendMessage
2106 if (hWnd == HWND_BROADCAST) // Handle Broadcast
2107 {
2108 HWND *List;
2109 PWND DesktopWindow;
2110 ULONG i;
2111
2112 DesktopWindow = UserGetDesktopWindow();
2113 List = IntWinListChildren(DesktopWindow);
2114
2115 if (List != NULL)
2116 {
2118 for (i = 0; List[i]; i++)
2119 {
2120 PWND pwnd = UserGetWindowObject(List[i]);
2121 if (!pwnd) continue;
2122
2123 if ( pwnd->fnid == FNID_MENU ||
2125 continue;
2126
2128 }
2130 }
2131 }
2132 else
2133 {
2135 }
2136 return Ret;
2137}
LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1765

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

Variable Documentation

◆ g_MsgMemory

MSGMEMORY g_MsgMemory[]
static
Initial value:
=
{
{ WM_STYLECHANGED, sizeof(STYLESTRUCT), MMS_FLAG_READ },
{ WM_STYLECHANGING, sizeof(STYLESTRUCT), MMS_FLAG_READWRITE },
{ WM_HELP, sizeof(HELPINFO), MMS_FLAG_READWRITE },
}
struct tagMDINEXTMENU MDINEXTMENU
#define WM_NEXTMENU
Definition: winuser.h:1834
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1689
#define WM_GETTEXT
Definition: winuser.h:1646
struct tagMEASUREITEMSTRUCT MEASUREITEMSTRUCT
struct _WINDOWPOS WINDOWPOS
struct tagDRAWITEMSTRUCT DRAWITEMSTRUCT
#define WM_DRAWITEM
Definition: winuser.h:1673
struct tagMINMAXINFO MINMAXINFO
#define WM_SETTEXT
Definition: winuser.h:1645
#define WM_GETMINMAXINFO
Definition: winuser.h:1668
struct tagSTYLESTRUCT STYLESTRUCT
struct tagHELPINFO HELPINFO
#define WM_MEASUREITEM
Definition: winuser.h:1674
#define WM_SIZING
Definition: winuser.h:1835
#define WM_MOVING
Definition: winuser.h:1837
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1690
#define WM_COPYGLOBALDATA
Definition: undocuser.h:38
#define RECT
Definition: precomp.h:26

Definition at line 143 of file message.c.

Referenced by FindMsgMemory().

◆ message_pointer_flags

const unsigned int message_pointer_flags[]
static

Definition at line 58 of file message.c.

Referenced by is_pointer_message().

◆ StrUserKernel

WCHAR StrUserKernel[3][20] = {{L"intl"}, {L"Environment"}, {L"Policy"}}

Definition at line 18 of file message.c.

Referenced by CopyMsgToKernelMem(), and PosInArray().