ReactOS  0.4.14-dev-1338-g0d187f7
message.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Win32k subsystem
4  * PURPOSE: Messages
5  * FILE: win32ss/user/ntuser/message.c
6  * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
7  */
8 
9 #include <win32k.h>
10 
11 #include <dde.h>
12 
13 DBG_DEFAULT_CHANNEL(UserMsg);
14 
15 #define PM_BADMSGFLAGS ~((QS_RAWINPUT << 16)|PM_QS_SENDMESSAGE|PM_QS_PAINT|PM_QS_POSTMESSAGE|PM_QS_INPUT|PM_NOYIELD|PM_REMOVE)
16 
17 /* FUNCTIONS *****************************************************************/
18 
21 {
22  return STATUS_SUCCESS;
23 }
24 
27 {
28  return STATUS_SUCCESS;
29 }
30 
31 /* From wine: */
32 /* flag for messages that contain pointers */
33 /* 32 messages per entry, messages 0..31 map to bits 0..31 */
34 
35 #define SET(msg) (1 << ((msg) & 31))
36 
37 static const unsigned int message_pointer_flags[] =
38 {
39  /* 0x00 - 0x1f */
42  /* 0x20 - 0x3f */
45  /* 0x40 - 0x5f */
47  /* 0x60 - 0x7f */
48  SET(WM_STYLECHANGING) | SET(WM_STYLECHANGED),
49  /* 0x80 - 0x9f */
51  /* 0xa0 - 0xbf */
53  /* 0xc0 - 0xdf */
55  /* 0xe0 - 0xff */
56  SET(SBM_GETRANGE) | SET(SBM_SETSCROLLINFO) | SET(SBM_GETSCROLLINFO) | SET(SBM_GETSCROLLBARINFO),
57  /* 0x100 - 0x11f */
58  0,
59  /* 0x120 - 0x13f */
60  0,
61  /* 0x140 - 0x15f */
65  /* 0x160 - 0x17f */
66  0,
67  /* 0x180 - 0x19f */
71  /* 0x1a0 - 0x1bf */
73  /* 0x1c0 - 0x1df */
74  0,
75  /* 0x1e0 - 0x1ff */
76  0,
77  /* 0x200 - 0x21f */
79  /* 0x220 - 0x23f */
82  /* 0x240 - 0x25f */
83  0,
84  /* 0x260 - 0x27f */
85  0,
86  /* 0x280 - 0x29f */
87  0,
88  /* 0x2a0 - 0x2bf */
89  0,
90  /* 0x2c0 - 0x2df */
91  0,
92  /* 0x2e0 - 0x2ff */
93  0,
94  /* 0x300 - 0x31f */
96 };
97 
98 /* check whether a given message type includes pointers */
99 static inline int is_pointer_message( UINT message )
100 {
101  if (message >= 8*sizeof(message_pointer_flags)) return FALSE;
102  return (message_pointer_flags[message / 32] & SET(message)) != 0;
103 }
104 #undef SET
105 
106 #define MMS_SIZE_WPARAM -1
107 #define MMS_SIZE_WPARAMWCHAR -2
108 #define MMS_SIZE_LPARAMSZ -3
109 #define MMS_SIZE_SPECIAL -4
110 #define MMS_FLAG_READ 0x01
111 #define MMS_FLAG_WRITE 0x02
112 #define MMS_FLAG_READWRITE (MMS_FLAG_READ | MMS_FLAG_WRITE)
113 typedef struct tagMSGMEMORY
114 {
118 }
120 
122 {
129  { WM_STYLECHANGED, sizeof(STYLESTRUCT), MMS_FLAG_READ },
130  { WM_STYLECHANGING, sizeof(STYLESTRUCT), MMS_FLAG_READWRITE },
136  { WM_SIZING, sizeof(RECT), MMS_FLAG_READWRITE },
137  { WM_MOVING, sizeof(RECT), MMS_FLAG_READWRITE },
140  { WM_HELP, sizeof(HELPINFO), MMS_FLAG_READWRITE },
142 };
143 
144 static PMSGMEMORY FASTCALL
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 }
162 
163 static UINT FASTCALL
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 }
242 
244 {
245  PMSGMEMORY MsgMemoryEntry = FindMsgMemory(Msg);
246  if(MsgMemoryEntry == NULL) return 0;
247  return MsgMemorySize(MsgMemoryEntry, wParam, lParam);
248 }
249 
250 static NTSTATUS
251 PackParam(LPARAM *lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL NonPagedPoolNeeded)
252 {
253  NCCALCSIZE_PARAMS *UnpackedNcCalcsize;
254  NCCALCSIZE_PARAMS *PackedNcCalcsize;
255  CREATESTRUCTW *UnpackedCs;
256  CREATESTRUCTW *PackedCs;
257  PLARGE_STRING WindowName;
258  PUNICODE_STRING ClassName;
260  UINT Size;
261  PCHAR CsData;
262 
263  *lParamPacked = lParam;
264 
265  if (NonPagedPoolNeeded)
267  else
269 
270  if (WM_NCCALCSIZE == Msg && wParam)
271  {
272 
273  UnpackedNcCalcsize = (NCCALCSIZE_PARAMS *) lParam;
274  PackedNcCalcsize = ExAllocatePoolWithTag(PoolType,
275  sizeof(NCCALCSIZE_PARAMS) + sizeof(WINDOWPOS),
276  TAG_MSG);
277 
278  if (NULL == PackedNcCalcsize)
279  {
280  ERR("Not enough memory to pack lParam\n");
281  return STATUS_NO_MEMORY;
282  }
283  RtlCopyMemory(PackedNcCalcsize, UnpackedNcCalcsize, sizeof(NCCALCSIZE_PARAMS));
284  PackedNcCalcsize->lppos = (PWINDOWPOS) (PackedNcCalcsize + 1);
285  RtlCopyMemory(PackedNcCalcsize->lppos, UnpackedNcCalcsize->lppos, sizeof(WINDOWPOS));
286  *lParamPacked = (LPARAM) PackedNcCalcsize;
287  }
288  else if (WM_CREATE == Msg || WM_NCCREATE == Msg)
289  {
290  UnpackedCs = (CREATESTRUCTW *) lParam;
291  WindowName = (PLARGE_STRING) UnpackedCs->lpszName;
292  ClassName = (PUNICODE_STRING) UnpackedCs->lpszClass;
293  Size = sizeof(CREATESTRUCTW) + WindowName->Length + sizeof(WCHAR);
294  if (IS_ATOM(ClassName->Buffer))
295  {
296  Size += sizeof(WCHAR) + sizeof(ATOM);
297  }
298  else
299  {
300  Size += sizeof(WCHAR) + ClassName->Length + sizeof(WCHAR);
301  }
303  if (NULL == PackedCs)
304  {
305  ERR("Not enough memory to pack lParam\n");
306  return STATUS_NO_MEMORY;
307  }
308  RtlCopyMemory(PackedCs, UnpackedCs, sizeof(CREATESTRUCTW));
309  CsData = (PCHAR) (PackedCs + 1);
310  PackedCs->lpszName = (LPCWSTR) (CsData - (PCHAR) PackedCs);
311  RtlCopyMemory(CsData, WindowName->Buffer, WindowName->Length);
312  CsData += WindowName->Length;
313  *((WCHAR *) CsData) = L'\0';
314  CsData += sizeof(WCHAR);
315  PackedCs->lpszClass = (LPCWSTR) (CsData - (PCHAR) PackedCs);
316  if (IS_ATOM(ClassName->Buffer))
317  {
318  *((WCHAR *) CsData) = L'A';
319  CsData += sizeof(WCHAR);
320  *((ATOM *) CsData) = (ATOM)(DWORD_PTR) ClassName->Buffer;
321  CsData += sizeof(ATOM);
322  }
323  else
324  {
325  NT_ASSERT(ClassName->Buffer != NULL);
326  *((WCHAR *) CsData) = L'S';
327  CsData += sizeof(WCHAR);
328  RtlCopyMemory(CsData, ClassName->Buffer, ClassName->Length);
329  CsData += ClassName->Length;
330  *((WCHAR *) CsData) = L'\0';
331  CsData += sizeof(WCHAR);
332  }
333  ASSERT(CsData == (PCHAR) PackedCs + Size);
334  *lParamPacked = (LPARAM) PackedCs;
335  }
336  else if (PoolType == NonPagedPool)
337  {
338  PMSGMEMORY MsgMemoryEntry;
339  PVOID PackedData;
340  SIZE_T size;
341 
342  MsgMemoryEntry = FindMsgMemory(Msg);
343 
344  if (!MsgMemoryEntry)
345  {
346  /* Keep previous behavior */
347  return STATUS_SUCCESS;
348  }
349  size = MsgMemorySize(MsgMemoryEntry, wParam, lParam);
350  if (!size)
351  {
352  ERR("No size for lParamPacked\n");
353  return STATUS_SUCCESS;
354  }
356  if (PackedData == NULL)
357  {
358  ERR("Not enough memory to pack lParam\n");
359  return STATUS_NO_MEMORY;
360  }
361  RtlCopyMemory(PackedData, (PVOID)lParam, MsgMemorySize(MsgMemoryEntry, wParam, lParam));
362  *lParamPacked = (LPARAM)PackedData;
363  }
364 
365  return STATUS_SUCCESS;
366 }
367 
368 static NTSTATUS
369 UnpackParam(LPARAM lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL NonPagedPoolUsed)
370 {
371  NCCALCSIZE_PARAMS *UnpackedParams;
372  NCCALCSIZE_PARAMS *PackedParams;
373  PWINDOWPOS UnpackedWindowPos;
374 
375  if (lParamPacked == lParam)
376  {
377  return STATUS_SUCCESS;
378  }
379 
380  if (WM_NCCALCSIZE == Msg && wParam)
381  {
382  PackedParams = (NCCALCSIZE_PARAMS *) lParamPacked;
383  UnpackedParams = (NCCALCSIZE_PARAMS *) lParam;
384  UnpackedWindowPos = UnpackedParams->lppos;
385  RtlCopyMemory(UnpackedParams, PackedParams, sizeof(NCCALCSIZE_PARAMS));
386  UnpackedParams->lppos = UnpackedWindowPos;
387  RtlCopyMemory(UnpackedWindowPos, PackedParams + 1, sizeof(WINDOWPOS));
388  ExFreePool((PVOID) lParamPacked);
389 
390  return STATUS_SUCCESS;
391  }
392  else if (WM_CREATE == Msg || WM_NCCREATE == Msg)
393  {
394  ExFreePool((PVOID) lParamPacked);
395 
396  return STATUS_SUCCESS;
397  }
398  else if (NonPagedPoolUsed)
399  {
400  PMSGMEMORY MsgMemoryEntry;
401  MsgMemoryEntry = FindMsgMemory(Msg);
402  ASSERT(MsgMemoryEntry);
403 
404  if (MsgMemoryEntry->Flags == MMS_FLAG_READWRITE)
405  {
406  //RtlCopyMemory((PVOID)lParam, (PVOID)lParamPacked, MsgMemoryEntry->Size);
407  }
408  ExFreePool((PVOID) lParamPacked);
409  return STATUS_SUCCESS;
410  }
411 
412  ASSERT(FALSE);
413 
415 }
416 
417 static NTSTATUS FASTCALL
418 CopyMsgToKernelMem(MSG *KernelModeMsg, MSG *UserModeMsg, PMSGMEMORY MsgMemoryEntry)
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 }
473 
474 static NTSTATUS FASTCALL
475 CopyMsgToUserMem(MSG *UserModeMsg, MSG *KernelModeMsg)
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 }
510 
511 //
512 // Wakeup any thread/process waiting on idle input.
513 //
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 }
543 
546 {
548 
549  TRACE("IdlePong ppi %p\n", ppi);
550  if ( ppi && ppi->InputIdleEvent )
551  {
552  KeClearEvent(ppi->InputIdleEvent);
553  }
554 }
555 
557 {
558  return msg < WM_USER || msg >= 0xc000;
559 }
560 
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 }
579 
580 //
581 // Pass Strings to User Heap Space for Message Hook Callbacks.
582 //
583 BOOL
584 FASTCALL
586  PWND Window,
587  CREATESTRUCTW *pCsw,
588  CREATESTRUCTW *Cs,
589  PVOID *ppszClass,
590  PVOID *ppszName )
591 {
592  PLARGE_STRING WindowName;
593  PUNICODE_STRING ClassName;
594  PVOID pszClass = NULL, pszName = NULL;
595 
596  /* Fill the new CREATESTRUCTW */
597  RtlCopyMemory(pCsw, Cs, sizeof(CREATESTRUCTW));
598  pCsw->style = Window->style; /* HCBT_CREATEWND needs the real window style */
599 
600  WindowName = (PLARGE_STRING) Cs->lpszName;
601  ClassName = (PUNICODE_STRING) Cs->lpszClass;
602 
603  // Based on the assumption this is from "unicode source" user32, ReactOS, answer is yes.
604  if (!IS_ATOM(ClassName->Buffer))
605  {
606  if (ClassName->Length)
607  {
608  if (Window->state & WNDS_ANSICREATOR)
609  {
611  AnsiString.MaximumLength = (USHORT)RtlUnicodeStringToAnsiSize(ClassName)+sizeof(CHAR);
612  pszClass = UserHeapAlloc(AnsiString.MaximumLength);
613  if (!pszClass)
614  {
615  ERR("UserHeapAlloc() failed!\n");
616  return FALSE;
617  }
618  RtlZeroMemory(pszClass, AnsiString.MaximumLength);
619  AnsiString.Buffer = (PCHAR)pszClass;
621  }
622  else
623  {
625  UnicodeString.MaximumLength = ClassName->Length + sizeof(UNICODE_NULL);
626  pszClass = UserHeapAlloc(UnicodeString.MaximumLength);
627  if (!pszClass)
628  {
629  ERR("UserHeapAlloc() failed!\n");
630  return FALSE;
631  }
632  RtlZeroMemory(pszClass, UnicodeString.MaximumLength);
633  UnicodeString.Buffer = (PWSTR)pszClass;
634  RtlCopyUnicodeString(&UnicodeString, ClassName);
635  }
636  *ppszClass = pszClass;
637  pCsw->lpszClass = UserHeapAddressToUser(pszClass);
638  }
639  else
640  {
641  pCsw->lpszClass = NULL;
642  }
643  }
644  else
645  {
646  pCsw->lpszClass = ClassName->Buffer;
647  }
648  if (WindowName->Length)
649  {
651  Name.Buffer = WindowName->Buffer;
652  Name.Length = (USHORT)min(WindowName->Length, MAXUSHORT); // FIXME: LARGE_STRING truncated
653  Name.MaximumLength = (USHORT)min(WindowName->MaximumLength, MAXUSHORT);
654 
655  if (Window->state & WNDS_ANSICREATOR)
656  {
658  AnsiString.MaximumLength = (USHORT)RtlUnicodeStringToAnsiSize(&Name) + sizeof(CHAR);
659  pszName = UserHeapAlloc(AnsiString.MaximumLength);
660  if (!pszName)
661  {
662  ERR("UserHeapAlloc() failed!\n");
663  return FALSE;
664  }
665  RtlZeroMemory(pszName, AnsiString.MaximumLength);
666  AnsiString.Buffer = (PCHAR)pszName;
668  }
669  else
670  {
672  UnicodeString.MaximumLength = Name.Length + sizeof(UNICODE_NULL);
673  pszName = UserHeapAlloc(UnicodeString.MaximumLength);
674  if (!pszName)
675  {
676  ERR("UserHeapAlloc() failed!\n");
677  return FALSE;
678  }
679  RtlZeroMemory(pszName, UnicodeString.MaximumLength);
680  UnicodeString.Buffer = (PWSTR)pszName;
682  }
683  *ppszName = pszName;
684  pCsw->lpszName = UserHeapAddressToUser(pszName);
685  }
686  else
687  {
688  pCsw->lpszName = NULL;
689  }
690 
691  return TRUE;
692 }
693 
694 static VOID FASTCALL
696 {
697  BOOL SameThread = FALSE;
698  CWPSTRUCT CWP;
699  PVOID pszClass = NULL, pszName = NULL;
700  CREATESTRUCTW Csw;
701 
703  if ( !ISITHOOKED(WH_CALLWNDPROC) && !(Window->head.rpdesk->pDeskInfo->fsHooks & HOOKID_TO_FLAG(WH_CALLWNDPROC)) )
704  return;
705 
706  if (Window->head.pti == ((PTHREADINFO)PsGetCurrentThreadWin32Thread()))
707  SameThread = TRUE;
708 
709  if ( Msg == WM_CREATE || Msg == WM_NCCREATE )
710  { //
711  // String pointers are in user heap space, like WH_CBT HCBT_CREATEWND.
712  //
713  if (!IntMsgCreateStructW( Window, &Csw, (CREATESTRUCTW *)lParam, &pszClass, &pszName ))
714  return;
715  lParam = (LPARAM)&Csw;
716  }
717 
718  CWP.hwnd = hWnd;
719  CWP.message = Msg;
720  CWP.wParam = wParam;
721  CWP.lParam = lParam;
722  co_HOOK_CallHooks( WH_CALLWNDPROC, HC_ACTION, SameThread, (LPARAM)&CWP );
723 
724  if (pszName) UserHeapFree(pszName);
725  if (pszClass) UserHeapFree(pszClass);
726 }
727 
728 static VOID FASTCALL
730 {
731  BOOL SameThread = FALSE;
732  CWPRETSTRUCT CWPR;
733  PVOID pszClass = NULL, pszName = NULL;
734  CREATESTRUCTW Csw;
735 
736  if ( !ISITHOOKED(WH_CALLWNDPROCRET) && !(Window->head.rpdesk->pDeskInfo->fsHooks & HOOKID_TO_FLAG(WH_CALLWNDPROCRET)) )
737  return;
738 
739  if (Window->head.pti == ((PTHREADINFO)PsGetCurrentThreadWin32Thread()))
740  SameThread = TRUE;
741 
742  if ( Msg == WM_CREATE || Msg == WM_NCCREATE )
743  {
744  if (!IntMsgCreateStructW( Window, &Csw, (CREATESTRUCTW *)lParam, &pszClass, &pszName ))
745  return;
746  lParam = (LPARAM)&Csw;
747  }
748 
749  CWPR.hwnd = hWnd;
750  CWPR.message = Msg;
751  CWPR.wParam = wParam;
752  CWPR.lParam = lParam;
753  CWPR.lResult = uResult ? (*uResult) : 0;
754  co_HOOK_CallHooks( WH_CALLWNDPROCRET, HC_ACTION, SameThread, (LPARAM)&CWPR );
755 
756  if (pszName) UserHeapFree(pszName);
757  if (pszClass) UserHeapFree(pszClass);
758 }
759 
761 {
762  LRESULT lRes;
763 // USER_REFERENCE_ENTRY Ref;
764 // PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
765 
766  if (!pWnd || UserIsDesktopWindow(pWnd) || UserIsMessageWindow(pWnd))
767  return 0;
768 
769  TRACE("Internal Event Msg 0x%x hWnd 0x%p\n", msg, pWnd->head.h);
770 
771  switch(msg)
772  {
773  case WM_ASYNC_SHOWWINDOW:
774  return co_WinPosShowWindow( pWnd, wparam );
776  {
777  PWINDOWPOS winpos = (PWINDOWPOS)lparam;
778  if (!winpos) return 0;
779  lRes = co_WinPosSetWindowPos( pWnd,
780  winpos->hwndInsertAfter,
781  winpos->x,
782  winpos->y,
783  winpos->cx,
784  winpos->cy,
785  winpos->flags);
787  return lRes;
788  }
790  {
791  ERR("WM_ASYNC_DESTROYWINDOW\n");
792  if (pWnd->style & WS_CHILD)
794  else
795  co_UserDestroyWindow(pWnd);
796  }
797  }
798  return 0;
799 }
800 
801 static LRESULT handle_internal_events( PTHREADINFO pti, PWND pWnd, DWORD dwQEvent, LONG_PTR ExtraInfo, PMSG pMsg)
802 {
803  LRESULT Result = 0;
804 
805  switch(dwQEvent)
806  {
807  case POSTEVENT_NWE:
808  {
809  co_EVENT_CallEvents( pMsg->message, pMsg->hwnd, pMsg->wParam, ExtraInfo);
810  }
811  break;
812  case POSTEVENT_SAW:
813  {
814  //ERR("HIE : SAW : pti 0x%p hWnd 0x%p\n",pti,pMsg->hwnd);
815  IntActivateWindow((PWND)pMsg->wParam, pti, (HANDLE)pMsg->lParam, (DWORD)ExtraInfo);
816  }
817  break;
818  case POSTEVENT_DAW:
819  {
820  //ERR("HIE : DAW : pti 0x%p tid 0x%p hWndPrev 0x%p\n",pti,ExtraInfo,pMsg->hwnd);
821  IntDeactivateWindow(pti, (HANDLE)ExtraInfo);
822  }
823  break;
824  }
825  return Result;
826 }
827 
830 {
831  LONG Time;
832  LRESULT retval = 0;
833  PTHREADINFO pti;
834  PWND Window = NULL;
835  BOOL DoCallBack = TRUE;
836 
837  if (pMsg->hwnd)
838  {
840  if (!Window) return 0;
841  }
842 
844 
845  if ( Window && Window->head.pti != pti)
846  {
848  return 0;
849  }
850 
851  if (((pMsg->message == WM_SYSTIMER) ||
852  (pMsg->message == WM_TIMER)) &&
853  (pMsg->lParam) )
854  {
855  if (pMsg->message == WM_TIMER)
856  {
857  if (ValidateTimerCallback(pti,pMsg->lParam))
858  {
860  retval = co_IntCallWindowProc((WNDPROC)pMsg->lParam,
861  TRUE,
862  pMsg->hwnd,
863  WM_TIMER,
864  pMsg->wParam,
865  (LPARAM)Time,
866  -1);
867  }
868  return retval;
869  }
870  else
871  {
872  PTIMER pTimer = FindSystemTimer(pMsg);
873  if (pTimer && pTimer->pfn)
874  {
876  pTimer->pfn(pMsg->hwnd, WM_SYSTIMER, (UINT)pMsg->wParam, Time);
877  }
878  return 0;
879  }
880  }
881  // Need a window!
882  if ( !Window ) return 0;
883 
884  if (pMsg->message == WM_PAINT) Window->state |= WNDS_PAINTNOTPROCESSED;
885 
886  if ( Window->state & WNDS_SERVERSIDEWINDOWPROC )
887  {
888  TRACE("Dispatch: Server Side Window Procedure\n");
889  switch(Window->fnid)
890  {
891  case FNID_DESKTOP:
892  DoCallBack = !DesktopWindowProc( Window,
893  pMsg->message,
894  pMsg->wParam,
895  pMsg->lParam,
896  &retval);
897  break;
898  case FNID_MESSAGEWND:
899  DoCallBack = !UserMessageWindowProc( Window,
900  pMsg->message,
901  pMsg->wParam,
902  pMsg->lParam,
903  &retval);
904  break;
905  case FNID_MENU:
906  DoCallBack = !PopupMenuWndProc( Window,
907  pMsg->message,
908  pMsg->wParam,
909  pMsg->lParam,
910  &retval);
911  break;
912  }
913  }
914 
915  /* Since we are doing a callback on the same thread right away, there is
916  no need to copy the lparam to kernel mode and then back to usermode.
917  We just pretend it isn't a pointer */
918 
919  if (DoCallBack)
920  retval = co_IntCallWindowProc( Window->lpfnWndProc,
921  !Window->Unicode,
922  pMsg->hwnd,
923  pMsg->message,
924  pMsg->wParam,
925  pMsg->lParam,
926  -1);
927 
928  if ( pMsg->message == WM_PAINT &&
929  VerifyWnd(Window) &&
930  Window->state & WNDS_PAINTNOTPROCESSED ) // <--- Cleared, paint was already processed!
931  {
932  Window->state2 &= ~WNDS2_WMPAINTSENT;
933  /* send a WM_ERASEBKGND if the non-client area is still invalid */
934  ERR("Message WM_PAINT count %d Internal Paint Set? %s\n",Window->head.pti->cPaintsReady, Window->state & WNDS_INTERNALPAINT ? "TRUE" : "FALSE");
936  }
937 
938  return retval;
939 }
940 
941 /*
942  * Internal version of PeekMessage() doing all the work
943  *
944  * MSDN:
945  * Sent messages
946  * Posted messages
947  * Input (hardware) messages and system internal events
948  * Sent messages (again)
949  * WM_PAINT messages
950  * WM_TIMER messages
951  */
954  PWND Window,
955  UINT MsgFilterMin,
956  UINT MsgFilterMax,
957  UINT RemoveMsg,
958  LONG_PTR *ExtraInfo,
959  BOOL bGMSG )
960 {
961  PTHREADINFO pti;
962  BOOL RemoveMessages;
963  UINT ProcessMask;
964  BOOL Hit = FALSE;
965 
967 
968  RemoveMessages = RemoveMsg & PM_REMOVE;
969  ProcessMask = HIWORD(RemoveMsg);
970 
971  /* Hint, "If wMsgFilterMin and wMsgFilterMax are both zero, PeekMessage returns
972  all available messages (that is, no range filtering is performed)". */
973  if (!ProcessMask) ProcessMask = (QS_ALLPOSTMESSAGE|QS_ALLINPUT);
974 
975  IdlePong();
976 
977  do
978  {
979  /* Update the last message-queue access time */
980  pti->pcti->timeLastRead = EngGetTickCount32();
981 
982  // Post mouse moves while looping through peek messages.
983  if (pti->MessageQueue->QF_flags & QF_MOUSEMOVED)
984  {
986  }
987 
988  /* Dispatch sent messages here. */
989  while ( co_MsqDispatchOneSentMessage(pti) )
990  {
991  /* if some PM_QS* flags were specified, only handle sent messages from now on */
992  if (HIWORD(RemoveMsg) && !bGMSG) Hit = TRUE; // wine does this; ProcessMask = QS_SENDMESSAGE;
993  }
994  if (Hit) return FALSE;
995 
996  /* Clear changed bits so we can wait on them if we don't find a message */
997  if (ProcessMask & QS_POSTMESSAGE)
998  {
999  pti->pcti->fsChangeBits &= ~(QS_POSTMESSAGE | QS_HOTKEY | QS_TIMER);
1000  if (MsgFilterMin == 0 && MsgFilterMax == 0) // Wine hack does this; ~0U)
1001  {
1002  pti->pcti->fsChangeBits &= ~QS_ALLPOSTMESSAGE;
1003  }
1004  }
1005 
1006  if (ProcessMask & QS_INPUT)
1007  {
1008  pti->pcti->fsChangeBits &= ~QS_INPUT;
1009  }
1010 
1011  /* Now check for normal messages. */
1012  if (( (ProcessMask & QS_POSTMESSAGE) ||
1013  (ProcessMask & QS_HOTKEY) ) &&
1014  MsqPeekMessage( pti,
1015  RemoveMessages,
1016  Window,
1017  MsgFilterMin,
1018  MsgFilterMax,
1019  ProcessMask,
1020  ExtraInfo,
1021  0,
1022  Msg ))
1023  {
1024  goto GotMessage;
1025  }
1026 
1027  /* Only check for quit messages if not posted messages pending. */
1028  if (ProcessMask & QS_POSTMESSAGE && pti->QuitPosted)
1029  {
1030  /* According to the PSDK, WM_QUIT messages are always returned, regardless
1031  of the filter specified */
1032  Msg->hwnd = NULL;
1033  Msg->message = WM_QUIT;
1034  Msg->wParam = pti->exitCode;
1035  Msg->lParam = 0;
1036  if (RemoveMessages)
1037  {
1038  pti->QuitPosted = FALSE;
1040  pti->pcti->fsWakeBits &= ~QS_ALLPOSTMESSAGE;
1041  pti->pcti->fsChangeBits &= ~QS_ALLPOSTMESSAGE;
1042  }
1043  goto GotMessage;
1044  }
1045 
1046  /* Check for hardware events. */
1047  if ((ProcessMask & QS_INPUT) &&
1049  RemoveMessages,
1050  Window,
1051  MsgFilterMin,
1052  MsgFilterMax,
1053  ProcessMask,
1054  Msg))
1055  {
1056  goto GotMessage;
1057  }
1058 
1059  /* Now check for System Event messages. */
1060  {
1061  LONG_PTR eExtraInfo;
1062  MSG eMsg;
1063  DWORD dwQEvent;
1064  if (MsqPeekMessage( pti,
1065  TRUE,
1066  Window,
1067  0,
1068  0,
1069  QS_EVENT,
1070  &eExtraInfo,
1071  &dwQEvent,
1072  &eMsg ))
1073  {
1074  handle_internal_events( pti, Window, dwQEvent, eExtraInfo, &eMsg);
1075  continue;
1076  }
1077  }
1078 
1079  /* Check for sent messages again. */
1080  while ( co_MsqDispatchOneSentMessage(pti) )
1081  {
1082  if (HIWORD(RemoveMsg) && !bGMSG) Hit = TRUE;
1083  }
1084  if (Hit) return FALSE;
1085 
1086  /* Check for paint messages. */
1087  if ((ProcessMask & QS_PAINT) &&
1088  pti->cPaintsReady &&
1090  MsgFilterMin,
1091  MsgFilterMax,
1092  pti,
1093  Msg,
1094  RemoveMessages))
1095  {
1096  goto GotMessage;
1097  }
1098 
1099  /* This is correct, check for the current threads timers waiting to be
1100  posted to this threads message queue. If any we loop again.
1101  */
1102  if ((ProcessMask & QS_TIMER) &&
1104  {
1105  continue;
1106  }
1107 
1108  return FALSE;
1109  }
1110  while (TRUE);
1111 
1112 GotMessage:
1113  /* Update the last message-queue access time */
1114  pti->pcti->timeLastRead = EngGetTickCount32();
1115  return TRUE;
1116 }
1117 
1118 BOOL FASTCALL
1120  UINT MsgFilterMin,
1121  UINT MsgFilterMax )
1122 {
1123  PTHREADINFO pti;
1125  MSG Msg;
1126  LONG_PTR ExtraInfo = 0;
1127 
1129 
1130  do
1131  {
1132  if ( co_IntPeekMessage( &Msg, // Dont reenter!
1133  Window,
1134  MsgFilterMin,
1135  MsgFilterMax,
1136  MAKELONG( PM_NOREMOVE, GetWakeMask( MsgFilterMin, MsgFilterMax)),
1137  &ExtraInfo,
1138  TRUE ) ) // act like GetMessage.
1139  {
1140  return TRUE;
1141  }
1142 
1143  /* Nothing found. Wait for new messages. */
1145  Window,
1146  MsgFilterMin,
1147  MsgFilterMax);
1148  if (!NT_SUCCESS(Status))
1149  {
1151  ERR("Exit co_IntWaitMessage on error!\n");
1152  return FALSE;
1153  }
1155  {
1156  return FALSE;
1157  }
1158  }
1159  while ( TRUE );
1160 
1161  return FALSE;
1162 }
1163 
1164 BOOL APIENTRY
1166  HWND hWnd,
1167  UINT MsgFilterMin,
1168  UINT MsgFilterMax,
1169  UINT RemoveMsg,
1170  BOOL bGMSG )
1171 {
1172  PWND Window;
1173  PTHREADINFO pti;
1174  BOOL Present = FALSE;
1175  NTSTATUS Status;
1176  LONG_PTR ExtraInfo = 0;
1177 
1178  if ( hWnd == HWND_TOPMOST || hWnd == HWND_BROADCAST )
1179  hWnd = HWND_BOTTOM;
1180 
1181  /* Validate input */
1182  if (hWnd && hWnd != HWND_BOTTOM)
1183  {
1184  if (!(Window = UserGetWindowObject(hWnd)))
1185  {
1186  if (bGMSG)
1187  return -1;
1188  else
1189  return FALSE;
1190  }
1191  }
1192  else
1193  {
1194  Window = (PWND)hWnd;
1195  }
1196 
1197  if (MsgFilterMax < MsgFilterMin)
1198  {
1199  MsgFilterMin = 0;
1200  MsgFilterMax = 0;
1201  }
1202 
1203  if (bGMSG)
1204  {
1205  RemoveMsg |= ((GetWakeMask( MsgFilterMin, MsgFilterMax ))<< 16);
1206  }
1207 
1209  pti->pClientInfo->cSpins++; // Bump up the spin count.
1210 
1211  do
1212  {
1213  Present = co_IntPeekMessage( pMsg,
1214  Window,
1215  MsgFilterMin,
1216  MsgFilterMax,
1217  RemoveMsg,
1218  &ExtraInfo,
1219  bGMSG );
1220  if (Present)
1221  {
1222  /* GetMessage or PostMessage must never get messages that contain pointers */
1223  ASSERT(FindMsgMemory(pMsg->message) == NULL);
1224 
1225  if ( pMsg->message >= WM_DDE_FIRST && pMsg->message <= WM_DDE_LAST )
1226  {
1227  if (!IntDdeGetMessageHook(pMsg, ExtraInfo))
1228  {
1229  TRACE("DDE Get return ERROR\n");
1230  continue;
1231  }
1232  }
1233 
1234  if (pMsg->message != WM_PAINT && pMsg->message != WM_QUIT)
1235  {
1236  if (!RtlEqualMemory(&pti->ptLast, &pMsg->pt, sizeof(POINT)))
1237  {
1238  pti->TIF_flags |= TIF_MSGPOSCHANGED;
1239  }
1240  pti->timeLast = pMsg->time;
1241  pti->ptLast = pMsg->pt;
1242  }
1243 
1244  // The WH_GETMESSAGE hook enables an application to monitor messages about to
1245  // be returned by the GetMessage or PeekMessage function.
1246 
1247  co_HOOK_CallHooks( WH_GETMESSAGE, HC_ACTION, RemoveMsg & PM_REMOVE, (LPARAM)pMsg);
1248 
1249  if ( bGMSG || pMsg->message == WM_PAINT) break;
1250  }
1251 
1252  if ( bGMSG )
1253  {
1255  Window,
1256  MsgFilterMin,
1257  MsgFilterMax);
1258  if ( !NT_SUCCESS(Status) ||
1259  Status == STATUS_USER_APC ||
1260  Status == STATUS_TIMEOUT )
1261  {
1262  Present = -1;
1263  break;
1264  }
1265  }
1266  else
1267  {
1268  if (!(RemoveMsg & PM_NOYIELD))
1269  {
1270  IdlePing();
1271  // Yield this thread!
1272  UserLeave();
1273  ZwYieldExecution();
1275  // Fall through to exit.
1276  IdlePong();
1277  }
1278  break;
1279  }
1280  }
1281  while( bGMSG && !Present );
1282 
1283  // Been spinning, time to swap vinyl...
1284  if (pti->pClientInfo->cSpins >= 100)
1285  {
1286  // Clear the spin cycle to fix the mix.
1287  pti->pClientInfo->cSpins = 0;
1288  //if (!(pti->TIF_flags & TIF_SPINNING)) // FIXME: Need to swap vinyl...
1289  }
1290  return Present;
1291 }
1292 
1293 BOOL FASTCALL
1295  UINT Msg,
1296  WPARAM wParam,
1297  LPARAM lParam )
1298 {
1299  MSG Message;
1300 
1301  if (is_pointer_message(Msg))
1302  {
1304  return FALSE;
1305  }
1306  Message.hwnd = NULL;
1307  Message.message = Msg;
1308  Message.wParam = wParam;
1309  Message.lParam = lParam;
1310  Message.pt = gpsi->ptCursor;
1311  Message.time = EngGetTickCount32();
1312  MsqPostMessage(pti, &Message, FALSE, QS_POSTMESSAGE, 0, 0);
1313  return TRUE;
1314 }
1315 
1318 {
1319  if ( ptiCur )
1320  {
1321  if (!Window ||
1322  Window->head.pti == ptiCur )
1323  {
1324  return NULL;
1325  }
1326  }
1327  return Window ? Window->head.pti : NULL;
1328 }
1329 
1330 BOOL FASTCALL
1332  UINT Msg,
1333  WPARAM wParam,
1334  LPARAM lParam )
1335 {
1336  PTHREADINFO pti;
1337  MSG Message;
1338  LONG_PTR ExtraInfo = 0;
1339 
1340  Message.hwnd = Wnd;
1341  Message.message = Msg;
1342  Message.wParam = wParam;
1343  Message.lParam = lParam;
1344  Message.pt = gpsi->ptCursor;
1345  Message.time = EngGetTickCount32();
1346 
1347  if (is_pointer_message(Message.message))
1348  {
1350  return FALSE;
1351  }
1352 
1353  if (Wnd == HWND_BROADCAST || Wnd == HWND_TOPMOST)
1354  {
1355  HWND *List;
1357  ULONG i;
1358 
1359  if (!is_message_broadcastable(Msg)) return TRUE;
1360 
1363 
1364  if (List != NULL)
1365  {
1367  for (i = 0; List[i]; i++)
1368  {
1369  PWND pwnd = UserGetWindowObject(List[i]);
1370  if (!pwnd) continue;
1371 
1372  if ( pwnd->fnid == FNID_MENU || // Also need pwnd->pcls->atomClassName == gaOleMainThreadWndClass
1374  continue;
1375 
1377  }
1379  }
1380  }
1381  else
1382  {
1383  PWND Window;
1384 
1385  if (!Wnd)
1386  {
1388  Msg,
1389  wParam,
1390  lParam);
1391  }
1392 
1393  Window = UserGetWindowObject(Wnd);
1394  if ( !Window )
1395  {
1396  ERR("UserPostMessage: Invalid handle 0x%p Msg 0x%x!\n", Wnd, Msg);
1397  return FALSE;
1398  }
1399 
1400  pti = Window->head.pti;
1401 
1402  if ( pti->TIF_flags & TIF_INCLEANUP )
1403  {
1404  ERR("Attempted to post message to window %p when the thread is in cleanup!\n", Wnd);
1405  return FALSE;
1406  }
1407 
1408  if ( Window->state & WNDS_DESTROYED )
1409  {
1410  ERR("Attempted to post message to window %p that is being destroyed!\n", Wnd);
1411  /* FIXME: Last error code? */
1412  return FALSE;
1413  }
1414 
1415  if ( Msg >= WM_DDE_FIRST && Msg <= WM_DDE_LAST )
1416  {
1417  if (!IntDdePostMessageHook(Window, Msg, wParam, &lParam, &ExtraInfo))
1418  {
1419  TRACE("Posting Exit DDE 0x%x\n",Msg);
1420  return FALSE;
1421  }
1422  Message.lParam = lParam;
1423  }
1424 
1425  MsqPostMessage(pti, &Message, FALSE, QS_POSTMESSAGE, 0, ExtraInfo);
1426  }
1427  return TRUE;
1428 }
1429 
1432  UINT Msg,
1433  WPARAM wParam,
1434  LPARAM lParam )
1435 {
1436  ULONG_PTR Result = 0;
1437 
1439  {
1440  return (LRESULT)Result;
1441  }
1442  return 0;
1443 }
1444 
1445 static LRESULT FASTCALL
1447  UINT Msg,
1448  WPARAM wParam,
1449  LPARAM lParam,
1450  UINT uFlags,
1451  UINT uTimeout,
1452  ULONG_PTR *uResult )
1453 {
1455  PWND Window = NULL;
1456  PMSGMEMORY MsgMemoryEntry;
1457  INT lParamBufferSize;
1458  LPARAM lParamPacked;
1459  PTHREADINFO Win32Thread, ptiSendTo = NULL;
1460  ULONG_PTR Result = 0;
1463  BOOL DoCallBack = TRUE;
1464 
1465  if (!(Window = UserGetWindowObject(hWnd)))
1466  {
1467  TRACE("SendMessageTimeoutSingle: Invalid handle 0x%p!\n",hWnd);
1468  RETURN( FALSE);
1469  }
1470 
1471  UserRefObjectCo(Window, &Ref);
1472 
1473  Win32Thread = PsGetCurrentThreadWin32Thread();
1474 
1475  ptiSendTo = IntSendTo(Window, Win32Thread, Msg);
1476 
1477  if ( Msg >= WM_DDE_FIRST && Msg <= WM_DDE_LAST )
1478  {
1480  {
1481  ERR("Sending Exit DDE 0x%x\n",Msg);
1482  RETURN( FALSE);
1483  }
1484  }
1485 
1486  if ( !ptiSendTo )
1487  {
1488  if (Win32Thread->TIF_flags & TIF_INCLEANUP)
1489  {
1490  /* Never send messages to exiting threads */
1491  RETURN( FALSE);
1492  }
1493 
1494  if (Msg & 0x80000000)
1495  {
1496  TRACE("SMTS: Internal Message!\n");
1498  if (uResult) *uResult = Result;
1499  RETURN( TRUE);
1500  }
1501 
1502  // Only happens when calling the client!
1504 
1505  if ( Window->state & WNDS_SERVERSIDEWINDOWPROC )
1506  {
1507  TRACE("SMT: Server Side Window Procedure\n");
1508  // Handle it here. Safeguard against excessive recursions.
1509  if (IoGetRemainingStackSize() < PAGE_SIZE)
1510  {
1511  ERR("Server Callback Exceeded Stack!\n");
1512  RETURN( FALSE);
1513  }
1514  /* Return after server side call, IntCallWndProcRet will not be called. */
1515  switch(Window->fnid)
1516  {
1517  case FNID_DESKTOP:
1518  DoCallBack = !DesktopWindowProc(Window, Msg, wParam, lParam,(LRESULT*)&Result);
1519  break;
1520  case FNID_MESSAGEWND:
1522  break;
1523  case FNID_MENU:
1524  DoCallBack = !PopupMenuWndProc( Window, Msg, wParam, lParam,(LRESULT*)&Result);
1525  break;
1526  }
1527  if (!DoCallBack)
1528  {
1529  if (uResult) *uResult = Result;
1530  RETURN( TRUE);
1531  }
1532  }
1533  /* See if this message type is present in the table */
1534  MsgMemoryEntry = FindMsgMemory(Msg);
1535  if (NULL == MsgMemoryEntry)
1536  {
1537  lParamBufferSize = -1;
1538  }
1539  else
1540  {
1541  lParamBufferSize = MsgMemorySize(MsgMemoryEntry, wParam, lParam);
1542  // If zero, do not allow callback on client side to allocate a buffer!!!!! See CORE-7695.
1543  if (!lParamBufferSize) lParamBufferSize = -1;
1544  }
1545 
1546  if (! NT_SUCCESS(PackParam(&lParamPacked, Msg, wParam, lParam, FALSE)))
1547  {
1548  ERR("Failed to pack message parameters\n");
1549  RETURN( FALSE);
1550  }
1551 
1552  Result = (ULONG_PTR)co_IntCallWindowProc( Window->lpfnWndProc,
1553  !Window->Unicode,
1554  hWnd,
1555  Msg,
1556  wParam,
1557  lParamPacked,
1558  lParamBufferSize );
1559  if (uResult)
1560  {
1561  *uResult = Result;
1562  }
1563 
1564  if (! NT_SUCCESS(UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE)))
1565  {
1566  ERR("Failed to unpack message parameters\n");
1567  RETURN( TRUE);
1568  }
1569 
1570  // Only happens when calling the client!
1571  IntCallWndProcRet( Window, hWnd, Msg, wParam, lParam, (LRESULT *)uResult);
1572 
1573  RETURN( TRUE);
1574  }
1575 
1576  if (Window->state & WNDS_DESTROYED)
1577  {
1578  /* FIXME: Last error? */
1579  ERR("Attempted to send message to window %p that is being destroyed!\n", hWnd);
1580  RETURN( FALSE);
1581  }
1582 
1583  if ((uFlags & SMTO_ABORTIFHUNG) && MsqIsHung(ptiSendTo, 4 * MSQ_HUNG))
1584  {
1585  // FIXME: Set window hung and add to a list.
1586  /* FIXME: Set a LastError? */
1587  ERR("Window %p (%p) (pti %p) is hung!\n", hWnd, Window, ptiSendTo);
1588  RETURN( FALSE);
1589  }
1590 
1591  do
1592  {
1593  Status = co_MsqSendMessage( ptiSendTo,
1594  hWnd,
1595  Msg,
1596  wParam,
1597  lParam,
1598  uTimeout,
1599  (uFlags & SMTO_BLOCK),
1600  MSQ_NORMAL,
1601  uResult );
1602  }
1603  while ((Status == STATUS_TIMEOUT) &&
1604  (uFlags & SMTO_NOTIMEOUTIFNOTHUNG) &&
1605  !MsqIsHung(ptiSendTo, MSQ_HUNG)); // FIXME: Set window hung and add to a list.
1606 
1607  if (Status == STATUS_TIMEOUT)
1608  {
1609  if (0 && MsqIsHung(ptiSendTo, MSQ_HUNG))
1610  {
1611  TRACE("Let's go Ghost!\n");
1613  }
1614 /*
1615  * MSDN says:
1616  * Microsoft Windows 2000: If GetLastError returns zero, then the function
1617  * timed out.
1618  * XP+ : If the function fails or times out, the return value is zero.
1619  * To get extended error information, call GetLastError. If GetLastError
1620  * returns ERROR_TIMEOUT, then the function timed out.
1621  */
1623  RETURN( FALSE);
1624  }
1625  else if (!NT_SUCCESS(Status))
1626  {
1628  RETURN( FALSE);
1629  }
1630 
1631  RETURN( TRUE);
1632 
1633 CLEANUP:
1635  END_CLEANUP;
1636 }
1637 
1640  UINT Msg,
1641  WPARAM wParam,
1642  LPARAM lParam,
1643  UINT uFlags,
1644  UINT uTimeout,
1645  ULONG_PTR *uResult )
1646 {
1648  HWND *Children;
1649  HWND *Child;
1650 
1651  if (hWnd != HWND_BROADCAST && hWnd != HWND_TOPMOST)
1652  {
1653  return co_IntSendMessageTimeoutSingle(hWnd, Msg, wParam, lParam, uFlags, uTimeout, uResult);
1654  }
1655 
1656  if (!is_message_broadcastable(Msg)) return TRUE;
1657 
1659  if (NULL == DesktopWindow)
1660  {
1662  return 0;
1663  }
1664 
1665  if (hWnd != HWND_TOPMOST)
1666  {
1667  /* Send message to the desktop window too! */
1668  co_IntSendMessageTimeoutSingle(DesktopWindow->head.h, Msg, wParam, lParam, uFlags, uTimeout, uResult);
1669  }
1670 
1671  Children = IntWinListChildren(DesktopWindow);
1672  if (NULL == Children)
1673  {
1674  return 0;
1675  }
1676 
1677  for (Child = Children; NULL != *Child; Child++)
1678  {
1679  PWND pwnd = UserGetWindowObject(*Child);
1680  if (!pwnd) continue;
1681 
1682  if ( pwnd->fnid == FNID_MENU ||
1684  continue;
1685 
1686  co_IntSendMessageTimeoutSingle(*Child, Msg, wParam, lParam, uFlags, uTimeout, uResult);
1687  }
1688 
1690 
1691  return (LRESULT) TRUE;
1692 }
1693 
1696  UINT Msg,
1697  WPARAM wParam,
1698  LPARAM lParam)
1699 {
1700  ULONG_PTR Result = 0;
1702  Msg,
1703  wParam,
1704  lParam,
1705  NULL,
1706  0,
1707  &Result);
1708 }
1709 /* MSDN:
1710  If you send a message in the range below WM_USER to the asynchronous message
1711  functions (PostMessage, SendNotifyMessage, and SendMessageCallback), its
1712  message parameters cannot include pointers. Otherwise, the operation will fail.
1713  The functions will return before the receiving thread has had a chance to
1714  process the message and the sender will free the memory before it is used.
1715 */
1718  UINT Msg,
1719  WPARAM wParam,
1720  LPARAM lParam,
1722  ULONG_PTR CompletionCallbackContext,
1723  ULONG_PTR *uResult)
1724 {
1725  ULONG_PTR Result;
1726  PWND Window = NULL;
1727  PMSGMEMORY MsgMemoryEntry;
1728  INT lParamBufferSize;
1729  LPARAM lParamPacked;
1730  PTHREADINFO Win32Thread, ptiSendTo = NULL;
1734  BOOL DoCallBack = TRUE;
1735 
1736  if (!(Window = UserGetWindowObject(hWnd)))
1737  {
1738  TRACE("SendMessageWithCallBack: Invalid handle 0x%p!\n",hWnd);
1739  RETURN(FALSE);
1740  }
1741 
1742  UserRefObjectCo(Window, &Ref);
1743 
1744  if (Window->state & WNDS_DESTROYED)
1745  {
1746  /* FIXME: last error? */
1747  ERR("Attempted to send message to window %p that is being destroyed!\n", hWnd);
1748  RETURN(FALSE);
1749  }
1750 
1751  Win32Thread = PsGetCurrentThreadWin32Thread();
1752 
1753  if (Win32Thread == NULL ||
1754  Win32Thread->TIF_flags & TIF_INCLEANUP)
1755  {
1756  RETURN(FALSE);
1757  }
1758 
1759  ptiSendTo = IntSendTo(Window, Win32Thread, Msg);
1760 
1761  if (Msg & 0x80000000 &&
1762  !ptiSendTo)
1763  {
1764  if (Win32Thread->TIF_flags & TIF_INCLEANUP) RETURN( FALSE);
1765 
1766  TRACE("SMWCB: Internal Message!\n");
1768  if (uResult) *uResult = Result;
1769  RETURN( TRUE);
1770  }
1771 
1772  /* See if this message type is present in the table */
1773  MsgMemoryEntry = FindMsgMemory(Msg);
1774  if (NULL == MsgMemoryEntry)
1775  {
1776  lParamBufferSize = -1;
1777  }
1778  else
1779  {
1780  lParamBufferSize = MsgMemorySize(MsgMemoryEntry, wParam, lParam);
1781  if (!lParamBufferSize) lParamBufferSize = -1;
1782  }
1783 
1784  if (! NT_SUCCESS(PackParam(&lParamPacked, Msg, wParam, lParam, !!ptiSendTo)))
1785  {
1786  ERR("Failed to pack message parameters\n");
1787  RETURN( FALSE);
1788  }
1789 
1790  /* If it can be sent now, then send it. */
1791  if ( !ptiSendTo )
1792  {
1793  if (Win32Thread->TIF_flags & TIF_INCLEANUP)
1794  {
1795  UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE);
1796  /* Never send messages to exiting threads */
1797  RETURN(FALSE);
1798  }
1799 
1801 
1802  if ( Window->state & WNDS_SERVERSIDEWINDOWPROC )
1803  {
1804  TRACE("SMWCB: Server Side Window Procedure\n");
1805  switch(Window->fnid)
1806  {
1807  case FNID_DESKTOP:
1808  DoCallBack = !DesktopWindowProc(Window, Msg, wParam, lParamPacked, (LRESULT*)&Result);
1809  break;
1810  case FNID_MESSAGEWND:
1812  break;
1813  case FNID_MENU:
1814  DoCallBack = !PopupMenuWndProc( Window, Msg, wParam, lParam,(LRESULT*)&Result);
1815  break;
1816  }
1817  }
1818 
1819  if (DoCallBack)
1820  Result = (ULONG_PTR)co_IntCallWindowProc( Window->lpfnWndProc,
1821  !Window->Unicode,
1822  hWnd,
1823  Msg,
1824  wParam,
1825  lParamPacked,
1826  lParamBufferSize );
1827  if(uResult)
1828  {
1829  *uResult = Result;
1830  }
1831 
1832  IntCallWndProcRet( Window, hWnd, Msg, wParam, lParam, (LRESULT *)uResult);
1833 
1834  if (CompletionCallback)
1835  {
1837  hWnd,
1838  Msg,
1839  CompletionCallbackContext,
1840  Result);
1841  }
1842  }
1843 
1844  if ( !ptiSendTo)
1845  {
1846  if (! NT_SUCCESS(UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE)))
1847  {
1848  ERR("Failed to unpack message parameters\n");
1849  }
1850  RETURN(TRUE);
1851  }
1852 
1854  {
1855  ERR("MsqSendMessage(): Not enough memory to allocate a message");
1856  RETURN( FALSE);
1857  }
1858 
1859  Message->Msg.hwnd = hWnd;
1860  Message->Msg.message = Msg;
1861  Message->Msg.wParam = wParam;
1862  Message->Msg.lParam = lParamPacked;
1863  Message->pkCompletionEvent = NULL; // No event needed.
1864  Message->lResult = 0;
1865  Message->QS_Flags = 0;
1866  Message->ptiReceiver = ptiSendTo;
1867  Message->ptiSender = NULL; // mjmartin, you are right! This is null.
1868  Message->ptiCallBackSender = Win32Thread;
1869  Message->CompletionCallback = CompletionCallback;
1870  Message->CompletionCallbackContext = CompletionCallbackContext;
1871  Message->HookMessage = MSQ_NORMAL;
1872  Message->HasPackedLParam = (lParamBufferSize > 0);
1873  Message->QS_Flags = QS_SENDMESSAGE;
1874  Message->flags = SMF_RECEIVERFREE;
1875 
1876  if (Msg & 0x80000000) // Higher priority event message!
1877  InsertHeadList(&ptiSendTo->SentMessagesListHead, &Message->ListEntry);
1878  else
1879  InsertTailList(&ptiSendTo->SentMessagesListHead, &Message->ListEntry);
1880  MsqWakeQueue(ptiSendTo, QS_SENDMESSAGE, TRUE);
1881 
1882  RETURN(TRUE);
1883 
1884 CLEANUP:
1886  END_CLEANUP;
1887 }
1888 
1889 #if 0
1890 /*
1891  This HACK function posts a message if the destination's message queue belongs to
1892  another thread, otherwise it sends the message. It does not support broadcast
1893  messages!
1894 */
1897  UINT Msg,
1898  WPARAM wParam,
1899  LPARAM lParam )
1900 {
1901  ULONG_PTR Result;
1902  PTHREADINFO pti;
1903  PWND Window;
1904 
1905  if ( hWnd == HWND_BROADCAST )
1906  {
1907  return 0;
1908  }
1909 
1910  if(!(Window = UserGetWindowObject(hWnd)))
1911  {
1912  TRACE("PostOrSendMessage: Invalid handle 0x%p!\n",hWnd);
1913  return 0;
1914  }
1915 
1917 
1918  if ( IntSendTo(Window, pti, Msg) &&
1919  FindMsgMemory(Msg) == 0 )
1920  {
1922  }
1923  else
1924  {
1926  {
1927  Result = 0;
1928  }
1929  }
1930 
1931  return (LRESULT)Result;
1932 }
1933 #endif
1934 
1935 static LRESULT FASTCALL
1937  UINT Msg,
1938  WPARAM wParam,
1939  LPARAM lParam,
1940  PDOSENDMESSAGE dsm)
1941 {
1942  LRESULT Result = TRUE;
1943  NTSTATUS Status;
1944  PWND Window = NULL;
1945  MSG UserModeMsg, KernelModeMsg;
1946  PMSGMEMORY MsgMemoryEntry;
1947  PTHREADINFO ptiSendTo;
1948 
1949  if (hWnd != HWND_BROADCAST && hWnd != HWND_TOPMOST)
1950  {
1952  if ( !Window )
1953  {
1954  return 0;
1955  }
1956  }
1957 
1958  /* Check for an exiting window. */
1959  if (Window && Window->state & WNDS_DESTROYED)
1960  {
1961  ERR("co_IntDoSendMessage Window Exiting!\n");
1962  }
1963 
1964  /* See if the current thread can handle this message */
1965  ptiSendTo = IntSendTo(Window, gptiCurrent, Msg);
1966 
1967  // If broadcasting or sending to another thread, save the users data.
1968  if (!Window || ptiSendTo )
1969  {
1970  UserModeMsg.hwnd = hWnd;
1971  UserModeMsg.message = Msg;
1972  UserModeMsg.wParam = wParam;
1973  UserModeMsg.lParam = lParam;
1974  MsgMemoryEntry = FindMsgMemory(UserModeMsg.message);
1975  Status = CopyMsgToKernelMem(&KernelModeMsg, &UserModeMsg, MsgMemoryEntry);
1976  if (!NT_SUCCESS(Status))
1977  {
1979  return (dsm ? 0 : -1);
1980  }
1981  }
1982  else
1983  {
1984  KernelModeMsg.hwnd = hWnd;
1985  KernelModeMsg.message = Msg;
1986  KernelModeMsg.wParam = wParam;
1987  KernelModeMsg.lParam = lParam;
1988  }
1989 
1990  if (!dsm)
1991  {
1992  Result = co_IntSendMessage( KernelModeMsg.hwnd,
1993  KernelModeMsg.message,
1994  KernelModeMsg.wParam,
1995  KernelModeMsg.lParam );
1996  }
1997  else
1998  {
1999  Result = co_IntSendMessageTimeout( KernelModeMsg.hwnd,
2000  KernelModeMsg.message,
2001  KernelModeMsg.wParam,
2002  KernelModeMsg.lParam,
2003  dsm->uFlags,
2004  dsm->uTimeout,
2005  &dsm->Result );
2006  }
2007 
2008  if (!Window || ptiSendTo )
2009  {
2010  Status = CopyMsgToUserMem(&UserModeMsg, &KernelModeMsg);
2011  if (!NT_SUCCESS(Status))
2012  {
2014  return(dsm ? 0 : -1);
2015  }
2016  }
2017 
2018  return (LRESULT)Result;
2019 }
2020 
2021 BOOL FASTCALL
2023  UINT Msg,
2024  WPARAM wParam,
2025  LPARAM lParam )
2026 {
2027  BOOL Ret = TRUE;
2028 
2029  if (is_pointer_message(Msg))
2030  {
2032  return FALSE;
2033  }
2034 
2035  // Basicly the same as IntPostOrSendMessage
2036  if (hWnd == HWND_BROADCAST) // Handle Broadcast
2037  {
2038  HWND *List;
2040  ULONG i;
2041 
2044 
2045  if (List != NULL)
2046  {
2048  for (i = 0; List[i]; i++)
2049  {
2050  PWND pwnd = UserGetWindowObject(List[i]);
2051  if (!pwnd) continue;
2052 
2053  if ( pwnd->fnid == FNID_MENU ||
2055  continue;
2056 
2058  }
2060  }
2061  }
2062  else
2063  {
2065  }
2066  return Ret;
2067 }
2068 
2069 
2072 {
2073  PTHREADINFO pti;
2074  DWORD Result;
2075 
2077 // wine:
2079 
2080  /* High word, types of messages currently in the queue.
2081  Low word, types of messages that have been added to the queue and that
2082  are still in the queue
2083  */
2084  Result = MAKELONG(pti->pcti->fsChangeBits & Changes, pti->pcti->fsWakeBits & Changes);
2085 
2086  pti->pcti->fsChangeBits &= ~Changes;
2087 
2088  return Result;
2089 }
2090 
2091 BOOL APIENTRY
2093 {
2095 
2096  if (pti->pcti)
2097  {
2098  pti->pcti->dwcPumpHook++;
2099  return TRUE;
2100  }
2101  return FALSE;
2102 }
2103 
2104 BOOL APIENTRY
2106 {
2108 
2109  if (pti->pcti)
2110  {
2111  if (pti->pcti->dwcPumpHook <= 0)
2112  {
2113  return FALSE;
2114  }
2115  pti->pcti->dwcPumpHook--;
2116  return TRUE;
2117  }
2118  return FALSE;
2119 }
2120 
2121 BOOL FASTCALL
2123 {
2124  BOOL Ret = FALSE;
2125 
2126  if ( co_HOOK_CallHooks( WH_SYSMSGFILTER, code, 0, (LPARAM)lpmsg))
2127  {
2128  Ret = TRUE;
2129  }
2130  else
2131  {
2132  Ret = co_HOOK_CallHooks( WH_MSGFILTER, code, 0, (LPARAM)lpmsg);
2133  }
2134  return Ret;
2135 }
2136 
2139 BOOL
2140 APIENTRY
2142  HWND hWnd,
2143  POINT pt) // Just like the User call.
2144 {
2145  MSG msg;
2146  RECT rect;
2147  ULONG wDragWidth, wDragHeight;
2149 
2150  TRACE("Enter NtUserDragDetect(%p)\n", hWnd);
2152 
2153  wDragWidth = UserGetSystemMetrics(SM_CXDRAG);
2154  wDragHeight= UserGetSystemMetrics(SM_CYDRAG);
2155 
2156  rect.left = pt.x - wDragWidth;
2157  rect.right = pt.x + wDragWidth;
2158 
2159  rect.top = pt.y - wDragHeight;
2160  rect.bottom = pt.y + wDragHeight;
2161 
2163 
2164  for (;;)
2165  {
2169  {
2170  if ( msg.message == WM_LBUTTONUP )
2171  {
2173  RETURN( FALSE);
2174  }
2175  if ( msg.message == WM_MOUSEMOVE )
2176  {
2177  POINT tmp;
2178  tmp.x = (short)LOWORD(msg.lParam);
2179  tmp.y = (short)HIWORD(msg.lParam);
2180  if( !RECTL_bPointInRect( &rect, tmp.x, tmp.y ) )
2181  {
2183  RETURN( TRUE);
2184  }
2185  }
2186  if ( msg.message == WM_KEYDOWN )
2187  {
2188  if ( msg.wParam == VK_ESCAPE )
2189  {
2191  RETURN( TRUE);
2192  }
2193  }
2194  if ( msg.message == WM_QUEUESYNC )
2195  {
2196  co_HOOK_CallHooks( WH_CBT, HCBT_QS, 0, 0 );
2197  }
2198  }
2199  co_IntWaitMessage(NULL, 0, 0);
2200  }
2201  RETURN( FALSE);
2202 
2203 CLEANUP:
2204  TRACE("Leave NtUserDragDetect, ret=%i\n",_ret_);
2205  UserLeave();
2206  END_CLEANUP;
2207 }
2208 
2209 BOOL APIENTRY
2211  UINT Msg,
2212  WPARAM wParam,
2213  LPARAM lParam)
2214 {
2215  BOOL ret;
2216 
2218 
2220 
2221  UserLeave();
2222 
2223  return ret;
2224 }
2225 
2226 BOOL APIENTRY
2228  UINT Msg,
2229  WPARAM wParam,
2230  LPARAM lParam)
2231 {
2232  BOOL ret = FALSE;
2233  PETHREAD peThread;
2234  PTHREADINFO pThread;
2235  NTSTATUS Status;
2236 
2238 
2239  Status = PsLookupThreadByThreadId(UlongToHandle(idThread), &peThread);
2240 
2241  if ( Status == STATUS_SUCCESS )
2242  {
2243  pThread = (PTHREADINFO)peThread->Tcb.Win32Thread;
2244  if( !pThread ||
2245  !pThread->MessageQueue ||
2246  (pThread->TIF_flags & TIF_INCLEANUP))
2247  {
2248  ObDereferenceObject( peThread );
2249  goto exit;
2250  }
2251  ret = UserPostThreadMessage( pThread, Msg, wParam, lParam);
2252  ObDereferenceObject( peThread );
2253  }
2254  else
2255  {
2257  }
2258 exit:
2259  UserLeave();
2260  return ret;
2261 }
2262 
2263 BOOL APIENTRY
2265 {
2266  BOOL ret;
2267 
2269  TRACE("NtUserWaitMessage Enter\n");
2270  ret = co_IntWaitMessage(NULL, 0, 0);
2271  TRACE("NtUserWaitMessage Leave\n");
2272  UserLeave();
2273 
2274  return ret;
2275 }
2276 
2277 BOOL APIENTRY
2279  HWND hWnd,
2280  UINT MsgFilterMin,
2281  UINT MsgFilterMax )
2282 {
2283  MSG Msg;
2284  BOOL Ret;
2285 
2286  if ( (MsgFilterMin|MsgFilterMax) & ~WM_MAXIMUM )
2287  {
2289  return FALSE;
2290  }
2291 
2293 
2294  RtlZeroMemory(&Msg, sizeof(MSG));
2295 
2296  Ret = co_IntGetPeekMessage(&Msg, hWnd, MsgFilterMin, MsgFilterMax, PM_REMOVE, TRUE);
2297 
2298  UserLeave();
2299 
2300  if (Ret)
2301  {
2302  _SEH2_TRY
2303  {
2304  ProbeForWrite(pMsg, sizeof(MSG), 1);
2305  RtlCopyMemory(pMsg, &Msg, sizeof(MSG));
2306  }
2308  {
2310  Ret = FALSE;
2311  }
2312  _SEH2_END;
2313  }
2314 
2315  if ((INT)Ret != -1)
2316  Ret = Ret ? (WM_QUIT != pMsg->message) : FALSE;
2317 
2318  return Ret;
2319 }
2320 
2321 BOOL APIENTRY
2323  HWND hWnd,
2324  UINT MsgFilterMin,
2325  UINT MsgFilterMax,
2326  UINT RemoveMsg)
2327 {
2328  MSG Msg;
2329  BOOL Ret;
2330 
2331  if ( RemoveMsg & PM_BADMSGFLAGS )
2332  {
2334  return FALSE;
2335  }
2336 
2338 
2339  RtlZeroMemory(&Msg, sizeof(MSG));
2340 
2341  Ret = co_IntGetPeekMessage(&Msg, hWnd, MsgFilterMin, MsgFilterMax, RemoveMsg, FALSE);
2342 
2343  UserLeave();
2344 
2345  if (Ret)
2346  {
2347  _SEH2_TRY
2348  {
2349  ProbeForWrite(pMsg, sizeof(MSG), 1);
2350  RtlCopyMemory(pMsg, &Msg, sizeof(MSG));
2351  }
2353  {
2355  Ret = FALSE;
2356  }
2357  _SEH2_END;
2358  }
2359 
2360  return Ret;
2361 }
2362 
2363 BOOL APIENTRY
2365 {
2366  BOOL Ret = FALSE;
2367  MSG Msg;
2368 
2369  _SEH2_TRY
2370  {
2371  ProbeForRead(lpmsg, sizeof(MSG), 1);
2372  RtlCopyMemory( &Msg, lpmsg, sizeof(MSG));
2373  }
2375  {
2376  _SEH2_YIELD(return FALSE);
2377  }
2378  _SEH2_END;
2379 
2381 
2383  {
2384  Ret = TRUE;
2385  }
2386  else
2387  {
2388  Ret = co_HOOK_CallHooks( WH_MSGFILTER, code, 0, (LPARAM)&Msg);
2389  }
2390 
2391  UserLeave();
2392 
2393  _SEH2_TRY
2394  {
2395  ProbeForWrite(lpmsg, sizeof(MSG), 1);
2396  RtlCopyMemory(lpmsg, &Msg, sizeof(MSG));
2397  }
2399  {
2400  Ret = FALSE;
2401  }
2402  _SEH2_END;
2403 
2404  return Ret;
2405 }
2406 
2409 {
2410  LRESULT Res = 0;
2411  MSG SafeMsg;
2412 
2413  _SEH2_TRY
2414  {
2415  ProbeForRead(UnsafeMsgInfo, sizeof(MSG), 1);
2416  RtlCopyMemory(&SafeMsg, UnsafeMsgInfo, sizeof(MSG));
2417  }
2419  {
2421  _SEH2_YIELD(return FALSE);
2422  }
2423  _SEH2_END;
2424 
2426 
2427  Res = IntDispatchMessage(&SafeMsg);
2428 
2429  UserLeave();
2430  return Res;
2431 }
2432 
2433 BOOL APIENTRY
2435 {
2436  MSG SafeMsg;
2437  BOOL Ret;
2438  PWND pWnd;
2439 
2440  _SEH2_TRY
2441  {
2442  ProbeForRead(lpMsg, sizeof(MSG), 1);
2443  RtlCopyMemory(&SafeMsg, lpMsg, sizeof(MSG));
2444  }
2446  {
2448  _SEH2_YIELD(return FALSE);
2449  }
2450  _SEH2_END;
2451 
2453  pWnd = UserGetWindowObject(SafeMsg.hwnd);
2454  if (pWnd) // Must have a window!
2455  {
2456  Ret = IntTranslateKbdMessage(&SafeMsg, flags);
2457  }
2458  else
2459  {
2460  TRACE("No Window for Translate. hwnd 0x%p Msg %u\n", SafeMsg.hwnd, SafeMsg.message);
2461  Ret = FALSE;
2462  }
2463  UserLeave();
2464 
2465  return Ret;
2466 }
2467 
2469 
2470 BOOL APIENTRY
2472  UINT Msg,
2473  WPARAM wParam,
2474  LPARAM lParam,
2475  ULONG_PTR ResultInfo,
2476  DWORD dwType, // fnID?
2477  BOOL Ansi)
2478 {
2479  LRESULT lResult = 0;
2480  BOOL Ret = FALSE;
2481  PWND Window = NULL;
2483 
2485 
2486  switch(dwType)
2487  {
2488  case FNID_SCROLLBAR:
2489  {
2490  lResult = ScrollBarWndProc(hWnd, Msg, wParam, lParam);
2491  break;
2492  }
2493  case FNID_DESKTOP:
2494  {
2496  if (Window)
2497  {
2498  //ERR("FNID_DESKTOP IN\n");
2499  Ret = DesktopWindowProc(Window, Msg, wParam, lParam, &lResult);
2500  //ERR("FNID_DESKTOP OUT\n");
2501  }
2502  break;
2503  }
2504  case FNID_MENU:
2505  {
2507  if (Window)
2508  {
2509  Ret = PopupMenuWndProc( Window, Msg, wParam, lParam, &lResult);
2510  }
2511  break;
2512  }
2513  case FNID_MESSAGEWND:
2514  {
2516  if (Window)
2517  {
2518  Ret = !UserMessageWindowProc(Window, Msg, wParam, lParam, &lResult);
2519  }
2520  break;
2521  }
2522  case FNID_DEFWINDOWPROC:
2523  /* Validate input */
2524  if (hWnd)
2525  {
2527  if (!Window)
2528  {
2529  UserLeave();
2530  return FALSE;
2531  }
2532  UserRefObjectCo(Window, &Ref);
2533  }
2534  lResult = IntDefWindowProc(Window, Msg, wParam, lParam, Ansi);
2535  Ret = TRUE;
2536  if (hWnd)
2538  break;
2541  break;
2543  {
2544  BROADCASTPARM parm, *retparam;
2545  DWORD_PTR RetVal = 0;
2546 
2547  if (ResultInfo)
2548  {
2549  _SEH2_TRY
2550  {
2551  ProbeForWrite((PVOID)ResultInfo, sizeof(BROADCASTPARM), 1);
2552  RtlCopyMemory(&parm, (PVOID)ResultInfo, sizeof(BROADCASTPARM));
2553  }
2555  {
2556  _SEH2_YIELD(break);
2557  }
2558  _SEH2_END;
2559  }
2560  else
2561  break;
2562 
2563  if ( parm.recipients & BSM_ALLDESKTOPS ||
2564  parm.recipients == BSM_ALLCOMPONENTS )
2565  {
2566  PLIST_ENTRY DesktopEntry;
2567  PDESKTOP rpdesk;
2568  HWND *List, hwndDenied = NULL;
2569  HDESK hDesk = NULL;
2570  PWND pwnd, pwndDesk;
2571  ULONG i;
2572  UINT fuFlags;
2573 
2574  for (DesktopEntry = InputWindowStation->DesktopListHead.Flink;
2575  DesktopEntry != &InputWindowStation->DesktopListHead;
2576  DesktopEntry = DesktopEntry->Flink)
2577  {
2578  rpdesk = CONTAINING_RECORD(DesktopEntry, DESKTOP, ListEntry);
2579  pwndDesk = rpdesk->pDeskInfo->spwnd;
2580  List = IntWinListChildren(pwndDesk);
2581 
2582  if (parm.flags & BSF_QUERY)
2583  {
2584  if (List != NULL)
2585  {
2586  if (parm.flags & BSF_FORCEIFHUNG || parm.flags & BSF_NOHANG)
2587  {
2588  fuFlags = SMTO_ABORTIFHUNG;
2589  }
2590  else if (parm.flags & BSF_NOTIMEOUTIFNOTHUNG)
2591  {
2592  fuFlags = SMTO_NOTIMEOUTIFNOTHUNG;
2593  }
2594  else
2595  {
2596  fuFlags = SMTO_NORMAL;
2597  }
2599  Msg,
2600  wParam,
2601  lParam,
2602  fuFlags,
2603  2000,
2604  &RetVal);
2605  Ret = TRUE;
2606  for (i = 0; List[i]; i++)
2607  {
2608  pwnd = UserGetWindowObject(List[i]);
2609  if (!pwnd) continue;
2610 
2611  if ( pwnd->fnid == FNID_MENU ||
2613  continue;
2614 
2615  if ( parm.flags & BSF_IGNORECURRENTTASK )
2616  {
2617  if ( pwnd->head.pti == gptiCurrent )
2618  continue;
2619  }
2621  Msg,
2622  wParam,
2623  lParam,
2624  fuFlags,
2625  2000,
2626  &RetVal);
2627 
2628  if (!RetVal && EngGetLastError() == ERROR_TIMEOUT)
2629  {
2630  if (!(parm.flags & BSF_FORCEIFHUNG))
2631  Ret = FALSE;
2632  }
2633  if (RetVal == BROADCAST_QUERY_DENY)
2634  {
2635  hwndDenied = List[i];
2636  hDesk = UserHMGetHandle(pwndDesk);
2637  Ret = FALSE;
2638  }
2639  }
2641  _SEH2_TRY
2642  {
2643  retparam = (PBROADCASTPARM) ResultInfo;
2644  retparam->hDesk = hDesk;
2645  retparam->hWnd = hwndDenied;
2646  }
2648  {
2649  _SEH2_YIELD(break);
2650  }
2651  _SEH2_END;
2652  if (!Ret) break; // Have a hit! Let everyone know!
2653  }
2654  }
2655  else if (parm.flags & BSF_POSTMESSAGE)
2656  {
2657  if (List != NULL)
2658  {
2660 
2661  for (i = 0; List[i]; i++)
2662  {
2663  pwnd = UserGetWindowObject(List[i]);
2664  if (!pwnd) continue;
2665 
2666  if ( pwnd->fnid == FNID_MENU ||
2668  continue;
2669 
2670  if ( parm.flags & BSF_IGNORECURRENTTASK )
2671  {
2672  if ( pwnd->head.pti == gptiCurrent )
2673  continue;
2674  }
2676  }
2678  }
2679  Ret = TRUE;
2680  }
2681  else
2682  {
2683  if (List != NULL)
2684  {
2686 
2687  for (i = 0; List[i]; i++)
2688  {
2689  pwnd = UserGetWindowObject(List[i]);
2690  if (!pwnd) continue;
2691 
2692  if ( pwnd->fnid == FNID_MENU ||
2694  continue;
2695 
2696  if ( parm.flags & BSF_IGNORECURRENTTASK )
2697  {
2698  if ( pwnd->head.pti == gptiCurrent )
2699  continue;
2700  }
2702  }
2704  }
2705  Ret = TRUE;
2706  }
2707  }
2708  }
2709  else if (parm.recipients & BSM_APPLICATIONS)
2710  {
2711  HWND *List, hwndDenied = NULL;
2712  HDESK hDesk = NULL;
2713  PWND pwnd, pwndDesk;
2714  ULONG i;
2715  UINT fuFlags;
2716 
2717  pwndDesk = UserGetDesktopWindow();
2718  List = IntWinListChildren(pwndDesk);
2719 
2720  if (parm.flags & BSF_QUERY)
2721  {
2722  if (List != NULL)
2723  {
2724  if (parm.flags & BSF_FORCEIFHUNG || parm.flags & BSF_NOHANG)
2725  {
2726  fuFlags = SMTO_ABORTIFHUNG;
2727  }
2728  else if (parm.flags & BSF_NOTIMEOUTIFNOTHUNG)
2729  {
2730  fuFlags = SMTO_NOTIMEOUTIFNOTHUNG;
2731  }
2732  else
2733  {
2734  fuFlags = SMTO_NORMAL;
2735  }
2737  Msg,
2738  wParam,
2739  lParam,
2740  fuFlags,
2741  2000,
2742  &RetVal);
2743  Ret = TRUE;
2744  for (i = 0; List[i]; i++)
2745  {
2746  pwnd = UserGetWindowObject(List[i]);
2747  if (!pwnd) continue;
2748 
2749  if ( pwnd->fnid == FNID_MENU ||
2751  continue;
2752 
2753  if ( parm.flags & BSF_IGNORECURRENTTASK )
2754  {
2755  if ( pwnd->head.pti == gptiCurrent )
2756  continue;
2757  }
2759  Msg,
2760  wParam,
2761  lParam,
2762  fuFlags,
2763  2000,
2764  &RetVal);
2765 
2766  if (!RetVal && EngGetLastError() == ERROR_TIMEOUT)
2767  {
2768  if (!(parm.flags & BSF_FORCEIFHUNG))
2769  Ret = FALSE;
2770  }
2771  if (RetVal == BROADCAST_QUERY_DENY)
2772  {
2773  hwndDenied = List[i];
2774  hDesk = UserHMGetHandle(pwndDesk);
2775  Ret = FALSE;
2776  }
2777  }
2779  _SEH2_TRY
2780  {
2781  retparam = (PBROADCASTPARM) ResultInfo;
2782  retparam->hDesk = hDesk;
2783  retparam->hWnd = hwndDenied;
2784  }
2786  {
2787  _SEH2_YIELD(break);
2788  }
2789  _SEH2_END;
2790  }
2791  }
2792  else if (parm.flags & BSF_POSTMESSAGE)
2793  {
2794  if (List != NULL)
2795  {
2797 
2798  for (i = 0; List[i]; i++)
2799  {
2800  pwnd = UserGetWindowObject(List[i]);
2801  if (!pwnd) continue;
2802 
2803  if ( pwnd->fnid == FNID_MENU ||
2805  continue;
2806 
2807  if ( parm.flags & BSF_IGNORECURRENTTASK )
2808  {
2809  if ( pwnd->head.pti == gptiCurrent )
2810  continue;
2811  }
2813  }
2815  }
2816  Ret = TRUE;
2817  }
2818  else
2819  {
2820  if (List != NULL)
2821  {
2823 
2824  for (i = 0; List[i]; i++)
2825  {
2826  pwnd = UserGetWindowObject(List[i]);
2827  if (!pwnd) continue;
2828 
2829  if ( pwnd->fnid == FNID_MENU ||
2831  continue;
2832 
2833  if ( parm.flags & BSF_IGNORECURRENTTASK )
2834  {
2835  if ( pwnd->head.pti == gptiCurrent )
2836  continue;
2837  }
2839  }
2841  }
2842  Ret = TRUE;
2843  }
2844  }
2845  }
2846  break;
2848  {
2849  CALL_BACK_INFO CallBackInfo;
2850  ULONG_PTR uResult;
2851 
2852  _SEH2_TRY
2853  {
2854  ProbeForRead((PVOID)ResultInfo, sizeof(CALL_BACK_INFO), 1);
2855  RtlCopyMemory(&CallBackInfo, (PVOID)ResultInfo, sizeof(CALL_BACK_INFO));
2856  }
2858  {
2859  _SEH2_YIELD(break);
2860  }
2861  _SEH2_END;
2862 
2863  if (is_pointer_message(Msg))
2864  {
2866  break;
2867  }
2868 
2870  CallBackInfo.CallBack, CallBackInfo.Context, &uResult)))
2871  {
2872  ERR("Callback failure!\n");
2873  }
2874  }
2875  break;
2876  case FNID_SENDMESSAGE:
2877  {
2878  lResult = co_IntDoSendMessage(hWnd, Msg, wParam, lParam, 0);
2879  Ret = TRUE;
2880 
2881  if (ResultInfo)
2882  {
2883  _SEH2_TRY
2884  {
2885  ProbeForWrite((PVOID)ResultInfo, sizeof(ULONG_PTR), 1);
2886  RtlCopyMemory((PVOID)ResultInfo, &lResult, sizeof(ULONG_PTR));
2887  }
2889  {
2890  Ret = FALSE;
2891  _SEH2_YIELD(break);
2892  }
2893  _SEH2_END;
2894  }
2895  break;
2896  }
2897  case FNID_SENDMESSAGEFF:
2899  {
2900  DOSENDMESSAGE dsm, *pdsm = (PDOSENDMESSAGE)ResultInfo;
2901  if (ResultInfo)
2902  {
2903  _SEH2_TRY
2904  {
2905  ProbeForRead(pdsm, sizeof(DOSENDMESSAGE), 1);
2906  RtlCopyMemory(&dsm, pdsm, sizeof(DOSENDMESSAGE));
2907  }
2909  {
2910  _SEH2_YIELD(break);
2911  }
2912  _SEH2_END;
2913  }
2914 
2915  Ret = co_IntDoSendMessage( hWnd, Msg, wParam, lParam, pdsm ? &dsm : NULL );
2916 
2917  if (pdsm)
2918  {
2919  _SEH2_TRY
2920  {
2921  ProbeForWrite(pdsm, sizeof(DOSENDMESSAGE), 1);
2922  RtlCopyMemory(pdsm, &dsm, sizeof(DOSENDMESSAGE));
2923  }
2925  {
2926  Ret = FALSE;
2927  _SEH2_YIELD(break);
2928  }
2929  _SEH2_END;
2930  }
2931  break;
2932  }
2933  // CallNextHook bypass.
2934  case FNID_CALLWNDPROC:
2935  case FNID_CALLWNDPROCRET:
2936  {
2937  PTHREADINFO pti;
2939  PHOOK NextObj, Hook;
2940 
2941  pti = GetW32ThreadInfo();
2942 
2943  Hook = pti->sphkCurrent;
2944 
2945  if (!Hook) break;
2946 
2947  NextObj = Hook->phkNext;
2948  ClientInfo = pti->pClientInfo;
2949  _SEH2_TRY
2950  {
2951  ClientInfo->phkCurrent = NextObj;
2952  }
2954  {
2955  ClientInfo = NULL;
2956  }
2957  _SEH2_END;
2958 
2959  if (!ClientInfo || !NextObj) break;
2960 
2961  NextObj->phkNext = IntGetNextHook(NextObj);
2962 
2963  if ( Hook->HookId == WH_CALLWNDPROC)
2964  {
2965  CWPSTRUCT CWP;
2966  CWP.hwnd = hWnd;
2967  CWP.message = Msg;
2968  CWP.wParam = wParam;
2969  CWP.lParam = lParam;
2970  TRACE("WH_CALLWNDPROC: Hook %p NextHook %p\n", Hook, NextObj);
2971 
2972  lResult = co_IntCallHookProc( Hook->HookId,
2973  HC_ACTION,
2974  ((ClientInfo->CI_flags & CI_CURTHPRHOOK) ? 1 : 0),
2975  (LPARAM)&CWP,
2976  Hook->Proc,
2977  Hook->ihmod,
2978  Hook->offPfn,
2979  Hook->Ansi,
2980  &Hook->ModuleName);
2981  }
2982  else
2983  {
2984  CWPRETSTRUCT CWPR;
2985  CWPR.hwnd = hWnd;
2986  CWPR.message = Msg;
2987  CWPR.wParam = wParam;
2988  CWPR.lParam = lParam;
2989  CWPR.lResult = ClientInfo->dwHookData;
2990 
2991  lResult = co_IntCallHookProc( Hook->HookId,
2992  HC_ACTION,
2993  ((ClientInfo->CI_flags & CI_CURTHPRHOOK) ? 1 : 0),
2994  (LPARAM)&CWPR,
2995  Hook->Proc,
2996  Hook->ihmod,
2997  Hook->offPfn,
2998  Hook->Ansi,
2999  &Hook->ModuleName);
3000  }
3001  }
3002  break;
3003  }
3004 
3005  switch(dwType)
3006  {
3007  case FNID_DEFWINDOWPROC:
3008  case FNID_CALLWNDPROC:
3009  case FNID_CALLWNDPROCRET:
3010  case FNID_SCROLLBAR:
3011  case FNID_DESKTOP:
3012  case FNID_MENU:
3013  if (ResultInfo)
3014  {
3015  _SEH2_TRY
3016  {
3017  ProbeForWrite((PVOID)ResultInfo, sizeof(LRESULT), 1);
3018  RtlCopyMemory((PVOID)ResultInfo, &lResult, sizeof(LRESULT));
3019  }
3021  {
3022  Ret = FALSE;
3023  }
3024  _SEH2_END;
3025  }
3026  break;
3027  default:
3028  break;
3029  }
3030 
3031  UserLeave();
3032 
3033  return Ret;
3034 }
3035 
3036 #define INFINITE 0xFFFFFFFF
3037 #define WAIT_FAILED ((DWORD)0xFFFFFFFF)
3038 
3039 DWORD
3040 APIENTRY
3042  IN DWORD dwMilliseconds,
3043  IN BOOL bSharedWow)
3044 {
3046  PPROCESSINFO W32Process;
3047  PTHREADINFO pti;
3048  NTSTATUS Status;
3049  HANDLE Handles[3];
3052 
3054 
3057  *PsProcessType,
3058  UserMode,
3059  (PVOID*)&Process,
3060  NULL);
3061 
3062  if (!NT_SUCCESS(Status))
3063  {
3064  UserLeave();
3066  return WAIT_FAILED;
3067  }
3068 
3070 
3071  W32Process = (PPROCESSINFO)Process->Win32Process;
3072 
3074  !W32Process ||
3075  pti->ppi == W32Process)
3076  {
3078  UserLeave();
3080  return WAIT_FAILED;
3081  }
3082 
3083  Handles[0] = Process;
3084  Handles[1] = W32Process->InputIdleEvent;
3085  Handles[2] = pti->pEventQueueServer; // IntMsqSetWakeMask returns hEventQueueClient
3086 
3087  if (!Handles[1])
3088  {
3090  UserLeave();
3091  return STATUS_SUCCESS; /* no event to wait on */
3092  }
3093 
3094  if (dwMilliseconds != INFINITE)
3095  Timeout.QuadPart = (LONGLONG) dwMilliseconds * (LONGLONG) -10000;
3096 
3098 
3099  W32Process->W32PF_flags |= W32PF_WAITFORINPUTIDLE;
3100  for (pti = W32Process->ptiList; pti; pti = pti->ptiSibling)
3101  {
3103  pti->pClientInfo->dwTIFlags = pti->TIF_flags;
3104  }
3105 
3107 
3108  TRACE("WFII: ppi %p\n", W32Process);
3109  TRACE("WFII: waiting for %p\n", Handles[1] );
3110 
3111  /*
3112  * We must add a refcount to our current PROCESSINFO,
3113  * because anything could happen (including process death) we're leaving win32k
3114  */
3115  IntReferenceProcessInfo(W32Process);
3116 
3117  do
3118  {
3119  UserLeave();
3121  Handles,
3122  WaitAny,
3123  UserRequest,
3124  UserMode,
3125  FALSE,
3126  dwMilliseconds == INFINITE ? NULL : &Timeout,
3127  NULL);
3129 
3130  if (!NT_SUCCESS(Status))
3131  {
3133  Status = WAIT_FAILED;
3134  goto WaitExit;
3135  }
3136 
3137  switch (Status)
3138  {
3139  case STATUS_WAIT_0:
3140  goto WaitExit;
3141 
3142  case STATUS_WAIT_2:
3143  {
3144  MSG Msg;
3145  co_IntGetPeekMessage( &Msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE, FALSE);
3146  ERR("WFII: WAIT 2\n");
3147  }
3148  break;
3149 
3150  case STATUS_TIMEOUT:
3151  ERR("WFII: timeout\n");
3152  case WAIT_FAILED:
3153  goto WaitExit;
3154 
3155  default:
3156  ERR("WFII: finished\n");
3158  goto WaitExit;
3159  }
3160  }
3161  while (TRUE);
3162 
3163 WaitExit:
3164  for (pti = W32Process->ptiList; pti; pti = pti->ptiSibling)
3165  {
3167  pti->pClientInfo->dwTIFlags = pti->TIF_flags;
3168  }
3169  W32Process->W32PF_flags &= ~W32PF_WAITFORINPUTIDLE;
3170  IntDereferenceProcessInfo(W32Process);
3172  UserLeave();
3173  return Status;
3174 }
3175 
3176 /* EOF */
LRESULT FASTCALL IntDefWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Ansi)
Definition: defwnd.c:532
#define BSM_ALLCOMPONENTS
Definition: dbt.h:47
signed char * PCHAR
Definition: retypes.h:7
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
struct @1588 Msg[]
static LRESULT FASTCALL co_IntSendMessageTimeoutSingle(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult)
Definition: message.c:1446
static LRESULT handle_internal_events(PTHREADINFO pti, PWND pWnd, DWORD dwQEvent, LONG_PTR ExtraInfo, PMSG pMsg)
Definition: message.c:801
#define IN
Definition: typedefs.h:39
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1331
DBG_DEFAULT_CHANNEL(UserMsg)
VOID FASTCALL MsqWakeQueue(PTHREADINFO pti, DWORD MessageBits, BOOL KeyEvent)
Definition: msgqueue.c:412
#define BSF_FORCEIFHUNG
Definition: dbt.h:54
WPARAM wParam
Definition: winuser.h:2994
#define HOOKID_TO_FLAG(HookId)
Definition: hook.h:5
Definition: tftpd.h:59
#define SET(msg)
Definition: message.c:35
#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)
static PMSGMEMORY FASTCALL FindMsgMemory(UINT Msg)
Definition: message.c:145
LRESULT co_UserFreeWindow(PWND Window, PPROCESSINFO ProcessData, PTHREADINFO ThreadData, BOOLEAN SendMessages)
Definition: window.c:546
KAPC_STATE
Definition: ketypes.h:1273
BOOL WINAPI PopupMenuWndProc(PWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: menu.c:4628
#define WH_GETMESSAGE
Definition: winuser.h:33
DWORD APIENTRY NtUserWaitForInputIdle(IN HANDLE hProcess, IN DWORD dwMilliseconds, IN BOOL bSharedWow)
Definition: message.c:3041
#define LB_DIR
Definition: winuser.h:2015
PDESKTOPINFO pDeskInfo
Definition: desktop.h:8
#define CLEANUP
Definition: ntuser.h:5
#define WM_MOUSEFIRST
Definition: winuser.h:1756
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
struct tagMDINEXTMENU MDINEXTMENU
#define LB_FINDSTRINGEXACT
Definition: winuser.h:2017
#define LB_ADDFILE
Definition: winuser.h:2012
BOOL FASTCALL MsqIsHung(PTHREADINFO pti, DWORD TimeOut)
Definition: msgqueue.c:2194
long y
Definition: polytest.cpp:48
BOOL FASTCALL IntGetPaintMessage(PWND Window, UINT MsgFilterMin, UINT MsgFilterMax, PTHREADINFO Thread, MSG *Message, BOOL Remove)
Definition: painting.c:1172
#define WM_GETDLGCODE
Definition: winuser.h:1671
#define RETURN(value)
Definition: ntuser.h:4
#define ERROR_INTERNAL_ERROR
Definition: winerror.h:840
static LRESULT handle_internal_message(PWND pWnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: message.c:760
#define BSF_IGNORECURRENTTASK
Definition: dbt.h:55
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
LRESULT FASTCALL IntDispatchMessage(PMSG pMsg)
Definition: message.c:829
#define LB_ADDSTRING
Definition: winuser.h:2013
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:158
#define WM_SYSTIMER
Definition: comctl32.h:112
#define BROADCAST_QUERY_DENY
Definition: winuser.h:178
#define UserIsDesktopWindow(pWnd)
Definition: desktop.h:220
long x
Definition: polytest.cpp:48
PVOID Buffer
Definition: ntuser.h:97
BOOL APIENTRY NtUserTranslateMessage(LPMSG lpMsg, UINT flags)
Definition: message.c:2434
WORD ATOM
Definition: dimm.idl:113
PHOOK FASTCALL IntGetNextHook(PHOOK Hook)
Definition: hook.c:996
POINT last
Definition: font.c:46
#define QS_ALLPOSTMESSAGE
Definition: winuser.h:876
#define MMS_SIZE_SPECIAL
Definition: message.c:109
#define pt(x, y)
Definition: drawing.c:79
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define CB_GETLBTEXT
Definition: winuser.h:1934
static BOOL is_message_broadcastable(UINT msg)
Definition: message.c:556
POINT pt
Definition: winuser.h:3094
PTHREADINFO ptiSibling
Definition: win32.h:115
#define ERROR_TIMEOUT
Definition: winerror.h:941
uint16_t * PWSTR
Definition: typedefs.h:55
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
#define EngGetTickCount32()
Definition: eng.h:43
#define WM_NCCALCSIZE
Definition: winuser.h:1667
VOID FASTCALL IdlePing(VOID)
Definition: message.c:515
#define WM_ASKCBFORMATNAME
Definition: winuser.h:1855
BOOL FASTCALL IntTranslateKbdMessage(LPMSG lpMsg, UINT flags)
Definition: keyboard.c:1136
BOOLEAN FASTCALL co_MsqDispatchOneSentMessage(_In_ PTHREADINFO pti)
Definition: msgqueue.c:873
NTSTATUS NTAPI PsLookupThreadByThreadId(IN HANDLE ThreadId, OUT PETHREAD *Thread)
Definition: thread.c:643
FLONG TIF_flags
Definition: win32.h:94
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
PWINSTATION_OBJECT InputWindowStation
Definition: winsta.c:21
#define WH_MSGFILTER
Definition: winuser.h:29
struct tagMSGMEMORY * PMSGMEMORY
#define WM_GETTEXT
Definition: winuser.h:1600
const GLint * first
Definition: glext.h:5794
HDESK hDesk
Definition: ntuser.h:1063
UINT cPaintsReady
Definition: win32.h:108
DWORD recipients
Definition: ntuser.h:1062
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
#define FNID_MENU
Definition: ntuser.h:823
BOOLEAN FASTCALL co_WinPosSetWindowPos(PWND Window, HWND WndInsertAfter, INT x, INT y, INT cx, INT cy, UINT flags)
Definition: winpos.c:1720
LONG NTSTATUS
Definition: precomp.h:26
#define LB_SETTABSTOPS
Definition: winuser.h:2051
struct tagHOOK * phkNext
Definition: ntuser.h:218
BOOL FASTCALL UserSendNotifyMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:2022
UINT FASTCALL GetWakeMask(UINT first, UINT last)
Definition: message.c:562
BOOL APIENTRY NtUserWaitMessage(VOID)
Definition: message.c:2264
#define WM_QUEUESYNC
Definition: winuser.h:1621
KTHREAD Tcb
Definition: pstypes.h:1034
#define BSF_NOTIMEOUTIFNOTHUNG
Definition: dbt.h:57
#define BSF_QUERY
Definition: dbt.h:59
HWND hWnd
Definition: settings.c:17
#define WM_QUIT
Definition: winuser.h:1605
struct _PROCESSINFO * PPROCESSINFO
Definition: ntwin32.h:5
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:25
#define MSQ_HUNG
Definition: msgqueue.h:3
#define FNID_DEFWINDOWPROC
Definition: ntuser.h:825
static __inline BOOL UserHeapFree(PVOID lpMem)
Definition: usrheap.h:42
#define QS_TIMER
Definition: winuser.h:893
HWND hwndInsertAfter
Definition: winuser.h:3564
#define WM_DEVMODECHANGE
Definition: winuser.h:1613
#define HWND_TOPMOST
Definition: winuser.h:1194
#define QS_SMRESULT
Definition: undocuser.h:93
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define MmCopyFromCaller
Definition: polytest.cpp:29
BOOLEAN QuitPosted
Definition: win32.h:104
WPARAM wParam
Definition: winuser.h:3091
BOOL APIENTRY NtUserPostThreadMessage(DWORD idThread, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:2227
BOOL APIENTRY IntDdePostMessageHook(IN PWND pWnd, IN UINT Msg, IN WPARAM wParam, IN OUT LPARAM *lParam, IN OUT LONG_PTR *ExtraInfo)
Definition: dde.c:172
LPARAM lParam
Definition: winuser.h:2993
NTSTATUS FASTCALL co_MsqWaitForNewMessages(PTHREADINFO pti, PWND WndFilter, UINT MsgFilterMin, UINT MsgFilterMax)
Definition: msgqueue.c:2164
#define MmCopyToCaller(x, y, z)
Definition: mmcopy.h:19
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
LIST_ENTRY DesktopListHead
Definition: winsta.h:18
BOOL FASTCALL IntCallMsgFilter(LPMSG lpmsg, INT code)
Definition: message.c:2122
UINT_PTR WPARAM
Definition: windef.h:207
#define MMS_SIZE_WPARAM
Definition: message.c:106
#define WS_CHILD
Definition: pedump.c:617
#define TIF_WAITFORINPUTIDLE
Definition: ntuser.h:254
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
#define InsertTailList(ListHead, Entry)
static __inline PVOID UserHeapAlloc(SIZE_T Bytes)
Definition: usrheap.h:34
LRESULT FASTCALL co_IntPostOrSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
LRESULT APIENTRY co_EVENT_CallEvents(DWORD event, HWND hwnd, UINT_PTR idObject, LONG_PTR idChild)
Definition: event.c:151
#define VK_ESCAPE
Definition: winuser.h:2189
#define BSF_NOHANG
Definition: dbt.h:56
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define BSF_POSTMESSAGE
Definition: dbt.h:58
#define FASTCALL
Definition: nt_native.h:50
#define WM_NCCREATE
Definition: winuser.h:1665
#define INFINITE
Definition: message.c:3036
RTL_ATOM atomClassName
Definition: ntuser.h:536
PSERVERINFO gpsi
Definition: main.c:27
int32_t INT
Definition: typedefs.h:57
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
& rect
Definition: startmenu.cpp:1413
WPARAM wParam
Definition: combotst.c:138
#define WM_QUERYDROPOBJECT
Definition: undocuser.h:54
#define LB_SELECTSTRING
Definition: winuser.h:2038
#define SMTO_ABORTIFHUNG
Definition: winuser.h:1209
#define WM_SETTINGCHANGE
Definition: winuser.h:1611
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
NTSTATUS FASTCALL IntInitMessageImpl(VOID)
Definition: message.c:20
#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
#define PM_NOREMOVE
Definition: winuser.h:1181
struct tagRECT RECT
BOOL APIENTRY IntUninitMessagePumpHook(VOID)
Definition: message.c:2105
PPROCESSINFO ppi
Definition: win32.h:87
#define EM_GETSEL
Definition: winuser.h:1979
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define WH_FOREGROUNDIDLE
Definition: winuser.h:41
#define CB_GETEDITSEL
Definition: winuser.h:1929
BOOL FASTCALL co_IntWaitMessage(PWND Window, UINT MsgFilterMin, UINT MsgFilterMax)
Definition: message.c:1119
#define WNDS_PAINTNOTPROCESSED
Definition: ntuser.h:595
CLIENT_DATA ClientInfo
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
#define WM_NEXTMENU
Definition: winuser.h:1788
#define STATUS_WAIT_2
Definition: ntstatus.h:72
PTHREADINFO gptiForeground
Definition: focus.c:14
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
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
#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
#define WM_KEYFIRST
Definition: winuser.h:1696
GLenum GLint GLuint mask
Definition: glext.h:6028
static NTSTATUS PackParam(LPARAM *lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL NonPagedPoolNeeded)
Definition: message.c:251
struct _WINDOWPOS WINDOWPOS
struct _BROADCASTPARM * PBROADCASTPARM
#define QS_HOTKEY
Definition: winuser.h:877
#define UNICODE_NULL
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:701
DWORD fnid
Definition: ntuser.h:673
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL FASTCALL UserPostThreadMessage(PTHREADINFO pti, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1294
long LONG
Definition: pedump.c:60
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2579
#define FNID_DESKTOP
Definition: ntuser.h:824
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:38
#define WM_DELETEITEM
Definition: winuser.h:1629
LIST_ENTRY SentMessagesListHead
Definition: win32.h:99
PTHREADINFO FASTCALL IntSendTo(PWND Window, PTHREADINFO ptiCur, UINT Msg)
Definition: message.c:1317
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
static NTSTATUS FASTCALL CopyMsgToUserMem(MSG *UserModeMsg, MSG *KernelModeMsg)
Definition: message.c:475
BOOL FASTCALL ValidateTimerCallback(PTHREADINFO pti, LPARAM lParam)
Definition: timer.c:150
#define SMF_RECEIVERFREE
Definition: msgqueue.h:40
struct NameRec_ * Name
Definition: cdprocs.h:464
Definition: timer.h:3
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define WM_SIZING
Definition: winuser.h:1789
THRDESKHEAD head
Definition: ntuser.h:659
#define CB_ADDSTRING
Definition: winuser.h:1918
#define WM_DRAGSELECT
Definition: undocuser.h:57
NTSYSAPI NTSTATUS NTAPI ZwYieldExecution(VOID)
#define LB_GETSELITEMS
Definition: winuser.h:2030
Definition: object.h:3
#define MAKELONG(a, b)
Definition: typedefs.h:248
#define CB_INSERTSTRING
Definition: winuser.h:1939
DWORD APIENTRY IntGetQueueStatus(DWORD Changes)
Definition: message.c:2071
static NTSTATUS UnpackParam(LPARAM lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL NonPagedPoolUsed)
Definition: message.c:369
BOOL APIENTRY co_IntPeekMessage(PMSG Msg, PWND Window, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg, LONG_PTR *ExtraInfo, BOOL bGMSG)
Definition: message.c:953
static LRESULT FASTCALL co_IntDoSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, PDOSENDMESSAGE dsm)
Definition: message.c:1936
smooth NULL
Definition: ftsmooth.c:416
#define IntReferenceProcessInfo(ppi)
Definition: win32.h:178
#define W32PF_WAITFORINPUTIDLE
Definition: win32.h:22
INT exitCode
Definition: win32.h:106
#define WM_WININICHANGE
Definition: winuser.h:1612
_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
#define WM_KEYDOWN
Definition: winuser.h:1697
LPARAM lParam
Definition: winuser.h:3092
LONG_PTR LPARAM
Definition: windef.h:208
static NTSTATUS FASTCALL CopyMsgToKernelMem(MSG *KernelModeMsg, MSG *UserModeMsg, PMSGMEMORY MsgMemoryEntry)
Definition: message.c:418
#define SM_CXDRAG
Definition: winuser.h:1018
struct tagCREATESTRUCTW CREATESTRUCTW
#define WH_CBT
Definition: winuser.h:35
PTHREADINFO gptiCurrent
Definition: ntuser.c:15
PWINDOWPOS lppos
Definition: winuser.h:3574
UINT flags
Definition: winuser.h:3569
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
#define WH_CALLWNDPROCRET
Definition: winuser.h:42
#define WM_DROPOBJECT
Definition: undocuser.h:53
VOID FASTCALL IntActivateWindow(PWND Wnd, PTHREADINFO pti, HANDLE tid, DWORD Type)
Definition: focus.c:267
BOOL APIENTRY NtUserGetMessage(PMSG pMsg, HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax)
Definition: message.c:2278
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:90
#define WM_SETTEXT
Definition: winuser.h:1599
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
struct _WINDOWPOS * PWINDOWPOS
#define FNID_SENDMESSAGE
Definition: ntuser.h:844
#define PCHAR
Definition: match.c:90
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:180
BOOLEAN FASTCALL co_WinPosShowWindow(PWND Wnd, INT Cmd)
Definition: winpos.c:2472
#define QS_INPUT
Definition: winuser.h:881
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
#define FNID_CALLWNDPROCRET
Definition: ntuser.h:839
#define WM_NCMOUSELAST
Definition: msgqueue.h:240
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:515
int HookId
Definition: ntuser.h:219
int64_t LONGLONG
Definition: typedefs.h:67
struct tagDRAWITEMSTRUCT DRAWITEMSTRUCT
struct _LIST_ENTRY * Flink
Definition: typedefs.h:120
BOOL APIENTRY NtUserMessageCall(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ResultInfo, DWORD dwType, BOOL Ansi)
Definition: message.c:2471
struct tagHELPINFO HELPINFO
#define WM_COPYDATA
Definition: winuser.h:1646
PTIMER FASTCALL FindSystemTimer(PMSG pMsg)
Definition: timer.c:126
#define WM_NCMOUSEFIRST
Definition: msgqueue.h:239
#define FNID_SENDMESSAGEFF
Definition: ntuser.h:845
SIGDN PWSTR * ppszName
Definition: shobjidl.idl:593
#define HWND_BOTTOM
Definition: winuser.h:1191
#define TRACE(s)
Definition: solgame.cpp:4
ULONG fsHooks
Definition: win32.h:116
HWND FASTCALL co_UserSetCapture(HWND hWnd)
Definition: focus.c:1340
SENDASYNCPROC CallBack
Definition: callback.h:48
GLsizeiptr size
Definition: glext.h:5919
struct _THREADINFO * PTHREADINFO
Definition: ntwin32.h:6
VOID FASTCALL ClearMsgBitsMask(PTHREADINFO pti, UINT MessageBits)
Definition: msgqueue.c:445
BOOLEAN Ansi
Definition: ntuser.h:228
#define CB_GETDROPPEDCONTROLRECT
Definition: winuser.h:1926
static VOID FASTCALL IntCallWndProc(PWND Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:695
INT_PTR ihmod
Definition: ntuser.h:222
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
UNICODE_STRING ModuleName
Definition: ntuser.h:229
NTSYSAPI ULONG NTAPI RtlEqualMemory(CONST VOID *Source1, CONST VOID *Source2, ULONG Length)
LIST_ENTRY List
Definition: psmgr.c:57
if(!(yy_init))
Definition: macro.lex.yy.c:714
__wchar_t WCHAR
Definition: xmlstorage.h:180
Implementation of the Explorer desktop window.
Definition: desktop.h:51
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
INT POOL_TYPE
Definition: typedefs.h:77
ULONG Length
Definition: ntuser.h:94
#define UlongToHandle(ul)
Definition: basetsd.h:97
#define WM_TIMER
Definition: winuser.h:1724
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1643
PKEVENT pEventQueueServer
Definition: win32.h:124
#define WM_MOUSELAST
Definition: winuser.h:1783
#define ISITHOOKED(HookId)
Definition: hook.h:6
void(CALLBACK * SENDASYNCPROC)(HWND, UINT, ULONG_PTR, LRESULT)
Definition: winuser.h:2891
LRESULT FASTCALL co_IntSendMessageTimeout(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult)
Definition: message.c:1639
BOOL APIENTRY NtUserDragDetect(HWND hWnd, POINT pt)
Definition: message.c:2141
#define QS_EVENT
Definition: undocuser.h:95
BOOL APIENTRY IntDdeGetMessageHook(PMSG pMsg, LONG_PTR ExtraInfo)
Definition: dde.c:326
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL APIENTRY NtUserCallMsgFilter(LPMSG lpmsg, INT code)
Definition: message.c:2364
#define DECLARE_RETURN(type)
Definition: ntuser.h:3
#define WM_KEYLAST
Definition: winuser.h:1710
#define WM_MEASUREITEM
Definition: winuser.h:1628
LPARAM lParam
Definition: winuser.h:3000
VOID FASTCALL MsqPostMessage(PTHREADINFO pti, MSG *Msg, BOOLEAN HardwareMessage, DWORD MessageBits, DWORD dwQEvent, LONG_PTR ExtraInfo)
Definition: msgqueue.c:1338
#define FNID_SENDMESSAGECALLBACK
Definition: ntuser.h:852
#define MMS_SIZE_LPARAMSZ
Definition: message.c:108
HOOKPROC Proc
Definition: ntuser.h:227
WPARAM wParam
Definition: winuser.h:3001
#define UserIsMessageWindow(pWnd)
Definition: desktop.h:223
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
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
BOOL FASTCALL IntMsgCreateStructW(PWND Window, CREATESTRUCTW *pCsw, CREATESTRUCTW *Cs, PVOID *ppszClass, PVOID *ppszName)
Definition: message.c:585
#define ICLS_SWITCH
Definition: ntuser.h:893
struct _CLIENTINFO * pClientInfo
Definition: win32.h:93
int Window
Definition: x11stubs.h:26
#define POSTEVENT_NWE
Definition: msgqueue.h:125
VOID APIENTRY co_IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback, HWND hWnd, UINT Msg, ULONG_PTR CompletionCallbackContext, LRESULT Result)
Definition: callback.c:245
BOOL FASTCALL PostTimerMessages(PWND Window)
Definition: timer.c:395
GLbitfield flags
Definition: glext.h:7161
BOOLEAN NTAPI PsGetProcessExitProcessCalled(PEPROCESS Process)
Definition: process.c:1043
VOID FASTCALL IntCoalesceMouseMove(PTHREADINFO pti)
Definition: msgqueue.c:551
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 HCBT_QS
Definition: winuser.h:57
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CHAR Message[80]
Definition: alive.c:5
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define WM_MDIGETACTIVE
Definition: winuser.h:1803
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
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1349
#define FNID_SENDNOTIFYMESSAGE
Definition: ntuser.h:851
#define WM_DDE_LAST
Definition: dde.h:46
int ret
#define EM_SETRECTNP
Definition: winuser.h:1999
LONG timeLast
Definition: win32.h:101
UINT message
Definition: winuser.h:3002
PUSER_SENT_MESSAGE FASTCALL AllocateUserMessage(BOOL KEvent)
Definition: msgqueue.c:763
#define WM_MOVING
Definition: winuser.h:1791
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
DWORD flags
Definition: ntuser.h:1061
struct tagMINMAXINFO MINMAXINFO
#define LB_GETTEXT
Definition: winuser.h:2031
static const WCHAR L[]
Definition: oid.c:1250
#define WNDS2_WMPAINTSENT
Definition: ntuser.h:609
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1431
#define WH_CALLWNDPROC
Definition: winuser.h:34
#define CI_CURTHPRHOOK
Definition: ntuser.h:281
static MSGMEMORY g_MsgMemory[]
Definition: message.c:121
#define SBM_GETRANGE
Definition: winuser.h:2061
LPCWSTR lpszName
Definition: winuser.h:2939
#define CB_SELECTSTRING
Definition: winuser.h:1942
BOOL APIENTRY IntInitMessagePumpHook(VOID)
Definition: message.c:2092
ULONG_PTR Result
Definition: ntuser.h:2616
#define WM_DRAGLOOP
Definition: undocuser.h:56
HWND *FASTCALL IntWinListChildren(PWND Window)
Definition: window.c:255
#define PAGE_SIZE
Definition: env_spec_w32.h:49
struct _WND * spwnd
Definition: ntuser.h:136
#define EM_SETTABSTOPS
Definition: winuser.h:2001
Definition: typedefs.h:118
#define WM_MAXIMUM
Definition: undocuser.h:62
struct tagHOOK * sphkCurrent
Definition: win32.h:117
UINT lParamMemorySize(UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:243
static __inline PVOID UserHeapAddressToUser(PVOID lpMem)
Definition: usrheap.h:92
UINT Size
Definition: message.c:116
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
uint32_t DWORD_PTR
Definition: typedefs.h:64
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
LRESULT APIENTRY NtUserDispatchMessage(PMSG UnsafeMsgInfo)
Definition: message.c:2408
#define WM_COPYGLOBALDATA
Definition: undocuser.h:36
struct tagDOSENDMESSAGE * PDOSENDMESSAGE
#define FNID_CALLWNDPROC
Definition: ntuser.h:838
#define TIF_MSGPOSCHANGED
Definition: ntuser.h:260
BOOL FASTCALL IntMakeHungWindowGhosted(HWND hwndHung)
Definition: ghost.c:156
POINT ptLast
Definition: win32.h:128
Status
Definition: gdiplustypes.h:24
NTSYSAPI DWORD WINAPI RtlUnicodeStringToAnsiSize(const UNICODE_STRING *)
LRESULT APIENTRY ScrollBarWndProc(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: scrollbar.c:1176
#define STATUS_USER_APC
Definition: ntstatus.h:78
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2881
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:88
BOOL FASTCALL IntDdeSendMessageHook(PWND pWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: dde.c:386
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
ULONG_PTR SIZE_T
Definition: typedefs.h:79
#define FNID_BROADCASTSYSTEMMESSAGE
Definition: ntuser.h:849
#define WM_COMPAREITEM
Definition: winuser.h:1637
#define MSQ_NORMAL
Definition: msgqueue.h:4
#define LB_FINDSTRING
Definition: winuser.h:2016
_SEH2_END
Definition: create.c:4424
struct _WND * PWND
static int is_pointer_message(UINT message)
Definition: message.c:99
static ULONG Timeout
Definition: ping.c:61
#define MMS_FLAG_READ
Definition: message.c:110
BOOL APIENTRY co_IntGetPeekMessage(PMSG pMsg, HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg, BOOL bGMSG)
Definition: message.c:1165
VOID FASTCALL IdlePong(VOID)
Definition: message.c:545
NTSTATUS FASTCALL IntCleanupMessageImpl(VOID)
Definition: message.c:26
#define EM_SETRECT
Definition: winuser.h:1998
#define CB_DIR
Definition: winuser.h:1920
#define WM_DRAGMOVE
Definition: undocuser.h:58
#define WM_DDE_FIRST
Definition: dde.h:47
unsigned short USHORT
Definition: pedump.c:61
#define FNID_SCROLLBAR
Definition: ntuser.h:821
struct tagNCCALCSIZE_PARAMS NCCALCSIZE_PARAMS
#define HC_ACTION
Definition: winuser.h:48
#define MMS_SIZE_WPARAMWCHAR
Definition: message.c:107
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:753
#define QS_ALLINPUT
Definition: winuser.h:874
#define WM_LBUTTONUP
Definition: winuser.h:1759
#define PM_NOYIELD
Definition: winuser.h:1183
#define ERROR_MESSAGE_SYNC_ONLY
Definition: winerror.h:681
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1492
struct tagMEASUREITEMSTRUCT MEASUREITEMSTRUCT
LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1695
#define QS_POSTMESSAGE
Definition: winuser.h:888
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define min(a, b)
Definition: monoChain.cc:55
struct tagSTYLESTRUCT STYLESTRUCT
unsigned int UINT
Definition: ndis.h:50
#define WM_MOUSEMOVE
Definition: winuser.h:1757
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
DWORD time
Definition: winuser.h:3093
VOID FASTCALL IntPaintWindow(PWND Window)
Definition: painting.c:1165
#define WNDS_INTERNALPAINT
Definition: ntuser.h:585
#define USERTAG_SWP
Definition: tags.h:280
HWND hwnd
Definition: winuser.h:3089
#define MAXUSHORT
Definition: typedefs.h:82
#define WM_DEVICECHANGE
Definition: winuser.h:1793
TIMERPROC pfn
Definition: timer.h:13
#define POSTEVENT_DAW
Definition: msgqueue.h:123
#define QS_PAINT
Definition: winuser.h:887
#define WM_MDICREATE
Definition: winuser.h:1794
#define WM_DRAWITEM
Definition: winuser.h:1627
static UINT FASTCALL MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam)
Definition: message.c:164
BOOL APIENTRY co_MsqPeekHardwareMessage(IN PTHREADINFO pti, IN BOOL Remove, IN PWND Window, IN UINT MsgFilterLow, IN UINT MsgFilterHigh, IN UINT QSflags, OUT MSG *pMsg)
Definition: msgqueue.c:1996
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1644
#define msg(x)
Definition: auth_time.c:54
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
static VOID FASTCALL IntCallWndProcRet(PWND Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *uResult)
Definition: message.c:729
struct tagCOPYDATASTRUCT COPYDATASTRUCT
#define BSM_ALLDESKTOPS
Definition: dbt.h:49
#define WM_CREATE
Definition: winuser.h:1590
ULONG_PTR Context
Definition: callback.h:49
#define EM_GETRECT
Definition: winuser.h:1978
PVOID Win32Thread
Definition: ketypes.h:1756
#define EM_GETLINE
Definition: winuser.h:1973
LPCWSTR lpszClass
Definition: winuser.h:2940
#define HIWORD(l)
Definition: typedefs.h:246
BOOL FASTCALL IntDeactivateWindow(PTHREADINFO pti, HANDLE tid)
Definition: focus.c:105
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ULONG_PTR
Definition: config.h:101
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 IS_ATOM(x)
Definition: class.h:3
struct tagMSGMEMORY MSGMEMORY
#define LB_GETITEMRECT
Definition: winuser.h:2025
#define SM_CYDRAG
Definition: winuser.h:1019
static const unsigned int message_pointer_flags[]
Definition: message.c:37
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
PTHREADINFO ptiList
Definition: win32.h:248
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define PM_REMOVE
Definition: winuser.h:1182
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
struct _LARGE_STRING * PLARGE_STRING
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
const TCHAR * CompletionCallback(unsigned __int64 &rnIndex, const BOOL *pblnForward, const TCHAR *pszContext, const TCHAR *pszBegin)
Definition: Completion.cpp:439
PWND FASTCALL VerifyWnd(PWND pWnd)
Definition: window.c:64
void exit(int exitcode)
Definition: _exit.c:33
#define USERTAG_WINDOWLIST
Definition: tags.h:297
LONG_PTR LRESULT
Definition: windef.h:209
#define QS_MOUSE
Definition: winuser.h:884
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
#define QS_KEY
Definition: winuser.h:883
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:92
UINT message
Definition: winuser.h:3090
return STATUS_SUCCESS
Definition: btrfs.c:2938
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T _In_ POOL_TYPE PoolType
Definition: fltkernel.h:1444
#define QF_MOUSEMOVED
Definition: msgqueue.h:99
#define WNDS_ANSICREATOR
Definition: ntuser.h:602
#define HWND_BROADCAST
Definition: winuser.h:1190
#define IntDereferenceProcessInfo(ppi)
Definition: win32.h:183
LRESULT lResult
Definition: winuser.h:2992
#define WNDS_SERVERSIDEWINDOWPROC
Definition: ntuser.h:591
#define CHAR(Char)
#define MMS_FLAG_WRITE
Definition: message.c:111
#define CB_FINDSTRING
Definition: winuser.h:1921
#define WNDS_DESTROYED
Definition: ntuser.h:604
#define POSTEVENT_SAW
Definition: msgqueue.h:124
#define WH_SYSMSGFILTER
Definition: winuser.h:36
BOOL APIENTRY NtUserPeekMessage(PMSG pMsg, HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg)
Definition: message.c:2322
#define MMS_FLAG_READWRITE
Definition: message.c:112
#define LB_INSERTSTRING
Definition: winuser.h:2035
LPARAM lParam
Definition: combotst.c:139
#define SMTO_BLOCK
Definition: winuser.h:1210
POBJECT_TYPE PsProcessType
Definition: process.c:20
#define WM_GETMINMAXINFO
Definition: winuser.h:1622
#define LOWORD(l)
Definition: pedump.c:82
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583
#define TIF_INCLEANUP
Definition: ntuser.h:240
#define BSM_APPLICATIONS
Definition: dbt.h:48
static PLARGE_INTEGER Time
Definition: time.c:105
UINT Message
Definition: message.c:115
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
#define FNID_SENDMESSAGEWTOOPTION
Definition: ntuser.h:847
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define WAIT_FAILED
Definition: message.c:3037
#define APIENTRY
Definition: api.h:79
#define EM_REPLACESEL
Definition: winuser.h:1988
#define END_CLEANUP
Definition: ntuser.h:6
ULONG MaximumLength
Definition: ntuser.h:95
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1013
#define TAG_MSG
Definition: tags.h:7
static UINT WPARAM wparam
Definition: combo.c:716
LRESULT FASTCALL co_IntSendMessageWithCallBack(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, SENDASYNCPROC CompletionCallback, ULONG_PTR CompletionCallbackContext, ULONG_PTR *uResult)
Definition: message.c:1717
ULONG_PTR offPfn
Definition: ntuser.h:220
BOOL APIENTRY NtUserPostMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:2210
#define PM_BADMSGFLAGS
Definition: message.c:15
PCLS pcls
Definition: ntuser.h:684
#define NT_ASSERT
Definition: rtlfuncs.h:3312
DWORD style
Definition: ntuser.h:670
#define CB_FINDSTRINGEXACT
Definition: winuser.h:1922