ReactOS  0.4.15-dev-499-g1f31905
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   ~((QS_RAWINPUT << 16)|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 tagMSGMEMORYPMSGMEMORY
 

Functions

 DBG_DEFAULT_CHANNEL (UserMsg)
 
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

static const unsigned int message_pointer_flags []
 
static MSGMEMORY g_MsgMemory []
 

Macro Definition Documentation

◆ INFINITE

#define INFINITE   0xFFFFFFFF

Definition at line 3051 of file message.c.

◆ MMS_FLAG_READ

#define MMS_FLAG_READ   0x01

Definition at line 111 of file message.c.

◆ MMS_FLAG_READWRITE

#define MMS_FLAG_READWRITE   (MMS_FLAG_READ | MMS_FLAG_WRITE)

Definition at line 113 of file message.c.

◆ MMS_FLAG_WRITE

#define MMS_FLAG_WRITE   0x02

Definition at line 112 of file message.c.

◆ MMS_SIZE_LPARAMSZ

#define MMS_SIZE_LPARAMSZ   -3

Definition at line 109 of file message.c.

◆ MMS_SIZE_SPECIAL

#define MMS_SIZE_SPECIAL   -4

Definition at line 110 of file message.c.

◆ MMS_SIZE_WPARAM

#define MMS_SIZE_WPARAM   -1

Definition at line 107 of file message.c.

◆ MMS_SIZE_WPARAMWCHAR

#define MMS_SIZE_WPARAMWCHAR   -2

Definition at line 108 of file message.c.

◆ PM_BADMSGFLAGS

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

Definition at line 15 of file message.c.

◆ SET

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

Definition at line 35 of file message.c.

◆ WAIT_FAILED

#define WAIT_FAILED   ((DWORD)0xFFFFFFFF)

Definition at line 3052 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 1951 of file message.c.

1956 {
1957  LRESULT Result = TRUE;
1958  NTSTATUS Status;
1959  PWND Window = NULL;
1960  MSG UserModeMsg, KernelModeMsg;
1961  PMSGMEMORY MsgMemoryEntry;
1962  PTHREADINFO ptiSendTo;
1963 
1964  if (hWnd != HWND_BROADCAST && hWnd != HWND_TOPMOST)
1965  {
1967  if ( !Window )
1968  {
1969  return 0;
1970  }
1971  }
1972 
1973  /* Check for an exiting window. */
1974  if (Window && Window->state & WNDS_DESTROYED)
1975  {
1976  ERR("co_IntDoSendMessage Window Exiting!\n");
1977  }
1978 
1979  /* See if the current thread can handle this message */
1980  ptiSendTo = IntSendTo(Window, gptiCurrent, Msg);
1981 
1982  // If broadcasting or sending to another thread, save the users data.
1983  if (!Window || ptiSendTo )
1984  {
1985  UserModeMsg.hwnd = hWnd;
1986  UserModeMsg.message = Msg;
1987  UserModeMsg.wParam = wParam;
1988  UserModeMsg.lParam = lParam;
1989  MsgMemoryEntry = FindMsgMemory(UserModeMsg.message);
1990  Status = CopyMsgToKernelMem(&KernelModeMsg, &UserModeMsg, MsgMemoryEntry);
1991  if (!NT_SUCCESS(Status))
1992  {
1994  return (dsm ? 0 : -1);
1995  }
1996  }
1997  else
1998  {
1999  KernelModeMsg.hwnd = hWnd;
2000  KernelModeMsg.message = Msg;
2001  KernelModeMsg.wParam = wParam;
2002  KernelModeMsg.lParam = lParam;
2003  }
2004 
2005  if (!dsm)
2006  {
2007  Result = co_IntSendMessage( KernelModeMsg.hwnd,
2008  KernelModeMsg.message,
2009  KernelModeMsg.wParam,
2010  KernelModeMsg.lParam );
2011  }
2012  else
2013  {
2014  Result = co_IntSendMessageTimeout( KernelModeMsg.hwnd,
2015  KernelModeMsg.message,
2016  KernelModeMsg.wParam,
2017  KernelModeMsg.lParam,
2018  dsm->uFlags,
2019  dsm->uTimeout,
2020  &dsm->Result );
2021  }
2022 
2023  if (!Window || ptiSendTo )
2024  {
2025  Status = CopyMsgToUserMem(&UserModeMsg, &KernelModeMsg);
2026  if (!NT_SUCCESS(Status))
2027  {
2029  return(dsm ? 0 : -1);
2030  }
2031  }
2032 
2033  return (LRESULT)Result;
2034 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
static PMSGMEMORY FASTCALL FindMsgMemory(UINT Msg)
Definition: message.c:147
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
LONG NTSTATUS
Definition: precomp.h:26
HWND hWnd
Definition: settings.c:17
#define HWND_TOPMOST
Definition: winuser.h:1194
struct @1604 Msg[]
WPARAM wParam
Definition: combotst.c:138
Definition: window.c:28
PTHREADINFO FASTCALL IntSendTo(PWND Window, PTHREADINFO ptiCur, UINT Msg)
Definition: message.c:1332
static NTSTATUS FASTCALL CopyMsgToUserMem(MSG *UserModeMsg, MSG *KernelModeMsg)
Definition: message.c:487
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
static NTSTATUS FASTCALL CopyMsgToKernelMem(MSG *KernelModeMsg, MSG *UserModeMsg, PMSGMEMORY MsgMemoryEntry)
Definition: message.c:430
PTHREADINFO gptiCurrent
Definition: ntuser.c:15
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
LRESULT FASTCALL co_IntSendMessageTimeout(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult)
Definition: message.c:1654
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
ULONG_PTR Result
Definition: ntuser.h:2614
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:657
LONG_PTR LRESULT
Definition: windef.h:209
#define HWND_BROADCAST
Definition: winuser.h:1190
#define WNDS_DESTROYED
Definition: ntuser.h:604
LPARAM lParam
Definition: combotst.c:139
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by NtUserMessageCall().

◆ co_IntGetPeekMessage()

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

Definition at line 1177 of file message.c.

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

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

◆ co_IntPeekMessage()

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

Definition at line 965 of file message.c.

972 {
973  PTHREADINFO pti;
974  BOOL RemoveMessages;
975  UINT ProcessMask;
976  BOOL Hit = FALSE;
977 
979 
980  RemoveMessages = RemoveMsg & PM_REMOVE;
981  ProcessMask = HIWORD(RemoveMsg);
982 
983  /* Hint, "If wMsgFilterMin and wMsgFilterMax are both zero, PeekMessage returns
984  all available messages (that is, no range filtering is performed)". */
985  if (!ProcessMask) ProcessMask = (QS_ALLPOSTMESSAGE|QS_ALLINPUT);
986 
987  IdlePong();
988 
989  do
990  {
991  /* Update the last message-queue access time */
992  pti->pcti->timeLastRead = EngGetTickCount32();
993 
994  // Post mouse moves while looping through peek messages.
995  if (pti->MessageQueue->QF_flags & QF_MOUSEMOVED)
996  {
998  }
999 
1000  /* Dispatch sent messages here. */
1001  while ( co_MsqDispatchOneSentMessage(pti) )
1002  {
1003  /* if some PM_QS* flags were specified, only handle sent messages from now on */
1004  if (HIWORD(RemoveMsg) && !bGMSG) Hit = TRUE; // wine does this; ProcessMask = QS_SENDMESSAGE;
1005  }
1006  if (Hit) return FALSE;
1007 
1008  /* Clear changed bits so we can wait on them if we don't find a message */
1009  if (ProcessMask & QS_POSTMESSAGE)
1010  {
1011  pti->pcti->fsChangeBits &= ~(QS_POSTMESSAGE | QS_HOTKEY | QS_TIMER);
1012  if (MsgFilterMin == 0 && MsgFilterMax == 0) // Wine hack does this; ~0U)
1013  {
1014  pti->pcti->fsChangeBits &= ~QS_ALLPOSTMESSAGE;
1015  }
1016  }
1017 
1018  if (ProcessMask & QS_INPUT)
1019  {
1020  pti->pcti->fsChangeBits &= ~QS_INPUT;
1021  }
1022 
1023  /* Now check for normal messages. */
1024  if (( (ProcessMask & QS_POSTMESSAGE) ||
1025  (ProcessMask & QS_HOTKEY) ) &&
1026  MsqPeekMessage( pti,
1027  RemoveMessages,
1028  Window,
1029  MsgFilterMin,
1030  MsgFilterMax,
1031  ProcessMask,
1032  ExtraInfo,
1033  0,
1034  Msg ))
1035  {
1036  goto GotMessage;
1037  }
1038 
1039  /* Only check for quit messages if not posted messages pending. */
1040  if (ProcessMask & QS_POSTMESSAGE && pti->QuitPosted)
1041  {
1042  /* According to the PSDK, WM_QUIT messages are always returned, regardless
1043  of the filter specified */
1044  Msg->hwnd = NULL;
1045  Msg->message = WM_QUIT;
1046  Msg->wParam = pti->exitCode;
1047  Msg->lParam = 0;
1048  if (RemoveMessages)
1049  {
1050  pti->QuitPosted = FALSE;
1052  pti->pcti->fsWakeBits &= ~QS_ALLPOSTMESSAGE;
1053  pti->pcti->fsChangeBits &= ~QS_ALLPOSTMESSAGE;
1054  }
1055  goto GotMessage;
1056  }
1057 
1058  /* Check for hardware events. */
1059  if ((ProcessMask & QS_INPUT) &&
1061  RemoveMessages,
1062  Window,
1063  MsgFilterMin,
1064  MsgFilterMax,
1065  ProcessMask,
1066  Msg))
1067  {
1068  goto GotMessage;
1069  }
1070 
1071  /* Now check for System Event messages. */
1072  {
1073  LONG_PTR eExtraInfo;
1074  MSG eMsg;
1075  DWORD dwQEvent;
1076  if (MsqPeekMessage( pti,
1077  TRUE,
1078  Window,
1079  0,
1080  0,
1081  QS_EVENT,
1082  &eExtraInfo,
1083  &dwQEvent,
1084  &eMsg ))
1085  {
1086  handle_internal_events( pti, Window, dwQEvent, eExtraInfo, &eMsg);
1087  continue;
1088  }
1089  }
1090 
1091  /* Check for sent messages again. */
1092  while ( co_MsqDispatchOneSentMessage(pti) )
1093  {
1094  if (HIWORD(RemoveMsg) && !bGMSG) Hit = TRUE;
1095  }
1096  if (Hit) return FALSE;
1097 
1098  /* Check for paint messages. */
1099  if ((ProcessMask & QS_PAINT) &&
1100  pti->cPaintsReady &&
1102  MsgFilterMin,
1103  MsgFilterMax,
1104  pti,
1105  Msg,
1106  RemoveMessages))
1107  {
1108  goto GotMessage;
1109  }
1110 
1111  /* This is correct, check for the current threads timers waiting to be
1112  posted to this threads message queue. If any we loop again.
1113  */
1114  if ((ProcessMask & QS_TIMER) &&
1116  {
1117  continue;
1118  }
1119 
1120  return FALSE;
1121  }
1122  while (TRUE);
1123 
1124 GotMessage:
1125  /* Update the last message-queue access time */
1126  pti->pcti->timeLastRead = EngGetTickCount32();
1127  return TRUE;
1128 }
static LRESULT handle_internal_events(PTHREADINFO pti, PWND pWnd, DWORD dwQEvent, LONG_PTR ExtraInfo, PMSG pMsg)
Definition: message.c:813
#define TRUE
Definition: types.h:120
BOOL FASTCALL IntGetPaintMessage(PWND Window, UINT MsgFilterMin, UINT MsgFilterMax, PTHREADINFO Thread, MSG *Message, BOOL Remove)
Definition: painting.c:1172
#define QS_ALLPOSTMESSAGE
Definition: winuser.h:876
#define EngGetTickCount32()
Definition: eng.h:43
BOOLEAN FASTCALL co_MsqDispatchOneSentMessage(_In_ PTHREADINFO pti)
Definition: msgqueue.c:873
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
UINT cPaintsReady
Definition: win32.h:108
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
#define WM_QUIT
Definition: winuser.h:1605
#define QS_TIMER
Definition: winuser.h:893
BOOLEAN QuitPosted
Definition: win32.h:104
struct @1604 Msg[]
Definition: window.c:28
#define QS_HOTKEY
Definition: winuser.h:877
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
INT exitCode
Definition: win32.h:106
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:90
#define QS_INPUT
Definition: winuser.h:881
VOID FASTCALL ClearMsgBitsMask(PTHREADINFO pti, UINT MessageBits)
Definition: msgqueue.c:445
#define QS_EVENT
Definition: undocuser.h:95
unsigned long DWORD
Definition: ntddk_ex.h:95
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:2107
BOOL FASTCALL PostTimerMessages(PWND Window)
Definition: timer.c:395
VOID FASTCALL IntCoalesceMouseMove(PTHREADINFO pti)
Definition: msgqueue.c:551
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:88
VOID FASTCALL IdlePong(VOID)
Definition: message.c:557
#define QS_ALLINPUT
Definition: winuser.h:874
#define QS_POSTMESSAGE
Definition: winuser.h:888
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define QS_PAINT
Definition: winuser.h:887
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:1996
#define HIWORD(l)
Definition: typedefs.h:246
#define PM_REMOVE
Definition: winuser.h:1182
#define QF_MOUSEMOVED
Definition: msgqueue.h:99

Referenced by co_IntGetPeekMessage(), and co_IntWaitMessage().

◆ co_IntSendMessage()

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

Definition at line 1446 of file message.c.

1450 {
1451  ULONG_PTR Result = 0;
1452 
1454  {
1455  return (LRESULT)Result;
1456  }
1457  return 0;
1458 }
HWND hWnd
Definition: settings.c:17
struct @1604 Msg[]
WPARAM wParam
Definition: combotst.c:138
#define SMTO_NORMAL
Definition: winuser.h:1211
uint32_t ULONG_PTR
Definition: typedefs.h:64
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
LRESULT FASTCALL co_IntSendMessageTimeout(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult)
Definition: message.c:1654
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139

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

◆ co_IntSendMessageNoWait()

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

Definition at line 1710 of file message.c.

1714 {
1715  ULONG_PTR Result = 0;
1717  Msg,
1718  wParam,
1719  lParam,
1720  NULL,
1721  0,
1722  &Result);
1723 }
HWND hWnd
Definition: settings.c:17
struct @1604 Msg[]
WPARAM wParam
Definition: combotst.c:138
uint32_t ULONG_PTR
Definition: typedefs.h:64
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
LPARAM lParam
Definition: combotst.c:139
LRESULT FASTCALL co_IntSendMessageWithCallBack(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, SENDASYNCPROC CompletionCallback, ULONG_PTR CompletionCallbackContext, ULONG_PTR *uResult)
Definition: message.c:1732

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

