ReactOS  0.4.14-dev-833-g5f692ed
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)
 
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)
 
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 Unknown2)
 

Variables

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

Macro Definition Documentation

◆ INFINITE

#define INFINITE   0xFFFFFFFF

Definition at line 2889 of file message.c.

◆ MMS_FLAG_READ

#define MMS_FLAG_READ   0x01

Definition at line 110 of file message.c.

◆ MMS_FLAG_READWRITE

#define MMS_FLAG_READWRITE   (MMS_FLAG_READ | MMS_FLAG_WRITE)

Definition at line 112 of file message.c.

◆ MMS_FLAG_WRITE

#define MMS_FLAG_WRITE   0x02

Definition at line 111 of file message.c.

◆ MMS_SIZE_LPARAMSZ

#define MMS_SIZE_LPARAMSZ   -3

Definition at line 108 of file message.c.

◆ MMS_SIZE_SPECIAL

#define MMS_SIZE_SPECIAL   -4

Definition at line 109 of file message.c.

◆ MMS_SIZE_WPARAM

#define MMS_SIZE_WPARAM   -1

Definition at line 106 of file message.c.

◆ MMS_SIZE_WPARAMWCHAR

#define MMS_SIZE_WPARAMWCHAR   -2

Definition at line 107 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 2890 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 1789 of file message.c.

1794 {
1795  LRESULT Result = TRUE;
1796  NTSTATUS Status;
1797  PWND Window = NULL;
1798  MSG UserModeMsg, KernelModeMsg;
1799  PMSGMEMORY MsgMemoryEntry;
1800  PTHREADINFO ptiSendTo;
1801 
1802  if (hWnd != HWND_BROADCAST && hWnd != HWND_TOPMOST)
1803  {
1805  if ( !Window )
1806  {
1807  return 0;
1808  }
1809  }
1810 
1811  /* Check for an exiting window. */
1812  if (Window && Window->state & WNDS_DESTROYED)
1813  {
1814  ERR("co_IntDoSendMessage Window Exiting!\n");
1815  }
1816 
1817  /* See if the current thread can handle this message */
1818  ptiSendTo = IntSendTo(Window, gptiCurrent, Msg);
1819 
1820  // If broadcasting or sending to another thread, save the users data.
1821  if (!Window || ptiSendTo )
1822  {
1823  UserModeMsg.hwnd = hWnd;
1824  UserModeMsg.message = Msg;
1825  UserModeMsg.wParam = wParam;
1826  UserModeMsg.lParam = lParam;
1827  MsgMemoryEntry = FindMsgMemory(UserModeMsg.message);
1828  Status = CopyMsgToKernelMem(&KernelModeMsg, &UserModeMsg, MsgMemoryEntry);
1829  if (!NT_SUCCESS(Status))
1830  {
1832  return (dsm ? 0 : -1);
1833  }
1834  }
1835  else
1836  {
1837  KernelModeMsg.hwnd = hWnd;
1838  KernelModeMsg.message = Msg;
1839  KernelModeMsg.wParam = wParam;
1840  KernelModeMsg.lParam = lParam;
1841  }
1842 
1843  if (!dsm)
1844  {
1845  Result = co_IntSendMessage( KernelModeMsg.hwnd,
1846  KernelModeMsg.message,
1847  KernelModeMsg.wParam,
1848  KernelModeMsg.lParam );
1849  }
1850  else
1851  {
1852  Result = co_IntSendMessageTimeout( KernelModeMsg.hwnd,
1853  KernelModeMsg.message,
1854  KernelModeMsg.wParam,
1855  KernelModeMsg.lParam,
1856  dsm->uFlags,
1857  dsm->uTimeout,
1858  &dsm->Result );
1859  }
1860 
1861  if (!Window || ptiSendTo )
1862  {
1863  Status = CopyMsgToUserMem(&UserModeMsg, &KernelModeMsg);
1864  if (!NT_SUCCESS(Status))
1865  {
1867  return(dsm ? 0 : -1);
1868  }
1869  }
1870 
1871  return (LRESULT)Result;
1872 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
static PMSGMEMORY FASTCALL FindMsgMemory(UINT Msg)
Definition: message.c:145
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
WPARAM wParam
Definition: combotst.c:138
Definition: window.c:28
PTHREADINFO FASTCALL IntSendTo(PWND Window, PTHREADINFO ptiCur, UINT Msg)
Definition: message.c:1170
static NTSTATUS FASTCALL CopyMsgToUserMem(MSG *UserModeMsg, MSG *KernelModeMsg)
Definition: message.c:475
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:418
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:1492
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1284
ULONG_PTR Result
Definition: ntuser.h:2616
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
struct @1587 Msg[]
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 1018 of file message.c.

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

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

◆ co_IntPeekMessage()

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

Definition at line 806 of file message.c.

813 {
814  PTHREADINFO pti;
815  BOOL RemoveMessages;
816  UINT ProcessMask;
817  BOOL Hit = FALSE;
818 
820 
821  RemoveMessages = RemoveMsg & PM_REMOVE;
822  ProcessMask = HIWORD(RemoveMsg);
823 
824  /* Hint, "If wMsgFilterMin and wMsgFilterMax are both zero, PeekMessage returns
825  all available messages (that is, no range filtering is performed)". */
826  if (!ProcessMask) ProcessMask = (QS_ALLPOSTMESSAGE|QS_ALLINPUT);
827 
828  IdlePong();
829 
830  do
831  {
832  /* Update the last message-queue access time */
833  pti->pcti->timeLastRead = EngGetTickCount32();
834 
835  // Post mouse moves while looping through peek messages.
836  if (pti->MessageQueue->QF_flags & QF_MOUSEMOVED)
837  {
839  }
840 
841  /* Dispatch sent messages here. */
842  while ( co_MsqDispatchOneSentMessage(pti) )
843  {
844  /* if some PM_QS* flags were specified, only handle sent messages from now on */
845  if (HIWORD(RemoveMsg) && !bGMSG) Hit = TRUE; // wine does this; ProcessMask = QS_SENDMESSAGE;
846  }
847  if (Hit) return FALSE;
848 
849  /* Clear changed bits so we can wait on them if we don't find a message */
850  if (ProcessMask & QS_POSTMESSAGE)
851  {
852  pti->pcti->fsChangeBits &= ~(QS_POSTMESSAGE | QS_HOTKEY | QS_TIMER);
853  if (MsgFilterMin == 0 && MsgFilterMax == 0) // Wine hack does this; ~0U)
854  {
855  pti->pcti->fsChangeBits &= ~QS_ALLPOSTMESSAGE;
856  }
857  }
858 
859  if (ProcessMask & QS_INPUT)
860  {
861  pti->pcti->fsChangeBits &= ~QS_INPUT;
862  }
863 
864  /* Now check for normal messages. */
865  if (( (ProcessMask & QS_POSTMESSAGE) ||
866  (ProcessMask & QS_HOTKEY) ) &&
867  MsqPeekMessage( pti,
868  RemoveMessages,
869  Window,
870  MsgFilterMin,
871  MsgFilterMax,
872  ProcessMask,
873  ExtraInfo,
874  0,
875  Msg ))
876  {
877  goto GotMessage;
878  }
879 
880  /* Only check for quit messages if not posted messages pending. */
881  if (ProcessMask & QS_POSTMESSAGE && pti->QuitPosted)
882  {
883  /* According to the PSDK, WM_QUIT messages are always returned, regardless
884  of the filter specified */
885  Msg->hwnd = NULL;
886  Msg->message = WM_QUIT;
887  Msg->wParam = pti->exitCode;
888  Msg->lParam = 0;
889  if (RemoveMessages)
890  {
891  pti->QuitPosted = FALSE;
893  pti->pcti->fsWakeBits &= ~QS_ALLPOSTMESSAGE;
894  pti->pcti->fsChangeBits &= ~QS_ALLPOSTMESSAGE;
895  }
896  goto GotMessage;
897  }
898 
899  /* Check for hardware events. */
900  if ((ProcessMask & QS_INPUT) &&
902  RemoveMessages,
903  Window,
904  MsgFilterMin,
905  MsgFilterMax,
906  ProcessMask,
907  Msg))
908  {
909  goto GotMessage;
910  }
911 
912  /* Now check for System Event messages. */
913  {
914  LONG_PTR eExtraInfo;
915  MSG eMsg;
916  DWORD dwQEvent;
917  if (MsqPeekMessage( pti,
918  TRUE,
919  Window,
920  0,
921  0,
922  QS_EVENT,
923  &eExtraInfo,
924  &dwQEvent,
925  &eMsg ))
926  {
927  handle_internal_events( pti, Window, dwQEvent, eExtraInfo, &eMsg);
928  continue;
929  }
930  }
931 
932  /* Check for sent messages again. */
933  while ( co_MsqDispatchOneSentMessage(pti) )
934  {
935  if (HIWORD(RemoveMsg) && !bGMSG) Hit = TRUE;
936  }
937  if (Hit) return FALSE;
938 
939  /* Check for paint messages. */
940  if ((ProcessMask & QS_PAINT) &&
941  pti->cPaintsReady &&
943  MsgFilterMin,
944  MsgFilterMax,
945  pti,
946  Msg,
947  RemoveMessages))
948  {
949  goto GotMessage;
950  }
951 
952  /* This is correct, check for the current threads timers waiting to be
953  posted to this threads message queue. If any we loop again.
954  */
955  if ((ProcessMask & QS_TIMER) &&
957  {
958  continue;
959  }
960 
961  return FALSE;
962  }
963  while (TRUE);
964 
965 GotMessage:
966  /* Update the last message-queue access time */
967  pti->pcti->timeLastRead = EngGetTickCount32();
968  return TRUE;
969 }
static LRESULT handle_internal_events(PTHREADINFO pti, PWND pWnd, DWORD dwQEvent, LONG_PTR ExtraInfo, PMSG pMsg)
Definition: message.c:654
#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
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:545
#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
struct @1587 Msg[]
#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 1284 of file message.c.

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

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

