ReactOS  0.4.11-dev-195-gef016bf
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
164 MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam)
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  {
218  COPYDATASTRUCT *cds = (COPYDATASTRUCT *)lParam;
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)
266  PoolType = NonPagedPool;
267  else
268  PoolType = PagedPool;
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  }
302  PackedCs = ExAllocatePoolWithTag(PoolType, Size, TAG_MSG);
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  }
355  PackedData = ExAllocatePoolWithTag(NonPagedPool, size, TAG_MSG);
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 */
440  KernelMem = ExAllocatePoolWithTag(PagedPool, Size, TAG_MSG);
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)) ||
570  ((first <= WM_NCMOUSELAST) && (last >= WM_NCMOUSEFIRST)) ) mask |= QS_MOUSE;
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 static VOID FASTCALL
582 {
583  BOOL SameThread = FALSE;
584  CWPSTRUCT CWP;
585 
586  if (Window->head.pti == ((PTHREADINFO)PsGetCurrentThreadWin32Thread()))
587  SameThread = TRUE;
588 
589  CWP.hwnd = hWnd;
590  CWP.message = Msg;
591  CWP.wParam = wParam;
592  CWP.lParam = lParam;
593  co_HOOK_CallHooks( WH_CALLWNDPROC, HC_ACTION, SameThread, (LPARAM)&CWP );
594 }
595 
596 static VOID FASTCALL
598 {
599  BOOL SameThread = FALSE;
600  CWPRETSTRUCT CWPR;
601 
602  if (Window->head.pti == ((PTHREADINFO)PsGetCurrentThreadWin32Thread()))
603  SameThread = TRUE;
604 
605  CWPR.hwnd = hWnd;
606  CWPR.message = Msg;
607  CWPR.wParam = wParam;
608  CWPR.lParam = lParam;
609  CWPR.lResult = uResult ? (*uResult) : 0;
610  co_HOOK_CallHooks( WH_CALLWNDPROCRET, HC_ACTION, SameThread, (LPARAM)&CWPR );
611 }
612 
614 {
615  LRESULT lRes;
616 // USER_REFERENCE_ENTRY Ref;
617 // PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
618 
619  if (!pWnd || UserIsDesktopWindow(pWnd) || UserIsMessageWindow(pWnd))
620  return 0;
621 
622  TRACE("Internal Event Msg 0x%x hWnd 0x%p\n", msg, pWnd->head.h);
623 
624  switch(msg)
625  {
626  case WM_ASYNC_SHOWWINDOW:
627  return co_WinPosShowWindow( pWnd, wparam );
629  {
630  PWINDOWPOS winpos = (PWINDOWPOS)lparam;
631  if (!winpos) return 0;
632  lRes = co_WinPosSetWindowPos( pWnd,
633  winpos->hwndInsertAfter,
634  winpos->x,
635  winpos->y,
636  winpos->cx,
637  winpos->cy,
638  winpos->flags);
640  return lRes;
641  }
643  {
644  ERR("WM_ASYNC_DESTROYWINDOW\n");
645  if (pWnd->style & WS_CHILD)
647  else
648  co_UserDestroyWindow(pWnd);
649  }
650  }
651  return 0;
652 }
653 
654 static LRESULT handle_internal_events( PTHREADINFO pti, PWND pWnd, DWORD dwQEvent, LONG_PTR ExtraInfo, PMSG pMsg)
655 {
656  LRESULT Result = 0;
657 
658  switch(dwQEvent)
659  {
660  case POSTEVENT_NWE:
661  {
662  co_EVENT_CallEvents( pMsg->message, pMsg->hwnd, pMsg->wParam, ExtraInfo);
663  }
664  break;
665  case POSTEVENT_SAW:
666  {
667  //ERR("HIE : SAW : pti 0x%p hWnd 0x%p\n",pti,pMsg->hwnd);
668  IntActivateWindow((PWND)pMsg->wParam, pti, (HANDLE)pMsg->lParam, (DWORD)ExtraInfo);
669  }
670  break;
671  case POSTEVENT_DAW:
672  {
673  //ERR("HIE : DAW : pti 0x%p tid 0x%p hWndPrev 0x%p\n",pti,ExtraInfo,pMsg->hwnd);
674  IntDeactivateWindow(pti, (HANDLE)ExtraInfo);
675  }
676  break;
677  }
678  return Result;
679 }
680 
683 {
684  LARGE_INTEGER TickCount;
685  LONG Time;
686  LRESULT retval = 0;
687  PTHREADINFO pti;
688  PWND Window = NULL;
689  BOOL DoCallBack = TRUE;
690 
691  if (pMsg->hwnd)
692  {
693  Window = UserGetWindowObject(pMsg->hwnd);
694  if (!Window) return 0;
695  }
696 
698 
699  if ( Window && Window->head.pti != pti)
700  {
702  return 0;
703  }
704 
705  if (((pMsg->message == WM_SYSTIMER) ||
706  (pMsg->message == WM_TIMER)) &&
707  (pMsg->lParam) )
708  {
709  if (pMsg->message == WM_TIMER)
710  {
711  if (ValidateTimerCallback(pti,pMsg->lParam))
712  {
713  KeQueryTickCount(&TickCount);
714  Time = MsqCalculateMessageTime(&TickCount);
715  retval = co_IntCallWindowProc((WNDPROC)pMsg->lParam,
716  TRUE,
717  pMsg->hwnd,
718  WM_TIMER,
719  pMsg->wParam,
720  (LPARAM)Time,
721  -1);
722  }
723  return retval;
724  }
725  else
726  {
727  PTIMER pTimer = FindSystemTimer(pMsg);
728  if (pTimer && pTimer->pfn)
729  {
730  KeQueryTickCount(&TickCount);
731  Time = MsqCalculateMessageTime(&TickCount);
732  pTimer->pfn(pMsg->hwnd, WM_SYSTIMER, (UINT)pMsg->wParam, Time);
733  }
734  return 0;
735  }
736  }
737  // Need a window!
738  if ( !Window ) return 0;
739 
740  if (pMsg->message == WM_PAINT) Window->state |= WNDS_PAINTNOTPROCESSED;
741 
742  if ( Window->state & WNDS_SERVERSIDEWINDOWPROC )
743  {
744  TRACE("Dispatch: Server Side Window Procedure\n");
745  switch(Window->fnid)
746  {
747  case FNID_DESKTOP:
748  DoCallBack = !DesktopWindowProc( Window,
749  pMsg->message,
750  pMsg->wParam,
751  pMsg->lParam,
752  &retval);
753  break;
754  case FNID_MESSAGEWND:
755  DoCallBack = !UserMessageWindowProc( Window,
756  pMsg->message,
757  pMsg->wParam,
758  pMsg->lParam,
759  &retval);
760  break;
761  case FNID_MENU:
762  DoCallBack = !PopupMenuWndProc( Window,
763  pMsg->message,
764  pMsg->wParam,
765  pMsg->lParam,
766  &retval);
767  break;
768  }
769  }
770 
771  /* Since we are doing a callback on the same thread right away, there is
772  no need to copy the lparam to kernel mode and then back to usermode.
773  We just pretend it isn't a pointer */
774 
775  if (DoCallBack)
776  retval = co_IntCallWindowProc( Window->lpfnWndProc,
777  !Window->Unicode,
778  pMsg->hwnd,
779  pMsg->message,
780  pMsg->wParam,
781  pMsg->lParam,
782  -1);
783 
784  if ( pMsg->message == WM_PAINT &&
785  VerifyWnd(Window) &&
786  Window->state & WNDS_PAINTNOTPROCESSED ) // <--- Cleared, paint was already processed!
787  {
788  Window->state2 &= ~WNDS2_WMPAINTSENT;
789  /* send a WM_ERASEBKGND if the non-client area is still invalid */
790  ERR("Message WM_PAINT count %d Internal Paint Set? %s\n",Window->head.pti->cPaintsReady, Window->state & WNDS_INTERNALPAINT ? "TRUE" : "FALSE");
791  IntPaintWindow( Window );
792  }
793 
794  return retval;
795 }
796 
797 /*
798  * Internal version of PeekMessage() doing all the work
799  *
800  * MSDN:
801  * Sent messages
802  * Posted messages
803  * Input (hardware) messages and system internal events
804  * Sent messages (again)
805  * WM_PAINT messages
806  * WM_TIMER messages
807  */
810  PWND Window,
811  UINT MsgFilterMin,
812  UINT MsgFilterMax,
813  UINT RemoveMsg,
814  LONG_PTR *ExtraInfo,
815  BOOL bGMSG )
816 {
817  PTHREADINFO pti;
818  LARGE_INTEGER LargeTickCount;
819  BOOL RemoveMessages;
820  UINT ProcessMask;
821  BOOL Hit = FALSE;
822 
824 
825  RemoveMessages = RemoveMsg & PM_REMOVE;
826  ProcessMask = HIWORD(RemoveMsg);
827 
828  /* Hint, "If wMsgFilterMin and wMsgFilterMax are both zero, PeekMessage returns
829  all available messages (that is, no range filtering is performed)". */
830  if (!ProcessMask) ProcessMask = (QS_ALLPOSTMESSAGE|QS_ALLINPUT);
831 
832  IdlePong();
833 
834  do
835  {
836  KeQueryTickCount(&LargeTickCount);
837  pti->timeLast = LargeTickCount.u.LowPart;
838  pti->pcti->tickLastMsgChecked = LargeTickCount.u.LowPart;
839 
840  // Post mouse moves while looping through peek messages.
841  if (pti->MessageQueue->QF_flags & QF_MOUSEMOVED)
842  {
844  }
845 
846  /* Dispatch sent messages here. */
847  while ( co_MsqDispatchOneSentMessage(pti) )
848  {
849  /* if some PM_QS* flags were specified, only handle sent messages from now on */
850  if (HIWORD(RemoveMsg) && !bGMSG) Hit = TRUE; // wine does this; ProcessMask = QS_SENDMESSAGE;
851  }
852  if (Hit) return FALSE;
853 
854  /* Clear changed bits so we can wait on them if we don't find a message */
855  if (ProcessMask & QS_POSTMESSAGE)
856  {
857  pti->pcti->fsChangeBits &= ~(QS_POSTMESSAGE | QS_HOTKEY | QS_TIMER);
858  if (MsgFilterMin == 0 && MsgFilterMax == 0) // Wine hack does this; ~0U)
859  {
860  pti->pcti->fsChangeBits &= ~QS_ALLPOSTMESSAGE;
861  }
862  }
863 
864  if (ProcessMask & QS_INPUT)
865  {
866  pti->pcti->fsChangeBits &= ~QS_INPUT;
867  }
868 
869  /* Now check for normal messages. */
870  if (( (ProcessMask & QS_POSTMESSAGE) ||
871  (ProcessMask & QS_HOTKEY) ) &&
872  MsqPeekMessage( pti,
873  RemoveMessages,
874  Window,
875  MsgFilterMin,
876  MsgFilterMax,
877  ProcessMask,
878  ExtraInfo,
879  0,
880  Msg ))
881  {
882  return TRUE;
883  }
884 
885  /* Only check for quit messages if not posted messages pending. */
886  if (ProcessMask & QS_POSTMESSAGE && pti->QuitPosted)
887  {
888  /* According to the PSDK, WM_QUIT messages are always returned, regardless
889  of the filter specified */
890  Msg->hwnd = NULL;
891  Msg->message = WM_QUIT;
892  Msg->wParam = pti->exitCode;
893  Msg->lParam = 0;
894  if (RemoveMessages)
895  {
896  pti->QuitPosted = FALSE;
897  ClearMsgBitsMask(pti, QS_POSTMESSAGE);
898  pti->pcti->fsWakeBits &= ~QS_ALLPOSTMESSAGE;
899  pti->pcti->fsChangeBits &= ~QS_ALLPOSTMESSAGE;
900  }
901  return TRUE;
902  }
903 
904  /* Check for hardware events. */
905  if ((ProcessMask & QS_INPUT) &&
907  RemoveMessages,
908  Window,
909  MsgFilterMin,
910  MsgFilterMax,
911  ProcessMask,
912  Msg))
913  {
914  return TRUE;
915  }
916 
917  /* Now check for System Event messages. */
918  {
919  LONG_PTR eExtraInfo;
920  MSG eMsg;
921  DWORD dwQEvent;
922  if (MsqPeekMessage( pti,
923  TRUE,
924  Window,
925  0,
926  0,
927  QS_EVENT,
928  &eExtraInfo,
929  &dwQEvent,
930  &eMsg ))
931  {
932  handle_internal_events( pti, Window, dwQEvent, eExtraInfo, &eMsg);
933  continue;
934  }
935  }
936 
937  /* Check for sent messages again. */
938  while ( co_MsqDispatchOneSentMessage(pti) )
939  {
940  if (HIWORD(RemoveMsg) && !bGMSG) Hit = TRUE;
941  }
942  if (Hit) return FALSE;
943 
944  /* Check for paint messages. */
945  if ((ProcessMask & QS_PAINT) &&
946  pti->cPaintsReady &&
947  IntGetPaintMessage( Window,
948  MsgFilterMin,
949  MsgFilterMax,
950  pti,
951  Msg,
952  RemoveMessages))
953  {
954  return TRUE;
955  }
956 
957  /* This is correct, check for the current threads timers waiting to be
958  posted to this threads message queue. If any we loop again.
959  */
960  if ((ProcessMask & QS_TIMER) &&
961  PostTimerMessages(Window))
962  {
963  continue;
964  }
965 
966  return FALSE;
967  }
968  while (TRUE);
969 
970  return TRUE;
971 }
972 
975  UINT MsgFilterMin,
976  UINT MsgFilterMax )
977 {
978  PTHREADINFO pti;
980  MSG Msg;
981  LONG_PTR ExtraInfo = 0;
982 
984 
985  do
986  {
987  if ( co_IntPeekMessage( &Msg, // Dont reenter!
988  Window,
989  MsgFilterMin,
990  MsgFilterMax,
991  MAKELONG( PM_NOREMOVE, GetWakeMask( MsgFilterMin, MsgFilterMax)),
992  &ExtraInfo,
993  TRUE ) ) // act like GetMessage.
994  {
995  return TRUE;
996  }
997 
998  /* Nothing found. Wait for new messages. */
999  Status = co_MsqWaitForNewMessages( pti,
1000  Window,
1001  MsgFilterMin,
1002  MsgFilterMax);
1003  if (!NT_SUCCESS(Status))
1004  {
1005  SetLastNtError(Status);
1006  ERR("Exit co_IntWaitMessage on error!\n");
1007  return FALSE;
1008  }
1009  if (Status == STATUS_USER_APC || Status == STATUS_TIMEOUT)
1010  {
1011  return FALSE;
1012  }
1013  }
1014  while ( TRUE );
1015 
1016  return FALSE;
1017 }
1018 
1019 BOOL APIENTRY
1021  HWND hWnd,
1022  UINT MsgFilterMin,
1023  UINT MsgFilterMax,
1024  UINT RemoveMsg,
1025  BOOL bGMSG )
1026 {
1027  PWND Window;
1028  PTHREADINFO pti;
1029  BOOL Present = FALSE;
1030  NTSTATUS Status;
1031  LONG_PTR ExtraInfo = 0;
1032 
1033  if ( hWnd == HWND_TOPMOST || hWnd == HWND_BROADCAST )
1034  hWnd = HWND_BOTTOM;
1035 
1036  /* Validate input */
1037  if (hWnd && hWnd != HWND_BOTTOM)
1038  {
1039  if (!(Window = UserGetWindowObject(hWnd)))
1040  {
1041  if (bGMSG)
1042  return -1;
1043  else
1044  return FALSE;
1045  }
1046  }
1047  else
1048  {
1049  Window = (PWND)hWnd;
1050  }
1051 
1052  if (MsgFilterMax < MsgFilterMin)
1053  {
1054  MsgFilterMin = 0;
1055  MsgFilterMax = 0;
1056  }
1057 
1058  if (bGMSG)
1059  {
1060  RemoveMsg |= ((GetWakeMask( MsgFilterMin, MsgFilterMax ))<< 16);
1061  }
1062 
1064  pti->pClientInfo->cSpins++; // Bump up the spin count.
1065 
1066  do
1067  {
1068  Present = co_IntPeekMessage( pMsg,
1069  Window,
1070  MsgFilterMin,
1071  MsgFilterMax,
1072  RemoveMsg,
1073  &ExtraInfo,
1074  bGMSG );
1075  if (Present)
1076  {
1077  /* GetMessage or PostMessage must never get messages that contain pointers */
1078  ASSERT(FindMsgMemory(pMsg->message) == NULL);
1079 
1080  if ( pMsg->message >= WM_DDE_FIRST && pMsg->message <= WM_DDE_LAST )
1081  {
1082  if (!IntDdeGetMessageHook(pMsg, ExtraInfo))
1083  {
1084  TRACE("DDE Get return ERROR\n");
1085  continue;
1086  }
1087  }
1088 
1089  if (pMsg->message != WM_PAINT && pMsg->message != WM_QUIT)
1090  {
1091  if (!RtlEqualMemory(&pti->ptLast, &pMsg->pt, sizeof(POINT)))
1092  {
1093  pti->TIF_flags |= TIF_MSGPOSCHANGED;
1094  }
1095  pti->timeLast = pMsg->time;
1096  pti->ptLast = pMsg->pt;
1097  }
1098 
1099  // The WH_GETMESSAGE hook enables an application to monitor messages about to
1100  // be returned by the GetMessage or PeekMessage function.
1101 
1102  co_HOOK_CallHooks( WH_GETMESSAGE, HC_ACTION, RemoveMsg & PM_REMOVE, (LPARAM)pMsg);
1103 
1104  if ( bGMSG || pMsg->message == WM_PAINT) break;
1105  }
1106 
1107  if ( bGMSG )
1108  {
1109  Status = co_MsqWaitForNewMessages( pti,
1110  Window,
1111  MsgFilterMin,
1112  MsgFilterMax);
1113  if ( !NT_SUCCESS(Status) ||
1114  Status == STATUS_USER_APC ||
1115  Status == STATUS_TIMEOUT )
1116  {
1117  Present = -1;
1118  break;
1119  }
1120  }
1121  else
1122  {
1123  if (!(RemoveMsg & PM_NOYIELD))
1124  {
1125  IdlePing();
1126  // Yield this thread!
1127  UserLeave();
1128  ZwYieldExecution();
1130  // Fall through to exit.
1131  IdlePong();
1132  }
1133  break;
1134  }
1135  }
1136  while( bGMSG && !Present );
1137 
1138  // Been spinning, time to swap vinyl...
1139  if (pti->pClientInfo->cSpins >= 100)
1140  {
1141  // Clear the spin cycle to fix the mix.
1142  pti->pClientInfo->cSpins = 0;
1143  //if (!(pti->TIF_flags & TIF_SPINNING)) // FIXME: Need to swap vinyl...
1144  }
1145  return Present;
1146 }
1147 
1148 BOOL FASTCALL
1150  UINT Msg,
1151  WPARAM wParam,
1152  LPARAM lParam )
1153 {
1154  MSG Message;
1155  LARGE_INTEGER LargeTickCount;
1156 
1157  if (is_pointer_message(Msg))
1158  {
1160  return FALSE;
1161  }
1162  Message.hwnd = NULL;
1163  Message.message = Msg;
1164  Message.wParam = wParam;
1165  Message.lParam = lParam;
1166  Message.pt = gpsi->ptCursor;
1167 
1168  KeQueryTickCount(&LargeTickCount);
1169  Message.time = MsqCalculateMessageTime(&LargeTickCount);
1170  MsqPostMessage(pti, &Message, FALSE, QS_POSTMESSAGE, 0, 0);
1171  return TRUE;
1172 }
1173 
1176 {
1177  if ( ptiCur )
1178  {
1179  if (!Window ||
1180  Window->head.pti == ptiCur )
1181  {
1182  return NULL;
1183  }
1184  }
1185  return Window ? Window->head.pti : NULL;
1186 }
1187 
1188 BOOL FASTCALL
1190  UINT Msg,
1191  WPARAM wParam,
1192  LPARAM lParam )
1193 {
1194  PTHREADINFO pti;
1195  MSG Message;
1196  LARGE_INTEGER LargeTickCount;
1197  LONG_PTR ExtraInfo = 0;
1198 
1199  Message.hwnd = Wnd;
1200  Message.message = Msg;
1201  Message.wParam = wParam;
1202  Message.lParam = lParam;
1203  Message.pt = gpsi->ptCursor;
1204  KeQueryTickCount(&LargeTickCount);
1205  Message.time = MsqCalculateMessageTime(&LargeTickCount);
1206 
1207  if (is_pointer_message(Message.message))
1208  {
1210  return FALSE;
1211  }
1212 
1213  if (Wnd == HWND_BROADCAST || Wnd == HWND_TOPMOST)
1214  {
1215  HWND *List;
1217  ULONG i;
1218 
1219  if (!is_message_broadcastable(Msg)) return TRUE;
1220 
1221  DesktopWindow = UserGetDesktopWindow();
1222  List = IntWinListChildren(DesktopWindow);
1223 
1224  if (List != NULL)
1225  {
1226  UserPostMessage(DesktopWindow->head.h, Msg, wParam, lParam);
1227  for (i = 0; List[i]; i++)
1228  {
1229  PWND pwnd = UserGetWindowObject(List[i]);
1230  if (!pwnd) continue;
1231 
1232  if ( pwnd->fnid == FNID_MENU || // Also need pwnd->pcls->atomClassName == gaOleMainThreadWndClass
1234  continue;
1235 
1236  UserPostMessage(List[i], Msg, wParam, lParam);
1237  }
1239  }
1240  }
1241  else
1242  {
1243  PWND Window;
1244 
1245  if (!Wnd)
1246  {
1248  Msg,
1249  wParam,
1250  lParam);
1251  }
1252 
1253  Window = UserGetWindowObject(Wnd);
1254  if ( !Window )
1255  {
1256  ERR("UserPostMessage: Invalid handle 0x%p Msg 0x%x!\n", Wnd, Msg);
1257  return FALSE;
1258  }
1259 
1260  pti = Window->head.pti;
1261 
1262  if ( pti->TIF_flags & TIF_INCLEANUP )
1263  {
1264  ERR("Attempted to post message to window %p when the thread is in cleanup!\n", Wnd);
1265  return FALSE;
1266  }
1267 
1268  if ( Window->state & WNDS_DESTROYED )
1269  {
1270  ERR("Attempted to post message to window %p that is being destroyed!\n", Wnd);
1271  /* FIXME: Last error code? */
1272  return FALSE;
1273  }
1274 
1275  if ( Msg >= WM_DDE_FIRST && Msg <= WM_DDE_LAST )
1276  {
1277  if (!IntDdePostMessageHook(Window, Msg, wParam, &lParam, &ExtraInfo))
1278  {
1279  TRACE("Posting Exit DDE 0x%x\n",Msg);
1280  return FALSE;
1281  }
1282  Message.lParam = lParam;
1283  }
1284 
1285  MsqPostMessage(pti, &Message, FALSE, QS_POSTMESSAGE, 0, ExtraInfo);
1286  }
1287  return TRUE;
1288 }
1289 
1292  UINT Msg,
1293  WPARAM wParam,
1294  LPARAM lParam )
1295 {
1296  ULONG_PTR Result = 0;
1297 
1298  if (co_IntSendMessageTimeout(hWnd, Msg, wParam, lParam, SMTO_NORMAL, 0, &Result))
1299  {
1300  return (LRESULT)Result;
1301  }
1302  return 0;
1303 }
1304 
1305 static LRESULT FASTCALL
1307  UINT Msg,
1308  WPARAM wParam,
1309  LPARAM lParam,
1310  UINT uFlags,
1311  UINT uTimeout,
1312  ULONG_PTR *uResult )
1313 {
1315  PWND Window = NULL;
1316  PMSGMEMORY MsgMemoryEntry;
1317  INT lParamBufferSize;
1318  LPARAM lParamPacked;
1319  PTHREADINFO Win32Thread, ptiSendTo = NULL;
1320  ULONG_PTR Result = 0;
1323  BOOL DoCallBack = TRUE;
1324 
1325  if (!(Window = UserGetWindowObject(hWnd)))
1326  {
1327  TRACE("SendMessageTimeoutSingle: Invalid handle 0x%p!\n",hWnd);
1328  RETURN( FALSE);
1329  }
1330 
1331  UserRefObjectCo(Window, &Ref);
1332 
1333  Win32Thread = PsGetCurrentThreadWin32Thread();
1334 
1335  ptiSendTo = IntSendTo(Window, Win32Thread, Msg);
1336 
1337  if ( Msg >= WM_DDE_FIRST && Msg <= WM_DDE_LAST )
1338  {
1339  if (!IntDdeSendMessageHook(Window, Msg, wParam, lParam))
1340  {
1341  ERR("Sending Exit DDE 0x%x\n",Msg);
1342  RETURN( FALSE);
1343  }
1344  }
1345 
1346  if ( !ptiSendTo )
1347  {
1348  if (Win32Thread->TIF_flags & TIF_INCLEANUP)
1349  {
1350  /* Never send messages to exiting threads */
1351  RETURN( FALSE);
1352  }
1353 
1354  if (Msg & 0x80000000)
1355  {
1356  TRACE("SMTS: Internal Message!\n");
1357  Result = (ULONG_PTR)handle_internal_message( Window, Msg, wParam, lParam );
1358  if (uResult) *uResult = Result;
1359  RETURN( TRUE);
1360  }
1361 
1362  // Only happens when calling the client!
1363  IntCallWndProc( Window, hWnd, Msg, wParam, lParam);
1364 
1365  if ( Window->state & WNDS_SERVERSIDEWINDOWPROC )
1366  {
1367  TRACE("SMT: Server Side Window Procedure\n");
1368  // Handle it here. Safeguard against excessive recursions.
1369  if (IoGetRemainingStackSize() < PAGE_SIZE)
1370  {
1371  ERR("Server Callback Exceeded Stack!\n");
1372  RETURN( FALSE);
1373  }
1374  /* Return after server side call, IntCallWndProcRet will not be called. */
1375  switch(Window->fnid)
1376  {
1377  case FNID_DESKTOP:
1378  DoCallBack = !DesktopWindowProc(Window, Msg, wParam, lParam,(LRESULT*)&Result);
1379  break;
1380  case FNID_MESSAGEWND:
1381  DoCallBack = !UserMessageWindowProc(Window, Msg, wParam, lParam,(LRESULT*)&Result);
1382  break;
1383  case FNID_MENU:
1384  DoCallBack = !PopupMenuWndProc( Window, Msg, wParam, lParam,(LRESULT*)&Result);
1385  break;
1386  }
1387  if (!DoCallBack)
1388  {
1389  if (uResult) *uResult = Result;
1390  RETURN( TRUE);
1391  }
1392  }
1393  /* See if this message type is present in the table */
1394  MsgMemoryEntry = FindMsgMemory(Msg);
1395  if (NULL == MsgMemoryEntry)
1396  {
1397  lParamBufferSize = -1;
1398  }
1399  else
1400  {
1401  lParamBufferSize = MsgMemorySize(MsgMemoryEntry, wParam, lParam);
1402  // If zero, do not allow callback on client side to allocate a buffer!!!!! See CORE-7695.
1403  if (!lParamBufferSize) lParamBufferSize = -1;
1404  }
1405 
1406  if (! NT_SUCCESS(PackParam(&lParamPacked, Msg, wParam, lParam, FALSE)))
1407  {
1408  ERR("Failed to pack message parameters\n");
1409  RETURN( FALSE);
1410  }
1411 
1412  Result = (ULONG_PTR)co_IntCallWindowProc( Window->lpfnWndProc,
1413  !Window->Unicode,
1414  hWnd,
1415  Msg,
1416  wParam,
1417  lParamPacked,
1418  lParamBufferSize );
1419  if (uResult)
1420  {
1421  *uResult = Result;
1422  }
1423 
1424  if (! NT_SUCCESS(UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE)))
1425  {
1426  ERR("Failed to unpack message parameters\n");
1427  RETURN( TRUE);
1428  }
1429 
1430  // Only happens when calling the client!
1431  IntCallWndProcRet( Window, hWnd, Msg, wParam, lParam, (LRESULT *)uResult);
1432 
1433  RETURN( TRUE);
1434  }
1435 
1436  if (uFlags & SMTO_ABORTIFHUNG && MsqIsHung(ptiSendTo))
1437  {
1438  // FIXME: Set window hung and add to a list.
1439  /* FIXME: Set a LastError? */
1440  RETURN( FALSE);
1441  }
1442 
1443  if (Window->state & WNDS_DESTROYED)
1444  {
1445  /* FIXME: Last error? */
1446  ERR("Attempted to send message to window %p that is being destroyed!\n", hWnd);
1447  RETURN( FALSE);
1448  }
1449 
1450  do
1451  {
1452  Status = co_MsqSendMessage( ptiSendTo,
1453  hWnd,
1454  Msg,
1455  wParam,
1456  lParam,
1457  uTimeout,
1458  (uFlags & SMTO_BLOCK),
1459  MSQ_NORMAL,
1460  uResult );
1461  }
1462  while ((STATUS_TIMEOUT == Status) &&
1463  (uFlags & SMTO_NOTIMEOUTIFNOTHUNG) &&
1464  !MsqIsHung(ptiSendTo)); // FIXME: Set window hung and add to a list.
1465 
1466  if (Status == STATUS_TIMEOUT)
1467  {
1468 /*
1469  * MSDN says:
1470  * Microsoft Windows 2000: If GetLastError returns zero, then the function
1471  * timed out.
1472  * XP+ : If the function fails or times out, the return value is zero.
1473  * To get extended error information, call GetLastError. If GetLastError
1474  * returns ERROR_TIMEOUT, then the function timed out.
1475  */
1477  RETURN( FALSE);
1478  }
1479  else if (!NT_SUCCESS(Status))
1480  {
1481  SetLastNtError(Status);
1482  RETURN( FALSE);
1483  }
1484 
1485  RETURN( TRUE);
1486 
1487 CLEANUP:
1488  if (Window) UserDerefObjectCo(Window);
1489  END_CLEANUP;
1490 }
1491 
1494  UINT Msg,
1495  WPARAM wParam,
1496  LPARAM lParam,
1497  UINT uFlags,
1498  UINT uTimeout,
1499  ULONG_PTR *uResult )
1500 {
1502  HWND *Children;
1503  HWND *Child;
1504 
1505  if (hWnd != HWND_BROADCAST && hWnd != HWND_TOPMOST)
1506  {
1507  return co_IntSendMessageTimeoutSingle(hWnd, Msg, wParam, lParam, uFlags, uTimeout, uResult);
1508  }
1509 
1510  if (!is_message_broadcastable(Msg)) return TRUE;
1511 
1512  DesktopWindow = UserGetDesktopWindow();
1513  if (NULL == DesktopWindow)
1514  {
1516  return 0;
1517  }
1518 
1519  if (hWnd != HWND_TOPMOST)
1520  {
1521  /* Send message to the desktop window too! */
1522  co_IntSendMessageTimeoutSingle(DesktopWindow->head.h, Msg, wParam, lParam, uFlags, uTimeout, uResult);
1523  }
1524 
1525  Children = IntWinListChildren(DesktopWindow);
1526  if (NULL == Children)
1527  {
1528  return 0;
1529  }
1530 
1531  for (Child = Children; NULL != *Child; Child++)
1532  {
1533  PWND pwnd = UserGetWindowObject(*Child);
1534  if (!pwnd) continue;
1535 
1536  if ( pwnd->fnid == FNID_MENU ||
1538  continue;
1539 
1540  co_IntSendMessageTimeoutSingle(*Child, Msg, wParam, lParam, uFlags, uTimeout, uResult);
1541  }
1542 
1544 
1545  return (LRESULT) TRUE;
1546 }
1547 
1550  UINT Msg,
1551  WPARAM wParam,
1552  LPARAM lParam)
1553 {
1554  ULONG_PTR Result = 0;
1555  return co_IntSendMessageWithCallBack( hWnd,
1556  Msg,
1557  wParam,
1558  lParam,
1559  NULL,
1560  0,
1561  &Result);
1562 }
1563 /* MSDN:
1564  If you send a message in the range below WM_USER to the asynchronous message
1565  functions (PostMessage, SendNotifyMessage, and SendMessageCallback), its
1566  message parameters cannot include pointers. Otherwise, the operation will fail.
1567  The functions will return before the receiving thread has had a chance to
1568  process the message and the sender will free the memory before it is used.
1569 */
1572  UINT Msg,
1573  WPARAM wParam,
1574  LPARAM lParam,
1576  ULONG_PTR CompletionCallbackContext,
1577  ULONG_PTR *uResult)
1578 {
1579  ULONG_PTR Result;
1580  PWND Window = NULL;
1581  PMSGMEMORY MsgMemoryEntry;
1582  INT lParamBufferSize;
1583  LPARAM lParamPacked;
1584  PTHREADINFO Win32Thread, ptiSendTo = NULL;
1588  BOOL DoCallBack = TRUE;
1589 
1590  if (!(Window = UserGetWindowObject(hWnd)))
1591  {
1592  TRACE("SendMessageWithCallBack: Invalid handle 0x%p!\n",hWnd);
1593  RETURN(FALSE);
1594  }
1595 
1596  UserRefObjectCo(Window, &Ref);
1597 
1598  if (Window->state & WNDS_DESTROYED)
1599  {
1600  /* FIXME: last error? */
1601  ERR("Attempted to send message to window %p that is being destroyed!\n", hWnd);
1602  RETURN(FALSE);
1603  }
1604 
1605  Win32Thread = PsGetCurrentThreadWin32Thread();
1606 
1607  if (Win32Thread == NULL ||
1608  Win32Thread->TIF_flags & TIF_INCLEANUP)
1609  {
1610  RETURN(FALSE);
1611  }
1612 
1613  ptiSendTo = IntSendTo(Window, Win32Thread, Msg);
1614 
1615  if (Msg & 0x80000000 &&
1616  !ptiSendTo)
1617  {
1618  if (Win32Thread->TIF_flags & TIF_INCLEANUP) RETURN( FALSE);
1619 
1620  TRACE("SMWCB: Internal Message!\n");
1621  Result = (ULONG_PTR)handle_internal_message( Window, Msg, wParam, lParam );
1622  if (uResult) *uResult = Result;
1623  RETURN( TRUE);
1624  }
1625 
1626  /* See if this message type is present in the table */
1627  MsgMemoryEntry = FindMsgMemory(Msg);
1628  if (NULL == MsgMemoryEntry)
1629  {
1630  lParamBufferSize = -1;
1631  }
1632  else
1633  {
1634  lParamBufferSize = MsgMemorySize(MsgMemoryEntry, wParam, lParam);
1635  if (!lParamBufferSize) lParamBufferSize = -1;
1636  }
1637 
1638  if (! NT_SUCCESS(PackParam(&lParamPacked, Msg, wParam, lParam, !!ptiSendTo)))
1639  {
1640  ERR("Failed to pack message parameters\n");
1641  RETURN( FALSE);
1642  }
1643 
1644  /* If it can be sent now, then send it. */
1645  if ( !ptiSendTo )
1646  {
1647  if (Win32Thread->TIF_flags & TIF_INCLEANUP)
1648  {
1649  UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE);
1650  /* Never send messages to exiting threads */
1651  RETURN(FALSE);
1652  }
1653 
1654  IntCallWndProc( Window, hWnd, Msg, wParam, lParam);
1655 
1656  if ( Window->state & WNDS_SERVERSIDEWINDOWPROC )
1657  {
1658  TRACE("SMWCB: Server Side Window Procedure\n");
1659  switch(Window->fnid)
1660  {
1661  case FNID_DESKTOP:
1662  DoCallBack = !DesktopWindowProc(Window, Msg, wParam, lParamPacked, (LRESULT*)&Result);
1663  break;
1664  case FNID_MESSAGEWND:
1665  DoCallBack = !UserMessageWindowProc(Window, Msg, wParam, lParam,(LRESULT*)&Result);
1666  break;
1667  case FNID_MENU:
1668  DoCallBack = !PopupMenuWndProc( Window, Msg, wParam, lParam,(LRESULT*)&Result);
1669  break;
1670  }
1671  }
1672 
1673  if (DoCallBack)
1674  Result = (ULONG_PTR)co_IntCallWindowProc( Window->lpfnWndProc,
1675  !Window->Unicode,
1676  hWnd,
1677  Msg,
1678  wParam,
1679  lParamPacked,
1680  lParamBufferSize );
1681  if(uResult)
1682  {
1683  *uResult = Result;
1684  }
1685 
1686  IntCallWndProcRet( Window, hWnd, Msg, wParam, lParam, (LRESULT *)uResult);
1687 
1688  if (CompletionCallback)
1689  {
1690  co_IntCallSentMessageCallback(CompletionCallback,
1691  hWnd,
1692  Msg,
1693  CompletionCallbackContext,
1694  Result);
1695  }
1696  }
1697 
1698  if ( !ptiSendTo)
1699  {
1700  if (! NT_SUCCESS(UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE)))
1701  {
1702  ERR("Failed to unpack message parameters\n");
1703  }
1704  RETURN(TRUE);
1705  }
1706 
1707  if(!(Message = AllocateUserMessage(FALSE)))
1708  {
1709  ERR("MsqSendMessage(): Not enough memory to allocate a message");
1710  RETURN( FALSE);
1711  }
1712 
1713  Message->Msg.hwnd = hWnd;
1714  Message->Msg.message = Msg;
1715  Message->Msg.wParam = wParam;
1716  Message->Msg.lParam = lParamPacked;
1717  Message->pkCompletionEvent = NULL; // No event needed.
1718  Message->lResult = 0;
1719  Message->QS_Flags = 0;
1720  Message->ptiReceiver = ptiSendTo;
1721  Message->ptiSender = NULL; // mjmartin, you are right! This is null.
1722  Message->ptiCallBackSender = Win32Thread;
1724  Message->CompletionCallbackContext = CompletionCallbackContext;
1725  Message->HookMessage = MSQ_NORMAL;
1726  Message->HasPackedLParam = (lParamBufferSize > 0);
1727  Message->QS_Flags = QS_SENDMESSAGE;
1728  Message->flags = SMF_RECEIVERFREE;
1729 
1730  if (Msg & 0x80000000) // Higher priority event message!
1731  InsertHeadList(&ptiSendTo->SentMessagesListHead, &Message->ListEntry);
1732  else
1733  InsertTailList(&ptiSendTo->SentMessagesListHead, &Message->ListEntry);
1734  MsqWakeQueue(ptiSendTo, QS_SENDMESSAGE, TRUE);
1735 
1736  RETURN(TRUE);
1737 
1738 CLEANUP:
1739  if (Window) UserDerefObjectCo(Window);
1740  END_CLEANUP;
1741 }
1742 
1743 #if 0
1744 /*
1745  This HACK function posts a message if the destination's message queue belongs to
1746  another thread, otherwise it sends the message. It does not support broadcast
1747  messages!
1748 */
1751  UINT Msg,
1752  WPARAM wParam,
1753  LPARAM lParam )
1754 {
1755  ULONG_PTR Result;
1756  PTHREADINFO pti;
1757  PWND Window;
1758 
1759  if ( hWnd == HWND_BROADCAST )
1760  {
1761  return 0;
1762  }
1763 
1764  if(!(Window = UserGetWindowObject(hWnd)))
1765  {
1766  TRACE("PostOrSendMessage: Invalid handle 0x%p!\n",hWnd);
1767  return 0;
1768  }
1769 
1771 
1772  if ( IntSendTo(Window, pti, Msg) &&
1773  FindMsgMemory(Msg) == 0 )
1774  {
1775  Result = UserPostMessage(hWnd, Msg, wParam, lParam);
1776  }
1777  else
1778  {
1779  if ( !co_IntSendMessageTimeoutSingle(hWnd, Msg, wParam, lParam, SMTO_NORMAL, 0, &Result) )
1780  {
1781  Result = 0;
1782  }
1783  }
1784 
1785  return (LRESULT)Result;
1786 }
1787 #endif
1788 
1789 static LRESULT FASTCALL
1791  UINT Msg,
1792  WPARAM wParam,
1793  LPARAM lParam,
1794  PDOSENDMESSAGE dsm)
1795 {
1796  LRESULT Result = TRUE;
1797  NTSTATUS Status;
1798  PWND Window = NULL;
1799  MSG UserModeMsg, KernelModeMsg;
1800  PMSGMEMORY MsgMemoryEntry;
1801  PTHREADINFO ptiSendTo;
1802 
1803  if (hWnd != HWND_BROADCAST && hWnd != HWND_TOPMOST)
1804  {
1805  Window = UserGetWindowObject(hWnd);
1806  if ( !Window )
1807  {
1808  return 0;
1809  }
1810  }
1811 
1812  /* Check for an exiting window. */
1813  if (Window && Window->state & WNDS_DESTROYED)
1814  {
1815  ERR("co_IntDoSendMessage Window Exiting!\n");
1816  }
1817 
1818  /* See if the current thread can handle this message */
1819  ptiSendTo = IntSendTo(Window, gptiCurrent, Msg);
1820 
1821  // If broadcasting or sending to another thread, save the users data.
1822  if (!Window || ptiSendTo )
1823  {
1824  UserModeMsg.hwnd = hWnd;
1825  UserModeMsg.message = Msg;
1826  UserModeMsg.wParam = wParam;
1827  UserModeMsg.lParam = lParam;
1828  MsgMemoryEntry = FindMsgMemory(UserModeMsg.message);
1829  Status = CopyMsgToKernelMem(&KernelModeMsg, &UserModeMsg, MsgMemoryEntry);
1830  if (!NT_SUCCESS(Status))
1831  {
1833  return (dsm ? 0 : -1);
1834  }
1835  }
1836  else
1837  {
1838  KernelModeMsg.hwnd = hWnd;
1839  KernelModeMsg.message = Msg;
1840  KernelModeMsg.wParam = wParam;
1841  KernelModeMsg.lParam = lParam;
1842  }
1843 
1844  if (!dsm)
1845  {
1846  Result = co_IntSendMessage( KernelModeMsg.hwnd,
1847  KernelModeMsg.message,
1848  KernelModeMsg.wParam,
1849  KernelModeMsg.lParam );
1850  }
1851  else
1852  {
1853  Result = co_IntSendMessageTimeout( KernelModeMsg.hwnd,
1854  KernelModeMsg.message,
1855  KernelModeMsg.wParam,
1856  KernelModeMsg.lParam,
1857  dsm->uFlags,
1858  dsm->uTimeout,
1859  &dsm->Result );
1860  }
1861 
1862  if (!Window || ptiSendTo )
1863  {
1864  Status = CopyMsgToUserMem(&UserModeMsg, &KernelModeMsg);
1865  if (!NT_SUCCESS(Status))
1866  {
1868  return(dsm ? 0 : -1);
1869  }
1870  }
1871 
1872  return (LRESULT)Result;
1873 }
1874 
1875 BOOL FASTCALL
1877  UINT Msg,
1878  WPARAM wParam,
1879  LPARAM lParam )
1880 {
1881  BOOL Ret = TRUE;
1882 
1883  if (is_pointer_message(Msg))
1884  {
1886  return FALSE;
1887  }
1888 
1889  // Basicly the same as IntPostOrSendMessage
1890  if (hWnd == HWND_BROADCAST) // Handle Broadcast
1891  {
1892  HWND *List;
1894  ULONG i;
1895 
1896  DesktopWindow = UserGetDesktopWindow();
1897  List = IntWinListChildren(DesktopWindow);
1898 
1899  if (List != NULL)
1900  {
1901  UserSendNotifyMessage(DesktopWindow->head.h, Msg, wParam, lParam);
1902  for (i = 0; List[i]; i++)
1903  {
1904  PWND pwnd = UserGetWindowObject(List[i]);
1905  if (!pwnd) continue;
1906 
1907  if ( pwnd->fnid == FNID_MENU ||
1909  continue;
1910 
1911  Ret = UserSendNotifyMessage(List[i], Msg, wParam, lParam);
1912  }
1914  }
1915  }
1916  else
1917  {
1918  Ret = co_IntSendMessageNoWait( hWnd, Msg, wParam, lParam);
1919  }
1920  return Ret;
1921 }
1922 
1923 
1926 {
1927  PTHREADINFO pti;
1928  DWORD Result;
1929 
1931 // wine:
1933 
1934  /* High word, types of messages currently in the queue.
1935  Low word, types of messages that have been added to the queue and that
1936  are still in the queue
1937  */
1938  Result = MAKELONG(pti->pcti->fsChangeBits & Changes, pti->pcti->fsWakeBits & Changes);
1939 
1940  pti->pcti->fsChangeBits &= ~Changes;
1941 
1942  return Result;
1943 }
1944 
1945 BOOL APIENTRY
1947 {
1949 
1950  if (pti->pcti)
1951  {
1952  pti->pcti->dwcPumpHook++;
1953  return TRUE;
1954  }
1955  return FALSE;
1956 }
1957 
1958 BOOL APIENTRY
1960 {
1962 
1963  if (pti->pcti)
1964  {
1965  if (pti->pcti->dwcPumpHook <= 0)
1966  {
1967  return FALSE;
1968  }
1969  pti->pcti->dwcPumpHook--;
1970  return TRUE;
1971  }
1972  return FALSE;
1973 }
1974 
1975 BOOL FASTCALL
1977 {
1978  BOOL Ret = FALSE;
1979 
1980  if ( co_HOOK_CallHooks( WH_SYSMSGFILTER, code, 0, (LPARAM)lpmsg))
1981  {
1982  Ret = TRUE;
1983  }
1984  else
1985  {
1986  Ret = co_HOOK_CallHooks( WH_MSGFILTER, code, 0, (LPARAM)lpmsg);
1987  }
1988  return Ret;
1989 }
1990 
1993 BOOL
1994 APIENTRY
1996  HWND hWnd,
1997  POINT pt) // Just like the User call.
1998 {
1999  MSG msg;
2000  RECT rect;
2001  ULONG wDragWidth, wDragHeight;
2003 
2004  TRACE("Enter NtUserDragDetect(%p)\n", hWnd);
2006 
2007  wDragWidth = UserGetSystemMetrics(SM_CXDRAG);
2008  wDragHeight= UserGetSystemMetrics(SM_CYDRAG);
2009 
2010  rect.left = pt.x - wDragWidth;
2011  rect.right = pt.x + wDragWidth;
2012 
2013  rect.top = pt.y - wDragHeight;
2014  rect.bottom = pt.y + wDragHeight;
2015 
2016  co_UserSetCapture(hWnd);
2017 
2018  for (;;)
2019  {
2023  {
2024  if ( msg.message == WM_LBUTTONUP )
2025  {
2027  RETURN( FALSE);
2028  }
2029  if ( msg.message == WM_MOUSEMOVE )
2030  {
2031  POINT tmp;
2032  tmp.x = (short)LOWORD(msg.lParam);
2033  tmp.y = (short)HIWORD(msg.lParam);
2034  if( !RECTL_bPointInRect( &rect, tmp.x, tmp.y ) )
2035  {
2037  RETURN( TRUE);
2038  }
2039  }
2040  if ( msg.message == WM_KEYDOWN )
2041  {
2042  if ( msg.wParam == VK_ESCAPE )
2043  {
2045  RETURN( TRUE);
2046  }
2047  }
2048  if ( msg.message == WM_QUEUESYNC )
2049  {
2050  co_HOOK_CallHooks( WH_CBT, HCBT_QS, 0, 0 );
2051  }
2052  }
2053  co_IntWaitMessage(NULL, 0, 0);
2054  }
2055  RETURN( FALSE);
2056 
2057 CLEANUP:
2058  TRACE("Leave NtUserDragDetect, ret=%i\n",_ret_);
2059  UserLeave();
2060  END_CLEANUP;
2061 }
2062 
2063 BOOL APIENTRY
2065  UINT Msg,
2066  WPARAM wParam,
2067  LPARAM lParam)
2068 {
2069  BOOL ret;
2070 
2072 
2073  ret = UserPostMessage(hWnd, Msg, wParam, lParam);
2074 
2075  UserLeave();
2076 
2077  return ret;
2078 }
2079 
2080 BOOL APIENTRY
2082  UINT Msg,
2083  WPARAM wParam,
2084  LPARAM lParam)
2085 {
2086  BOOL ret = FALSE;
2087  PETHREAD peThread;
2088  PTHREADINFO pThread;
2089  NTSTATUS Status;
2090 
2092 
2093  Status = PsLookupThreadByThreadId(UlongToHandle(idThread), &peThread);
2094 
2095  if ( Status == STATUS_SUCCESS )
2096  {
2097  pThread = (PTHREADINFO)peThread->Tcb.Win32Thread;
2098  if( !pThread ||
2099  !pThread->MessageQueue ||
2100  (pThread->TIF_flags & TIF_INCLEANUP))
2101  {
2102  ObDereferenceObject( peThread );
2103  goto exit;
2104  }
2105  ret = UserPostThreadMessage( pThread, Msg, wParam, lParam);
2106  ObDereferenceObject( peThread );
2107  }
2108  else
2109  {
2110  SetLastNtError( Status );
2111  }
2112 exit:
2113  UserLeave();
2114  return ret;
2115 }
2116 
2117 BOOL APIENTRY
2119 {
2120  BOOL ret;
2121 
2123  TRACE("NtUserWaitMessage Enter\n");
2124  ret = co_IntWaitMessage(NULL, 0, 0);
2125  TRACE("NtUserWaitMessage Leave\n");
2126  UserLeave();
2127 
2128  return ret;
2129 }
2130 
2131 BOOL APIENTRY
2133  HWND hWnd,
2134  UINT MsgFilterMin,
2135  UINT MsgFilterMax )
2136 {
2137  MSG Msg;
2138  BOOL Ret;
2139 
2140  if ( (MsgFilterMin|MsgFilterMax) & ~WM_MAXIMUM )
2141  {
2143  return FALSE;
2144  }
2145 
2147 
2148  RtlZeroMemory(&Msg, sizeof(MSG));
2149 
2150  Ret = co_IntGetPeekMessage(&Msg, hWnd, MsgFilterMin, MsgFilterMax, PM_REMOVE, TRUE);
2151 
2152  UserLeave();
2153 
2154  if (Ret)
2155  {
2156  _SEH2_TRY
2157  {
2158  ProbeForWrite(pMsg, sizeof(MSG), 1);
2159  RtlCopyMemory(pMsg, &Msg, sizeof(MSG));
2160  }
2162  {
2164  Ret = FALSE;
2165  }
2166  _SEH2_END;
2167  }
2168 
2169  if ((INT)Ret != -1)
2170  Ret = Ret ? (WM_QUIT != pMsg->message) : FALSE;
2171 
2172  return Ret;
2173 }
2174 
2175 BOOL APIENTRY
2177  HWND hWnd,
2178  UINT MsgFilterMin,
2179  UINT MsgFilterMax,
2180  UINT RemoveMsg)
2181 {
2182  MSG Msg;
2183  BOOL Ret;
2184 
2185  if ( RemoveMsg & PM_BADMSGFLAGS )
2186  {
2188  return FALSE;
2189  }
2190 
2192 
2193  RtlZeroMemory(&Msg, sizeof(MSG));
2194 
2195  Ret = co_IntGetPeekMessage(&Msg, hWnd, MsgFilterMin, MsgFilterMax, RemoveMsg, FALSE);
2196 
2197  UserLeave();
2198 
2199  if (Ret)
2200  {
2201  _SEH2_TRY
2202  {
2203  ProbeForWrite(pMsg, sizeof(MSG), 1);
2204  RtlCopyMemory(pMsg, &Msg, sizeof(MSG));
2205  }
2207  {
2209  Ret = FALSE;
2210  }
2211  _SEH2_END;
2212  }
2213 
2214  return Ret;
2215 }
2216 
2217 BOOL APIENTRY
2219 {
2220  BOOL Ret = FALSE;
2221  MSG Msg;
2222 
2223  _SEH2_TRY
2224  {
2225  ProbeForRead(lpmsg, sizeof(MSG), 1);
2226  RtlCopyMemory( &Msg, lpmsg, sizeof(MSG));
2227  }
2229  {
2230  _SEH2_YIELD(return FALSE);
2231  }
2232  _SEH2_END;
2233 
2235 
2236  if ( co_HOOK_CallHooks( WH_SYSMSGFILTER, code, 0, (LPARAM)&Msg))
2237  {
2238  Ret = TRUE;
2239  }
2240  else
2241  {
2242  Ret = co_HOOK_CallHooks( WH_MSGFILTER, code, 0, (LPARAM)&Msg);
2243  }
2244 
2245  UserLeave();
2246 
2247  _SEH2_TRY
2248  {
2249  ProbeForWrite(lpmsg, sizeof(MSG), 1);
2250  RtlCopyMemory(lpmsg, &Msg, sizeof(MSG));
2251  }
2253  {
2254  Ret = FALSE;
2255  }
2256  _SEH2_END;
2257 
2258  return Ret;
2259 }
2260 
2263 {
2264  LRESULT Res = 0;
2265  MSG SafeMsg;
2266 
2267  _SEH2_TRY
2268  {
2269  ProbeForRead(UnsafeMsgInfo, sizeof(MSG), 1);
2270  RtlCopyMemory(&SafeMsg, UnsafeMsgInfo, sizeof(MSG));
2271  }
2273  {
2275  _SEH2_YIELD(return FALSE);
2276  }
2277  _SEH2_END;
2278 
2280 
2281  Res = IntDispatchMessage(&SafeMsg);
2282 
2283  UserLeave();
2284  return Res;
2285 }
2286 
2287 BOOL APIENTRY
2289 {
2290  MSG SafeMsg;
2291  BOOL Ret;
2292  PWND pWnd;
2293 
2294  _SEH2_TRY
2295  {
2296  ProbeForRead(lpMsg, sizeof(MSG), 1);
2297  RtlCopyMemory(&SafeMsg, lpMsg, sizeof(MSG));
2298  }
2300  {
2302  _SEH2_YIELD(return FALSE);
2303  }
2304  _SEH2_END;
2305 
2307  pWnd = UserGetWindowObject(SafeMsg.hwnd);
2308  if (pWnd) // Must have a window!
2309  {
2310  Ret = IntTranslateKbdMessage(&SafeMsg, flags);
2311  }
2312  else
2313  {
2314  TRACE("No Window for Translate. hwnd 0x%p Msg %u\n", SafeMsg.hwnd, SafeMsg.message);
2315  Ret = FALSE;
2316  }
2317  UserLeave();
2318 
2319  return Ret;
2320 }
2321 
2322 LRESULT APIENTRY ScrollBarWndProc(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam);
2323 
2324 BOOL APIENTRY
2326  UINT Msg,
2327  WPARAM wParam,
2328  LPARAM lParam,
2329  ULONG_PTR ResultInfo,
2330  DWORD dwType, // fnID?
2331  BOOL Ansi)
2332 {
2333  LRESULT lResult = 0;
2334  BOOL Ret = FALSE;
2335  PWND Window = NULL;
2337 
2339 
2340  switch(dwType)
2341  {
2342  case FNID_SCROLLBAR:
2343  {
2344  lResult = ScrollBarWndProc(hWnd, Msg, wParam, lParam);
2345  break;
2346  }
2347  case FNID_DESKTOP:
2348  {
2349  Window = UserGetWindowObject(hWnd);
2350  if (Window)
2351  {
2352  //ERR("FNID_DESKTOP IN\n");
2353  Ret = DesktopWindowProc(Window, Msg, wParam, lParam, &lResult);
2354  //ERR("FNID_DESKTOP OUT\n");
2355  }
2356  break;
2357  }
2358  case FNID_MENU:
2359  {
2360  Window = UserGetWindowObject(hWnd);
2361  if (Window)
2362  {
2363  Ret = PopupMenuWndProc( Window, Msg, wParam, lParam, &lResult);
2364  }
2365  break;
2366  }
2367  case FNID_MESSAGEWND:
2368  {
2369  Window = UserGetWindowObject(hWnd);
2370  if (Window)
2371  {
2372  Ret = !UserMessageWindowProc(Window, Msg, wParam, lParam, &lResult);
2373  }
2374  break;
2375  }
2376  case FNID_DEFWINDOWPROC:
2377  /* Validate input */
2378  if (hWnd)
2379  {
2380  Window = UserGetWindowObject(hWnd);
2381  if (!Window)
2382  {
2383  UserLeave();
2384  return FALSE;
2385  }
2386  UserRefObjectCo(Window, &Ref);
2387  }
2388  lResult = IntDefWindowProc(Window, Msg, wParam, lParam, Ansi);
2389  Ret = TRUE;
2390  if (hWnd)
2391  UserDerefObjectCo(Window);
2392  break;
2394  Ret = UserSendNotifyMessage(hWnd, Msg, wParam, lParam);
2395  break;
2397  {
2398  BROADCASTPARM parm, *retparam;
2399  DWORD_PTR RetVal = 0;
2400 
2401  if (ResultInfo)
2402  {
2403  _SEH2_TRY
2404  {
2405  ProbeForWrite((PVOID)ResultInfo, sizeof(BROADCASTPARM), 1);
2406  RtlCopyMemory(&parm, (PVOID)ResultInfo, sizeof(BROADCASTPARM));
2407  }
2409  {
2410  _SEH2_YIELD(break);
2411  }
2412  _SEH2_END;
2413  }
2414  else
2415  break;
2416 
2417  if ( parm.recipients & BSM_ALLDESKTOPS ||
2418  parm.recipients == BSM_ALLCOMPONENTS )
2419  {
2420  PLIST_ENTRY DesktopEntry;
2421  PDESKTOP rpdesk;
2422  HWND *List, hwndDenied = NULL;
2423  HDESK hDesk = NULL;
2424  PWND pwnd, pwndDesk;
2425  ULONG i;
2426  UINT fuFlags;
2427 
2428  for (DesktopEntry = InputWindowStation->DesktopListHead.Flink;
2429  DesktopEntry != &InputWindowStation->DesktopListHead;
2430  DesktopEntry = DesktopEntry->Flink)
2431  {
2432  rpdesk = CONTAINING_RECORD(DesktopEntry, DESKTOP, ListEntry);
2433  pwndDesk = rpdesk->pDeskInfo->spwnd;
2434  List = IntWinListChildren(pwndDesk);
2435 
2436  if (parm.flags & BSF_QUERY)
2437  {
2438  if (List != NULL)
2439  {
2440  if (parm.flags & BSF_FORCEIFHUNG || parm.flags & BSF_NOHANG)
2441  {
2442  fuFlags = SMTO_ABORTIFHUNG;
2443  }
2444  else if (parm.flags & BSF_NOTIMEOUTIFNOTHUNG)
2445  {
2446  fuFlags = SMTO_NOTIMEOUTIFNOTHUNG;
2447  }
2448  else
2449  {
2450  fuFlags = SMTO_NORMAL;
2451  }
2453  Msg,
2454  wParam,
2455  lParam,
2456  fuFlags,
2457  2000,
2458  &RetVal);
2459  Ret = TRUE;
2460  for (i = 0; List[i]; i++)
2461  {
2462  pwnd = UserGetWindowObject(List[i]);
2463  if (!pwnd) continue;
2464 
2465  if ( pwnd->fnid == FNID_MENU ||
2467  continue;
2468 
2469  if ( parm.flags & BSF_IGNORECURRENTTASK )
2470  {
2471  if ( pwnd->head.pti == gptiCurrent )
2472  continue;
2473  }
2474  co_IntSendMessageTimeout( List[i],
2475  Msg,
2476  wParam,
2477  lParam,
2478  fuFlags,
2479  2000,
2480  &RetVal);
2481 
2482  if (!RetVal && EngGetLastError() == ERROR_TIMEOUT)
2483  {
2484  if (!(parm.flags & BSF_FORCEIFHUNG))
2485  Ret = FALSE;
2486  }
2487  if (RetVal == BROADCAST_QUERY_DENY)
2488  {
2489  hwndDenied = List[i];
2490  hDesk = UserHMGetHandle(pwndDesk);
2491  Ret = FALSE;
2492  }
2493  }
2495  _SEH2_TRY
2496  {
2497  retparam = (PBROADCASTPARM) ResultInfo;
2498  retparam->hDesk = hDesk;
2499  retparam->hWnd = hwndDenied;
2500  }
2502  {
2503  _SEH2_YIELD(break);
2504  }
2505  _SEH2_END;
2506  if (!Ret) break; // Have a hit! Let everyone know!
2507  }
2508  }
2509  else if (parm.flags & BSF_POSTMESSAGE)
2510  {
2511  if (List != NULL)
2512  {
2513  UserPostMessage(UserHMGetHandle(pwndDesk), Msg, wParam, lParam);
2514 
2515  for (i = 0; List[i]; i++)
2516  {
2517  pwnd = UserGetWindowObject(List[i]);
2518  if (!pwnd) continue;
2519 
2520  if ( pwnd->fnid == FNID_MENU ||
2522  continue;
2523 
2524  if ( parm.flags & BSF_IGNORECURRENTTASK )
2525  {
2526  if ( pwnd->head.pti == gptiCurrent )
2527  continue;
2528  }
2529  UserPostMessage(List[i], Msg, wParam, lParam);
2530  }
2532  }
2533  Ret = TRUE;
2534  }
2535  else
2536  {
2537  if (List != NULL)
2538  {
2539  UserSendNotifyMessage(UserHMGetHandle(pwndDesk), Msg, wParam, lParam);
2540 
2541  for (i = 0; List[i]; i++)
2542  {
2543  pwnd = UserGetWindowObject(List[i]);
2544  if (!pwnd) continue;
2545 
2546  if ( pwnd->fnid == FNID_MENU ||
2548  continue;
2549 
2550  if ( parm.flags & BSF_IGNORECURRENTTASK )
2551  {
2552  if ( pwnd->head.pti == gptiCurrent )
2553  continue;
2554  }
2555  UserSendNotifyMessage(List[i], Msg, wParam, lParam);
2556  }
2558  }
2559  Ret = TRUE;
2560  }
2561  }
2562  }
2563  else if (parm.recipients & BSM_APPLICATIONS)
2564  {
2565  HWND *List, hwndDenied = NULL;
2566  HDESK hDesk = NULL;
2567  PWND pwnd, pwndDesk;
2568  ULONG i;
2569  UINT fuFlags;
2570 
2571  pwndDesk = UserGetDesktopWindow();
2572  List = IntWinListChildren(pwndDesk);
2573 
2574  if (parm.flags & BSF_QUERY)
2575  {
2576  if (List != NULL)
2577  {
2578  if (parm.flags & BSF_FORCEIFHUNG || parm.flags & BSF_NOHANG)
2579  {
2580  fuFlags = SMTO_ABORTIFHUNG;
2581  }
2582  else if (parm.flags & BSF_NOTIMEOUTIFNOTHUNG)
2583  {
2584  fuFlags = SMTO_NOTIMEOUTIFNOTHUNG;
2585  }
2586  else
2587  {
2588  fuFlags = SMTO_NORMAL;
2589  }
2591  Msg,
2592  wParam,
2593  lParam,
2594  fuFlags,
2595  2000,
2596  &RetVal);
2597  Ret = TRUE;
2598  for (i = 0; List[i]; i++)
2599  {
2600  pwnd = UserGetWindowObject(List[i]);
2601  if (!pwnd) continue;
2602 
2603  if ( pwnd->fnid == FNID_MENU ||
2605  continue;
2606 
2607  if ( parm.flags & BSF_IGNORECURRENTTASK )
2608  {
2609  if ( pwnd->head.pti == gptiCurrent )
2610  continue;
2611  }
2612  co_IntSendMessageTimeout( List[i],
2613  Msg,
2614  wParam,
2615  lParam,
2616  fuFlags,
2617  2000,
2618  &RetVal);
2619 
2620  if (!RetVal && EngGetLastError() == ERROR_TIMEOUT)
2621  {
2622  if (!(parm.flags & BSF_FORCEIFHUNG))
2623  Ret = FALSE;
2624  }
2625  if (RetVal == BROADCAST_QUERY_DENY)
2626  {
2627  hwndDenied = List[i];
2628  hDesk = UserHMGetHandle(pwndDesk);
2629  Ret = FALSE;
2630  }
2631  }
2633  _SEH2_TRY
2634  {
2635  retparam = (PBROADCASTPARM) ResultInfo;
2636  retparam->hDesk = hDesk;
2637  retparam->hWnd = hwndDenied;
2638  }
2640  {
2641  _SEH2_YIELD(break);
2642  }
2643  _SEH2_END;
2644  }
2645  }
2646  else if (parm.flags & BSF_POSTMESSAGE)
2647  {
2648  if (List != NULL)
2649  {
2650  UserPostMessage(UserHMGetHandle(pwndDesk), Msg, wParam, lParam);
2651 
2652  for (i = 0; List[i]; i++)
2653  {
2654  pwnd = UserGetWindowObject(List[i]);
2655  if (!pwnd) continue;
2656 
2657  if ( pwnd->fnid == FNID_MENU ||
2659  continue;
2660 
2661  if ( parm.flags & BSF_IGNORECURRENTTASK )
2662  {
2663  if ( pwnd->head.pti == gptiCurrent )
2664  continue;
2665  }
2666  UserPostMessage(List[i], Msg, wParam, lParam);
2667  }
2669  }
2670  Ret = TRUE;
2671  }
2672  else
2673  {
2674  if (List != NULL)
2675  {
2676  UserSendNotifyMessage(UserHMGetHandle(pwndDesk), Msg, wParam, lParam);
2677 
2678  for (i = 0; List[i]; i++)
2679  {
2680  pwnd = UserGetWindowObject(List[i]);
2681  if (!pwnd) continue;
2682 
2683  if ( pwnd->fnid == FNID_MENU ||
2685  continue;
2686 
2687  if ( parm.flags & BSF_IGNORECURRENTTASK )
2688  {
2689  if ( pwnd->head.pti == gptiCurrent )
2690  continue;
2691  }
2692  UserSendNotifyMessage(List[i], Msg, wParam, lParam);
2693  }
2695  }
2696  Ret = TRUE;
2697  }
2698  }
2699  }
2700  break;
2702  {
2703  CALL_BACK_INFO CallBackInfo;
2704  ULONG_PTR uResult;
2705 
2706  _SEH2_TRY
2707  {
2708  ProbeForRead((PVOID)ResultInfo, sizeof(CALL_BACK_INFO), 1);
2709  RtlCopyMemory(&CallBackInfo, (PVOID)ResultInfo, sizeof(CALL_BACK_INFO));
2710  }
2712  {
2713  _SEH2_YIELD(break);
2714  }
2715  _SEH2_END;
2716 
2717  if (is_pointer_message(Msg))
2718  {
2720  break;
2721  }
2722 
2723  if (!(Ret = co_IntSendMessageWithCallBack(hWnd, Msg, wParam, lParam,
2724  CallBackInfo.CallBack, CallBackInfo.Context, &uResult)))
2725  {
2726  ERR("Callback failure!\n");
2727  }
2728  }
2729  break;
2730  case FNID_SENDMESSAGE:
2731  {
2732  lResult = co_IntDoSendMessage(hWnd, Msg, wParam, lParam, 0);
2733  Ret = TRUE;
2734 
2735  if (ResultInfo)
2736  {
2737  _SEH2_TRY
2738  {
2739  ProbeForWrite((PVOID)ResultInfo, sizeof(ULONG_PTR), 1);
2740  RtlCopyMemory((PVOID)ResultInfo, &lResult, sizeof(ULONG_PTR));
2741  }
2743  {
2744  Ret = FALSE;
2745  _SEH2_YIELD(break);
2746  }
2747  _SEH2_END;
2748  }
2749  break;
2750  }
2751  case FNID_SENDMESSAGEFF:
2753  {
2754  DOSENDMESSAGE dsm, *pdsm = (PDOSENDMESSAGE)ResultInfo;
2755  if (ResultInfo)
2756  {
2757  _SEH2_TRY
2758  {
2759  ProbeForRead(pdsm, sizeof(DOSENDMESSAGE), 1);
2760  RtlCopyMemory(&dsm, pdsm, sizeof(DOSENDMESSAGE));
2761  }
2763  {
2764  _SEH2_YIELD(break);
2765  }
2766  _SEH2_END;
2767  }
2768 
2769  Ret = co_IntDoSendMessage( hWnd, Msg, wParam, lParam, pdsm ? &dsm : NULL );
2770 
2771  if (pdsm)
2772  {
2773  _SEH2_TRY
2774  {
2775  ProbeForWrite(pdsm, sizeof(DOSENDMESSAGE), 1);
2776  RtlCopyMemory(pdsm, &dsm, sizeof(DOSENDMESSAGE));
2777  }
2779  {
2780  Ret = FALSE;
2781  _SEH2_YIELD(break);
2782  }
2783  _SEH2_END;
2784  }
2785  break;
2786  }
2787  // CallNextHook bypass.
2788  case FNID_CALLWNDPROC:
2789  case FNID_CALLWNDPROCRET:
2790  {
2791  PTHREADINFO pti;
2793  PHOOK NextObj, Hook;
2794 
2795  pti = GetW32ThreadInfo();
2796 
2797  Hook = pti->sphkCurrent;
2798 
2799  if (!Hook) break;
2800 
2801  NextObj = Hook->phkNext;
2802  ClientInfo = pti->pClientInfo;
2803  _SEH2_TRY
2804  {
2805  ClientInfo->phkCurrent = NextObj;
2806  }
2808  {
2809  ClientInfo = NULL;
2810  }
2811  _SEH2_END;
2812 
2813  if (!ClientInfo || !NextObj) break;
2814 
2815  NextObj->phkNext = IntGetNextHook(NextObj);
2816 
2817  if ( Hook->HookId == WH_CALLWNDPROC)
2818  {
2819  CWPSTRUCT CWP;
2820  CWP.hwnd = hWnd;
2821  CWP.message = Msg;
2822  CWP.wParam = wParam;
2823  CWP.lParam = lParam;
2824  TRACE("WH_CALLWNDPROC: Hook %p NextHook %p\n", Hook, NextObj);
2825 
2826  lResult = co_IntCallHookProc( Hook->HookId,
2827  HC_ACTION,
2828  ((ClientInfo->CI_flags & CI_CURTHPRHOOK) ? 1 : 0),
2829  (LPARAM)&CWP,
2830  Hook->Proc,
2831  Hook->ihmod,
2832  Hook->offPfn,
2833  Hook->Ansi,
2834  &Hook->ModuleName);
2835  }
2836  else
2837  {
2838  CWPRETSTRUCT CWPR;
2839  CWPR.hwnd = hWnd;
2840  CWPR.message = Msg;
2841  CWPR.wParam = wParam;
2842  CWPR.lParam = lParam;
2843  CWPR.lResult = ClientInfo->dwHookData;
2844 
2845  lResult = co_IntCallHookProc( Hook->HookId,
2846  HC_ACTION,
2847  ((ClientInfo->CI_flags & CI_CURTHPRHOOK) ? 1 : 0),
2848  (LPARAM)&CWPR,
2849  Hook->Proc,
2850  Hook->ihmod,
2851  Hook->offPfn,
2852  Hook->Ansi,
2853  &Hook->ModuleName);
2854  }
2855  }
2856  break;
2857  }
2858 
2859  switch(dwType)
2860  {
2861  case FNID_DEFWINDOWPROC:
2862  case FNID_CALLWNDPROC:
2863  case FNID_CALLWNDPROCRET:
2864  case FNID_SCROLLBAR:
2865  case FNID_DESKTOP:
2866  case FNID_MENU:
2867  if (ResultInfo)
2868  {
2869  _SEH2_TRY
2870  {
2871  ProbeForWrite((PVOID)ResultInfo, sizeof(LRESULT), 1);
2872  RtlCopyMemory((PVOID)ResultInfo, &lResult, sizeof(LRESULT));
2873  }
2875  {
2876  Ret = FALSE;
2877  }
2878  _SEH2_END;
2879  }
2880  break;
2881  default:
2882  break;
2883  }
2884 
2885  UserLeave();
2886 
2887  return Ret;
2888 }
2889 
2890 #define INFINITE 0xFFFFFFFF
2891 #define WAIT_FAILED ((DWORD)0xFFFFFFFF)
2892 
2893 DWORD
2894 APIENTRY
2896  IN DWORD dwMilliseconds,
2897  IN BOOL Unknown2)
2898 {
2900  PPROCESSINFO W32Process;
2901  PTHREADINFO pti;
2902  NTSTATUS Status;
2903  HANDLE Handles[3];
2906 
2908 
2909  Status = ObReferenceObjectByHandle(hProcess,
2911  *PsProcessType,
2912  UserMode,
2913  (PVOID*)&Process,
2914  NULL);
2915 
2916  if (!NT_SUCCESS(Status))
2917  {
2918  UserLeave();
2919  SetLastNtError(Status);
2920  return WAIT_FAILED;
2921  }
2922 
2924 
2925  W32Process = (PPROCESSINFO)Process->Win32Process;
2926 
2927  if ( PsGetProcessExitProcessCalled(Process) ||
2928  !W32Process ||
2929  pti->ppi == W32Process)
2930  {
2931  ObDereferenceObject(Process);
2932  UserLeave();
2934  return WAIT_FAILED;
2935  }
2936 
2937  Handles[0] = Process;
2938  Handles[1] = W32Process->InputIdleEvent;
2939  Handles[2] = pti->pEventQueueServer; // IntMsqSetWakeMask returns hEventQueueClient
2940 
2941  if (!Handles[1])
2942  {
2943  ObDereferenceObject(Process);
2944  UserLeave();
2945  return STATUS_SUCCESS; /* no event to wait on */
2946  }
2947 
2948  if (dwMilliseconds != INFINITE)
2949  Timeout.QuadPart = (LONGLONG) dwMilliseconds * (LONGLONG) -10000;
2950 
2951  KeStackAttachProcess(&Process->Pcb, &ApcState);
2952 
2953  W32Process->W32PF_flags |= W32PF_WAITFORINPUTIDLE;
2954  for (pti = W32Process->ptiList; pti; pti = pti->ptiSibling)
2955  {
2957  pti->pClientInfo->dwTIFlags = pti->TIF_flags;
2958  }
2959 
2960  KeUnstackDetachProcess(&ApcState);
2961 
2962  TRACE("WFII: ppi %p\n", W32Process);
2963  TRACE("WFII: waiting for %p\n", Handles[1] );
2964 
2965  /*
2966  * We must add a refcount to our current PROCESSINFO,
2967  * because anything could happen (including process death) we're leaving win32k
2968  */
2969  IntReferenceProcessInfo(W32Process);
2970 
2971  do
2972  {
2973  UserLeave();
2974  Status = KeWaitForMultipleObjects( 3,
2975  Handles,
2976  WaitAny,
2977  UserRequest,
2978  UserMode,
2979  FALSE,
2980  dwMilliseconds == INFINITE ? NULL : &Timeout,
2981  NULL);
2983 
2984  if (!NT_SUCCESS(Status))
2985  {
2986  SetLastNtError(Status);
2987  Status = WAIT_FAILED;
2988  goto WaitExit;
2989  }
2990 
2991  switch (Status)
2992  {
2993  case STATUS_WAIT_0:
2994  goto WaitExit;
2995 
2996  case STATUS_WAIT_2:
2997  {
2998  MSG Msg;
2999  co_IntGetPeekMessage( &Msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE, FALSE);
3000  ERR("WFII: WAIT 2\n");
3001  }
3002  break;
3003 
3004  case STATUS_TIMEOUT:
3005  ERR("WFII: timeout\n");
3006  case WAIT_FAILED:
3007  goto WaitExit;
3008 
3009  default:
3010  ERR("WFII: finished\n");
3011  Status = STATUS_SUCCESS;
3012  goto WaitExit;
3013  }
3014  }
3015  while (TRUE);
3016 
3017 WaitExit:
3018  for (pti = W32Process->ptiList; pti; pti = pti->ptiSibling)
3019  {
3021  pti->pClientInfo->dwTIFlags = pti->TIF_flags;
3022  }
3023  W32Process->W32PF_flags &= ~W32PF_WAITFORINPUTIDLE;
3024  IntDereferenceProcessInfo(W32Process);
3025  ObDereferenceObject(Process);
3026  UserLeave();
3027  return Status;
3028 }
3029 
3030 /* EOF */
DWORD *typedef PVOID
Definition: winlogon.h:61
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
static LRESULT FASTCALL co_IntSendMessageTimeoutSingle(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult)
Definition: message.c:1306
static LRESULT handle_internal_events(PTHREADINFO pti, PWND pWnd, DWORD dwQEvent, LONG_PTR ExtraInfo, PMSG pMsg)
Definition: message.c:654
#define IN
Definition: typedefs.h:38
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1189
DBG_DEFAULT_CHANNEL(UserMsg)
VOID FASTCALL MsqWakeQueue(PTHREADINFO pti, DWORD MessageBits, BOOL KeyEvent)
Definition: msgqueue.c:412
PTHREADINFO ptiSender
Definition: msgqueue.h:28
#define BSF_FORCEIFHUNG
Definition: dbt.h:54
WPARAM wParam
Definition: winuser.h:2972
#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)
struct @1570 Msg[]
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:4426
#define WH_GETMESSAGE
Definition: winuser.h:33
#define LB_DIR
Definition: winuser.h:1994
PDESKTOPINFO pDeskInfo
Definition: desktop.h:8
#define CLEANUP
Definition: ntuser.h:5
#define WM_MOUSEFIRST
Definition: winuser.h:1750
struct tagMDINEXTMENU MDINEXTMENU
#define LB_FINDSTRINGEXACT
Definition: winuser.h:1996
#define LB_ADDFILE
Definition: winuser.h:1991
PKEVENT pkCompletionEvent
Definition: msgqueue.h:25
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
LRESULT lResult
Definition: msgqueue.h:26
#define ERROR_INTERNAL_ERROR
Definition: winerror.h:840
static LRESULT handle_internal_message(PWND pWnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: message.c:613
#define BSF_IGNORECURRENTTASK
Definition: dbt.h:55
LRESULT FASTCALL IntDispatchMessage(PMSG pMsg)
Definition: message.c:682
#define LB_ADDSTRING
Definition: winuser.h:1992
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:158
#define WM_SYSTIMER
Definition: comctl32.h:113
#define BROADCAST_QUERY_DENY
Definition: winuser.h:178
#define UserIsDesktopWindow(pWnd)
Definition: desktop.h:219
long x
Definition: polytest.cpp:48
PVOID Buffer
Definition: ntuser.h:97
BOOL APIENTRY NtUserTranslateMessage(LPMSG lpMsg, UINT flags)
Definition: message.c:2288
WORD ATOM
Definition: dimm.idl:113
PHOOK FASTCALL IntGetNextHook(PHOOK Hook)
Definition: hook.c:996
POINT last
Definition: font.c:46
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
#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
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CB_GETLBTEXT
Definition: winuser.h:1913
static BOOL is_message_broadcastable(UINT msg)
Definition: message.c:556
POINT pt
Definition: winuser.h:3072
PTHREADINFO ptiSibling
Definition: win32.h:115
#define ERROR_TIMEOUT
Definition: winerror.h:941
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
WNDPROC lpfnWndProc
Definition: ntuser.h:682
#define WM_NCCALCSIZE
Definition: winuser.h:1667
VOID FASTCALL IdlePing(VOID)
Definition: message.c:515
#define WM_ASKCBFORMATNAME
Definition: winuser.h:1834
BOOL FASTCALL IntTranslateKbdMessage(LPMSG lpMsg, UINT flags)
Definition: keyboard.c:1125
BOOLEAN FASTCALL co_MsqDispatchOneSentMessage(_In_ PTHREADINFO pti)
Definition: msgqueue.c:877
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
BOOL FASTCALL MsqIsHung(PTHREADINFO pti)
Definition: msgqueue.c:2198
#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:1651
#define LB_SETTABSTOPS
Definition: winuser.h:2030
struct tagHOOK * phkNext
Definition: ntuser.h:218
BOOL FASTCALL UserSendNotifyMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1876
UINT FASTCALL GetWakeMask(UINT first, UINT last)
Definition: message.c:562
BOOL APIENTRY NtUserWaitMessage(VOID)
Definition: message.c:2118
#define WM_QUEUESYNC
Definition: winuser.h:1621
KTHREAD Tcb
Definition: pstypes.h:1034
ULONG_PTR CI_flags
Definition: ntuser.h:287
#define BSF_NOTIMEOUTIFNOTHUNG
Definition: dbt.h:57
#define BSF_QUERY
Definition: dbt.h:59
HWND hWnd
Definition: settings.c:17
PVOID *typedef PWSTR
Definition: winlogon.h:66
#define WM_QUIT
Definition: winuser.h:1605
struct _PROCESSINFO * PPROCESSINFO
Definition: ntwin32.h:5
LONG top
Definition: windef.h:297
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:25
HANDLE HWND
Definition: compat.h:13
#define FNID_DEFWINDOWPROC
Definition: ntuser.h:825
#define QS_TIMER
Definition: winuser.h:893
HWND hwndInsertAfter
Definition: winuser.h:3531
#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:3069
BOOL APIENTRY NtUserPostThreadMessage(DWORD idThread, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:2081
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:2971
NTSTATUS FASTCALL co_MsqWaitForNewMessages(PTHREADINFO pti, PWND WndFilter, UINT MsgFilterMin, UINT MsgFilterMax)
Definition: msgqueue.c:2168
#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:1976
#define MMS_SIZE_WPARAM
Definition: message.c:106
#define WS_CHILD
Definition: pedump.c:617
_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 TIF_WAITFORINPUTIDLE
Definition: ntuser.h:254
BOOL FASTCALL DesktopWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: desktop.c:1384
LONG left
Definition: windef.h:296
LRESULT APIENTRY co_IntCallWindowProc(WNDPROC Proc, BOOLEAN IsAnsiProc, HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, INT lParamBufferSize)
Definition: callback.c:289
#define InsertTailList(ListHead, Entry)
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:2168
#define WCHAR
Definition: msvc.h:43
#define BSF_NOHANG
Definition: dbt.h:56
SENDASYNCPROC CompletionCallback
Definition: msgqueue.h:30
LONG right
Definition: windef.h:298
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define BSF_POSTMESSAGE
Definition: dbt.h:58
static __inline LONG MsqCalculateMessageTime(IN PLARGE_INTEGER TickCount)
Definition: msgqueue.h:253
#define FASTCALL
Definition: nt_native.h:50
#define WM_NCCREATE
Definition: winuser.h:1665
#define INFINITE
Definition: message.c:2890
RTL_ATOM atomClassName
Definition: ntuser.h:536
GLuint const GLubyte mask[]
Definition: s_context.h:57
PSERVERINFO gpsi
Definition: main.c:27
int32_t INT
Definition: typedefs.h:56
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
& rect
Definition: startmenu.cpp:1413
#define WM_QUERYDROPOBJECT
Definition: undocuser.h:54
DWORD DWORD
Definition: winlogon.h:84
#define LB_SELECTSTRING
Definition: winuser.h:2017
#define SMTO_ABORTIFHUNG
Definition: winuser.h:1209
#define WM_SETTINGCHANGE
Definition: winuser.h:1611
NTSTATUS FASTCALL IntInitMessageImpl(VOID)
Definition: message.c:20
#define SMTO_NORMAL
Definition: winuser.h:1211
LIST_ENTRY ListEntry
Definition: msgqueue.h:22
_SEH2_TRY
Definition: create.c:4250
#define FNID_MESSAGEWND
Definition: ntuser.h:826
UINT_PTR WPARAM
Definition: windef.h:207
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:783
#define PM_NOREMOVE
Definition: winuser.h:1181
struct tagRECT RECT
BOOL APIENTRY IntUninitMessagePumpHook(VOID)
Definition: message.c:1959
PPROCESSINFO ppi
Definition: win32.h:87
#define EM_GETSEL
Definition: winuser.h:1958
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define WH_FOREGROUNDIDLE
Definition: winuser.h:41
#define CB_GETEDITSEL
Definition: winuser.h:1908
BOOL FASTCALL co_IntWaitMessage(PWND Window, UINT MsgFilterMin, UINT MsgFilterMax)
Definition: message.c:974
#define WNDS_PAINTNOTPROCESSED
Definition: ntuser.h:595
CLIENT_DATA ClientInfo
typedef HDESK
Definition: winlogon.h:83
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
#define WM_NEXTMENU
Definition: winuser.h:1782
#define STATUS_WAIT_2
Definition: ntstatus.h:72
PTHREADINFO gptiForeground
Definition: focus.c:14
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:91
Definition: window.c:29
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#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:1690
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 FALSE
Definition: types.h:117
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:701
DWORD fnid
Definition: ntuser.h:673
BOOL FASTCALL UserPostThreadMessage(PTHREADINFO pti, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1149
long LONG
Definition: pedump.c:60
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2619
#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
LONG_PTR LPARAM
Definition: windef.h:208
PTHREADINFO FASTCALL IntSendTo(PWND Window, PTHREADINFO ptiCur, UINT Msg)
Definition: message.c:1175
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
Definition: timer.h:3
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define WM_SIZING
Definition: winuser.h:1783
THRDESKHEAD head
Definition: ntuser.h:659
#define CB_ADDSTRING
Definition: winuser.h:1897
#define WM_DRAGSELECT
Definition: undocuser.h:57
NTSYSAPI NTSTATUS NTAPI ZwYieldExecution(VOID)
#define APIENTRY
Definition: nt_native.h:48
#define LB_GETSELITEMS
Definition: winuser.h:2009
Definition: object.h:3
#define MAKELONG(a, b)
Definition: typedefs.h:248
#define CB_INSERTSTRING
Definition: winuser.h:1918
DWORD APIENTRY IntGetQueueStatus(DWORD Changes)
Definition: message.c:1925
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:809
static LRESULT FASTCALL co_IntDoSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, PDOSENDMESSAGE dsm)
Definition: message.c:1790
PTHREADINFO ptiReceiver
Definition: msgqueue.h:29
smooth NULL
Definition: ftsmooth.c:416
#define IntReferenceProcessInfo(ppi)
Definition: win32.h:177
#define W32PF_WAITFORINPUTIDLE
Definition: win32.h:22
INT exitCode
Definition: win32.h:106
#define WM_WININICHANGE
Definition: winuser.h:1612
#define QS_SENDMESSAGE
Definition: winuser.h:892
#define WM_KEYDOWN
Definition: winuser.h:1691
LPARAM lParam
Definition: winuser.h:3070
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:3541
UINT flags
Definition: winuser.h:3536
#define WH_CALLWNDPROCRET
Definition: winuser.h:42
#define WM_DROPOBJECT
Definition: undocuser.h:53
ULONG_PTR CompletionCallbackContext
Definition: msgqueue.h:32
VOID FASTCALL IntActivateWindow(PWND Wnd, PTHREADINFO pti, HANDLE tid, DWORD Type)
Definition: focus.c:268
BOOL APIENTRY NtUserGetMessage(PMSG pMsg, HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax)
Definition: message.c:2132
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:90
#define WM_SETTEXT
Definition: winuser.h:1599
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
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
UINTN Size
Definition: acefiex.h:555
#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:2369
#define QS_INPUT
Definition: winuser.h:881
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:243
#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:513
int HookId
Definition: ntuser.h:219
int64_t LONGLONG
Definition: typedefs.h:66
struct tagDRAWITEMSTRUCT DRAWITEMSTRUCT
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
BOOL APIENTRY NtUserMessageCall(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ResultInfo, DWORD dwType, BOOL Ansi)
Definition: message.c:2325
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
#define HWND_BOTTOM
Definition: winuser.h:1191
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2859
#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:47
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizeiptr size
Definition: glext.h:5919
struct _THREADINFO * PTHREADINFO
Definition: ntwin32.h:6
VOID FASTCALL ClearMsgBitsMask(PTHREADINFO pti, UINT MessageBits)
Definition: msgqueue.c:445
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN Ansi
Definition: ntuser.h:228
#define CB_GETDROPPEDCONTROLRECT
Definition: winuser.h:1905
static VOID FASTCALL IntCallWndProc(PWND Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:581
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:717
Implementation of the Explorer desktop window.
Definition: desktop.h:51
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
INT POOL_TYPE
Definition: typedefs.h:76
ULONG Length
Definition: ntuser.h:94
UINT WPARAM wParam
Definition: precomp.h:45
#define UlongToHandle(ul)
Definition: basetsd.h:97
#define WM_TIMER
Definition: winuser.h:1718
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1643
PKEVENT pEventQueueServer
Definition: win32.h:124
#define WM_MOUSELAST
Definition: winuser.h:1777
LRESULT FASTCALL co_IntSendMessageTimeout(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult)
Definition: message.c:1493
BOOL APIENTRY NtUserDragDetect(HWND hWnd, POINT pt)
Definition: message.c:1995
#define QS_EVENT
Definition: undocuser.h:95
BOOL APIENTRY IntDdeGetMessageHook(PMSG pMsg, LONG_PTR ExtraInfo)
Definition: dde.c:326
BOOL APIENTRY NtUserCallMsgFilter(LPMSG lpmsg, INT code)
Definition: message.c:2218
#define DECLARE_RETURN(type)
Definition: ntuser.h:3
#define WM_KEYLAST
Definition: winuser.h:1704
#define WM_MEASUREITEM
Definition: winuser.h:1628
PHOOK phkCurrent
Definition: ntuser.h:295
LPARAM lParam
Definition: winuser.h:2978
VOID FASTCALL MsqPostMessage(PTHREADINFO pti, MSG *Msg, BOOLEAN HardwareMessage, DWORD MessageBits, DWORD dwQEvent, LONG_PTR ExtraInfo)
Definition: msgqueue.c:1342
#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:2979
#define UserIsMessageWindow(pWnd)
Definition: desktop.h:222
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:2111
NTSTATUS NTAPI KeWaitForMultipleObjects(IN ULONG Count, IN PVOID Object[], IN WAIT_TYPE WaitType, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL, OUT PKWAIT_BLOCK WaitBlockArray OPTIONAL)
Definition: wait.c:586
#define 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:1470
#define WM_PAINT
Definition: winuser.h:1602
#define HCBT_QS
Definition: winuser.h:57
CHAR Message[80]
Definition: alive.c:5
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define WM_MDIGETACTIVE
Definition: winuser.h:1797
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1089
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1332
#define FNID_SENDNOTIFYMESSAGE
Definition: ntuser.h:851
#define WM_DDE_LAST
Definition: dde.h:46
PVOID * Win32Process
Definition: pstypes.h:1233
int ret
#define EM_SETRECTNP
Definition: winuser.h:1978
LONG timeLast
Definition: win32.h:101
UINT message
Definition: winuser.h:2980
PUSER_SENT_MESSAGE FASTCALL AllocateUserMessage(BOOL KEvent)
Definition: msgqueue.c:767
#define WM_MOVING
Definition: winuser.h:1785
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:2010
static const WCHAR L[]
Definition: oid.c:1087
#define WNDS2_WMPAINTSENT
Definition: ntuser.h:609
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1291
#define WH_CALLWNDPROC
Definition: winuser.h:34
IN REFCLSID IN PUNKNOWN IN POOL_TYPE PoolType
Definition: unknown.h:68
#define CI_CURTHPRHOOK
Definition: ntuser.h:281
static MSGMEMORY g_MsgMemory[]
Definition: message.c:121
#define SBM_GETRANGE
Definition: winuser.h:2040
LPCWSTR lpszName
Definition: winuser.h:2917
#define CB_SELECTSTRING
Definition: winuser.h:1921
BOOL APIENTRY IntInitMessagePumpHook(VOID)
Definition: message.c:1946
ULONG_PTR Result
Definition: ntuser.h:2616
#define WM_DRAGLOOP
Definition: undocuser.h:56
HWND *FASTCALL IntWinListChildren(PWND Window)
Definition: window.c:255
BOOL HasPackedLParam
Definition: msgqueue.h:34
#define PAGE_SIZE
Definition: env_spec_w32.h:49
PTHREADINFO ptiCallBackSender
Definition: msgqueue.h:31
struct _WND * spwnd
Definition: ntuser.h:136
#define EM_SETTABSTOPS
Definition: winuser.h:1980
Definition: typedefs.h:117
#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
KPROCESS Pcb
Definition: pstypes.h:1193
UINT Size
Definition: message.c:116
uint32_t DWORD_PTR
Definition: typedefs.h:63
UINT UINT uTimeout
Definition: msvc.h:63
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
UINT WPARAM LPARAM lparam
Definition: msvc.h:92
LRESULT APIENTRY NtUserDispatchMessage(PMSG UnsafeMsgInfo)
Definition: message.c:2262
#define WM_COPYGLOBALDATA
Definition: undocuser.h:36
struct tagDOSENDMESSAGE * PDOSENDMESSAGE
#define FNID_CALLWNDPROC
Definition: ntuser.h:838
ULONG_PTR dwHookData
Definition: ntuser.h:301
#define TIF_MSGPOSCHANGED
Definition: ntuser.h:260
POINT ptLast
Definition: win32.h:127
Status
Definition: gdiplustypes.h:24
LRESULT APIENTRY ScrollBarWndProc(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: scrollbar.c:1129
#define STATUS_USER_APC
Definition: ntstatus.h:78
#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:251
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define FNID_BROADCASTSYSTEMMESSAGE
Definition: ntuser.h:849
#define WM_COMPAREITEM
Definition: winuser.h:1637
DWORD *typedef HANDLE
Definition: winlogon.h:61
#define MSQ_NORMAL
Definition: msgqueue.h:4
#define LB_FINDSTRING
Definition: winuser.h:1995
_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:1020
VOID FASTCALL IdlePong(VOID)
Definition: message.c:545
NTSTATUS FASTCALL IntCleanupMessageImpl(VOID)
Definition: message.c:26
#define EM_SETRECT
Definition: winuser.h:1977
#define CB_DIR
Definition: winuser.h:1899
#define WM_DRAGMOVE
Definition: undocuser.h:58
#define WM_DDE_FIRST
Definition: dde.h:47
#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:1753
#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:1471
struct tagMEASUREITEMSTRUCT MEASUREITEMSTRUCT
LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1549
DWORD state
Definition: ntuser.h:665
#define QS_POSTMESSAGE
Definition: winuser.h:888
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
FORCEINLINE BOOL RECTL_bPointInRect(_In_ const RECTL *prcl, _In_ INT x, _In_ INT y)
Definition: rect.h:52
UINT WPARAM LPARAM lParam
Definition: precomp.h:45
struct tagSTYLESTRUCT STYLESTRUCT
unsigned int UINT
Definition: ndis.h:50
#define WM_MOUSEMOVE
Definition: winuser.h:1751
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
DWORD time
Definition: winuser.h:3071
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:3067
#define WM_DEVICECHANGE
Definition: winuser.h:1787
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:1788
DWORD UINT uFlags
Definition: wglext.h:734
#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:2000
#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:597
struct _LARGE_INTEGER::@2192 u
struct tagCOPYDATASTRUCT COPYDATASTRUCT
#define BSM_ALLDESKTOPS
Definition: dbt.h:49
#define WM_CREATE
Definition: winuser.h:1590
ULONG_PTR Context
Definition: callback.h:48
#define EM_GETRECT
Definition: winuser.h:1957
PVOID Win32Thread
Definition: ketypes.h:1756
#define EM_GETLINE
Definition: winuser.h:1952
LPCWSTR lpszClass
Definition: winuser.h:2918
UINT msg
Definition: msvc.h:92
#define HIWORD(l)
Definition: typedefs.h:246
BOOL FASTCALL IntDeactivateWindow(PTHREADINFO pti, HANDLE tid)
Definition: focus.c:106
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:565
DWORD state2
Definition: ntuser.h:666
LONG bottom
Definition: windef.h:299
#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:718
#define IS_ATOM(x)
Definition: class.h:3
struct tagMSGMEMORY MSGMEMORY
#define LB_GETITEMRECT
Definition: winuser.h:2004
#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:1061
PTHREADINFO ptiList
Definition: win32.h:247
#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
DWORD APIENTRY NtUserWaitForInputIdle(IN HANDLE hProcess, IN DWORD dwMilliseconds, IN BOOL Unknown2)
Definition: message.c:2895
#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:3068
#define UINT
Definition: msvc.h:27
return STATUS_SUCCESS
Definition: btrfs.c:2710
void(CALLBACK * SENDASYNCPROC)(HWND, UINT, ULONG_PTR, LRESULT)
Definition: winuser.h:2869
#define QF_MOUSEMOVED
Definition: msgqueue.h:99
#define HWND_BROADCAST
Definition: winuser.h:1190
#define IntDereferenceProcessInfo(ppi)
Definition: win32.h:182
LRESULT lResult
Definition: winuser.h:2970
#define WNDS_SERVERSIDEWINDOWPROC
Definition: ntuser.h:591
#define MMS_FLAG_WRITE
Definition: message.c:111
#define CB_FINDSTRING
Definition: winuser.h:1900
#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:2176
#define MMS_FLAG_READWRITE
Definition: message.c:112
#define LB_INSERTSTRING
Definition: winuser.h:2014
#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
UINT Unicode
Definition: ntuser.h:720
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:2891
#define RETURN(rrr)
Definition: decompress.c:40
#define EM_REPLACESEL
Definition: winuser.h:1967
#define END_CLEANUP
Definition: ntuser.h:6
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1013
#define TAG_MSG
Definition: tags.h:7
UINT WPARAM LPARAM LRESULT & lResult
Definition: precomp.h:45
LONGLONG QuadPart
Definition: typedefs.h:112
#define LPARAM
Definition: msvc.h:38
LRESULT FASTCALL co_IntSendMessageWithCallBack(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, SENDASYNCPROC CompletionCallback, ULONG_PTR CompletionCallbackContext, ULONG_PTR *uResult)
Definition: message.c:1571
ULONG_PTR offPfn
Definition: ntuser.h:220
BOOL APIENTRY NtUserPostMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:2064
#define PM_BADMSGFLAGS
Definition: message.c:15
UINT WPARAM wparam
Definition: msvc.h:92
#define LPCWSTR
Definition: msvc.h:45
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:1901