◆ co_IntSendMessageTimeout()

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

Definition at line 1654 of file message.c.

1661 {
1663  HWND *Children;
1664  HWND *Child;
1665 
1666  if (hWnd != HWND_BROADCAST && hWnd != HWND_TOPMOST)
1667  {
1668  return co_IntSendMessageTimeoutSingle(hWnd, Msg, wParam, lParam, uFlags, uTimeout, uResult);
1669  }
1670 
1671  if (!is_message_broadcastable(Msg)) return TRUE;
1672 
1674  if (NULL == DesktopWindow)
1675  {
1677  return 0;
1678  }
1679 
1680  if (hWnd != HWND_TOPMOST)
1681  {
1682  /* Send message to the desktop window too! */
1683  co_IntSendMessageTimeoutSingle(DesktopWindow->head.h, Msg, wParam, lParam, uFlags, uTimeout, uResult);
1684  }
1685 
1686  Children = IntWinListChildren(DesktopWindow);
1687  if (NULL == Children)
1688  {
1689  return 0;
1690  }
1691 
1692  for (Child = Children; NULL != *Child; Child++)
1693  {
1694  PWND pwnd = UserGetWindowObject(*Child);
1695  if (!pwnd) continue;
1696 
1697  if ( pwnd->fnid == FNID_MENU ||
1699  continue;
1700 
1701  co_IntSendMessageTimeoutSingle(*Child, Msg, wParam, lParam, uFlags, uTimeout, uResult);
1702  }
1703 
1705 
1706  return (LRESULT) TRUE;
1707 }
static LRESULT FASTCALL co_IntSendMessageTimeoutSingle(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult)
Definition: message.c:1461
#define TRUE
Definition: types.h:120
#define ERROR_INTERNAL_ERROR
Definition: winerror.h:840
static BOOL is_message_broadcastable(UINT msg)
Definition: message.c:568
#define FNID_MENU
Definition: ntuser.h:823
HWND hWnd
Definition: settings.c:17
#define HWND_TOPMOST
Definition: winuser.h:1194
struct @1604 Msg[]
UINT uFlags
Definition: api.c:59
RTL_ATOM atomClassName
Definition: ntuser.h:536
PSERVERINFO gpsi
Definition: main.c:27
WPARAM wParam
Definition: combotst.c:138
DWORD fnid
Definition: ntuser.h:673
smooth NULL
Definition: ftsmooth.c:416
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
Implementation of the Explorer desktop window.
Definition: desktop.h:51
#define ICLS_SWITCH
Definition: ntuser.h:893
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1349
HWND *FASTCALL IntWinListChildren(PWND Window)
Definition: window.c:255
Definition: ntuser.h:657
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE Child
Definition: acpixf.h:728
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define USERTAG_WINDOWLIST
Definition: tags.h:297
LONG_PTR LRESULT
Definition: windef.h:209
#define HWND_BROADCAST
Definition: winuser.h:1190
LPARAM lParam
Definition: combotst.c:139
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1013
PCLS pcls
Definition: ntuser.h:684

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

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

1468 {
1470  PWND Window = NULL;
1471  PMSGMEMORY MsgMemoryEntry;
1472  INT lParamBufferSize;
1473  LPARAM lParamPacked;
1474  PTHREADINFO Win32Thread, ptiSendTo = NULL;
1475  ULONG_PTR Result = 0;
1478  BOOL DoCallBack = TRUE;
1479 
1480  if (!(Window = UserGetWindowObject(hWnd)))
1481  {
1482  TRACE("SendMessageTimeoutSingle: Invalid handle 0x%p!\n",hWnd);
1483  RETURN( FALSE);
1484  }
1485 
1486  UserRefObjectCo(Window, &Ref);
1487 
1488  Win32Thread = PsGetCurrentThreadWin32Thread();
1489 
1490  ptiSendTo = IntSendTo(Window, Win32Thread, Msg);
1491 
1492  if ( Msg >= WM_DDE_FIRST && Msg <= WM_DDE_LAST )
1493  {
1495  {
1496  ERR("Sending Exit DDE 0x%x\n",Msg);
1497  RETURN( FALSE);
1498  }
1499  }
1500 
1501  if ( !ptiSendTo )
1502  {
1503  if (Win32Thread->TIF_flags & TIF_INCLEANUP)
1504  {
1505  /* Never send messages to exiting threads */
1506  RETURN( FALSE);
1507  }
1508 
1509  if (Msg & 0x80000000)
1510  {
1511  TRACE("SMTS: Internal Message!\n");
1513  if (uResult) *uResult = Result;
1514  RETURN( TRUE);
1515  }
1516 
1517  // Only happens when calling the client!
1519 
1520  if ( Window->state & WNDS_SERVERSIDEWINDOWPROC )
1521  {
1522  TRACE("SMT: Server Side Window Procedure\n");
1523  // Handle it here. Safeguard against excessive recursions.
1524  if (IoGetRemainingStackSize() < PAGE_SIZE)
1525  {
1526  ERR("Server Callback Exceeded Stack!\n");
1527  RETURN( FALSE);
1528  }
1529  /* Return after server side call, IntCallWndProcRet will not be called. */
1530  switch(Window->fnid)
1531  {
1532  case FNID_DESKTOP:
1533  DoCallBack = !DesktopWindowProc(Window, Msg, wParam, lParam,(LRESULT*)&Result);
1534  break;
1535  case FNID_MESSAGEWND:
1537  break;
1538  case FNID_MENU:
1539  DoCallBack = !PopupMenuWndProc( Window, Msg, wParam, lParam,(LRESULT*)&Result);
1540  break;
1541  }
1542  if (!DoCallBack)
1543  {
1544  if (uResult) *uResult = Result;
1545  RETURN( TRUE);
1546  }
1547  }
1548  /* See if this message type is present in the table */
1549  MsgMemoryEntry = FindMsgMemory(Msg);
1550  if (NULL == MsgMemoryEntry)
1551  {
1552  lParamBufferSize = -1;
1553  }
1554  else
1555  {
1556  lParamBufferSize = MsgMemorySize(MsgMemoryEntry, wParam, lParam);
1557  // If zero, do not allow callback on client side to allocate a buffer!!!!! See CORE-7695.
1558  if (!lParamBufferSize) lParamBufferSize = -1;
1559  }
1560 
1561  if (! NT_SUCCESS(PackParam(&lParamPacked, Msg, wParam, lParam, FALSE)))
1562  {
1563  ERR("Failed to pack message parameters\n");
1564  RETURN( FALSE);
1565  }
1566 
1567  Result = (ULONG_PTR)co_IntCallWindowProc( Window->lpfnWndProc,
1568  !Window->Unicode,
1569  hWnd,
1570  Msg,
1571  wParam,
1572  lParamPacked,
1573  lParamBufferSize );
1574  if (uResult)
1575  {
1576  *uResult = Result;
1577  }
1578 
1579  if (! NT_SUCCESS(UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE)))
1580  {
1581  ERR("Failed to unpack message parameters\n");
1582  RETURN( TRUE);
1583  }
1584 
1585  // Only happens when calling the client!
1586  IntCallWndProcRet( Window, hWnd, Msg, wParam, lParam, (LRESULT *)uResult);
1587 
1588  RETURN( TRUE);
1589  }
1590 
1591  if (Window->state & WNDS_DESTROYED)
1592  {
1593  /* FIXME: Last error? */
1594  ERR("Attempted to send message to window %p that is being destroyed!\n", hWnd);
1595  RETURN( FALSE);
1596  }
1597 
1598  if ((uFlags & SMTO_ABORTIFHUNG) && MsqIsHung(ptiSendTo, 4 * MSQ_HUNG))
1599  {
1600  // FIXME: Set window hung and add to a list.
1601  /* FIXME: Set a LastError? */
1602  ERR("Window %p (%p) (pti %p) is hung!\n", hWnd, Window, ptiSendTo);
1603  RETURN( FALSE);
1604  }
1605 
1606  do
1607  {
1608  Status = co_MsqSendMessage( ptiSendTo,
1609  hWnd,
1610  Msg,
1611  wParam,
1612  lParam,
1613  uTimeout,
1614  (uFlags & SMTO_BLOCK),
1615  MSQ_NORMAL,
1616  uResult );
1617  }
1618  while ((Status == STATUS_TIMEOUT) &&
1619  (uFlags & SMTO_NOTIMEOUTIFNOTHUNG) &&
1620  !MsqIsHung(ptiSendTo, MSQ_HUNG)); // FIXME: Set window hung and add to a list.
1621 
1622  if (Status == STATUS_TIMEOUT)
1623  {
1624  if (0 && MsqIsHung(ptiSendTo, MSQ_HUNG))
1625  {
1626  TRACE("Let's go Ghost!\n");
1628  }
1629 /*
1630  * MSDN says:
1631  * Microsoft Windows 2000: If GetLastError returns zero, then the function
1632  * timed out.
1633  * XP+ : If the function fails or times out, the return value is zero.
1634  * To get extended error information, call GetLastError. If GetLastError
1635  * returns ERROR_TIMEOUT, then the function timed out.
1636  */
1638  RETURN( FALSE);
1639  }
1640  else if (!NT_SUCCESS(Status))
1641  {
1643  RETURN( FALSE);
1644  }
1645 
1646  RETURN( TRUE);
1647 
1648 CLEANUP:
1650  END_CLEANUP;
1651 }
#define TRUE
Definition: types.h:120
static PMSGMEMORY FASTCALL FindMsgMemory(UINT Msg)
Definition: message.c:147
BOOL WINAPI PopupMenuWndProc(PWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: menu.c:4628
#define CLEANUP
Definition: ntuser.h:5
BOOL FASTCALL MsqIsHung(PTHREADINFO pti, DWORD TimeOut)
Definition: msgqueue.c:2194
#define RETURN(value)
Definition: ntuser.h:4
static LRESULT handle_internal_message(PWND pWnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: message.c:772
#define ERROR_TIMEOUT
Definition: winerror.h:941
FLONG TIF_flags
Definition: win32.h:94
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
#define FNID_MENU
Definition: ntuser.h:823
LONG NTSTATUS
Definition: precomp.h:26
HWND hWnd
Definition: settings.c:17
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:25
#define MSQ_HUNG
Definition: msgqueue.h:3
struct @1604 Msg[]
BOOL FASTCALL DesktopWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: desktop.c:1401
LRESULT APIENTRY co_IntCallWindowProc(WNDPROC Proc, BOOLEAN IsAnsiProc, HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, INT lParamBufferSize)
Definition: callback.c:282
UINT uFlags
Definition: api.c:59
int32_t INT
Definition: typedefs.h:57
WPARAM wParam
Definition: combotst.c:138
#define SMTO_ABORTIFHUNG
Definition: winuser.h:1209
#define FNID_MESSAGEWND
Definition: ntuser.h:826
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
Definition: window.c:28
static NTSTATUS PackParam(LPARAM *lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL NonPagedPoolNeeded)
Definition: message.c:263
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FNID_DESKTOP
Definition: ntuser.h:824
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:38
PTHREADINFO FASTCALL IntSendTo(PWND Window, PTHREADINFO ptiCur, UINT Msg)
Definition: message.c:1332
Definition: object.h:3
static NTSTATUS UnpackParam(LPARAM lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL NonPagedPoolUsed)
Definition: message.c:381
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
LONG_PTR LPARAM
Definition: windef.h:208
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
#define TRACE(s)
Definition: solgame.cpp:4
static VOID FASTCALL IntCallWndProc(PWND Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:707
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DECLARE_RETURN(type)
Definition: ntuser.h:3
BOOL FASTCALL UserMessageWindowProc(PWND pwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: desktop.c:1487
#define WM_DDE_LAST
Definition: dde.h:46
#define PAGE_SIZE
Definition: env_spec_w32.h:49
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
BOOL FASTCALL IntMakeHungWindowGhosted(HWND hwndHung)
Definition: ghost.c:156
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:657
BOOL FASTCALL IntDdeSendMessageHook(PWND pWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: dde.c:386
#define MSQ_NORMAL
Definition: msgqueue.h:4
#define WM_DDE_FIRST
Definition: dde.h:47
static UINT FASTCALL MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam)
Definition: message.c:166
static VOID FASTCALL IntCallWndProcRet(PWND Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *uResult)
Definition: message.c:741
#define ULONG_PTR
Definition: config.h:101
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:1057
LONG_PTR LRESULT
Definition: windef.h:209
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define WNDS_SERVERSIDEWINDOWPROC
Definition: ntuser.h:591
#define WNDS_DESTROYED
Definition: ntuser.h:604
LPARAM lParam
Definition: combotst.c:139
#define SMTO_BLOCK
Definition: winuser.h:1210
#define TIF_INCLEANUP
Definition: ntuser.h:240
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
#define END_CLEANUP
Definition: ntuser.h:6

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

1739 {
1740  ULONG_PTR Result;
1741  PWND Window = NULL;
1742  PMSGMEMORY MsgMemoryEntry;
1743  INT lParamBufferSize;
1744  LPARAM lParamPacked;
1745  PTHREADINFO Win32Thread, ptiSendTo = NULL;
1749  BOOL DoCallBack = TRUE;
1750 
1751  if (!(Window = UserGetWindowObject(hWnd)))
1752  {
1753  TRACE("SendMessageWithCallBack: Invalid handle 0x%p!\n",hWnd);
1754  RETURN(FALSE);
1755  }
1756 
1757  UserRefObjectCo(Window, &Ref);
1758 
1759  if (Window->state & WNDS_DESTROYED)
1760  {
1761  /* FIXME: last error? */
1762  ERR("Attempted to send message to window %p that is being destroyed!\n", hWnd);
1763  RETURN(FALSE);
1764  }
1765 
1766  Win32Thread = PsGetCurrentThreadWin32Thread();
1767 
1768  if (Win32Thread == NULL ||
1769  Win32Thread->TIF_flags & TIF_INCLEANUP)
1770  {
1771  RETURN(FALSE);
1772  }
1773 
1774  ptiSendTo = IntSendTo(Window, Win32Thread, Msg);
1775 
1776  if (Msg & 0x80000000 &&
1777  !ptiSendTo)
1778  {
1779  if (Win32Thread->TIF_flags & TIF_INCLEANUP) RETURN( FALSE);
1780 
1781  TRACE("SMWCB: Internal Message!\n");
1783  if (uResult) *uResult = Result;
1784  RETURN( TRUE);
1785  }
1786 
1787  /* See if this message type is present in the table */
1788  MsgMemoryEntry = FindMsgMemory(Msg);
1789  if (NULL == MsgMemoryEntry)
1790  {
1791  lParamBufferSize = -1;
1792  }
1793  else
1794  {
1795  lParamBufferSize = MsgMemorySize(MsgMemoryEntry, wParam, lParam);
1796  if (!lParamBufferSize) lParamBufferSize = -1;
1797  }
1798 
1799  if (! NT_SUCCESS(PackParam(&lParamPacked, Msg, wParam, lParam, !!ptiSendTo)))
1800  {
1801  ERR("Failed to pack message parameters\n");
1802  RETURN( FALSE);
1803  }
1804 
1805  /* If it can be sent now, then send it. */
1806  if ( !ptiSendTo )
1807  {
1808  if (Win32Thread->TIF_flags & TIF_INCLEANUP)
1809  {
1810  UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE);
1811  /* Never send messages to exiting threads */
1812  RETURN(FALSE);
1813  }
1814 
1816 
1817  if ( Window->state & WNDS_SERVERSIDEWINDOWPROC )
1818  {
1819  TRACE("SMWCB: Server Side Window Procedure\n");
1820  switch(Window->fnid)
1821  {
1822  case FNID_DESKTOP:
1823  DoCallBack = !DesktopWindowProc(Window, Msg, wParam, lParamPacked, (LRESULT*)&Result);
1824  break;
1825  case FNID_MESSAGEWND:
1827  break;
1828  case FNID_MENU:
1829  DoCallBack = !PopupMenuWndProc( Window, Msg, wParam, lParam,(LRESULT*)&Result);
1830  break;
1831  }
1832  }
1833 
1834  if (DoCallBack)
1835  Result = (ULONG_PTR)co_IntCallWindowProc( Window->lpfnWndProc,
1836  !Window->Unicode,
1837  hWnd,
1838  Msg,
1839  wParam,
1840  lParamPacked,
1841  lParamBufferSize );
1842  if(uResult)
1843  {
1844  *uResult = Result;
1845  }
1846 
1847  IntCallWndProcRet( Window, hWnd, Msg, wParam, lParam, (LRESULT *)uResult);
1848 
1849  if (CompletionCallback)
1850  {
1852  hWnd,
1853  Msg,
1854  CompletionCallbackContext,
1855  Result);
1856  }
1857  }
1858 
1859  if ( !ptiSendTo)
1860  {
1861  if (! NT_SUCCESS(UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE)))
1862  {
1863  ERR("Failed to unpack message parameters\n");
1864  }
1865  RETURN(TRUE);
1866  }
1867 
1869  {
1870  ERR("MsqSendMessage(): Not enough memory to allocate a message");
1871  RETURN( FALSE);
1872  }
1873 
1874  Message->Msg.hwnd = hWnd;
1875  Message->Msg.message = Msg;
1876  Message->Msg.wParam = wParam;
1877  Message->Msg.lParam = lParamPacked;
1878  Message->pkCompletionEvent = NULL; // No event needed.
1879  Message->lResult = 0;
1880  Message->QS_Flags = 0;
1881  Message->ptiReceiver = ptiSendTo;
1882  Message->ptiSender = NULL; // mjmartin, you are right! This is null.
1883  Message->ptiCallBackSender = Win32Thread;
1884  Message->CompletionCallback = CompletionCallback;
1885  Message->CompletionCallbackContext = CompletionCallbackContext;
1886  Message->HookMessage = MSQ_NORMAL;
1887  Message->HasPackedLParam = (lParamBufferSize > 0);
1888  Message->QS_Flags = QS_SENDMESSAGE;
1889  Message->flags = SMF_RECEIVERFREE;
1890 
1891  if (Msg & 0x80000000) // Higher priority event message!
1892  InsertHeadList(&ptiSendTo->SentMessagesListHead, &Message->ListEntry);
1893  else
1894  InsertTailList(&ptiSendTo->SentMessagesListHead, &Message->ListEntry);
1895  MsqWakeQueue(ptiSendTo, QS_SENDMESSAGE, TRUE);
1896 
1897  RETURN(TRUE);
1898 
1899 CLEANUP:
1901  END_CLEANUP;
1902 }
VOID FASTCALL MsqWakeQueue(PTHREADINFO pti, DWORD MessageBits, BOOL KeyEvent)
Definition: msgqueue.c:412
#define TRUE
Definition: types.h:120
static PMSGMEMORY FASTCALL FindMsgMemory(UINT Msg)
Definition: message.c:147
BOOL WINAPI PopupMenuWndProc(PWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: menu.c:4628
#define CLEANUP
Definition: ntuser.h:5
#define RETURN(value)
Definition: ntuser.h:4
static LRESULT handle_internal_message(PWND pWnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: message.c:772
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
FLONG TIF_flags
Definition: win32.h:94
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
#define FNID_MENU
Definition: ntuser.h:823
HWND hWnd
Definition: settings.c:17
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:25
struct @1604 Msg[]
BOOL FASTCALL DesktopWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: desktop.c:1401
LRESULT APIENTRY co_IntCallWindowProc(WNDPROC Proc, BOOLEAN IsAnsiProc, HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, INT lParamBufferSize)
Definition: callback.c:282
#define InsertTailList(ListHead, Entry)
int32_t INT
Definition: typedefs.h:57
WPARAM wParam
Definition: combotst.c:138
#define FNID_MESSAGEWND
Definition: ntuser.h:826
uint32_t ULONG_PTR
Definition: typedefs.h:64
Definition: window.c:28
static NTSTATUS PackParam(LPARAM *lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL NonPagedPoolNeeded)
Definition: message.c:263
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FNID_DESKTOP
Definition: ntuser.h:824
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:38
LIST_ENTRY SentMessagesListHead
Definition: win32.h:99
PTHREADINFO FASTCALL IntSendTo(PWND Window, PTHREADINFO ptiCur, UINT Msg)
Definition: message.c:1332
#define SMF_RECEIVERFREE
Definition: msgqueue.h:40
Definition: object.h:3
static NTSTATUS UnpackParam(LPARAM lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL NonPagedPoolUsed)
Definition: message.c:381
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define QS_SENDMESSAGE
Definition: winuser.h:892
LONG_PTR LPARAM
Definition: windef.h:208
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
#define TRACE(s)
Definition: solgame.cpp:4
static VOID FASTCALL IntCallWndProc(PWND Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:707
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DECLARE_RETURN(type)
Definition: ntuser.h:3
VOID APIENTRY co_IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback, HWND hWnd, UINT Msg, ULONG_PTR CompletionCallbackContext, LRESULT Result)
Definition: callback.c:238
BOOL FASTCALL UserMessageWindowProc(PWND pwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: desktop.c:1487
CHAR Message[80]
Definition: alive.c:5
PUSER_SENT_MESSAGE FASTCALL AllocateUserMessage(BOOL KEvent)
Definition: msgqueue.c:763
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:657
#define MSQ_NORMAL
Definition: msgqueue.h:4
static UINT FASTCALL MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam)
Definition: message.c:166
static VOID FASTCALL IntCallWndProcRet(PWND Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *uResult)
Definition: message.c:741
#define ULONG_PTR
Definition: config.h:101
const TCHAR * CompletionCallback(unsigned __int64 &rnIndex, const BOOL *pblnForward, const TCHAR *pszContext, const TCHAR *pszBegin)
Definition: Completion.cpp:439
LONG_PTR LRESULT
Definition: windef.h:209
#define WNDS_SERVERSIDEWINDOWPROC
Definition: ntuser.h:591
#define WNDS_DESTROYED
Definition: ntuser.h:604
LPARAM lParam
Definition: combotst.c:139
#define TIF_INCLEANUP
Definition: ntuser.h:240
#define END_CLEANUP
Definition: ntuser.h:6

Referenced by co_IntSendMessageNoWait(), and NtUserMessageCall().

◆ co_IntWaitMessage()

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

Definition at line 1131 of file message.c.

1134 {
1135  PTHREADINFO pti;
1137  MSG Msg;
1138  LONG_PTR ExtraInfo = 0;
1139 
1141 
1142  do
1143  {
1144  if ( co_IntPeekMessage( &Msg, // Dont reenter!
1145  Window,
1146  MsgFilterMin,
1147  MsgFilterMax,
1148  MAKELONG( PM_NOREMOVE, GetWakeMask( MsgFilterMin, MsgFilterMax)),
1149  &ExtraInfo,
1150  TRUE ) ) // act like GetMessage.
1151  {
1152  return TRUE;
1153  }
1154 
1155  /* Nothing found. Wait for new messages. */
1157  Window,
1158  MsgFilterMin,
1159  MsgFilterMax);
1160  if (!NT_SUCCESS(Status))
1161  {
1163  ERR("Exit co_IntWaitMessage on error!\n");
1164  return FALSE;
1165  }
1167  {
1168  return FALSE;
1169  }
1170  }
1171  while ( TRUE );
1172 
1173  return FALSE;
1174 }
#define TRUE
Definition: types.h:120
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
LONG NTSTATUS
Definition: precomp.h:26
UINT FASTCALL GetWakeMask(UINT first, UINT last)
Definition: message.c:574
NTSTATUS FASTCALL co_MsqWaitForNewMessages(PTHREADINFO pti, PWND WndFilter, UINT MsgFilterMin, UINT MsgFilterMax)
Definition: msgqueue.c:2164
struct @1604 Msg[]
#define PM_NOREMOVE
Definition: winuser.h:1181
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
Definition: window.c:28
#define MAKELONG(a, b)
Definition: typedefs.h:248
BOOL APIENTRY co_IntPeekMessage(PMSG Msg, PWND Window, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg, LONG_PTR *ExtraInfo, BOOL bGMSG)
Definition: message.c:965
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
Status
Definition: gdiplustypes.h:24
#define STATUS_USER_APC
Definition: ntstatus.h:78
#define ERR(fmt,...)
Definition: debug.h:110
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
return STATUS_SUCCESS
Definition: btrfs.c:3014

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

◆ CopyMsgToKernelMem()

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

Definition at line 430 of file message.c.

431 {
433 
434  PVOID KernelMem;
435  UINT Size;
436 
437  *KernelModeMsg = *UserModeMsg;
438 
439  /* See if this message type is present in the table */
440  if (NULL == MsgMemoryEntry)
441  {
442  /* Not present, no copying needed */
443  return STATUS_SUCCESS;
444  }
445 
446  /* Determine required size */
447  Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, UserModeMsg->lParam);
448 
449  if (0 != Size)
450  {
451  /* Allocate kernel mem */
453  if (NULL == KernelMem)
454  {
455  ERR("Not enough memory to copy message to kernel mem\n");
456  return STATUS_NO_MEMORY;
457  }
458  KernelModeMsg->lParam = (LPARAM) KernelMem;
459 
460  /* Copy data if required */
461  if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_READ))
462  {
463  TRACE("Copy Message %u from usermode buffer\n", KernelModeMsg->message);
464  Status = MmCopyFromCaller(KernelMem, (PVOID) UserModeMsg->lParam, Size);
465  if (! NT_SUCCESS(Status))
466  {
467  ERR("Failed to copy message to kernel: invalid usermode lParam buffer\n");
468  ExFreePoolWithTag(KernelMem, TAG_MSG);
469  return Status;
470  }
471  }
472  else
473  {
474  /* Make sure we don't pass any secrets to usermode */
475  RtlZeroMemory(KernelMem, Size);
476  }
477  }
478  else
479  {
480  KernelModeMsg->lParam = 0;
481  }
482 
483  return STATUS_SUCCESS;
484 }
LONG NTSTATUS
Definition: precomp.h:26
#define MmCopyFromCaller
Definition: polytest.cpp:29
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:110
#define MMS_FLAG_READ
Definition: message.c:111
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
unsigned int UINT
Definition: ndis.h:50
static UINT FASTCALL MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam)
Definition: message.c:166
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define TAG_MSG
Definition: tags.h:7