◆ co_IntSendMessageNoWait()

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

Definition at line 1548 of file message.c.

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

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

◆ co_IntSendMessageTimeout()

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

Definition at line 1492 of file message.c.

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

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

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

1306 {
1308  PWND Window = NULL;
1309  PMSGMEMORY MsgMemoryEntry;
1310  INT lParamBufferSize;
1311  LPARAM lParamPacked;
1312  PTHREADINFO Win32Thread, ptiSendTo = NULL;
1313  ULONG_PTR Result = 0;
1316  BOOL DoCallBack = TRUE;
1317 
1318  if (!(Window = UserGetWindowObject(hWnd)))
1319  {
1320  TRACE("SendMessageTimeoutSingle: Invalid handle 0x%p!\n",hWnd);
1321  RETURN( FALSE);
1322  }
1323 
1324  UserRefObjectCo(Window, &Ref);
1325 
1326  Win32Thread = PsGetCurrentThreadWin32Thread();
1327 
1328  ptiSendTo = IntSendTo(Window, Win32Thread, Msg);
1329 
1330  if ( Msg >= WM_DDE_FIRST && Msg <= WM_DDE_LAST )
1331  {
1333  {
1334  ERR("Sending Exit DDE 0x%x\n",Msg);
1335  RETURN( FALSE);
1336  }
1337  }
1338 
1339  if ( !ptiSendTo )
1340  {
1341  if (Win32Thread->TIF_flags & TIF_INCLEANUP)
1342  {
1343  /* Never send messages to exiting threads */
1344  RETURN( FALSE);
1345  }
1346 
1347  if (Msg & 0x80000000)
1348  {
1349  TRACE("SMTS: Internal Message!\n");
1351  if (uResult) *uResult = Result;
1352  RETURN( TRUE);
1353  }
1354 
1355  // Only happens when calling the client!
1357 
1358  if ( Window->state & WNDS_SERVERSIDEWINDOWPROC )
1359  {
1360  TRACE("SMT: Server Side Window Procedure\n");
1361  // Handle it here. Safeguard against excessive recursions.
1362  if (IoGetRemainingStackSize() < PAGE_SIZE)
1363  {
1364  ERR("Server Callback Exceeded Stack!\n");
1365  RETURN( FALSE);
1366  }
1367  /* Return after server side call, IntCallWndProcRet will not be called. */
1368  switch(Window->fnid)
1369  {
1370  case FNID_DESKTOP:
1371  DoCallBack = !DesktopWindowProc(Window, Msg, wParam, lParam,(LRESULT*)&Result);
1372  break;
1373  case FNID_MESSAGEWND:
1375  break;
1376  case FNID_MENU:
1377  DoCallBack = !PopupMenuWndProc( Window, Msg, wParam, lParam,(LRESULT*)&Result);
1378  break;
1379  }
1380  if (!DoCallBack)
1381  {
1382  if (uResult) *uResult = Result;
1383  RETURN( TRUE);
1384  }
1385  }
1386  /* See if this message type is present in the table */
1387  MsgMemoryEntry = FindMsgMemory(Msg);
1388  if (NULL == MsgMemoryEntry)
1389  {
1390  lParamBufferSize = -1;
1391  }
1392  else
1393  {
1394  lParamBufferSize = MsgMemorySize(MsgMemoryEntry, wParam, lParam);
1395  // If zero, do not allow callback on client side to allocate a buffer!!!!! See CORE-7695.
1396  if (!lParamBufferSize) lParamBufferSize = -1;
1397  }
1398 
1399  if (! NT_SUCCESS(PackParam(&lParamPacked, Msg, wParam, lParam, FALSE)))
1400  {
1401  ERR("Failed to pack message parameters\n");
1402  RETURN( FALSE);
1403  }
1404 
1405  Result = (ULONG_PTR)co_IntCallWindowProc( Window->lpfnWndProc,
1406  !Window->Unicode,
1407  hWnd,
1408  Msg,
1409  wParam,
1410  lParamPacked,
1411  lParamBufferSize );
1412  if (uResult)
1413  {
1414  *uResult = Result;
1415  }
1416 
1417  if (! NT_SUCCESS(UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE)))
1418  {
1419  ERR("Failed to unpack message parameters\n");
1420  RETURN( TRUE);
1421  }
1422 
1423  // Only happens when calling the client!
1424  IntCallWndProcRet( Window, hWnd, Msg, wParam, lParam, (LRESULT *)uResult);
1425 
1426  RETURN( TRUE);
1427  }
1428 
1429  if (Window->state & WNDS_DESTROYED)
1430  {
1431  /* FIXME: Last error? */
1432  ERR("Attempted to send message to window %p that is being destroyed!\n", hWnd);
1433  RETURN( FALSE);
1434  }
1435 
1436  if ((uFlags & SMTO_ABORTIFHUNG) && MsqIsHung(ptiSendTo, 4 * MSQ_HUNG))
1437  {
1438  // FIXME: Set window hung and add to a list.
1439  /* FIXME: Set a LastError? */
1440  ERR("Window %p (%p) (pti %p) is hung!\n", hWnd, Window, ptiSendTo);
1441  RETURN( FALSE);
1442  }
1443 
1444  do
1445  {
1446  Status = co_MsqSendMessage( ptiSendTo,
1447  hWnd,
1448  Msg,
1449  wParam,
1450  lParam,
1451  uTimeout,
1452  (uFlags & SMTO_BLOCK),
1453  MSQ_NORMAL,
1454  uResult );
1455  }
1456  while ((Status == STATUS_TIMEOUT) &&
1457  (uFlags & SMTO_NOTIMEOUTIFNOTHUNG) &&
1458  !MsqIsHung(ptiSendTo, MSQ_HUNG)); // FIXME: Set window hung and add to a list.
1459 
1460  if (Status == STATUS_TIMEOUT)
1461  {
1462  if (0 && MsqIsHung(ptiSendTo, MSQ_HUNG))
1463  {
1464  TRACE("Let's go Ghost!\n");
1466  }
1467 /*
1468  * MSDN says:
1469  * Microsoft Windows 2000: If GetLastError returns zero, then the function
1470  * timed out.
1471  * XP+ : If the function fails or times out, the return value is zero.
1472  * To get extended error information, call GetLastError. If GetLastError
1473  * returns ERROR_TIMEOUT, then the function timed out.
1474  */
1476  RETURN( FALSE);
1477  }
1478  else if (!NT_SUCCESS(Status))
1479  {
1481  RETURN( FALSE);
1482  }
1483 
1484  RETURN( TRUE);
1485 
1486 CLEANUP:
1488  END_CLEANUP;
1489 }
#define TRUE
Definition: types.h:120
static PMSGMEMORY FASTCALL FindMsgMemory(UINT Msg)
Definition: message.c:145
BOOL WINAPI PopupMenuWndProc(PWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: menu.c:4628
#define CLEANUP
Definition: ntuser.h:5
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:613
#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
BOOL FASTCALL DesktopWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: desktop.c:1401
LRESULT APIENTRY co_IntCallWindowProc(WNDPROC Proc, BOOLEAN IsAnsiProc, HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, INT lParamBufferSize)
Definition: callback.c:289
UINT uFlags
Definition: api.c:59
int32_t INT
Definition: typedefs.h:56
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:63
#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:251
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FNID_DESKTOP
Definition: ntuser.h:824
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:38
PTHREADINFO FASTCALL IntSendTo(PWND Window, PTHREADINFO ptiCur, UINT Msg)
Definition: message.c:1170
Definition: object.h:3
static NTSTATUS UnpackParam(LPARAM lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL NonPagedPoolUsed)
Definition: message.c:369
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
LONG_PTR LPARAM
Definition: windef.h:208
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
#define TRACE(s)
Definition: solgame.cpp:4
static VOID FASTCALL IntCallWndProc(PWND Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:581
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DECLARE_RETURN(type)
Definition: ntuser.h:3
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:109
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:164
static VOID FASTCALL IntCallWndProcRet(PWND Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *uResult)
Definition: message.c:597
struct @1587 Msg[]
#define ULONG_PTR
Definition: config.h:101
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:2938
#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 1570 of file message.c.

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

Referenced by co_IntSendMessageNoWait(), and NtUserMessageCall().

◆ co_IntWaitMessage()

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

Definition at line 972 of file message.c.

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

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

◆ CopyMsgToKernelMem()

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

Definition at line 418 of file message.c.

419 {
421 
422  PVOID KernelMem;
423  UINT Size;
424 
425  *KernelModeMsg = *UserModeMsg;
426 
427  /* See if this message type is present in the table */
428  if (NULL == MsgMemoryEntry)
429  {
430  /* Not present, no copying needed */
431  return STATUS_SUCCESS;
432  }
433 
434  /* Determine required size */
435  Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, UserModeMsg->lParam);
436 
437  if (0 != Size)
438  {
439  /* Allocate kernel mem */
441  if (NULL == KernelMem)
442  {
443  ERR("Not enough memory to copy message to kernel mem\n");
444  return STATUS_NO_MEMORY;
445  }
446  KernelModeMsg->lParam = (LPARAM) KernelMem;
447 
448  /* Copy data if required */
449  if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_READ))
450  {
451  TRACE("Copy Message %u from usermode buffer\n", KernelModeMsg->message);
452  Status = MmCopyFromCaller(KernelMem, (PVOID) UserModeMsg->lParam, Size);
453  if (! NT_SUCCESS(Status))
454  {
455  ERR("Failed to copy message to kernel: invalid usermode lParam buffer\n");
456  ExFreePoolWithTag(KernelMem, TAG_MSG);
457  return Status;
458  }
459  }
460  else
461  {
462  /* Make sure we don't pass any secrets to usermode */
463  RtlZeroMemory(KernelMem, Size);
464  }
465  }
466  else
467  {
468  KernelModeMsg->lParam = 0;
469  }
470 
471  return STATUS_SUCCESS;
472 }
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:359
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
#define MMS_FLAG_READ
Definition: message.c:110
#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:164
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define TAG_MSG
Definition: tags.h:7

Referenced by co_IntDoSendMessage().

◆ CopyMsgToUserMem()

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

Definition at line 475 of file message.c.

476 {
478  PMSGMEMORY MsgMemoryEntry;
479  UINT Size;
480 
481  /* See if this message type is present in the table */
482  MsgMemoryEntry = FindMsgMemory(UserModeMsg->message);
483  if (NULL == MsgMemoryEntry)
484  {
485  /* Not present, no copying needed */
486  return STATUS_SUCCESS;
487  }
488 
489  /* Determine required size */
490  Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, UserModeMsg->lParam);
491 
492  if (0 != Size)
493  {
494  /* Copy data if required */
495  if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_WRITE))
496  {
497  Status = MmCopyToCaller((PVOID) UserModeMsg->lParam, (PVOID) KernelModeMsg->lParam, Size);
498  if (! NT_SUCCESS(Status))
499  {
500  ERR("Failed to copy message from kernel: invalid usermode lParam buffer\n");
501  ExFreePool((PVOID) KernelModeMsg->lParam);
502  return Status;
503  }
504  }
505  ExFreePool((PVOID) KernelModeMsg->lParam);
506  }
507 
508  return STATUS_SUCCESS;
509 }
static PMSGMEMORY FASTCALL FindMsgMemory(UINT Msg)
Definition: message.c:145
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:359
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
unsigned int UINT
Definition: ndis.h:50
static UINT FASTCALL MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam)
Definition: message.c:164
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define MMS_FLAG_WRITE
Definition: message.c:111
#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 145 of file message.c.

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

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