Referenced by co_IntDoSendMessage().

◆ CopyMsgToUserMem()

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

Definition at line 487 of file message.c.

488 {
490  PMSGMEMORY MsgMemoryEntry;
491  UINT Size;
492 
493  /* See if this message type is present in the table */
494  MsgMemoryEntry = FindMsgMemory(UserModeMsg->message);
495  if (NULL == MsgMemoryEntry)
496  {
497  /* Not present, no copying needed */
498  return STATUS_SUCCESS;
499  }
500 
501  /* Determine required size */
502  Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, UserModeMsg->lParam);
503 
504  if (0 != Size)
505  {
506  /* Copy data if required */
507  if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_WRITE))
508  {
509  Status = MmCopyToCaller((PVOID) UserModeMsg->lParam, (PVOID) KernelModeMsg->lParam, Size);
510  if (! NT_SUCCESS(Status))
511  {
512  ERR("Failed to copy message from kernel: invalid usermode lParam buffer\n");
513  ExFreePool((PVOID) KernelModeMsg->lParam);
514  return Status;
515  }
516  }
517  ExFreePool((PVOID) KernelModeMsg->lParam);
518  }
519 
520  return STATUS_SUCCESS;
521 }
static PMSGMEMORY FASTCALL FindMsgMemory(UINT Msg)
Definition: message.c:147
LONG NTSTATUS
Definition: precomp.h:26
#define MmCopyToCaller(x, y, z)
Definition: mmcopy.h:19
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:110
unsigned int UINT
Definition: ndis.h:50
static UINT FASTCALL MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam)
Definition: message.c:166
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define MMS_FLAG_WRITE
Definition: message.c:112
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by co_IntDoSendMessage().

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserMsg  )