563 {
564  UINT mask = QS_POSTMESSAGE | QS_SENDMESSAGE; /* Always selected */
565 
566  if (first || last)
567  {
568  if ((first <= WM_KEYLAST) && (last >= WM_KEYFIRST)) mask |= QS_KEY;
569  if ( ((first <= WM_MOUSELAST) && (last >= WM_MOUSEFIRST)) ||
571  if ((first <= WM_TIMER) && (last >= WM_TIMER)) mask |= QS_TIMER;
572  if ((first <= WM_SYSTIMER) && (last >= WM_SYSTIMER)) mask |= QS_TIMER;
573  if ((first <= WM_PAINT) && (last >= WM_PAINT)) mask |= QS_PAINT;
574  }
575  else mask = QS_ALLINPUT;
576 
577  return mask;
578 }
#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 654 of file message.c.

655 {
656  LRESULT Result = 0;
657 
658  switch(dwQEvent)
659  {
660  case POSTEVENT_NWE:
661  {
662  co_EVENT_CallEvents( pMsg->message, pMsg->hwnd, pMsg->wParam, ExtraInfo);
663  }
664  break;
665  case POSTEVENT_SAW:
666  {
667  //ERR("HIE : SAW : pti 0x%p hWnd 0x%p\n",pti,pMsg->hwnd);
668  IntActivateWindow((PWND)pMsg->wParam, pti, (HANDLE)pMsg->lParam, (DWORD)ExtraInfo);
669  }
670  break;
671  case POSTEVENT_DAW:
672  {
673  //ERR("HIE : DAW : pti 0x%p tid 0x%p hWndPrev 0x%p\n",pti,ExtraInfo,pMsg->hwnd);
674  IntDeactivateWindow(pti, (HANDLE)ExtraInfo);
675  }
676  break;
677  }
678  return Result;
679 }
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:268
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:106
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 613 of file message.c.

614 {
615  LRESULT lRes;
616 // USER_REFERENCE_ENTRY Ref;
617 // PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
618 
619  if (!pWnd || UserIsDesktopWindow(pWnd) || UserIsMessageWindow(pWnd))
620  return 0;
621 
622  TRACE("Internal Event Msg 0x%x hWnd 0x%p\n", msg, pWnd->head.h);
623 
624  switch(msg)
625  {
626  case WM_ASYNC_SHOWWINDOW:
627  return co_WinPosShowWindow( pWnd, wparam );
629  {
630  PWINDOWPOS winpos = (PWINDOWPOS)lparam;
631  if (!winpos) return 0;
632  lRes = co_WinPosSetWindowPos( pWnd,
633  winpos->hwndInsertAfter,
634  winpos->x,
635  winpos->y,
636  winpos->cx,
637  winpos->cy,
638  winpos->flags);
640  return lRes;
641  }
643  {
644  ERR("WM_ASYNC_DESTROYWINDOW\n");
645  if (pWnd->style & WS_CHILD)
647  else
648  co_UserDestroyWindow(pWnd);
649  }
650  }
651  return 0;
652 }
#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:2648
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:2470
#define TRACE(s)
Definition: solgame.cpp:4
#define UserIsMessageWindow(pWnd)
Definition: desktop.h:223
#define ERR(fmt,...)
Definition: debug.h:109
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 515 of file message.c.

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

Referenced by co_IntGetPeekMessage(), and IntMsqSetWakeMask().

◆ IdlePong()

VOID FASTCALL IdlePong ( VOID  )

Definition at line 545 of file message.c.

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

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

◆ IntCallMsgFilter()

BOOL FASTCALL IntCallMsgFilter ( LPMSG  lpmsg,
INT  code 
)

Definition at line 1975 of file message.c.

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

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

◆ IntCallWndProc()

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

Definition at line 581 of file message.c.

582 {
583  BOOL SameThread = FALSE;
584  CWPSTRUCT CWP;
585 
586  if (Window->head.pti == ((PTHREADINFO)PsGetCurrentThreadWin32Thread()))
587  SameThread = TRUE;
588 
589  CWP.hwnd = hWnd;
590  CWP.message = Msg;
591  CWP.wParam = wParam;
592  CWP.lParam = lParam;
593  co_HOOK_CallHooks( WH_CALLWNDPROC, HC_ACTION, SameThread, (LPARAM)&CWP );
594 }
#define TRUE
Definition: types.h:120
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
Definition: window.c:28
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG_PTR LPARAM
Definition: windef.h:208
LPARAM lParam
Definition: winuser.h:3000
WPARAM wParam
Definition: winuser.h:3001
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
struct @1587 Msg[]
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 597 of file message.c.

598 {
599  BOOL SameThread = FALSE;
600  CWPRETSTRUCT CWPR;
601 
602  if (Window->head.pti == ((PTHREADINFO)PsGetCurrentThreadWin32Thread()))
603  SameThread = TRUE;
604 
605  CWPR.hwnd = hWnd;
606  CWPR.message = Msg;
607  CWPR.wParam = wParam;
608  CWPR.lParam = lParam;
609  CWPR.lResult = uResult ? (*uResult) : 0;
610  co_HOOK_CallHooks( WH_CALLWNDPROCRET, HC_ACTION, SameThread, (LPARAM)&CWPR );
611 }
WPARAM wParam
Definition: winuser.h:2994
#define TRUE
Definition: types.h:120
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
HWND hWnd
Definition: settings.c:17
LPARAM lParam
Definition: winuser.h:2993
WPARAM wParam
Definition: combotst.c:138
Definition: window.c:28
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG_PTR LPARAM
Definition: windef.h:208
#define WH_CALLWNDPROCRET
Definition: winuser.h:42
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1103
#define HC_ACTION
Definition: winuser.h:48
struct @1587 Msg[]
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:2938

◆ IntDispatchMessage()

LRESULT FASTCALL IntDispatchMessage ( PMSG  pMsg)

Definition at line 682 of file message.c.

683 {
684  LONG Time;
685  LRESULT retval = 0;
686  PTHREADINFO pti;
687  PWND Window = NULL;
688  BOOL DoCallBack = TRUE;
689 
690  if (pMsg->hwnd)
691  {
693  if (!Window) return 0;
694  }
695 
697 
698  if ( Window && Window->head.pti != pti)
699  {
701  return 0;
702  }
703 
704  if (((pMsg->message == WM_SYSTIMER) ||
705  (pMsg->message == WM_TIMER)) &&
706  (pMsg->lParam) )
707  {
708  if (pMsg->message == WM_TIMER)
709  {
710  if (ValidateTimerCallback(pti,pMsg->lParam))
711  {
713  retval = co_IntCallWindowProc((WNDPROC)pMsg->lParam,
714  TRUE,
715  pMsg->hwnd,
716  WM_TIMER,
717  pMsg->wParam,
718  (LPARAM)Time,
719  -1);
720  }
721  return retval;
722  }
723  else
724  {
725  PTIMER pTimer = FindSystemTimer(pMsg);
726  if (pTimer && pTimer->pfn)
727  {
729  pTimer->pfn(pMsg->hwnd, WM_SYSTIMER, (UINT)pMsg->wParam, Time);
730  }
731  return 0;
732  }
733  }
734  // Need a window!
735  if ( !Window ) return 0;
736 
737  if (pMsg->message == WM_PAINT) Window->state |= WNDS_PAINTNOTPROCESSED;
738 
739  if ( Window->state & WNDS_SERVERSIDEWINDOWPROC )
740  {
741  TRACE("Dispatch: Server Side Window Procedure\n");
742  switch(Window->fnid)
743  {
744  case FNID_DESKTOP:
745  DoCallBack = !DesktopWindowProc( Window,
746  pMsg->message,
747  pMsg->wParam,
748  pMsg->lParam,
749  &retval);
750  break;
751  case FNID_MESSAGEWND:
752  DoCallBack = !UserMessageWindowProc( Window,
753  pMsg->message,
754  pMsg->wParam,
755  pMsg->lParam,
756  &retval);
757  break;
758  case FNID_MENU:
759  DoCallBack = !PopupMenuWndProc( Window,
760  pMsg->message,
761  pMsg->wParam,
762  pMsg->lParam,
763  &retval);
764  break;
765  }
766  }
767 
768  /* Since we are doing a callback on the same thread right away, there is
769  no need to copy the lparam to kernel mode and then back to usermode.
770  We just pretend it isn't a pointer */
771 
772  if (DoCallBack)
773  retval = co_IntCallWindowProc( Window->lpfnWndProc,
774  !Window->Unicode,
775  pMsg->hwnd,
776  pMsg->message,
777  pMsg->wParam,
778  pMsg->lParam,
779  -1);
780 
781  if ( pMsg->message == WM_PAINT &&
782  VerifyWnd(Window) &&
783  Window->state & WNDS_PAINTNOTPROCESSED ) // <--- Cleared, paint was already processed!
784  {
785  Window->state2 &= ~WNDS2_WMPAINTSENT;
786  /* send a WM_ERASEBKGND if the non-client area is still invalid */
787  ERR("Message WM_PAINT count %d Internal Paint Set? %s\n",Window->head.pti->cPaintsReady, Window->state & WNDS_INTERNALPAINT ? "TRUE" : "FALSE");
789  }
790 
791  return retval;
792 }
#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:289
#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:109
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 1924 of file message.c.

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

Referenced by NtUserCallOneParam(), and NtUserGetThreadState().

◆ 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:2938

◆ IntInitMessagePumpHook()

BOOL APIENTRY IntInitMessagePumpHook ( VOID  )

Definition at line 1945 of file message.c.

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

Referenced by NtUserCallNoParam().

◆ IntSendTo()

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

Definition at line 1170 of file message.c.

1171 {
1172  if ( ptiCur )
1173  {
1174  if (!Window ||
1175  Window->head.pti == ptiCur )
1176  {
1177  return NULL;
1178  }
1179  }
1180  return Window ? Window->head.pti : NULL;
1181 }
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 1958 of file message.c.

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

Referenced by NtUserCallNoParam().

◆ is_message_broadcastable()

static BOOL is_message_broadcastable ( UINT  msg)
static

Definition at line 556 of file message.c.

557 {
558  return msg < WM_USER || msg >= 0xc000;
559 }

Referenced by co_IntSendMessageTimeout(), and UserPostMessage().

◆ is_pointer_message()

static int is_pointer_message ( UINT  message)
inlinestatic

Definition at line 99 of file message.c.

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

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

◆ lParamMemorySize()

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

Definition at line 243 of file message.c.

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

Referenced by co_IntCallHookProc().

◆ MsgMemorySize()

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

Definition at line 164 of file message.c.

165 {
166  CREATESTRUCTW *Cs;
167  PLARGE_STRING WindowName;
168  PUNICODE_STRING ClassName;
169  UINT Size = 0;
170 
171  _SEH2_TRY
172  {
173  if (MMS_SIZE_WPARAM == MsgMemoryEntry->Size)
174  {
175  Size = (UINT)wParam;
176  }
177  else if (MMS_SIZE_WPARAMWCHAR == MsgMemoryEntry->Size)
178  {
179  Size = (UINT) (wParam * sizeof(WCHAR));
180  }
181  else if (MMS_SIZE_LPARAMSZ == MsgMemoryEntry->Size)
182  {
183  // WM_SETTEXT and WM_SETTINGCHANGE can be null!
184  if (!lParam)
185  {
186  TRACE("lParam is NULL!\n");
187  Size = 0;
188  }
189  else
190  Size = (UINT) ((wcslen((PWSTR) lParam) + 1) * sizeof(WCHAR));
191  }
192  else if (MMS_SIZE_SPECIAL == MsgMemoryEntry->Size)
193  {
194  switch(MsgMemoryEntry->Message)
195  {
196  case WM_CREATE:
197  case WM_NCCREATE:
198  Cs = (CREATESTRUCTW *) lParam;
199  WindowName = (PLARGE_STRING) Cs->lpszName;
200  ClassName = (PUNICODE_STRING) Cs->lpszClass;
201  Size = sizeof(CREATESTRUCTW) + WindowName->Length + sizeof(WCHAR);
202  if (IS_ATOM(ClassName->Buffer))
203  {
204  Size += sizeof(WCHAR) + sizeof(ATOM);
205  }
206  else
207  {
208  Size += sizeof(WCHAR) + ClassName->Length + sizeof(WCHAR);
209  }
210  break;
211 
212  case WM_NCCALCSIZE:
213  Size = wParam ? sizeof(NCCALCSIZE_PARAMS) + sizeof(WINDOWPOS) : sizeof(RECT);
214  break;
215 
216  case WM_COPYDATA:
217  {
219  Size = sizeof(COPYDATASTRUCT) + cds->cbData;
220  }
221  break;
222 
223  default:
224  ASSERT(FALSE);
225  Size = 0;
226  break;
227  }
228  }
229  else
230  {
231  Size = MsgMemoryEntry->Size;
232  }
233  }
235  {
236  ERR("Exception caught in MsgMemorySize()! Status: 0x%x\n", _SEH2_GetExceptionCode());
237  Size = 0;
238  }
239  _SEH2_END;
240  return Size;
241 }
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
WORD ATOM
Definition: dimm.idl:113
#define MMS_SIZE_SPECIAL
Definition: message.c:109
uint16_t * PWSTR
Definition: typedefs.h:54
#define WM_NCCALCSIZE
Definition: winuser.h:1667
#define MMS_SIZE_WPARAM
Definition: message.c:106
#define WM_NCCREATE
Definition: winuser.h:1665
WPARAM wParam
Definition: combotst.c:138
_SEH2_TRY
Definition: create.c:4250
#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:108
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
LPCWSTR lpszName
Definition: winuser.h:2939
UINT Size
Definition: message.c:116
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define ERR(fmt,...)
Definition: debug.h:109
_SEH2_END
Definition: create.c:4424
struct tagNCCALCSIZE_PARAMS NCCALCSIZE_PARAMS
#define MMS_SIZE_WPARAMWCHAR
Definition: message.c:107
unsigned int UINT
Definition: ndis.h:50
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:115

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

◆ NtUserCallMsgFilter()

BOOL APIENTRY NtUserCallMsgFilter ( LPMSG  lpmsg,
INT  code 
)

Definition at line 2217 of file message.c.

2218 {
2219  BOOL Ret = FALSE;
2220  MSG Msg;
2221 
2222  _SEH2_TRY
2223  {
2224  ProbeForRead(lpmsg, sizeof(MSG), 1);
2225  RtlCopyMemory( &Msg, lpmsg, sizeof(MSG));
2226  }
2228  {
2229  _SEH2_YIELD(return FALSE);
2230  }
2231  _SEH2_END;
2232 
2234 
2236  {
2237  Ret = TRUE;
2238  }
2239  else
2240  {
2241  Ret = co_HOOK_CallHooks( WH_MSGFILTER, code, 0, (LPARAM)&Msg);
2242  }
2243 
2244  UserLeave();
2245 
2246  _SEH2_TRY
2247  {
2248  ProbeForWrite(lpmsg, sizeof(MSG), 1);
2249  RtlCopyMemory(lpmsg, &Msg, sizeof(MSG));
2250  }
2252  {
2253  Ret = FALSE;
2254  }
2255  _SEH2_END;
2256 
2257  return Ret;
2258 }
#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
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4250
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:4424
struct @1587 Msg[]
#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 2261 of file message.c.

2262 {
2263  LRESULT Res = 0;
2264  MSG SafeMsg;
2265 
2266  _SEH2_TRY
2267  {
2268  ProbeForRead(UnsafeMsgInfo, sizeof(MSG), 1);
2269  RtlCopyMemory(&SafeMsg, UnsafeMsgInfo, sizeof(MSG));
2270  }
2272  {
2274  _SEH2_YIELD(return FALSE);
2275  }
2276  _SEH2_END;
2277 
2279 
2280  Res = IntDispatchMessage(&SafeMsg);
2281 
2282  UserLeave();
2283  return Res;
2284 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
LRESULT FASTCALL IntDispatchMessage(PMSG pMsg)
Definition: message.c:682
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
_SEH2_TRY
Definition: create.c:4250
#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:4424
#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 1994 of file message.c.

1997 {
1998  MSG msg;
1999  RECT rect;
2000  ULONG wDragWidth, wDragHeight;
2002 
2003  TRACE("Enter NtUserDragDetect(%p)\n", hWnd);
2005 
2006  wDragWidth = UserGetSystemMetrics(SM_CXDRAG);
2007  wDragHeight= UserGetSystemMetrics(SM_CYDRAG);
2008 
2009  rect.left = pt.x - wDragWidth;
2010  rect.right = pt.x + wDragWidth;
2011 
2012  rect.top = pt.y - wDragHeight;
2013  rect.bottom = pt.y + wDragHeight;
2014 
2016 
2017  for (;;)
2018  {
2022  {
2023  if ( msg.message == WM_LBUTTONUP )
2024  {
2026  RETURN( FALSE);
2027  }
2028  if ( msg.message == WM_MOUSEMOVE )
2029  {
2030  POINT tmp;
2031  tmp.x = (short)LOWORD(msg.lParam);
2032  tmp.y = (short)HIWORD(msg.lParam);
2033  if( !RECTL_bPointInRect( &rect, tmp.x, tmp.y ) )
2034  {
2036  RETURN( TRUE);
2037  }
2038  }
2039  if ( msg.message == WM_KEYDOWN )
2040  {
2041  if ( msg.wParam == VK_ESCAPE )
2042  {
2044  RETURN( TRUE);
2045  }
2046  }
2047  if ( msg.message == WM_QUEUESYNC )
2048  {
2049  co_HOOK_CallHooks( WH_CBT, HCBT_QS, 0, 0 );
2050  }
2051  }
2052  co_IntWaitMessage(NULL, 0, 0);
2053  }
2054  RETURN( FALSE);
2055 
2056 CLEANUP:
2057  TRACE("Leave NtUserDragDetect, ret=%i\n",_ret_);
2058  UserLeave();
2059  END_CLEANUP;
2060 }
#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:972
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:1018
#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 2131 of file message.c.

2135 {
2136  MSG Msg;
2137  BOOL Ret;
2138 
2139  if ( (MsgFilterMin|MsgFilterMax) & ~WM_MAXIMUM )
2140  {
2142  return FALSE;
2143  }
2144 
2146 
2147  RtlZeroMemory(&Msg, sizeof(MSG));
2148 
2149  Ret = co_IntGetPeekMessage(&Msg, hWnd, MsgFilterMin, MsgFilterMax, PM_REMOVE, TRUE);
2150 
2151  UserLeave();
2152 
2153  if (Ret)
2154  {
2155  _SEH2_TRY
2156  {
2157  ProbeForWrite(pMsg, sizeof(MSG), 1);
2158  RtlCopyMemory(pMsg, &Msg, sizeof(MSG));
2159  }
2161  {
2163  Ret = FALSE;
2164  }
2165  _SEH2_END;
2166  }
2167 
2168  if ((INT)Ret != -1)
2169  Ret = Ret ? (WM_QUIT != pMsg->message) : FALSE;
2170 
2171  return Ret;
2172 }
#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
int32_t INT
Definition: typedefs.h:56
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4250
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:4424
BOOL APIENTRY co_IntGetPeekMessage(PMSG pMsg, HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg, BOOL bGMSG)
Definition: message.c:1018
struct @1587 Msg[]
#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 2324 of file message.c.

2331 {
2332  LRESULT lResult = 0;
2333  BOOL Ret = FALSE;
2334  PWND Window = NULL;
2336 
2338 
2339  switch(dwType)
2340  {
2341  case FNID_SCROLLBAR:
2342  {
2343  lResult = ScrollBarWndProc(hWnd, Msg, wParam, lParam);
2344  break;
2345  }
2346  case FNID_DESKTOP:
2347  {
2349  if (Window)
2350  {
2351  //ERR("FNID_DESKTOP IN\n");
2352  Ret = DesktopWindowProc(Window, Msg, wParam, lParam, &lResult);
2353  //ERR("FNID_DESKTOP OUT\n");
2354  }
2355  break;
2356  }
2357  case FNID_MENU:
2358  {
2360  if (Window)
2361  {
2362  Ret = PopupMenuWndProc( Window, Msg, wParam, lParam, &lResult);
2363  }
2364  break;
2365  }
2366  case FNID_MESSAGEWND:
2367  {
2369  if (Window)
2370  {
2371  Ret = !UserMessageWindowProc(Window, Msg, wParam, lParam, &lResult);
2372  }
2373  break;
2374  }
2375  case FNID_DEFWINDOWPROC:
2376  /* Validate input */
2377  if (hWnd)
2378  {
2380  if (!Window)
2381  {
2382  UserLeave();
2383  return FALSE;
2384  }
2385  UserRefObjectCo(Window, &Ref);
2386  }
2387  lResult = IntDefWindowProc(Window, Msg, wParam, lParam, Ansi);
2388  Ret = TRUE;
2389  if (hWnd)
2391  break;
2394  break;
2396  {
2397  BROADCASTPARM parm, *retparam;
2398  DWORD_PTR RetVal = 0;
2399 
2400  if (ResultInfo)
2401  {
2402  _SEH2_TRY
2403  {
2404  ProbeForWrite((PVOID)ResultInfo, sizeof(BROADCASTPARM), 1);
2405  RtlCopyMemory(&parm, (PVOID)ResultInfo, sizeof(BROADCASTPARM));
2406  }
2408  {
2409  _SEH2_YIELD(break);
2410  }
2411  _SEH2_END;
2412  }
2413  else
2414  break;
2415 
2416  if ( parm.recipients & BSM_ALLDESKTOPS ||
2417  parm.recipients == BSM_ALLCOMPONENTS )
2418  {
2419  PLIST_ENTRY DesktopEntry;
2420  PDESKTOP rpdesk;
2421  HWND *List, hwndDenied = NULL;
2422  HDESK hDesk = NULL;
2423  PWND pwnd, pwndDesk;
2424  ULONG i;
2425  UINT fuFlags;
2426 
2427  for (DesktopEntry = InputWindowStation->DesktopListHead.Flink;
2428  DesktopEntry != &InputWindowStation->DesktopListHead;
2429  DesktopEntry = DesktopEntry->Flink)
2430  {
2431  rpdesk = CONTAINING_RECORD(DesktopEntry, DESKTOP, ListEntry);
2432  pwndDesk = rpdesk->pDeskInfo->spwnd;
2433  List = IntWinListChildren(pwndDesk);
2434 
2435  if (parm.flags & BSF_QUERY)
2436  {
2437  if (List != NULL)
2438  {
2439  if (parm.flags & BSF_FORCEIFHUNG || parm.flags & BSF_NOHANG)
2440  {
2441  fuFlags = SMTO_ABORTIFHUNG;
2442  }
2443  else if (parm.flags & BSF_NOTIMEOUTIFNOTHUNG)
2444  {
2445  fuFlags = SMTO_NOTIMEOUTIFNOTHUNG;
2446  }
2447  else
2448  {
2449  fuFlags = SMTO_NORMAL;
2450  }
2452  Msg,
2453  wParam,
2454  lParam,
2455  fuFlags,
2456  2000,
2457  &RetVal);
2458  Ret = TRUE;
2459  for (i = 0; List[i]; i++)
2460  {
2461  pwnd = UserGetWindowObject(List[i]);
2462  if (!pwnd) continue;
2463 
2464  if ( pwnd->fnid == FNID_MENU ||
2466  continue;
2467 
2468  if ( parm.flags & BSF_IGNORECURRENTTASK )
2469  {
2470  if ( pwnd->head.pti == gptiCurrent )
2471  continue;
2472  }
2474  Msg,
2475  wParam,
2476  lParam,
2477  fuFlags,
2478  2000,
2479  &RetVal);
2480 
2481  if (!RetVal && EngGetLastError() == ERROR_TIMEOUT)
2482  {
2483  if (!(parm.flags & BSF_FORCEIFHUNG))
2484  Ret = FALSE;
2485  }
2486  if (RetVal == BROADCAST_QUERY_DENY)
2487  {
2488  hwndDenied = List[i];
2489  hDesk = UserHMGetHandle(pwndDesk);
2490  Ret = FALSE;
2491  }
2492  }
2494  _SEH2_TRY
2495  {
2496  retparam = (PBROADCASTPARM) ResultInfo;
2497  retparam->hDesk = hDesk;
2498  retparam->hWnd = hwndDenied;
2499  }
2501  {
2502  _SEH2_YIELD(break);
2503  }
2504  _SEH2_END;
2505  if (!Ret) break; // Have a hit! Let everyone know!
2506  }
2507  }
2508  else if (parm.flags & BSF_POSTMESSAGE)
2509  {
2510  if (List != NULL)
2511  {
2513 
2514  for (i = 0; List[i]; i++)
2515  {
2516  pwnd = UserGetWindowObject(List[i]);
2517  if (!pwnd) continue;
2518 
2519  if ( pwnd->fnid == FNID_MENU ||
2521  continue;
2522 
2523  if ( parm.flags & BSF_IGNORECURRENTTASK )
2524  {
2525  if ( pwnd->head.pti == gptiCurrent )
2526  continue;
2527  }
2529  }
2531  }
2532  Ret = TRUE;
2533  }
2534  else
2535  {
2536  if (List != NULL)
2537  {
2539 
2540  for (i = 0; List[i]; i++)
2541  {
2542  pwnd = UserGetWindowObject(List[i]);
2543  if (!pwnd) continue;
2544 
2545  if ( pwnd->fnid == FNID_MENU ||
2547  continue;
2548 
2549  if ( parm.flags & BSF_IGNORECURRENTTASK )
2550  {
2551  if ( pwnd->head.pti == gptiCurrent )
2552  continue;
2553  }
2555  }
2557  }
2558  Ret = TRUE;
2559  }
2560  }
2561  }
2562  else if (parm.recipients & BSM_APPLICATIONS)
2563  {
2564  HWND *List, hwndDenied = NULL;
2565  HDESK hDesk = NULL;
2566  PWND pwnd, pwndDesk;
2567  ULONG i;
2568  UINT fuFlags;
2569 
2570  pwndDesk = UserGetDesktopWindow();
2571  List = IntWinListChildren(pwndDesk);
2572 
2573  if (parm.flags & BSF_QUERY)
2574  {
2575  if (List != NULL)
2576  {
2577  if (parm.flags & BSF_FORCEIFHUNG || parm.flags & BSF_NOHANG)
2578  {
2579  fuFlags = SMTO_ABORTIFHUNG;
2580  }
2581  else if (parm.flags & BSF_NOTIMEOUTIFNOTHUNG)
2582  {
2583  fuFlags = SMTO_NOTIMEOUTIFNOTHUNG;
2584  }
2585  else
2586  {
2587  fuFlags = SMTO_NORMAL;
2588  }
2590  Msg,
2591  wParam,
2592  lParam,
2593  fuFlags,
2594  2000,
2595  &RetVal);
2596  Ret = TRUE;
2597  for (i = 0; List[i]; i++)
2598  {
2599  pwnd = UserGetWindowObject(List[i]);
2600  if (!pwnd) continue;
2601 
2602  if ( pwnd->fnid == FNID_MENU ||
2604  continue;
2605 
2606  if ( parm.flags & BSF_IGNORECURRENTTASK )
2607  {
2608  if ( pwnd->head.pti == gptiCurrent )
2609  continue;
2610  }
2612  Msg,
2613  wParam,
2614  lParam,
2615  fuFlags,
2616  2000,
2617  &RetVal);
2618 
2619  if (!RetVal && EngGetLastError() == ERROR_TIMEOUT)
2620  {
2621  if (!(parm.flags & BSF_FORCEIFHUNG))
2622  Ret = FALSE;
2623  }
2624  if (RetVal == BROADCAST_QUERY_DENY)
2625  {
2626  hwndDenied = List[i];
2627  hDesk = UserHMGetHandle(pwndDesk);
2628  Ret = FALSE;
2629  }
2630  }
2632  _SEH2_TRY
2633  {
2634  retparam = (PBROADCASTPARM) ResultInfo;
2635  retparam->hDesk = hDesk;
2636  retparam->hWnd = hwndDenied;
2637  }
2639  {
2640  _SEH2_YIELD(break);
2641  }
2642  _SEH2_END;
2643  }
2644  }
2645  else if (parm.flags & BSF_POSTMESSAGE)
2646  {
2647  if (List != NULL)
2648  {
2650 
2651  for (i = 0; List[i]; i++)
2652  {
2653  pwnd = UserGetWindowObject(List[i]);
2654  if (!pwnd) continue;
2655 
2656  if ( pwnd->fnid == FNID_MENU ||
2658  continue;
2659 
2660  if ( parm.flags & BSF_IGNORECURRENTTASK )
2661  {
2662  if ( pwnd->head.pti == gptiCurrent )
2663  continue;
2664  }
2666  }
2668  }
2669  Ret = TRUE;
2670  }
2671  else
2672  {
2673  if (List != NULL)
2674  {
2676 
2677  for (i = 0; List[i]; i++)
2678  {
2679  pwnd = UserGetWindowObject(List[i]);
2680  if (!pwnd) continue;
2681 
2682  if ( pwnd->fnid == FNID_MENU ||
2684  continue;
2685 
2686  if ( parm.flags & BSF_IGNORECURRENTTASK )
2687  {
2688  if ( pwnd->head.pti == gptiCurrent )
2689  continue;
2690  }
2692  }
2694  }
2695  Ret = TRUE;
2696  }
2697  }
2698  }
2699  break;
2701  {
2702  CALL_BACK_INFO CallBackInfo;
2703  ULONG_PTR uResult;
2704 
2705  _SEH2_TRY
2706  {
2707  ProbeForRead((PVOID)ResultInfo, sizeof(CALL_BACK_INFO), 1);
2708  RtlCopyMemory(&CallBackInfo, (PVOID)ResultInfo, sizeof(CALL_BACK_INFO));
2709  }
2711  {
2712  _SEH2_YIELD(break);
2713  }
2714  _SEH2_END;
2715 
2716  if (is_pointer_message(Msg))
2717  {
2719  break;
2720  }
2721 
2723  CallBackInfo.CallBack, CallBackInfo.Context, &uResult)))
2724  {
2725  ERR("Callback failure!\n");
2726  }
2727  }
2728  break;
2729  case FNID_SENDMESSAGE:
2730  {
2731  lResult = co_IntDoSendMessage(hWnd, Msg, wParam, lParam, 0);
2732  Ret = TRUE;
2733 
2734  if (ResultInfo)
2735  {
2736  _SEH2_TRY
2737  {
2738  ProbeForWrite((PVOID)ResultInfo, sizeof(ULONG_PTR), 1);
2739  RtlCopyMemory((PVOID)ResultInfo, &lResult, sizeof(ULONG_PTR));
2740  }
2742  {
2743  Ret = FALSE;
2744  _SEH2_YIELD(break);
2745  }
2746  _SEH2_END;
2747  }
2748  break;
2749  }
2750  case FNID_SENDMESSAGEFF:
2752  {
2753  DOSENDMESSAGE dsm, *pdsm = (PDOSENDMESSAGE)ResultInfo;
2754  if (ResultInfo)
2755  {
2756  _SEH2_TRY
2757  {
2758  ProbeForRead(pdsm, sizeof(DOSENDMESSAGE), 1);
2759  RtlCopyMemory(&dsm, pdsm, sizeof(DOSENDMESSAGE));
2760  }
2762  {
2763  _SEH2_YIELD(break);
2764  }
2765  _SEH2_END;
2766  }
2767 
2768  Ret = co_IntDoSendMessage( hWnd, Msg, wParam, lParam, pdsm ? &dsm : NULL );
2769 
2770  if (pdsm)
2771  {
2772  _SEH2_TRY
2773  {
2774  ProbeForWrite(pdsm, sizeof(DOSENDMESSAGE), 1);
2775  RtlCopyMemory(pdsm, &dsm, sizeof(DOSENDMESSAGE));
2776  }
2778  {
2779  Ret = FALSE;
2780  _SEH2_YIELD(break);
2781  }
2782  _SEH2_END;
2783  }
2784  break;
2785  }
2786  // CallNextHook bypass.
2787  case FNID_CALLWNDPROC:
2788  case FNID_CALLWNDPROCRET:
2789  {
2790  PTHREADINFO pti;
2792  PHOOK NextObj, Hook;
2793 
2794  pti = GetW32ThreadInfo();
2795 
2796  Hook = pti->sphkCurrent;
2797 
2798  if (!Hook) break;
2799 
2800  NextObj = Hook->phkNext;
2801  ClientInfo = pti->pClientInfo;
2802  _SEH2_TRY
2803  {
2804  ClientInfo->phkCurrent = NextObj;
2805  }
2807  {
2808  ClientInfo = NULL;
2809  }
2810  _SEH2_END;
2811 
2812  if (!ClientInfo || !NextObj) break;
2813 
2814  NextObj->phkNext = IntGetNextHook(NextObj);
2815 
2816  if ( Hook->HookId == WH_CALLWNDPROC)
2817  {
2818  CWPSTRUCT CWP;
2819  CWP.hwnd = hWnd;
2820  CWP.message = Msg;
2821  CWP.wParam = wParam;
2822  CWP.lParam = lParam;
2823  TRACE("WH_CALLWNDPROC: Hook %p NextHook %p\n", Hook, NextObj);
2824 
2825  lResult = co_IntCallHookProc( Hook->HookId,
2826  HC_ACTION,
2827  ((ClientInfo->CI_flags & CI_CURTHPRHOOK) ? 1 : 0),
2828  (LPARAM)&CWP,
2829  Hook->Proc,
2830  Hook->ihmod,
2831  Hook->offPfn,
2832  Hook->Ansi,
2833  &Hook->ModuleName);
2834  }
2835  else
2836  {
2837  CWPRETSTRUCT CWPR;
2838  CWPR.hwnd = hWnd;
2839  CWPR.message = Msg;
2840  CWPR.wParam = wParam;
2841  CWPR.lParam = lParam;
2842  CWPR.lResult = ClientInfo->dwHookData;
2843 
2844  lResult = co_IntCallHookProc( Hook->HookId,
2845  HC_ACTION,
2846  ((ClientInfo->CI_flags & CI_CURTHPRHOOK) ? 1 : 0),
2847  (LPARAM)&CWPR,
2848  Hook->Proc,
2849  Hook->ihmod,
2850  Hook->offPfn,
2851  Hook->Ansi,
2852  &Hook->ModuleName);
2853  }
2854  }
2855  break;
2856  }
2857 
2858  switch(dwType)
2859  {
2860  case FNID_DEFWINDOWPROC:
2861  case FNID_CALLWNDPROC:
2862  case FNID_CALLWNDPROCRET:
2863  case FNID_SCROLLBAR:
2864  case FNID_DESKTOP:
2865  case FNID_MENU:
2866  if (ResultInfo)
2867  {
2868  _SEH2_TRY
2869  {
2870  ProbeForWrite((PVOID)ResultInfo, sizeof(LRESULT), 1);
2871  RtlCopyMemory((PVOID)ResultInfo, &lResult, sizeof(LRESULT));
2872  }
2874  {
2875  Ret = FALSE;
2876  }
2877  _SEH2_END;
2878  }
2879  break;
2880  default:
2881  break;
2882  }
2883 
2884  UserLeave();
2885 
2886  return Ret;
2887 }
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:1184
#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:1875
#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
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:4250
#define FNID_MESSAGEWND
Definition: ntuser.h:826
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:780
uint32_t ULONG_PTR
Definition: typedefs.h:63
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:1789
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:513
int HookId
Definition: ntuser.h:219
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#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:1492
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:117
struct tagHOOK * sphkCurrent
Definition: win32.h:117
uint32_t DWORD_PTR
Definition: typedefs.h:63
struct tagDOSENDMESSAGE * PDOSENDMESSAGE
#define FNID_CALLWNDPROC
Definition: ntuser.h:838
LRESULT APIENTRY ScrollBarWndProc(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: scrollbar.c:1147
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
#define FNID_BROADCASTSYSTEMMESSAGE
Definition: ntuser.h:849
_SEH2_END
Definition: create.c:4424
static int is_pointer_message(UINT message)
Definition: message.c:99
#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
struct @1587 Msg[]
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
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:1570
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 2175 of file message.c.

2180 {
2181  MSG Msg;
2182  BOOL Ret;
2183 
2184  if ( RemoveMsg & PM_BADMSGFLAGS )
2185  {
2187  return FALSE;
2188  }
2189 
2191 
2192  RtlZeroMemory(&Msg, sizeof(MSG));
2193 
2194  Ret = co_IntGetPeekMessage(&Msg, hWnd, MsgFilterMin, MsgFilterMax, RemoveMsg, FALSE);
2195 
2196  UserLeave();
2197 
2198  if (Ret)
2199  {
2200  _SEH2_TRY
2201  {
2202  ProbeForWrite(pMsg, sizeof(MSG), 1);
2203  RtlCopyMemory(pMsg, &Msg, sizeof(MSG));
2204  }
2206  {
2208  Ret = FALSE;
2209  }
2210  _SEH2_END;
2211  }
2212 
2213  return Ret;
2214 }
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
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4250
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:4424
BOOL APIENTRY co_IntGetPeekMessage(PMSG pMsg, HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg, BOOL bGMSG)
Definition: message.c:1018
struct @1587 Msg[]
#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 2063 of file message.c.

2067 {
2068  BOOL ret;
2069 
2071 
2073 
2074  UserLeave();
2075 
2076  return ret;
2077 }
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1184
HWND hWnd
Definition: settings.c:17
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
struct @1587 Msg[]
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 2080 of file message.c.

2084 {
2085  BOOL ret = FALSE;
2086  PETHREAD peThread;
2087  PTHREADINFO pThread;
2088  NTSTATUS Status;
2089 
2091 
2092  Status = PsLookupThreadByThreadId(UlongToHandle(idThread), &peThread);
2093 
2094  if ( Status == STATUS_SUCCESS )
2095  {
2096  pThread = (PTHREADINFO)peThread->Tcb.Win32Thread;
2097  if( !pThread ||
2098  !pThread->MessageQueue ||
2099  (pThread->TIF_flags & TIF_INCLEANUP))
2100  {
2101  ObDereferenceObject( peThread );
2102  goto exit;
2103  }
2104  ret = UserPostThreadMessage( pThread, Msg, wParam, lParam);
2105  ObDereferenceObject( peThread );
2106  }
2107  else
2108  {
2110  }
2111 exit:
2112  UserLeave();
2113  return ret;
2114 }
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:1034
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
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:1147
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
struct @1587 Msg[]
PVOID Win32Thread
Definition: ketypes.h:1756
void exit(int exitcode)
Definition: _exit.c:33
return STATUS_SUCCESS
Definition: btrfs.c:2938
LPARAM lParam
Definition: combotst.c:139
#define TIF_INCLEANUP
Definition: ntuser.h:240

Referenced by PostThreadMessageA(), and PostThreadMessageW().

◆ NtUserTranslateMessage()

BOOL APIENTRY NtUserTranslateMessage ( LPMSG  lpMsg,
UINT  flags 
)

Definition at line 2287 of file message.c.

2288 {
2289  MSG SafeMsg;
2290  BOOL Ret;
2291  PWND pWnd;
2292 
2293  _SEH2_TRY
2294  {
2295  ProbeForRead(lpMsg, sizeof(MSG), 1);
2296  RtlCopyMemory(&SafeMsg, lpMsg, sizeof(MSG));
2297  }
2299  {
2301  _SEH2_YIELD(return FALSE);
2302  }
2303  _SEH2_END;
2304 
2306  pWnd = UserGetWindowObject(SafeMsg.hwnd);
2307  if (pWnd) // Must have a window!
2308  {
2309  Ret = IntTranslateKbdMessage(&SafeMsg, flags);
2310  }
2311  else
2312  {
2313  TRACE("No Window for Translate. hwnd 0x%p Msg %u\n", SafeMsg.hwnd, SafeMsg.message);
2314  Ret = FALSE;
2315  }
2316  UserLeave();
2317 
2318  return Ret;
2319 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
BOOL FASTCALL IntTranslateKbdMessage(LPMSG lpMsg, UINT flags)
Definition: keyboard.c:1136
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
_SEH2_TRY
Definition: create.c:4250
unsigned int BOOL
Definition: ntddk_ex.h:94
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
#define TRACE(s)
Definition: solgame.cpp:4
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
GLbitfield flags
Definition: glext.h:7161
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
Definition: ntuser.h:657
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
_SEH2_END
Definition: create.c:4424
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12

Referenced by TranslateMessageEx().

◆ NtUserWaitForInputIdle()

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

Definition at line 2894 of file message.c.

2897 {
2899  PPROCESSINFO W32Process;
2900  PTHREADINFO pti;
2901  NTSTATUS Status;
2902  HANDLE Handles[3];
2905 
2907 
2910  *PsProcessType,
2911  UserMode,
2912  (PVOID*)&Process,
2913  NULL);
2914 
2915  if (!NT_SUCCESS(Status))
2916  {
2917  UserLeave();
2919  return WAIT_FAILED;
2920  }
2921 
2923 
2924  W32Process = (PPROCESSINFO)Process->Win32Process;
2925 
2927  !W32Process ||
2928  pti->ppi == W32Process)
2929  {
2931  UserLeave();
2933  return WAIT_FAILED;
2934  }
2935 
2936  Handles[0] = Process;
2937  Handles[1] = W32Process->InputIdleEvent;
2938  Handles[2] = pti->pEventQueueServer; // IntMsqSetWakeMask returns hEventQueueClient
2939 
2940  if (!Handles[1])
2941  {
2943  UserLeave();
2944  return STATUS_SUCCESS; /* no event to wait on */
2945  }
2946 
2947  if (dwMilliseconds != INFINITE)
2948  Timeout.QuadPart = (LONGLONG) dwMilliseconds * (LONGLONG) -10000;
2949 
2951 
2952  W32Process->W32PF_flags |= W32PF_WAITFORINPUTIDLE;
2953  for (pti = W32Process->ptiList; pti; pti = pti->ptiSibling)
2954  {
2956  pti->pClientInfo->dwTIFlags = pti->TIF_flags;
2957  }
2958 
2960 
2961  TRACE("WFII: ppi %p\n", W32Process);
2962  TRACE("WFII: waiting for %p\n", Handles[1] );
2963 
2964  /*
2965  * We must add a refcount to our current PROCESSINFO,
2966  * because anything could happen (including process death) we're leaving win32k
2967  */
2968  IntReferenceProcessInfo(W32Process);
2969 
2970  do
2971  {
2972  UserLeave();
2974  Handles,
2975  WaitAny,
2976  UserRequest,
2977  UserMode,
2978  FALSE,
2979  dwMilliseconds == INFINITE ? NULL : &Timeout,
2980  NULL);
2982 
2983  if (!NT_SUCCESS(Status))
2984  {
2986  Status = WAIT_FAILED;
2987  goto WaitExit;
2988  }
2989 
2990  switch (Status)
2991  {
2992  case STATUS_WAIT_0:
2993  goto WaitExit;
2994 
2995  case STATUS_WAIT_2:
2996  {
2997  MSG Msg;
2998  co_IntGetPeekMessage( &Msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE, FALSE);
2999  ERR("WFII: WAIT 2\n");
3000  }
3001  break;
3002 
3003  case STATUS_TIMEOUT:
3004  ERR("WFII: timeout\n");
3005  case WAIT_FAILED:
3006  goto WaitExit;
3007 
3008  default:
3009  ERR("WFII: finished\n");
3011  goto WaitExit;
3012  }
3013  }
3014  while (TRUE);
3015 
3016 WaitExit:
3017  for (pti = W32Process->ptiList; pti; pti = pti->ptiSibling)
3018  {
3020  pti->pClientInfo->dwTIFlags = pti->TIF_flags;
3021  }
3022  W32Process->W32PF_flags &= ~W32PF_WAITFORINPUTIDLE;
3023  IntDereferenceProcessInfo(W32Process);
3025  UserLeave();
3026  return Status;
3027 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
KAPC_STATE
Definition: ketypes.h:1273
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:158
PTHREADINFO ptiSibling
Definition: win32.h:115
FLONG TIF_flags
Definition: win32.h:94
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
struct _PROCESSINFO * PPROCESSINFO
Definition: ntwin32.h:5
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define TIF_WAITFORINPUTIDLE
Definition: ntuser.h:254
#define INFINITE
Definition: message.c:2889
PPROCESSINFO ppi
Definition: win32.h:87
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
#define STATUS_WAIT_2
Definition: ntstatus.h:72
#define STATUS_WAIT_0
Definition: ntstatus.h:223
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:496
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:701
smooth NULL
Definition: ftsmooth.c:416
#define IntReferenceProcessInfo(ppi)
Definition: win32.h:178
#define W32PF_WAITFORINPUTIDLE
Definition: win32.h:22
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
int64_t LONGLONG
Definition: typedefs.h:66
#define TRACE(s)
Definition: solgame.cpp:4
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PKEVENT pEventQueueServer
Definition: win32.h:124
NTSTATUS NTAPI KeWaitForMultipleObjects(IN ULONG Count, IN PVOID Object[], IN WAIT_TYPE WaitType, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL, OUT PKWAIT_BLOCK WaitBlockArray OPTIONAL)
Definition: wait.c:586
struct _CLIENTINFO * pClientInfo
Definition: win32.h:93
BOOLEAN NTAPI PsGetProcessExitProcessCalled(PEPROCESS Process)
Definition: process.c:1043
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
static ULONG Timeout
Definition: ping.c:61
BOOL APIENTRY co_IntGetPeekMessage(PMSG pMsg, HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg, BOOL bGMSG)
Definition: message.c:1018
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:753
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1492
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
struct @1587 Msg[]
PTHREADINFO ptiList
Definition: win32.h:248
#define PM_REMOVE
Definition: winuser.h:1182