◆ FindMsgMemory()

static PMSGMEMORY FASTCALL FindMsgMemory ( UINT  Msg)
static

Definition at line 147 of file message.c.

148 {
149  PMSGMEMORY MsgMemoryEntry;
150 
151  /* See if this message type is present in the table */
152  for (MsgMemoryEntry = g_MsgMemory;
153  MsgMemoryEntry < g_MsgMemory + sizeof(g_MsgMemory) / sizeof(MSGMEMORY);
154  MsgMemoryEntry++)
155  {
156  if (Msg == MsgMemoryEntry->Message)
157  {
158  return MsgMemoryEntry;
159  }
160  }
161 
162  return NULL;
163 }
struct @1604 Msg[]
smooth NULL
Definition: ftsmooth.c:416
static MSGMEMORY g_MsgMemory[]
Definition: message.c:122
UINT Message
Definition: message.c:116

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

575 {
576  UINT mask = QS_POSTMESSAGE | QS_SENDMESSAGE; /* Always selected */
577 
578  if (first || last)
579  {
580  if ((first <= WM_KEYLAST) && (last >= WM_KEYFIRST)) mask |= QS_KEY;
581  if ( ((first <= WM_MOUSELAST) && (last >= WM_MOUSEFIRST)) ||
583  if ((first <= WM_TIMER) && (last >= WM_TIMER)) mask |= QS_TIMER;
584  if ((first <= WM_SYSTIMER) && (last >= WM_SYSTIMER)) mask |= QS_TIMER;
585  if ((first <= WM_PAINT) && (last >= WM_PAINT)) mask |= QS_PAINT;
586  }
587  else mask = QS_ALLINPUT;
588 
589  return mask;
590 }
#define WM_MOUSEFIRST
Definition: winuser.h:1756
#define WM_SYSTIMER
Definition: comctl32.h:112
POINT last
Definition: font.c:46
const GLint * first
Definition: glext.h:5794
#define QS_TIMER
Definition: winuser.h:893
#define WM_KEYFIRST
Definition: winuser.h:1696
GLenum GLint GLuint mask
Definition: glext.h:6028
#define QS_SENDMESSAGE
Definition: winuser.h:892
#define WM_NCMOUSELAST
Definition: msgqueue.h:240
#define WM_NCMOUSEFIRST
Definition: msgqueue.h:239
#define WM_TIMER
Definition: winuser.h:1724
#define WM_MOUSELAST
Definition: winuser.h:1783
#define WM_KEYLAST
Definition: winuser.h:1710
#define WM_PAINT
Definition: winuser.h:1602
#define QS_ALLINPUT
Definition: winuser.h:874
#define QS_POSTMESSAGE
Definition: winuser.h:888
unsigned int UINT
Definition: ndis.h:50
#define QS_PAINT
Definition: winuser.h:887
#define QS_MOUSE
Definition: winuser.h:884
#define QS_KEY
Definition: winuser.h:883

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

814 {
815  LRESULT Result = 0;
816 
817  switch(dwQEvent)
818  {
819  case POSTEVENT_NWE:
820  {
821  co_EVENT_CallEvents( pMsg->message, pMsg->hwnd, pMsg->wParam, ExtraInfo);
822  }
823  break;
824  case POSTEVENT_SAW:
825  {
826  //ERR("HIE : SAW : pti 0x%p hWnd 0x%p\n",pti,pMsg->hwnd);
827  IntActivateWindow((PWND)pMsg->wParam, pti, (HANDLE)pMsg->lParam, (DWORD)ExtraInfo);
828  }
829  break;
830  case POSTEVENT_DAW:
831  {
832  //ERR("HIE : DAW : pti 0x%p tid 0x%p hWndPrev 0x%p\n",pti,ExtraInfo,pMsg->hwnd);
833  IntDeactivateWindow(pti, (HANDLE)ExtraInfo);
834  }
835  break;
836  }
837  return Result;
838 }
WPARAM wParam
Definition: winuser.h:3091
LRESULT APIENTRY co_EVENT_CallEvents(DWORD event, HWND hwnd, UINT_PTR idObject, LONG_PTR idChild)
Definition: event.c:151
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
LPARAM lParam
Definition: winuser.h:3092
VOID FASTCALL IntActivateWindow(PWND Wnd, PTHREADINFO pti, HANDLE tid, DWORD Type)
Definition: focus.c:267
unsigned long DWORD
Definition: ntddk_ex.h:95
#define POSTEVENT_NWE
Definition: msgqueue.h:125
Definition: ntuser.h:657
HWND hwnd
Definition: winuser.h:3089
#define POSTEVENT_DAW
Definition: msgqueue.h:123
BOOL FASTCALL IntDeactivateWindow(PTHREADINFO pti, HANDLE tid)
Definition: focus.c:105
LONG_PTR LRESULT
Definition: windef.h:209
UINT message
Definition: winuser.h:3090
#define POSTEVENT_SAW
Definition: msgqueue.h:124

Referenced by co_IntPeekMessage().

◆ handle_internal_message()

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

Definition at line 772 of file message.c.

773 {
774  LRESULT lRes;
775 // USER_REFERENCE_ENTRY Ref;
776 // PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
777 
778  if (!pWnd || UserIsDesktopWindow(pWnd) || UserIsMessageWindow(pWnd))
779  return 0;
780 
781  TRACE("Internal Event Msg 0x%x hWnd 0x%p\n", msg, pWnd->head.h);
782 
783  switch(msg)
784  {
785  case WM_ASYNC_SHOWWINDOW:
786  return co_WinPosShowWindow( pWnd, wparam );
788  {
789  PWINDOWPOS winpos = (PWINDOWPOS)lparam;
790  if (!winpos) return 0;
791  lRes = co_WinPosSetWindowPos( pWnd,
792  winpos->hwndInsertAfter,
793  winpos->x,
794  winpos->y,
795  winpos->cx,
796  winpos->cy,
797  winpos->flags);
799  return lRes;
800  }
802  {
803  ERR("WM_ASYNC_DESTROYWINDOW\n");
804  if (pWnd->style & WS_CHILD)
806  else
807  co_UserDestroyWindow(pWnd);
808  }
809  }
810  return 0;
811 }
#define TRUE
Definition: types.h:120
LRESULT co_UserFreeWindow(PWND Window, PPROCESSINFO ProcessData, PTHREADINFO ThreadData, BOOLEAN SendMessages)
Definition: window.c:546
#define UserIsDesktopWindow(pWnd)
Definition: desktop.h:220
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
BOOLEAN FASTCALL co_WinPosSetWindowPos(PWND Window, HWND WndInsertAfter, INT x, INT y, INT cx, INT cy, UINT flags)
Definition: winpos.c:1720
HWND hwndInsertAfter
Definition: winuser.h:3564
#define WS_CHILD
Definition: pedump.c:617
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2579
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
THRDESKHEAD head
Definition: ntuser.h:659
UINT flags
Definition: winuser.h:3569
struct _WINDOWPOS * PWINDOWPOS
BOOLEAN FASTCALL co_WinPosShowWindow(PWND Wnd, INT Cmd)
Definition: winpos.c:2472
#define TRACE(s)
Definition: solgame.cpp:4
#define UserIsMessageWindow(pWnd)
Definition: desktop.h:223
#define ERR(fmt,...)
Definition: debug.h:110
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
#define USERTAG_SWP
Definition: tags.h:280
#define msg(x)
Definition: auth_time.c:54
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
LONG_PTR LRESULT
Definition: windef.h:209
static UINT WPARAM wparam
Definition: combo.c:716
DWORD style
Definition: ntuser.h:670

Referenced by co_IntSendMessageTimeoutSingle(), and co_IntSendMessageWithCallBack().

◆ IdlePing()

VOID FASTCALL IdlePing ( VOID  )

Definition at line 527 of file message.c.

528 {
530  PTHREADINFO pti;
531 
533 
534  if ( pti )
535  {
536  pti->pClientInfo->cSpins = 0; // Reset spins.
537 
538  if ( pti->pDeskInfo && pti == gptiForeground )
539  {
541  pti->pDeskInfo->fsHooks & HOOKID_TO_FLAG(WH_FOREGROUNDIDLE) )
542  {
544  }
545  }
546  }
547 
548  TRACE("IdlePing ppi %p\n", ppi);
549  if ( ppi && ppi->InputIdleEvent )
550  {
551  TRACE("InputIdleEvent\n");
552  KeSetEvent( ppi->InputIdleEvent, IO_NO_INCREMENT, FALSE);
553  }
554 }
#define HOOKID_TO_FLAG(HookId)
Definition: hook.h:5
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define WH_FOREGROUNDIDLE
Definition: winuser.h:41
PTHREADINFO gptiForeground
Definition: focus.c:14
#define TRACE(s)
Definition: solgame.cpp:4
ULONG fsHooks
Definition: win32.h:116
struct _CLIENTINFO * pClientInfo
Definition: win32.h:93
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1103
#define HC_ACTION
Definition: winuser.h:48
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
#define IO_NO_INCREMENT
Definition: iotypes.h:568
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:92

Referenced by co_IntGetPeekMessage(), and IntMsqSetWakeMask().

◆ IdlePong()

VOID FASTCALL IdlePong ( VOID  )

Definition at line 557 of file message.c.

558 {
560 
561  TRACE("IdlePong ppi %p\n", ppi);
562  if ( ppi && ppi->InputIdleEvent )
563  {
564  KeClearEvent(ppi->InputIdleEvent);
565  }
566 }
#define TRACE(s)
Definition: solgame.cpp:4
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22

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

◆ IntCallMsgFilter()

BOOL FASTCALL IntCallMsgFilter ( LPMSG  lpmsg,
INT  code 
)

Definition at line 2137 of file message.c.

2138 {
2139  BOOL Ret = FALSE;
2140 
2141  if ( co_HOOK_CallHooks( WH_SYSMSGFILTER, code, 0, (LPARAM)lpmsg))
2142  {
2143  Ret = TRUE;
2144  }
2145  else
2146  {
2147  Ret = co_HOOK_CallHooks( WH_MSGFILTER, code, 0, (LPARAM)lpmsg);
2148  }
2149  return Ret;
2150 }
#define TRUE
Definition: types.h:120
#define WH_MSGFILTER
Definition: winuser.h:29
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG_PTR LPARAM
Definition: windef.h:208
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1103
#define WH_SYSMSGFILTER
Definition: winuser.h:36

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

◆ IntCallWndProc()

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

Definition at line 707 of file message.c.

708 {
709  BOOL SameThread = FALSE;
710  CWPSTRUCT CWP;
711  PVOID pszClass = NULL, pszName = NULL;
712  CREATESTRUCTW Csw;
713 
715  if ( !ISITHOOKED(WH_CALLWNDPROC) && !(Window->head.rpdesk->pDeskInfo->fsHooks & HOOKID_TO_FLAG(WH_CALLWNDPROC)) )
716  return;
717 
718  if (Window->head.pti == ((PTHREADINFO)PsGetCurrentThreadWin32Thread()))
719  SameThread = TRUE;
720 
721  if ( Msg == WM_CREATE || Msg == WM_NCCREATE )
722  { //
723  // String pointers are in user heap space, like WH_CBT HCBT_CREATEWND.
724  //
725  if (!IntMsgCreateStructW( Window, &Csw, (CREATESTRUCTW *)lParam, &pszClass, &pszName ))
726  return;
727  lParam = (LPARAM)&Csw;
728  }
729 
730  CWP.hwnd = hWnd;
731  CWP.message = Msg;
732  CWP.wParam = wParam;
733  CWP.lParam = lParam;
734  co_HOOK_CallHooks( WH_CALLWNDPROC, HC_ACTION, SameThread, (LPARAM)&CWP );
735 
736  if (pszName) UserHeapFree(pszName);
737  if (pszClass) UserHeapFree(pszClass);
738 }
#define HOOKID_TO_FLAG(HookId)
Definition: hook.h:5
#define TRUE
Definition: types.h:120
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
HWND hWnd
Definition: settings.c:17
static __inline BOOL UserHeapFree(PVOID lpMem)
Definition: usrheap.h:42
struct @1604 Msg[]
#define WM_NCCREATE
Definition: winuser.h:1665
WPARAM wParam
Definition: combotst.c:138
Definition: window.c:28
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define ISITHOOKED(HookId)
Definition: hook.h:6
LPARAM lParam
Definition: winuser.h:3000
WPARAM wParam
Definition: winuser.h:3001
BOOL FASTCALL IntMsgCreateStructW(PWND Window, CREATESTRUCTW *pCsw, CREATESTRUCTW *Cs, PVOID *ppszClass, PVOID *ppszName)
Definition: message.c:597
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1103
UINT message
Definition: winuser.h:3002
#define WH_CALLWNDPROC
Definition: winuser.h:34
#define HC_ACTION
Definition: winuser.h:48
#define WM_CREATE
Definition: winuser.h:1590
LPARAM lParam
Definition: combotst.c:139

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

742 {
743  BOOL SameThread = FALSE;
744  CWPRETSTRUCT CWPR;
745  PVOID pszClass = NULL, pszName = NULL;
746  CREATESTRUCTW Csw;
747 
748  if ( !ISITHOOKED(WH_CALLWNDPROCRET) && !(Window->head.rpdesk->pDeskInfo->fsHooks & HOOKID_TO_FLAG(WH_CALLWNDPROCRET)) )
749  return;
750 
751  if (Window->head.pti == ((PTHREADINFO)PsGetCurrentThreadWin32Thread()))
752  SameThread = TRUE;
753 
754  if ( Msg == WM_CREATE || Msg == WM_NCCREATE )
755  {
756  if (!IntMsgCreateStructW( Window, &Csw, (CREATESTRUCTW *)lParam, &pszClass, &pszName ))
757  return;
758  lParam = (LPARAM)&Csw;
759  }
760 
761  CWPR.hwnd = hWnd;
762  CWPR.message = Msg;
763  CWPR.wParam = wParam;
764  CWPR.lParam = lParam;
765  CWPR.lResult = uResult ? (*uResult) : 0;
766  co_HOOK_CallHooks( WH_CALLWNDPROCRET, HC_ACTION, SameThread, (LPARAM)&CWPR );
767 
768  if (pszName) UserHeapFree(pszName);
769  if (pszClass) UserHeapFree(pszClass);
770 }
WPARAM wParam
Definition: winuser.h:2994
#define HOOKID_TO_FLAG(HookId)
Definition: hook.h:5
#define TRUE
Definition: types.h:120
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
HWND hWnd
Definition: settings.c:17
static __inline BOOL UserHeapFree(PVOID lpMem)
Definition: usrheap.h:42
LPARAM lParam
Definition: winuser.h:2993
struct @1604 Msg[]
#define WM_NCCREATE
Definition: winuser.h:1665
WPARAM wParam
Definition: combotst.c:138
Definition: window.c:28
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define WH_CALLWNDPROCRET
Definition: winuser.h:42
#define ISITHOOKED(HookId)
Definition: hook.h:6
BOOL FASTCALL IntMsgCreateStructW(PWND Window, CREATESTRUCTW *pCsw, CREATESTRUCTW *Cs, PVOID *ppszClass, PVOID *ppszName)
Definition: message.c:597
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1103
#define HC_ACTION
Definition: winuser.h:48
#define WM_CREATE
Definition: winuser.h:1590
LRESULT lResult
Definition: winuser.h:2992
LPARAM lParam
Definition: combotst.c:139

Referenced by co_IntSendMessageTimeoutSingle(), and co_IntSendMessageWithCallBack().

◆ IntCleanupMessageImpl()

NTSTATUS FASTCALL IntCleanupMessageImpl ( VOID  )

Definition at line 26 of file message.c.

27 {
28  return STATUS_SUCCESS;
29 }
return STATUS_SUCCESS
Definition: btrfs.c:3014

◆ IntDispatchMessage()

LRESULT FASTCALL IntDispatchMessage ( PMSG  pMsg)

Definition at line 841 of file message.c.

842 {
843  LONG Time;
844  LRESULT retval = 0;
845  PTHREADINFO pti;
846  PWND Window = NULL;
847  BOOL DoCallBack = TRUE;
848 
849  if (pMsg->hwnd)
850  {
852  if (!Window) return 0;
853  }
854 
856 
857  if ( Window && Window->head.pti != pti)
858  {
860  return 0;
861  }
862 
863  if (((pMsg->message == WM_SYSTIMER) ||
864  (pMsg->message == WM_TIMER)) &&
865  (pMsg->lParam) )
866  {
867  if (pMsg->message == WM_TIMER)
868  {
869  if (ValidateTimerCallback(pti,pMsg->lParam))
870  {
872  retval = co_IntCallWindowProc((WNDPROC)pMsg->lParam,
873  TRUE,
874  pMsg->hwnd,
875  WM_TIMER,
876  pMsg->wParam,
877  (LPARAM)Time,
878  -1);
879  }
880  return retval;
881  }
882  else
883  {
884  PTIMER pTimer = FindSystemTimer(pMsg);
885  if (pTimer && pTimer->pfn)
886  {
888  pTimer->pfn(pMsg->hwnd, WM_SYSTIMER, (UINT)pMsg->wParam, Time);
889  }
890  return 0;
891  }
892  }
893  // Need a window!
894  if ( !Window ) return 0;
895 
896  if (pMsg->message == WM_PAINT) Window->state |= WNDS_PAINTNOTPROCESSED;
897 
898  if ( Window->state & WNDS_SERVERSIDEWINDOWPROC )
899  {
900  TRACE("Dispatch: Server Side Window Procedure\n");
901  switch(Window->fnid)
902  {
903  case FNID_DESKTOP:
904  DoCallBack = !DesktopWindowProc( Window,
905  pMsg->message,
906  pMsg->wParam,
907  pMsg->lParam,
908  &retval);
909  break;
910  case FNID_MESSAGEWND:
911  DoCallBack = !UserMessageWindowProc( Window,
912  pMsg->message,
913  pMsg->wParam,
914  pMsg->lParam,
915  &retval);
916  break;
917  case FNID_MENU:
918  DoCallBack = !PopupMenuWndProc( Window,
919  pMsg->message,
920  pMsg->wParam,
921  pMsg->lParam,
922  &retval);
923  break;
924  }
925  }
926 
927  /* Since we are doing a callback on the same thread right away, there is
928  no need to copy the lparam to kernel mode and then back to usermode.
929  We just pretend it isn't a pointer */
930 
931  if (DoCallBack)
932  retval = co_IntCallWindowProc( Window->lpfnWndProc,
933  !Window->Unicode,
934  pMsg->hwnd,
935  pMsg->message,
936  pMsg->wParam,
937  pMsg->lParam,
938  -1);
939 
940  if ( pMsg->message == WM_PAINT &&
941  VerifyWnd(Window) &&
942  Window->state & WNDS_PAINTNOTPROCESSED ) // <--- Cleared, paint was already processed!
943  {
944  Window->state2 &= ~WNDS2_WMPAINTSENT;
945  /* send a WM_ERASEBKGND if the non-client area is still invalid */
946  ERR("Message WM_PAINT count %d Internal Paint Set? %s\n",Window->head.pti->cPaintsReady, Window->state & WNDS_INTERNALPAINT ? "TRUE" : "FALSE");
948  }
949 
950  return retval;
951 }
#define TRUE
Definition: types.h:120
BOOL WINAPI PopupMenuWndProc(PWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: menu.c:4628
#define WM_SYSTIMER
Definition: comctl32.h:112
#define EngGetTickCount32()
Definition: eng.h:43
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
#define FNID_MENU
Definition: ntuser.h:823
WPARAM wParam
Definition: winuser.h:3091
BOOL FASTCALL DesktopWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: desktop.c:1401
LRESULT APIENTRY co_IntCallWindowProc(WNDPROC Proc, BOOLEAN IsAnsiProc, HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, INT lParamBufferSize)
Definition: callback.c:282
#define FNID_MESSAGEWND
Definition: ntuser.h:826
#define WNDS_PAINTNOTPROCESSED
Definition: ntuser.h:595
Definition: window.c:28
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define FNID_DESKTOP
Definition: ntuser.h:824
BOOL FASTCALL ValidateTimerCallback(PTHREADINFO pti, LPARAM lParam)
Definition: timer.c:150
Definition: timer.h:3
smooth NULL
Definition: ftsmooth.c:416
LPARAM lParam
Definition: winuser.h:3092
LONG_PTR LPARAM
Definition: windef.h:208
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
PTIMER FASTCALL FindSystemTimer(PMSG pMsg)
Definition: timer.c:126
#define TRACE(s)
Definition: solgame.cpp:4
#define WM_TIMER
Definition: winuser.h:1724
BOOL FASTCALL UserMessageWindowProc(PWND pwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: desktop.c:1487
#define WM_PAINT
Definition: winuser.h:1602
#define WNDS2_WMPAINTSENT
Definition: ntuser.h:609
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2881
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:657
#define ERROR_MESSAGE_SYNC_ONLY
Definition: winerror.h:681
unsigned int UINT
Definition: ndis.h:50
VOID FASTCALL IntPaintWindow(PWND Window)
Definition: painting.c:1165
#define WNDS_INTERNALPAINT
Definition: ntuser.h:585
HWND hwnd
Definition: winuser.h:3089
TIMERPROC pfn
Definition: timer.h:13
PWND FASTCALL VerifyWnd(PWND pWnd)
Definition: window.c:64
LONG_PTR LRESULT
Definition: windef.h:209
UINT message
Definition: winuser.h:3090
#define WNDS_SERVERSIDEWINDOWPROC
Definition: ntuser.h:591
static PLARGE_INTEGER Time
Definition: time.c:105
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

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

◆ IntGetQueueStatus()

DWORD APIENTRY IntGetQueueStatus ( DWORD  Changes)

Definition at line 2086 of file message.c.

2087 {
2088  PTHREADINFO pti;
2089  DWORD Result;
2090 
2092 // wine:
2094 
2095  /* High word, types of messages currently in the queue.
2096  Low word, types of messages that have been added to the queue and that
2097  are still in the queue
2098  */
2099  Result = MAKELONG(pti->pcti->fsChangeBits & Changes, pti->pcti->fsWakeBits & Changes);
2100 
2101  pti->pcti->fsChangeBits &= ~Changes;
2102 
2103  return Result;
2104 }
#define QS_ALLPOSTMESSAGE
Definition: winuser.h:876
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
#define QS_SMRESULT
Definition: undocuser.h:93
#define MAKELONG(a, b)
Definition: typedefs.h:248
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:90
unsigned long DWORD
Definition: ntddk_ex.h:95
#define QS_ALLINPUT
Definition: winuser.h:874

Referenced by NtUserCallOneParam(), and NtUserGetThreadState().

◆ IntInitMessageImpl()

NTSTATUS FASTCALL IntInitMessageImpl ( VOID  )

Definition at line 20 of file message.c.

21 {
22  return STATUS_SUCCESS;
23 }
return STATUS_SUCCESS
Definition: btrfs.c:3014

◆ IntInitMessagePumpHook()

BOOL APIENTRY IntInitMessagePumpHook ( VOID  )

Definition at line 2107 of file message.c.

2108 {
2110 
2111  if (pti->pcti)
2112  {
2113  pti->pcti->dwcPumpHook++;
2114  return TRUE;
2115  }
2116  return FALSE;
2117 }
#define TRUE
Definition: types.h:120
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:90

Referenced by NtUserCallNoParam().

◆ IntMsgCreateStructW()

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

Definition at line 597 of file message.c.

603 {
604  PLARGE_STRING WindowName;
605  PUNICODE_STRING ClassName;
606  PVOID pszClass = NULL, pszName = NULL;
607 
608  /* Fill the new CREATESTRUCTW */
609  RtlCopyMemory(pCsw, Cs, sizeof(CREATESTRUCTW));
610  pCsw->style = Window->style; /* HCBT_CREATEWND needs the real window style */
611 
612  WindowName = (PLARGE_STRING) Cs->lpszName;
613  ClassName = (PUNICODE_STRING) Cs->lpszClass;
614 
615  // Based on the assumption this is from "unicode source" user32, ReactOS, answer is yes.
616  if (!IS_ATOM(ClassName->Buffer))
617  {
618  if (ClassName->Length)
619  {
620  if (Window->state & WNDS_ANSICREATOR)
621  {
623  AnsiString.MaximumLength = (USHORT)RtlUnicodeStringToAnsiSize(ClassName)+sizeof(CHAR);
624  pszClass = UserHeapAlloc(AnsiString.MaximumLength);
625  if (!pszClass)
626  {
627  ERR("UserHeapAlloc() failed!\n");
628  return FALSE;
629  }
630  RtlZeroMemory(pszClass, AnsiString.MaximumLength);
631  AnsiString.Buffer = (PCHAR)pszClass;
633  }
634  else
635  {
637  UnicodeString.MaximumLength = ClassName->Length + sizeof(UNICODE_NULL);
638  pszClass = UserHeapAlloc(UnicodeString.MaximumLength);
639  if (!pszClass)
640  {
641  ERR("UserHeapAlloc() failed!\n");
642  return FALSE;
643  }
644  RtlZeroMemory(pszClass, UnicodeString.MaximumLength);
645  UnicodeString.Buffer = (PWSTR)pszClass;
646  RtlCopyUnicodeString(&UnicodeString, ClassName);
647  }
648  *ppszClass = pszClass;
649  pCsw->lpszClass = UserHeapAddressToUser(pszClass);
650  }
651  else
652  {
653  pCsw->lpszClass = NULL;
654  }
655  }
656  else
657  {
658  pCsw->lpszClass = ClassName->Buffer;
659  }
660  if (WindowName->Length)
661  {
663  Name.Buffer = WindowName->Buffer;
664  Name.Length = (USHORT)min(WindowName->Length, MAXUSHORT); // FIXME: LARGE_STRING truncated
665  Name.MaximumLength = (USHORT)min(WindowName->MaximumLength, MAXUSHORT);
666 
667  if (Window->state & WNDS_ANSICREATOR)
668  {
670  AnsiString.MaximumLength = (USHORT)RtlUnicodeStringToAnsiSize(&Name) + sizeof(CHAR);
671  pszName = UserHeapAlloc(AnsiString.MaximumLength);
672  if (!pszName)
673  {
674  ERR("UserHeapAlloc() failed!\n");
675  return FALSE;
676  }
677  RtlZeroMemory(pszName, AnsiString.MaximumLength);
678  AnsiString.Buffer = (PCHAR)pszName;
680  }
681  else
682  {
684  UnicodeString.MaximumLength = Name.Length + sizeof(UNICODE_NULL);
685  pszName = UserHeapAlloc(UnicodeString.MaximumLength);
686  if (!pszName)
687  {
688  ERR("UserHeapAlloc() failed!\n");
689  return FALSE;
690  }
691  RtlZeroMemory(pszName, UnicodeString.MaximumLength);
692  UnicodeString.Buffer = (PWSTR)pszName;
694  }
695  *ppszName = pszName;
696  pCsw->lpszName = UserHeapAddressToUser(pszName);
697  }
698  else
699  {
700  pCsw->lpszName = NULL;
701  }
702 
703  return TRUE;
704 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1979
PVOID Buffer
Definition: ntuser.h:97
uint16_t * PWSTR
Definition: typedefs.h:55
static __inline PVOID UserHeapAlloc(SIZE_T Bytes)
Definition: usrheap.h:34
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
Definition: window.c:28
#define UNICODE_NULL
struct NameRec_ * Name
Definition: cdprocs.h:459
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
#define PCHAR
Definition: match.c:90
SIGDN PWSTR * ppszName
Definition: shobjidl.idl:593
ULONG Length
Definition: ntuser.h:94
LPCWSTR lpszName
Definition: winuser.h:2939
static __inline PVOID UserHeapAddressToUser(PVOID lpMem)
Definition: usrheap.h:92
NTSYSAPI DWORD WINAPI RtlUnicodeStringToAnsiSize(const UNICODE_STRING *)
#define ERR(fmt,...)
Definition: debug.h:110
unsigned short USHORT
Definition: pedump.c:61
#define min(a, b)
Definition: monoChain.cc:55
#define MAXUSHORT
Definition: typedefs.h:82
LPCWSTR lpszClass
Definition: winuser.h:2940
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define IS_ATOM(x)
Definition: class.h:3
struct _LARGE_STRING * PLARGE_STRING
#define WNDS_ANSICREATOR
Definition: ntuser.h:602
#define CHAR(Char)
ULONG MaximumLength
Definition: ntuser.h:95

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

◆ IntSendTo()

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

Definition at line 1332 of file message.c.

1333 {
1334  if ( ptiCur )
1335  {
1336  if (!Window ||
1337  Window->head.pti == ptiCur )
1338  {
1339  return NULL;
1340  }
1341  }
1342  return Window ? Window->head.pti : NULL;
1343 }
Definition: window.c:28
smooth NULL
Definition: ftsmooth.c:416

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

◆ IntUninitMessagePumpHook()

BOOL APIENTRY IntUninitMessagePumpHook ( VOID  )

Definition at line 2120 of file message.c.

2121 {
2123 
2124  if (pti->pcti)
2125  {
2126  if (pti->pcti->dwcPumpHook <= 0)
2127  {
2128  return FALSE;
2129  }
2130  pti->pcti->dwcPumpHook--;
2131  return TRUE;
2132  }
2133  return FALSE;
2134 }
#define TRUE
Definition: types.h:120
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:90

Referenced by NtUserCallNoParam().

◆ is_message_broadcastable()

static BOOL is_message_broadcastable ( UINT  msg)
static

Definition at line 568 of file message.c.

569 {
570  return msg < WM_USER || msg >= 0xc000;
571 }

Referenced by co_IntSendMessageTimeout(), and UserPostMessage().

◆ is_pointer_message()

static int is_pointer_message ( UINT  message,
WPARAM  wparam 
)
inlinestatic

Definition at line 99 of file message.c.

100 {
101  if (message >= 8*sizeof(message_pointer_flags)) return FALSE;
102  if (message == WM_DEVICECHANGE && !(wparam & 0x8000)) return FALSE;
103  return (message_pointer_flags[message / 32] & SET(message)) != 0;
104 }
Definition: tftpd.h:59
#define SET(msg)
Definition: message.c:35
#define WM_DEVICECHANGE
Definition: winuser.h:1793
static const unsigned int message_pointer_flags[]
Definition: message.c:37
static UINT WPARAM wparam
Definition: combo.c:716

Referenced by NtUserMessageCall(), UserPostMessage(), UserPostThreadMessage(), and UserSendNotifyMessage().

◆ lParamMemorySize()

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

Definition at line 255 of file message.c.

256 {
257  PMSGMEMORY MsgMemoryEntry = FindMsgMemory(Msg);
258  if(MsgMemoryEntry == NULL) return 0;
259  return MsgMemorySize(MsgMemoryEntry, wParam, lParam);
260 }
static PMSGMEMORY FASTCALL FindMsgMemory(UINT Msg)
Definition: message.c:147
struct @1604 Msg[]
WPARAM wParam
Definition: combotst.c:138
smooth NULL
Definition: ftsmooth.c:416
static UINT FASTCALL MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam)
Definition: message.c:166
LPARAM lParam
Definition: combotst.c:139

Referenced by co_IntCallHookProc().

◆ MsgMemorySize()

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

Definition at line 166 of file message.c.

167 {
168  CREATESTRUCTW *Cs;
169  PLARGE_STRING WindowName;
170  PUNICODE_STRING ClassName;
171  UINT Size = 0;
172 
173  _SEH2_TRY
174  {
175  if (MMS_SIZE_WPARAM == MsgMemoryEntry->Size)
176  {
177  Size = (UINT)wParam;
178  }
179  else if (MMS_SIZE_WPARAMWCHAR == MsgMemoryEntry->Size)
180  {
181  Size = (UINT) (wParam * sizeof(WCHAR));
182  }
183  else if (MMS_SIZE_LPARAMSZ == MsgMemoryEntry->Size)
184  {
185  // WM_SETTEXT and WM_SETTINGCHANGE can be null!
186  if (!lParam)
187  {
188  TRACE("lParam is NULL!\n");
189  Size = 0;
190  }
191  else
192  Size = (UINT) ((wcslen((PWSTR) lParam) + 1) * sizeof(WCHAR));
193  }
194  else if (MMS_SIZE_SPECIAL == MsgMemoryEntry->Size)
195  {
196  switch(MsgMemoryEntry->Message)
197  {
198  case WM_CREATE:
199  case WM_NCCREATE:
200  Cs = (CREATESTRUCTW *) lParam;
201  WindowName = (PLARGE_STRING) Cs->lpszName;
202  ClassName = (PUNICODE_STRING) Cs->lpszClass;
203  Size = sizeof(CREATESTRUCTW) + WindowName->Length + sizeof(WCHAR);
204  if (IS_ATOM(ClassName->Buffer))
205  {
206  Size += sizeof(WCHAR) + sizeof(ATOM);
207  }
208  else
209  {
210  Size += sizeof(WCHAR) + ClassName->Length + sizeof(WCHAR);
211  }
212  break;
213 
214  case WM_NCCALCSIZE:
215  Size = wParam ? sizeof(NCCALCSIZE_PARAMS) + sizeof(WINDOWPOS) : sizeof(RECT);
216  break;
217 
218  case WM_COPYDATA:
219  {
221  Size = sizeof(COPYDATASTRUCT) + cds->cbData;
222  }
223  break;
224 
225  case WM_DEVICECHANGE:
226  {
227  if ( lParam && (wParam & 0x8000) )
228  {
230  Size = header->dbch_size;
231  }
232  }
233  break;
234 
235  default:
236  ASSERT(FALSE);
237  Size = 0;
238  break;
239  }
240  }
241  else
242  {
243  Size = MsgMemoryEntry->Size;
244  }
245  }
247  {
248  ERR("Exception caught in MsgMemorySize()! Status: 0x%x\n", _SEH2_GetExceptionCode());
249  Size = 0;
250  }
251  _SEH2_END;
252  return Size;
253 }
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
WORD ATOM
Definition: dimm.idl:113
#define MMS_SIZE_SPECIAL
Definition: message.c:110
uint16_t * PWSTR
Definition: typedefs.h:55
#define WM_NCCALCSIZE
Definition: winuser.h:1667
#define MMS_SIZE_WPARAM
Definition: message.c:107
#define WM_NCCREATE
Definition: winuser.h:1665
WPARAM wParam
Definition: combotst.c:138
_SEH2_TRY
Definition: create.c:4226
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
struct tagCREATESTRUCTW CREATESTRUCTW
#define WM_COPYDATA
Definition: winuser.h:1646
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
ULONG Length
Definition: ntuser.h:94
#define MMS_SIZE_LPARAMSZ
Definition: message.c:109
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
LPCWSTR lpszName
Definition: winuser.h:2939
UINT Size
Definition: message.c:117
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define ERR(fmt,...)
Definition: debug.h:110
_SEH2_END
Definition: create.c:4400
struct tagNCCALCSIZE_PARAMS NCCALCSIZE_PARAMS
#define MMS_SIZE_WPARAMWCHAR
Definition: message.c:108
unsigned int UINT
Definition: ndis.h:50
#define WM_DEVICECHANGE
Definition: winuser.h:1793
struct tagCOPYDATASTRUCT COPYDATASTRUCT
#define WM_CREATE
Definition: winuser.h:1590
LPCWSTR lpszClass
Definition: winuser.h:2940
#define IS_ATOM(x)
Definition: class.h:3
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
struct _LARGE_STRING * PLARGE_STRING
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
LPARAM lParam
Definition: combotst.c:139
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
UINT Message
Definition: message.c:116

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

◆ NtUserCallMsgFilter()

BOOL APIENTRY NtUserCallMsgFilter ( LPMSG  lpmsg,
INT  code 
)

Definition at line 2379 of file message.c.

2380 {
2381  BOOL Ret = FALSE;
2382  MSG Msg;
2383 
2384  _SEH2_TRY
2385  {
2386  ProbeForRead(lpmsg, sizeof(MSG), 1);
2387  RtlCopyMemory( &Msg, lpmsg, sizeof(MSG));
2388  }
2390  {
2391  _SEH2_YIELD(return FALSE);
2392  }
2393  _SEH2_END;
2394 
2396 
2398  {
2399  Ret = TRUE;
2400  }
2401  else
2402  {
2403  Ret = co_HOOK_CallHooks( WH_MSGFILTER, code, 0, (LPARAM)&Msg);
2404  }
2405 
2406  UserLeave();
2407 
2408  _SEH2_TRY
2409  {
2410  ProbeForWrite(lpmsg, sizeof(MSG), 1);
2411  RtlCopyMemory(lpmsg, &Msg, sizeof(MSG));
2412  }
2414  {
2415  Ret = FALSE;
2416  }
2417  _SEH2_END;
2418 
2419  return Ret;
2420 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define WH_MSGFILTER
Definition: winuser.h:29
struct @1604 Msg[]
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4226
unsigned int BOOL
Definition: ntddk_ex.h:94
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
LONG_PTR LPARAM
Definition: windef.h:208
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1103
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
_SEH2_END
Definition: create.c:4400
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define WH_SYSMSGFILTER
Definition: winuser.h:36

Referenced by CallMsgFilterA(), and CallMsgFilterW().

◆ NtUserDispatchMessage()

LRESULT APIENTRY NtUserDispatchMessage ( PMSG  UnsafeMsgInfo)

Definition at line 2423 of file message.c.

2424 {
2425  LRESULT Res = 0;
2426  MSG SafeMsg;
2427 
2428  _SEH2_TRY
2429  {
2430  ProbeForRead(UnsafeMsgInfo, sizeof(MSG), 1);
2431  RtlCopyMemory(&SafeMsg, UnsafeMsgInfo, sizeof(MSG));
2432  }
2434  {
2436  _SEH2_YIELD(return FALSE);
2437  }
2438  _SEH2_END;
2439 
2441 
2442  Res = IntDispatchMessage(&SafeMsg);
2443 
2444  UserLeave();
2445  return Res;
2446 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
LRESULT FASTCALL IntDispatchMessage(PMSG pMsg)
Definition: message.c:841
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
_SEH2_TRY
Definition: create.c:4226
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
_SEH2_END
Definition: create.c:4400
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
LONG_PTR LRESULT
Definition: windef.h:209

Referenced by DispatchMessageA(), and DispatchMessageW().

◆ NtUserDragDetect()

BOOL APIENTRY NtUserDragDetect ( HWND  hWnd,
POINT  pt 
)

Functions

Definition at line 2156 of file message.c.

2159 {
2160  MSG msg;
2161  RECT rect;
2162  ULONG wDragWidth, wDragHeight;
2164 
2165  TRACE("Enter NtUserDragDetect(%p)\n", hWnd);
2167 
2168  wDragWidth = UserGetSystemMetrics(SM_CXDRAG);
2169  wDragHeight= UserGetSystemMetrics(SM_CYDRAG);
2170 
2171  rect.left = pt.x - wDragWidth;
2172  rect.right = pt.x + wDragWidth;
2173 
2174  rect.top = pt.y - wDragHeight;
2175  rect.bottom = pt.y + wDragHeight;
2176 
2178 
2179  for (;;)
2180  {
2184  {
2185  if ( msg.message == WM_LBUTTONUP )
2186  {
2188  RETURN( FALSE);
2189  }
2190  if ( msg.message == WM_MOUSEMOVE )
2191  {
2192  POINT tmp;
2193  tmp.x = (short)LOWORD(msg.lParam);
2194  tmp.y = (short)HIWORD(msg.lParam);
2195  if( !RECTL_bPointInRect( &rect, tmp.x, tmp.y ) )
2196  {
2198  RETURN( TRUE);
2199  }
2200  }
2201  if ( msg.message == WM_KEYDOWN )
2202  {
2203  if ( msg.wParam == VK_ESCAPE )
2204  {
2206  RETURN( TRUE);
2207  }
2208  }
2209  if ( msg.message == WM_QUEUESYNC )
2210  {
2211  co_HOOK_CallHooks( WH_CBT, HCBT_QS, 0, 0 );
2212  }
2213  }
2214  co_IntWaitMessage(NULL, 0, 0);
2215  }
2216  RETURN( FALSE);
2217 
2218 CLEANUP:
2219  TRACE("Leave NtUserDragDetect, ret=%i\n",_ret_);
2220  UserLeave();
2221  END_CLEANUP;
2222 }
#define TRUE
Definition: types.h:120
#define CLEANUP
Definition: ntuser.h:5
#define WM_MOUSEFIRST
Definition: winuser.h:1756
long y
Definition: polytest.cpp:48
#define RETURN(value)
Definition: ntuser.h:4
long x
Definition: polytest.cpp:48
#define pt(x, y)
Definition: drawing.c:79
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define WM_QUEUESYNC
Definition: winuser.h:1621
HWND hWnd
Definition: settings.c:17
#define VK_ESCAPE
Definition: winuser.h:2189
& rect
Definition: startmenu.cpp:1413
BOOL FASTCALL co_IntWaitMessage(PWND Window, UINT MsgFilterMin, UINT MsgFilterMax)
Definition: message.c:1131
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define WM_KEYFIRST
Definition: winuser.h:1696
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define WM_KEYDOWN
Definition: winuser.h:1697
#define SM_CXDRAG
Definition: winuser.h:1018
#define WH_CBT
Definition: winuser.h:35
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:180
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
#define TRACE(s)
Definition: solgame.cpp:4
HWND FASTCALL co_UserSetCapture(HWND hWnd)
Definition: focus.c:1340
#define WM_MOUSELAST
Definition: winuser.h:1783
#define DECLARE_RETURN(type)
Definition: ntuser.h:3
#define WM_KEYLAST
Definition: winuser.h:1710
#define HCBT_QS
Definition: winuser.h:57
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1103
FORCEINLINE BOOL RECTL_bPointInRect(_In_ const RECTL *prcl, _In_ INT x, _In_ INT y)
Definition: rect.h:52
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
BOOL APIENTRY co_IntGetPeekMessage(PMSG pMsg, HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg, BOOL bGMSG)
Definition: message.c:1177
#define WM_LBUTTONUP
Definition: winuser.h:1759
#define WM_MOUSEMOVE
Definition: winuser.h:1757
#define msg(x)
Definition: auth_time.c:54
#define HIWORD(l)
Definition: typedefs.h:246
unsigned int ULONG
Definition: retypes.h:1
#define SM_CYDRAG
Definition: winuser.h:1019
#define PM_REMOVE
Definition: winuser.h:1182
#define LOWORD(l)
Definition: pedump.c:82
#define END_CLEANUP
Definition: ntuser.h:6

Referenced by DragDetect().

◆ NtUserGetMessage()

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

Definition at line 2293 of file message.c.

2297 {
2298  MSG Msg;
2299  BOOL Ret;
2300 
2301  if ( (MsgFilterMin|MsgFilterMax) & ~WM_MAXIMUM )
2302  {
2304  return FALSE;
2305  }
2306 
2308 
2309  RtlZeroMemory(&Msg, sizeof(MSG));
2310 
2311  Ret = co_IntGetPeekMessage(&Msg, hWnd, MsgFilterMin, MsgFilterMax, PM_REMOVE, TRUE);
2312 
2313  UserLeave();
2314 
2315  if (Ret)
2316  {
2317  _SEH2_TRY
2318  {
2319  ProbeForWrite(pMsg, sizeof(MSG), 1);
2320  RtlCopyMemory(pMsg, &Msg, sizeof(MSG));
2321  }
2323  {
2325  Ret = FALSE;
2326  }
2327  _SEH2_END;
2328  }
2329 
2330  if ((INT)Ret != -1)
2331  Ret = Ret ? (WM_QUIT != pMsg->message) : FALSE;
2332 
2333  return Ret;
2334 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
HWND hWnd
Definition: settings.c:17
#define WM_QUIT
Definition: winuser.h:1605
struct @1604 Msg[]
int32_t INT
Definition: typedefs.h:57
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4226
unsigned int BOOL
Definition: ntddk_ex.h:94
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
#define WM_MAXIMUM
Definition: undocuser.h:62
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
_SEH2_END
Definition: create.c:4400
BOOL APIENTRY co_IntGetPeekMessage(PMSG pMsg, HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg, BOOL bGMSG)
Definition: message.c:1177
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define PM_REMOVE
Definition: winuser.h:1182
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
UINT message
Definition: winuser.h:3090
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

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

2493 {
2494  LRESULT lResult = 0;
2495  BOOL Ret = FALSE;
2496  PWND Window = NULL;
2498 
2500 
2501  switch(dwType)
2502  {
2503  case FNID_SCROLLBAR:
2504  {
2505  lResult = ScrollBarWndProc(hWnd, Msg, wParam, lParam);
2506  break;
2507  }
2508  case FNID_DESKTOP:
2509  {
2511  if (Window)
2512  {
2513  //ERR("FNID_DESKTOP IN\n");
2514  Ret = DesktopWindowProc(Window, Msg, wParam, lParam, &lResult);
2515  //ERR("FNID_DESKTOP OUT\n");
2516  }
2517  break;
2518  }
2519  case FNID_MENU:
2520  {
2522  if (Window)
2523  {
2524  Ret = PopupMenuWndProc( Window, Msg, wParam, lParam, &lResult);
2525  }
2526  break;
2527  }
2528  case FNID_MESSAGEWND:
2529  {
2531  if (Window)
2532  {
2533  Ret = !UserMessageWindowProc(Window, Msg, wParam, lParam, &lResult);
2534  }
2535  break;
2536  }
2537  case FNID_DEFWINDOWPROC:
2538  /* Validate input */
2539  if (hWnd)
2540  {
2542  if (!Window)
2543  {
2544  UserLeave();
2545  return FALSE;
2546  }
2547  UserRefObjectCo(Window, &Ref);
2548  }
2549  lResult = IntDefWindowProc(Window, Msg, wParam, lParam, Ansi);
2550  Ret = TRUE;
2551  if (hWnd)
2553  break;
2556  break;
2558  {
2559  BROADCASTPARM parm, *retparam;
2560  DWORD_PTR RetVal = 0;
2561 
2562  if (ResultInfo)
2563  {
2564  _SEH2_TRY
2565  {
2566  ProbeForWrite((PVOID)ResultInfo, sizeof(BROADCASTPARM), 1);
2567  RtlCopyMemory(&parm, (PVOID)ResultInfo, sizeof(BROADCASTPARM));
2568  }
2570  {
2571  _SEH2_YIELD(break);
2572  }
2573  _SEH2_END;
2574  }
2575  else
2576  break;
2577 
2578  if ( parm.recipients & BSM_ALLDESKTOPS ||
2579  parm.recipients == BSM_ALLCOMPONENTS )
2580  {
2581  PLIST_ENTRY DesktopEntry;
2582  PDESKTOP rpdesk;
2583  HWND *List, hwndDenied = NULL;
2584  HDESK hDesk = NULL;
2585  PWND pwnd, pwndDesk;
2586  ULONG i;
2587  UINT fuFlags;
2588 
2589  for (DesktopEntry = InputWindowStation->DesktopListHead.Flink;
2590  DesktopEntry != &InputWindowStation->DesktopListHead;
2591  DesktopEntry = DesktopEntry->Flink)
2592  {
2593  rpdesk = CONTAINING_RECORD(DesktopEntry, DESKTOP, ListEntry);
2594  pwndDesk = rpdesk->pDeskInfo->spwnd;
2595  List = IntWinListChildren(pwndDesk);
2596 
2597  if (parm.flags & BSF_QUERY)
2598  {
2599  if (List != NULL)
2600  {
2601  if (parm.flags & BSF_FORCEIFHUNG || parm.flags & BSF_NOHANG)
2602  {
2603  fuFlags = SMTO_ABORTIFHUNG;
2604  }
2605  else if (parm.flags & BSF_NOTIMEOUTIFNOTHUNG)
2606  {
2607  fuFlags = SMTO_NOTIMEOUTIFNOTHUNG;
2608  }
2609  else
2610  {
2611  fuFlags = SMTO_NORMAL;
2612  }
2614  Msg,
2615  wParam,
2616  lParam,
2617  fuFlags,
2618  2000,
2619  &RetVal);
2620  Ret = TRUE;
2621  for (i = 0; List[i]; i++)
2622  {
2623  pwnd = UserGetWindowObject(List[i]);
2624  if (!pwnd) continue;
2625 
2626  if ( pwnd->fnid == FNID_MENU ||
2628  continue;
2629 
2630  if ( parm.flags & BSF_IGNORECURRENTTASK )
2631  {
2632  if ( pwnd->head.pti == gptiCurrent )
2633  continue;
2634  }
2636  Msg,
2637  wParam,
2638  lParam,
2639  fuFlags,
2640  2000,
2641  &RetVal);
2642 
2643  if (!RetVal && EngGetLastError() == ERROR_TIMEOUT)
2644  {
2645  if (!(parm.flags & BSF_FORCEIFHUNG))
2646  Ret = FALSE;
2647  }
2648  if (RetVal == BROADCAST_QUERY_DENY)
2649  {
2650  hwndDenied = List[i];
2651  hDesk = UserHMGetHandle(pwndDesk);
2652  Ret = FALSE;
2653  }
2654  }
2656  _SEH2_TRY
2657  {
2658  retparam = (PBROADCASTPARM) ResultInfo;
2659  retparam->hDesk = hDesk;
2660  retparam->hWnd = hwndDenied;
2661  }
2663  {
2664  _SEH2_YIELD(break);
2665  }
2666  _SEH2_END;
2667  if (!Ret) break; // Have a hit! Let everyone know!
2668  }
2669  }
2670  else if (parm.flags & BSF_POSTMESSAGE)
2671  {
2672  if (List != NULL)
2673  {
2675 
2676  for (i = 0; List[i]; i++)
2677  {
2678  pwnd = UserGetWindowObject(List[i]);
2679  if (!pwnd) continue;
2680 
2681  if ( pwnd->fnid == FNID_MENU ||
2683  continue;
2684 
2685  if ( parm.flags & BSF_IGNORECURRENTTASK )
2686  {
2687  if ( pwnd->head.pti == gptiCurrent )
2688  continue;
2689  }
2691  }
2693  }
2694  Ret = TRUE;
2695  }
2696  else
2697  {
2698  if (List != NULL)
2699  {
2701 
2702  for (i = 0; List[i]; i++)
2703  {
2704  pwnd = UserGetWindowObject(List[i]);
2705  if (!pwnd) continue;
2706 
2707  if ( pwnd->fnid == FNID_MENU ||
2709  continue;
2710 
2711  if ( parm.flags & BSF_IGNORECURRENTTASK )
2712  {
2713  if ( pwnd->head.pti == gptiCurrent )
2714  continue;
2715  }
2717  }
2719  }
2720  Ret = TRUE;
2721  }
2722  }
2723  }
2724  else if (parm.recipients & BSM_APPLICATIONS)
2725  {
2726  HWND *List, hwndDenied = NULL;
2727  HDESK hDesk = NULL;
2728  PWND pwnd, pwndDesk;
2729  ULONG i;
2730  UINT fuFlags;
2731 
2732  pwndDesk = UserGetDesktopWindow();
2733  List = IntWinListChildren(pwndDesk);
2734 
2735  if (parm.flags & BSF_QUERY)
2736  {
2737  if (List != NULL)
2738  {
2739  if (parm.flags & BSF_FORCEIFHUNG || parm.flags & BSF_NOHANG)
2740  {
2741  fuFlags = SMTO_ABORTIFHUNG;
2742  }
2743  else if (parm.flags & BSF_NOTIMEOUTIFNOTHUNG)
2744  {
2745  fuFlags = SMTO_NOTIMEOUTIFNOTHUNG;
2746  }
2747  else
2748  {
2749  fuFlags = SMTO_NORMAL;
2750  }
2752  Msg,
2753  wParam,
2754  lParam,
2755  fuFlags,
2756  2000,
2757  &RetVal);
2758  Ret = TRUE;
2759  for (i = 0; List[i]; i++)
2760  {
2761  pwnd = UserGetWindowObject(List[i]);
2762  if (!pwnd) continue;
2763 
2764  if ( pwnd->fnid == FNID_MENU ||
2766  continue;
2767 
2768  if ( parm.flags & BSF_IGNORECURRENTTASK )
2769  {
2770  if ( pwnd->head.pti == gptiCurrent )
2771  continue;
2772  }
2774  Msg,
2775  wParam,
2776  lParam,
2777  fuFlags,
2778  2000,
2779  &RetVal);
2780 
2781  if (!RetVal && EngGetLastError() == ERROR_TIMEOUT)
2782  {
2783  if (!(parm.flags & BSF_FORCEIFHUNG))
2784  Ret = FALSE;
2785  }
2786  if (RetVal == BROADCAST_QUERY_DENY)
2787  {
2788  hwndDenied = List[i];
2789  hDesk = UserHMGetHandle(pwndDesk);
2790  Ret = FALSE;
2791  }
2792  }
2794  _SEH2_TRY
2795  {
2796  retparam = (PBROADCASTPARM) ResultInfo;
2797  retparam->hDesk = hDesk;
2798  retparam->hWnd = hwndDenied;
2799  }
2801  {
2802  _SEH2_YIELD(break);
2803  }
2804  _SEH2_END;
2805  }
2806  }
2807  else if (parm.flags & BSF_POSTMESSAGE)
2808  {
2809  if (List != NULL)
2810  {
2812 
2813  for (i = 0; List[i]; i++)
2814  {
2815  pwnd = UserGetWindowObject(List[i]);
2816  if (!pwnd) continue;
2817 
2818  if ( pwnd->fnid == FNID_MENU ||
2820  continue;
2821 
2822  if ( parm.flags & BSF_IGNORECURRENTTASK )
2823  {
2824  if ( pwnd->head.pti == gptiCurrent )
2825  continue;
2826  }
2828  }
2830  }
2831  Ret = TRUE;
2832  }
2833  else
2834  {
2835  if (List != NULL)
2836  {
2838 
2839  for (i = 0; List[i]; i++)
2840  {
2841  pwnd = UserGetWindowObject(List[i]);
2842  if (!pwnd) continue;
2843 
2844  if ( pwnd->fnid == FNID_MENU ||
2846  continue;
2847 
2848  if ( parm.flags & BSF_IGNORECURRENTTASK )
2849  {
2850  if ( pwnd->head.pti == gptiCurrent )
2851  continue;
2852  }
2854  }
2856  }
2857  Ret = TRUE;
2858  }
2859  }
2860  }
2861  break;
2863  {
2864  CALL_BACK_INFO CallBackInfo;
2865  ULONG_PTR uResult;
2866 
2867  _SEH2_TRY
2868  {
2869  ProbeForRead((PVOID)ResultInfo, sizeof(CALL_BACK_INFO), 1);
2870  RtlCopyMemory(&CallBackInfo, (PVOID)ResultInfo, sizeof(CALL_BACK_INFO));
2871  }
2873  {
2874  _SEH2_YIELD(break);
2875  }
2876  _SEH2_END;
2877 
2879  {
2881  break;
2882  }
2883 
2885  CallBackInfo.CallBack, CallBackInfo.Context, &uResult)))
2886  {
2887  ERR("Callback failure!\n");
2888  }
2889  }
2890  break;
2891  case FNID_SENDMESSAGE:
2892  {
2893  lResult = co_IntDoSendMessage(hWnd, Msg, wParam, lParam, 0);
2894  Ret = TRUE;
2895 
2896  if (ResultInfo)
2897  {
2898  _SEH2_TRY
2899  {
2900  ProbeForWrite((PVOID)ResultInfo, sizeof(ULONG_PTR), 1);
2901  RtlCopyMemory((PVOID)ResultInfo, &lResult, sizeof(ULONG_PTR));
2902  }
2904  {
2905  Ret = FALSE;
2906  _SEH2_YIELD(break);
2907  }
2908  _SEH2_END;
2909  }
2910  break;
2911  }
2912  case FNID_SENDMESSAGEFF:
2914  {
2915  DOSENDMESSAGE dsm, *pdsm = (PDOSENDMESSAGE)ResultInfo;
2916  if (ResultInfo)
2917  {
2918  _SEH2_TRY
2919  {
2920  ProbeForRead(pdsm, sizeof(DOSENDMESSAGE), 1);
2921  RtlCopyMemory(&dsm, pdsm, sizeof(DOSENDMESSAGE));
2922  }
2924  {
2925  _SEH2_YIELD(break);
2926  }
2927  _SEH2_END;
2928  }
2929 
2930  Ret = co_IntDoSendMessage( hWnd, Msg, wParam, lParam, pdsm ? &dsm : NULL );
2931 
2932  if (pdsm)
2933  {
2934  _SEH2_TRY
2935  {
2936  ProbeForWrite(pdsm, sizeof(DOSENDMESSAGE), 1);
2937  RtlCopyMemory(pdsm, &dsm, sizeof(DOSENDMESSAGE));
2938  }
2940  {
2941  Ret = FALSE;
2942  _SEH2_YIELD(break);
2943  }
2944  _SEH2_END;
2945  }
2946  break;
2947  }
2948  // CallNextHook bypass.
2949  case FNID_CALLWNDPROC:
2950  case FNID_CALLWNDPROCRET:
2951  {
2952  PTHREADINFO pti;
2954  PHOOK NextObj, Hook;
2955 
2956  pti = GetW32ThreadInfo();
2957 
2958  Hook = pti->sphkCurrent;
2959 
2960  if (!Hook) break;
2961 
2962  NextObj = Hook->phkNext;
2963  ClientInfo = pti->pClientInfo;
2964  _SEH2_TRY
2965  {
2966  ClientInfo->phkCurrent = NextObj;
2967  }
2969  {
2970  ClientInfo = NULL;
2971  }
2972  _SEH2_END;
2973 
2974  if (!ClientInfo || !NextObj) break;
2975 
2976  NextObj->phkNext = IntGetNextHook(NextObj);
2977 
2978  if ( Hook->HookId == WH_CALLWNDPROC)
2979  {
2980  CWPSTRUCT CWP;
2981  CWP.hwnd = hWnd;
2982  CWP.message = Msg;
2983  CWP.wParam = wParam;
2984  CWP.lParam = lParam;
2985  TRACE("WH_CALLWNDPROC: Hook %p NextHook %p\n", Hook, NextObj);
2986 
2987  lResult = co_IntCallHookProc( Hook->HookId,
2988  HC_ACTION,
2989  ((ClientInfo->CI_flags & CI_CURTHPRHOOK) ? 1 : 0),
2990  (LPARAM)&CWP,
2991  Hook->Proc,
2992  Hook->ihmod,
2993  Hook->offPfn,
2994  Hook->Ansi,
2995  &Hook->ModuleName);
2996  }
2997  else
2998  {
2999  CWPRETSTRUCT CWPR;
3000  CWPR.hwnd = hWnd;
3001  CWPR.message = Msg;
3002  CWPR.wParam = wParam;
3003  CWPR.lParam = lParam;
3004  CWPR.lResult = ClientInfo->dwHookData;
3005 
3006  lResult = co_IntCallHookProc( Hook->HookId,
3007  HC_ACTION,
3008  ((ClientInfo->CI_flags & CI_CURTHPRHOOK) ? 1 : 0),
3009  (LPARAM)&CWPR,
3010  Hook->Proc,
3011  Hook->ihmod,
3012  Hook->offPfn,
3013  Hook->Ansi,
3014  &Hook->ModuleName);
3015  }
3016  }
3017  break;
3018  }
3019 
3020  switch(dwType)
3021  {
3022  case FNID_DEFWINDOWPROC:
3023  case FNID_CALLWNDPROC:
3024  case FNID_CALLWNDPROCRET:
3025  case FNID_SCROLLBAR:
3026  case FNID_DESKTOP:
3027  case FNID_MENU:
3028  if (ResultInfo)
3029  {
3030  _SEH2_TRY
3031  {
3032  ProbeForWrite((PVOID)ResultInfo, sizeof(LRESULT), 1);
3033  RtlCopyMemory((PVOID)ResultInfo, &lResult, sizeof(LRESULT));
3034  }
3036  {
3037  Ret = FALSE;
3038  }
3039  _SEH2_END;
3040  }
3041  break;
3042  default:
3043  break;
3044  }
3045 
3046  UserLeave();
3047 
3048  return Ret;
3049 }
LRESULT FASTCALL IntDefWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Ansi)
Definition: defwnd.c:532
#define BSM_ALLCOMPONENTS
Definition: dbt.h:47
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1346
#define BSF_FORCEIFHUNG
Definition: dbt.h:54
WPARAM wParam
Definition: winuser.h:2994
#define TRUE
Definition: types.h:120
ENGAPI ULONG APIENTRY EngGetLastError(VOID)
Definition: error.c:12
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
BOOL WINAPI PopupMenuWndProc(PWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: menu.c:4628
PDESKTOPINFO pDeskInfo
Definition: desktop.h:8
#define BSF_IGNORECURRENTTASK
Definition: dbt.h:55
#define BROADCAST_QUERY_DENY
Definition: winuser.h:178
PHOOK FASTCALL IntGetNextHook(PHOOK Hook)
Definition: hook.c:996
#define ERROR_TIMEOUT
Definition: winerror.h:941
PWINSTATION_OBJECT InputWindowStation
Definition: winsta.c:21
HDESK hDesk
Definition: ntuser.h:1063
DWORD recipients
Definition: ntuser.h:1062
#define FNID_MENU
Definition: ntuser.h:823
struct tagHOOK * phkNext
Definition: ntuser.h:218
BOOL FASTCALL UserSendNotifyMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:2037
#define BSF_NOTIMEOUTIFNOTHUNG
Definition: dbt.h:57
#define BSF_QUERY
Definition: dbt.h:59
HWND hWnd
Definition: settings.c:17
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:25
#define FNID_DEFWINDOWPROC
Definition: ntuser.h:825
LPARAM lParam
Definition: winuser.h:2993
LIST_ENTRY DesktopListHead
Definition: winsta.h:18
struct @1604 Msg[]
BOOL FASTCALL DesktopWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: desktop.c:1401
#define BSF_NOHANG
Definition: dbt.h:56
#define BSF_POSTMESSAGE
Definition: dbt.h:58
RTL_ATOM atomClassName
Definition: ntuser.h:536
PSERVERINFO gpsi
Definition: main.c:27
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
WPARAM wParam
Definition: combotst.c:138
#define SMTO_ABORTIFHUNG
Definition: winuser.h:1209
#define SMTO_NORMAL
Definition: winuser.h:1211
_SEH2_TRY
Definition: create.c:4226
#define FNID_MESSAGEWND
Definition: ntuser.h:826
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:779
uint32_t ULONG_PTR
Definition: typedefs.h:64
CLIENT_DATA ClientInfo
Definition: window.c:28
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
struct _BROADCASTPARM * PBROADCASTPARM
DWORD fnid
Definition: ntuser.h:673
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FNID_DESKTOP
Definition: ntuser.h:824
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:38
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
THRDESKHEAD head
Definition: ntuser.h:659
Definition: object.h:3
static LRESULT FASTCALL co_IntDoSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, PDOSENDMESSAGE dsm)
Definition: message.c:1951
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
PTHREADINFO gptiCurrent
Definition: ntuser.c:15
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define FNID_SENDMESSAGE
Definition: ntuser.h:844
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
#define FNID_CALLWNDPROCRET
Definition: ntuser.h:839
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
int HookId
Definition: ntuser.h:219
struct _LIST_ENTRY * Flink
Definition: typedefs.h:120
#define FNID_SENDMESSAGEFF
Definition: ntuser.h:845
#define TRACE(s)
Definition: solgame.cpp:4
SENDASYNCPROC CallBack
Definition: callback.h:48
BOOLEAN Ansi
Definition: ntuser.h:228
INT_PTR ihmod
Definition: ntuser.h:222
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
UNICODE_STRING ModuleName
Definition: ntuser.h:229
LIST_ENTRY List
Definition: psmgr.c:57
LRESULT FASTCALL co_IntSendMessageTimeout(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult)
Definition: message.c:1654
LPARAM lParam
Definition: winuser.h:3000
#define FNID_SENDMESSAGECALLBACK
Definition: ntuser.h:852
HOOKPROC Proc
Definition: ntuser.h:227
WPARAM wParam
Definition: winuser.h:3001
#define ICLS_SWITCH
Definition: ntuser.h:893
struct _CLIENTINFO * pClientInfo
Definition: win32.h:93
BOOL FASTCALL UserMessageWindowProc(PWND pwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: desktop.c:1487
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1349
#define FNID_SENDNOTIFYMESSAGE
Definition: ntuser.h:851
UINT message
Definition: winuser.h:3002
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
DWORD flags
Definition: ntuser.h:1061
#define WH_CALLWNDPROC
Definition: winuser.h:34
#define CI_CURTHPRHOOK
Definition: ntuser.h:281
HWND *FASTCALL IntWinListChildren(PWND Window)
Definition: window.c:255
struct _WND * spwnd
Definition: ntuser.h:136
Definition: typedefs.h:118
struct tagHOOK * sphkCurrent
Definition: win32.h:117
uint32_t DWORD_PTR
Definition: typedefs.h:64
struct tagDOSENDMESSAGE * PDOSENDMESSAGE
#define FNID_CALLWNDPROC
Definition: ntuser.h:838
LRESULT APIENTRY ScrollBarWndProc(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: scrollbar.c:1176
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:657
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
#define FNID_BROADCASTSYSTEMMESSAGE
Definition: ntuser.h:849
_SEH2_END
Definition: create.c:4400
#define FNID_SCROLLBAR
Definition: ntuser.h:821
#define HC_ACTION
Definition: winuser.h:48
#define ERROR_MESSAGE_SYNC_ONLY
Definition: winerror.h:681
unsigned int UINT
Definition: ndis.h:50
#define BSM_ALLDESKTOPS
Definition: dbt.h:49
ULONG_PTR Context
Definition: callback.h:49
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define USERTAG_WINDOWLIST
Definition: tags.h:297
LONG_PTR LRESULT
Definition: windef.h:209
static int is_pointer_message(UINT message, WPARAM wparam)
Definition: message.c:99
LRESULT lResult
Definition: winuser.h:2992
LPARAM lParam
Definition: combotst.c:139
#define BSM_APPLICATIONS
Definition: dbt.h:48
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
#define FNID_SENDMESSAGEWTOOPTION
Definition: ntuser.h:847
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1013
LRESULT FASTCALL co_IntSendMessageWithCallBack(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, SENDASYNCPROC CompletionCallback, ULONG_PTR CompletionCallbackContext, ULONG_PTR *uResult)
Definition: message.c:1732
ULONG_PTR offPfn
Definition: ntuser.h:220
PCLS pcls
Definition: ntuser.h:684

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

2342 {
2343  MSG Msg;
2344  BOOL Ret;
2345 
2346  if ( RemoveMsg & PM_BADMSGFLAGS )
2347  {
2349  return FALSE;
2350  }
2351 
2353 
2354  RtlZeroMemory(&Msg, sizeof(MSG));
2355 
2356  Ret = co_IntGetPeekMessage(&Msg, hWnd, MsgFilterMin, MsgFilterMax, RemoveMsg, FALSE);
2357 
2358  UserLeave();
2359 
2360  if (Ret)
2361  {
2362  _SEH2_TRY
2363  {
2364  ProbeForWrite(pMsg, sizeof(MSG), 1);
2365  RtlCopyMemory(pMsg, &Msg, sizeof(MSG));
2366  }
2368  {
2370  Ret = FALSE;
2371  }
2372  _SEH2_END;
2373  }
2374 
2375  return Ret;
2376 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
HWND hWnd
Definition: settings.c:17
struct @1604 Msg[]
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4226
unsigned int BOOL
Definition: ntddk_ex.h:94
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
_SEH2_END
Definition: create.c:4400
BOOL APIENTRY co_IntGetPeekMessage(PMSG pMsg, HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg, BOOL bGMSG)
Definition: message.c:1177
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
#define PM_BADMSGFLAGS
Definition: message.c:15

Referenced by PeekMessageWorker().

◆ NtUserPostMessage()

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

Definition at line 2225 of file message.c.

2229 {
2230  BOOL ret;
2231 
2233 
2235 
2236  UserLeave();
2237 
2238  return ret;
2239 }
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1346
HWND hWnd
Definition: settings.c:17
struct @1604 Msg[]
WPARAM wParam
Definition: combotst.c:138
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
int ret
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
LPARAM lParam
Definition: combotst.c:139

Referenced by PostMessageA(), and PostMessageW().

◆ NtUserPostThreadMessage()

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

Definition at line 2242 of file message.c.

2246 {
2247  BOOL ret = FALSE;
2248  PETHREAD peThread;
2249  PTHREADINFO pThread;
2250  NTSTATUS Status;
2251 
2253 
2254  Status = PsLookupThreadByThreadId(UlongToHandle(idThread), &peThread);
2255 
2256  if ( Status == STATUS_SUCCESS )
2257  {
2258  pThread = (PTHREADINFO)peThread->Tcb.Win32Thread;
2259  if( !pThread ||
2260  !pThread->MessageQueue ||
2261  (pThread->TIF_flags & TIF_INCLEANUP))
2262  {
2263  ObDereferenceObject( peThread );
2264  goto exit;
2265  }
2266  ret = UserPostThreadMessage( pThread, Msg, wParam, lParam);
2267  ObDereferenceObject( peThread );
2268  }
2269  else
2270  {
2272  }
2273 exit:
2274  UserLeave();
2275  return ret;
2276 }
NTSTATUS NTAPI PsLookupThreadByThreadId(IN HANDLE ThreadId, OUT PETHREAD *Thread)
Definition: thread.c:643
FLONG TIF_flags
Definition: win32.h:94
LONG NTSTATUS
Definition: precomp.h:26
KTHREAD Tcb
Definition: pstypes.h:1042
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
struct @1604 Msg[]
WPARAM wParam
Definition: combotst.c:138
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL FASTCALL UserPostThreadMessage(PTHREADINFO pti, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1309
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
struct _THREADINFO * PTHREADINFO
Definition: ntwin32.h:6
#define UlongToHandle(ul)
Definition: basetsd.h:97
int ret
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
Status
Definition: gdiplustypes.h:24
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:88
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
PVOID Win32Thread
Definition: ketypes.h:1756
void exit(int exitcode)
Definition: _exit.c:33
return STATUS_SUCCESS
Definition: btrfs.c:3014
LPARAM lParam
Definition: combotst.c:139
#define TIF_INCLEANUP
Definition: ntuser.h:240

Referenced by PostThreadMessageA(), and PostThreadMessageW().

◆ NtUserTranslateMessage()

BOOL APIENTRY NtUserTranslateMessage ( LPMSG  lpMsg,