2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
24 * FILE: subsys/win32k/ntuser/message.c
25 * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
27 * 06-06-2001 CSH Created
30 /* INCLUDES ******************************************************************/
42 } DOSENDMESSAGE
, *PDOSENDMESSAGE
;
44 /* FUNCTIONS *****************************************************************/
47 IntInitMessageImpl(VOID
)
49 return STATUS_SUCCESS
;
53 IntCleanupMessageImpl(VOID
)
55 return STATUS_SUCCESS
;
58 #define MMS_SIZE_WPARAM -1
59 #define MMS_SIZE_WPARAMWCHAR -2
60 #define MMS_SIZE_LPARAMSZ -3
61 #define MMS_SIZE_SPECIAL -4
62 #define MMS_FLAG_READ 0x01
63 #define MMS_FLAG_WRITE 0x02
64 #define MMS_FLAG_READWRITE (MMS_FLAG_READ | MMS_FLAG_WRITE)
65 typedef struct tagMSGMEMORY
70 } MSGMEMORY
, *PMSGMEMORY
;
72 static MSGMEMORY MsgMemory
[] =
74 { WM_CREATE
, MMS_SIZE_SPECIAL
, MMS_FLAG_READWRITE
},
75 { WM_DDE_ACK
, sizeof(KMDDELPARAM
), MMS_FLAG_READ
},
76 { WM_DDE_EXECUTE
, MMS_SIZE_WPARAM
, MMS_FLAG_READ
},
77 { WM_GETMINMAXINFO
, sizeof(MINMAXINFO
), MMS_FLAG_READWRITE
},
78 { WM_GETTEXT
, MMS_SIZE_WPARAMWCHAR
, MMS_FLAG_WRITE
},
79 { WM_NCCALCSIZE
, MMS_SIZE_SPECIAL
, MMS_FLAG_READWRITE
},
80 { WM_NCCREATE
, MMS_SIZE_SPECIAL
, MMS_FLAG_READWRITE
},
81 { WM_SETTEXT
, MMS_SIZE_LPARAMSZ
, MMS_FLAG_READ
},
82 { WM_STYLECHANGED
, sizeof(STYLESTRUCT
), MMS_FLAG_READ
},
83 { WM_STYLECHANGING
, sizeof(STYLESTRUCT
), MMS_FLAG_READWRITE
},
84 { WM_COPYDATA
, MMS_SIZE_SPECIAL
, MMS_FLAG_READ
},
85 { WM_WINDOWPOSCHANGED
, sizeof(WINDOWPOS
), MMS_FLAG_READ
},
86 { WM_WINDOWPOSCHANGING
, sizeof(WINDOWPOS
), MMS_FLAG_READWRITE
},
89 static PMSGMEMORY FASTCALL
90 FindMsgMemory(UINT Msg
)
92 PMSGMEMORY MsgMemoryEntry
;
94 /* See if this message type is present in the table */
95 for (MsgMemoryEntry
= MsgMemory
;
96 MsgMemoryEntry
< MsgMemory
+ sizeof(MsgMemory
) / sizeof(MSGMEMORY
);
99 if (Msg
== MsgMemoryEntry
->Message
)
101 return MsgMemoryEntry
;
109 MsgMemorySize(PMSGMEMORY MsgMemoryEntry
, WPARAM wParam
, LPARAM lParam
)
112 PUNICODE_STRING WindowName
;
113 PUNICODE_STRING ClassName
;
116 if (MMS_SIZE_WPARAM
== MsgMemoryEntry
->Size
)
118 return (UINT
) wParam
;
120 else if (MMS_SIZE_WPARAMWCHAR
== MsgMemoryEntry
->Size
)
122 return (UINT
) (wParam
* sizeof(WCHAR
));
124 else if (MMS_SIZE_LPARAMSZ
== MsgMemoryEntry
->Size
)
126 return (UINT
) ((wcslen((PWSTR
) lParam
) + 1) * sizeof(WCHAR
));
128 else if (MMS_SIZE_SPECIAL
== MsgMemoryEntry
->Size
)
130 switch(MsgMemoryEntry
->Message
)
134 Cs
= (CREATESTRUCTW
*) lParam
;
135 WindowName
= (PUNICODE_STRING
) Cs
->lpszName
;
136 ClassName
= (PUNICODE_STRING
) Cs
->lpszClass
;
137 Size
= sizeof(CREATESTRUCTW
) + WindowName
->Length
+ sizeof(WCHAR
);
138 if (IS_ATOM(ClassName
->Buffer
))
140 Size
+= sizeof(WCHAR
) + sizeof(ATOM
);
144 Size
+= sizeof(WCHAR
) + ClassName
->Length
+ sizeof(WCHAR
);
150 return wParam
? sizeof(NCCALCSIZE_PARAMS
) + sizeof(WINDOWPOS
) : sizeof(RECT
);
154 return sizeof(COPYDATASTRUCT
) + ((PCOPYDATASTRUCT
)lParam
)->cbData
;
164 return MsgMemoryEntry
->Size
;
168 static FASTCALL NTSTATUS
169 PackParam(LPARAM
*lParamPacked
, UINT Msg
, WPARAM wParam
, LPARAM lParam
)
171 NCCALCSIZE_PARAMS
*UnpackedNcCalcsize
;
172 NCCALCSIZE_PARAMS
*PackedNcCalcsize
;
173 CREATESTRUCTW
*UnpackedCs
;
174 CREATESTRUCTW
*PackedCs
;
175 PUNICODE_STRING WindowName
;
176 PUNICODE_STRING ClassName
;
180 *lParamPacked
= lParam
;
181 if (WM_NCCALCSIZE
== Msg
&& wParam
)
183 UnpackedNcCalcsize
= (NCCALCSIZE_PARAMS
*) lParam
;
184 if (UnpackedNcCalcsize
->lppos
!= (PWINDOWPOS
) (UnpackedNcCalcsize
+ 1))
186 PackedNcCalcsize
= ExAllocatePoolWithTag(PagedPool
,
187 sizeof(NCCALCSIZE_PARAMS
) + sizeof(WINDOWPOS
),
189 if (NULL
== PackedNcCalcsize
)
191 DPRINT1("Not enough memory to pack lParam\n");
192 return STATUS_NO_MEMORY
;
194 RtlCopyMemory(PackedNcCalcsize
, UnpackedNcCalcsize
, sizeof(NCCALCSIZE_PARAMS
));
195 PackedNcCalcsize
->lppos
= (PWINDOWPOS
) (PackedNcCalcsize
+ 1);
196 RtlCopyMemory(PackedNcCalcsize
->lppos
, UnpackedNcCalcsize
->lppos
, sizeof(WINDOWPOS
));
197 *lParamPacked
= (LPARAM
) PackedNcCalcsize
;
200 else if (WM_CREATE
== Msg
|| WM_NCCREATE
== Msg
)
202 UnpackedCs
= (CREATESTRUCTW
*) lParam
;
203 WindowName
= (PUNICODE_STRING
) UnpackedCs
->lpszName
;
204 ClassName
= (PUNICODE_STRING
) UnpackedCs
->lpszClass
;
205 Size
= sizeof(CREATESTRUCTW
) + WindowName
->Length
+ sizeof(WCHAR
);
206 if (IS_ATOM(ClassName
->Buffer
))
208 Size
+= sizeof(WCHAR
) + sizeof(ATOM
);
212 Size
+= sizeof(WCHAR
) + ClassName
->Length
+ sizeof(WCHAR
);
214 PackedCs
= ExAllocatePoolWithTag(PagedPool
, Size
, TAG_MSG
);
215 if (NULL
== PackedCs
)
217 DPRINT1("Not enough memory to pack lParam\n");
218 return STATUS_NO_MEMORY
;
220 RtlCopyMemory(PackedCs
, UnpackedCs
, sizeof(CREATESTRUCTW
));
221 CsData
= (PCHAR
) (PackedCs
+ 1);
222 PackedCs
->lpszName
= (LPCWSTR
) (CsData
- (PCHAR
) PackedCs
);
223 RtlCopyMemory(CsData
, WindowName
->Buffer
, WindowName
->Length
);
224 CsData
+= WindowName
->Length
;
225 *((WCHAR
*) CsData
) = L
'\0';
226 CsData
+= sizeof(WCHAR
);
227 PackedCs
->lpszClass
= (LPCWSTR
) (CsData
- (PCHAR
) PackedCs
);
228 if (IS_ATOM(ClassName
->Buffer
))
230 *((WCHAR
*) CsData
) = L
'A';
231 CsData
+= sizeof(WCHAR
);
232 *((ATOM
*) CsData
) = (ATOM
)(DWORD_PTR
) ClassName
->Buffer
;
233 CsData
+= sizeof(ATOM
);
237 *((WCHAR
*) CsData
) = L
'S';
238 CsData
+= sizeof(WCHAR
);
239 RtlCopyMemory(CsData
, ClassName
->Buffer
, ClassName
->Length
);
240 CsData
+= ClassName
->Length
;
241 *((WCHAR
*) CsData
) = L
'\0';
242 CsData
+= sizeof(WCHAR
);
244 ASSERT(CsData
== (PCHAR
) PackedCs
+ Size
);
245 *lParamPacked
= (LPARAM
) PackedCs
;
248 return STATUS_SUCCESS
;
251 static FASTCALL NTSTATUS
252 UnpackParam(LPARAM lParamPacked
, UINT Msg
, WPARAM wParam
, LPARAM lParam
)
254 NCCALCSIZE_PARAMS
*UnpackedParams
;
255 NCCALCSIZE_PARAMS
*PackedParams
;
256 PWINDOWPOS UnpackedWindowPos
;
258 if (lParamPacked
== lParam
)
260 return STATUS_SUCCESS
;
263 if (WM_NCCALCSIZE
== Msg
&& wParam
)
265 PackedParams
= (NCCALCSIZE_PARAMS
*) lParamPacked
;
266 UnpackedParams
= (NCCALCSIZE_PARAMS
*) lParam
;
267 UnpackedWindowPos
= UnpackedParams
->lppos
;
268 RtlCopyMemory(UnpackedParams
, PackedParams
, sizeof(NCCALCSIZE_PARAMS
));
269 UnpackedParams
->lppos
= UnpackedWindowPos
;
270 RtlCopyMemory(UnpackedWindowPos
, PackedParams
+ 1, sizeof(WINDOWPOS
));
271 ExFreePool((PVOID
) lParamPacked
);
273 return STATUS_SUCCESS
;
275 else if (WM_CREATE
== Msg
|| WM_NCCREATE
== Msg
)
277 ExFreePool((PVOID
) lParamPacked
);
279 return STATUS_SUCCESS
;
284 return STATUS_INVALID_PARAMETER
;
289 NtUserDispatchMessage(PNTUSERDISPATCHMESSAGEINFO UnsafeMsgInfo
)
292 NTUSERDISPATCHMESSAGEINFO MsgInfo
;
293 PWINDOW_OBJECT WindowObject
;
294 LRESULT Result
= TRUE
;
296 Status
= MmCopyFromCaller(&MsgInfo
, UnsafeMsgInfo
, sizeof(NTUSERDISPATCHMESSAGEINFO
));
297 if (! NT_SUCCESS(Status
))
299 SetLastNtError(Status
);
303 /* Process timer messages. */
304 if (WM_TIMER
== MsgInfo
.Msg
.message
&& 0 != MsgInfo
.Msg
.lParam
)
306 LARGE_INTEGER LargeTickCount
;
307 /* FIXME: Call hooks. */
309 /* FIXME: Check for continuing validity of timer. */
311 MsgInfo
.HandledByKernel
= FALSE
;
312 KeQueryTickCount(&LargeTickCount
);
313 MsgInfo
.Proc
= (WNDPROC
) MsgInfo
.Msg
.lParam
;
314 MsgInfo
.Msg
.lParam
= (LPARAM
)LargeTickCount
.u
.LowPart
;
316 else if (NULL
== MsgInfo
.Msg
.hwnd
)
318 MsgInfo
.HandledByKernel
= TRUE
;
323 /* Get the window object. */
324 WindowObject
= IntGetWindowObject(MsgInfo
.Msg
.hwnd
);
325 if (NULL
== WindowObject
)
327 SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE
);
328 MsgInfo
.HandledByKernel
= TRUE
;
333 if (WindowObject
->OwnerThread
!= PsGetCurrentThread())
335 IntReleaseWindowObject(WindowObject
);
336 DPRINT1("Window doesn't belong to the calling thread!\n");
337 MsgInfo
.HandledByKernel
= TRUE
;
342 /* FIXME: Call hook procedures. */
344 MsgInfo
.HandledByKernel
= FALSE
;
346 if (0xFFFF0000 != ((DWORD
) WindowObject
->WndProcW
& 0xFFFF0000))
348 if (0xFFFF0000 != ((DWORD
) WindowObject
->WndProcA
& 0xFFFF0000))
350 /* Both Unicode and Ansi winprocs are real, use whatever
352 MsgInfo
.Proc
= (MsgInfo
.Ansi
? WindowObject
->WndProcA
353 : WindowObject
->WndProcW
);
357 /* Real Unicode winproc */
358 MsgInfo
.Ansi
= FALSE
;
359 MsgInfo
.Proc
= WindowObject
->WndProcW
;
364 /* Must have real Ansi winproc */
366 MsgInfo
.Proc
= WindowObject
->WndProcA
;
369 IntReleaseWindowObject(WindowObject
);
372 Status
= MmCopyToCaller(UnsafeMsgInfo
, &MsgInfo
, sizeof(NTUSERDISPATCHMESSAGEINFO
));
373 if (! NT_SUCCESS(Status
))
375 SetLastNtError(Status
);
384 NtUserTranslateMessage(LPMSG lpMsg
,
390 Status
= MmCopyFromCaller(&SafeMsg
, lpMsg
, sizeof(MSG
));
391 if(!NT_SUCCESS(Status
))
393 SetLastNtError(Status
);
397 return IntTranslateKbdMessage(&SafeMsg
, dwhkl
);
402 IntSendHitTestMessages(PUSER_MESSAGE_QUEUE ThreadQueue
, LPMSG Msg
)
404 if(!Msg
->hwnd
|| ThreadQueue
->CaptureWindow
)
413 IntSendMessage(Msg
->hwnd
, WM_SETCURSOR
, (WPARAM
)Msg
->hwnd
, MAKELPARAM(HTCLIENT
, Msg
->message
));
418 IntSendMessage(Msg
->hwnd
, WM_SETCURSOR
, (WPARAM
)Msg
->hwnd
, MAKELPARAM(Msg
->wParam
, Msg
->message
));
425 case WM_LBUTTONDBLCLK
:
426 case WM_MBUTTONDBLCLK
:
427 case WM_RBUTTONDBLCLK
:
428 case WM_XBUTTONDBLCLK
:
431 PSYSTEM_CURSORINFO CurInfo
;
433 if(!IntGetWindowStationObject(InputWindowStation
))
437 CurInfo
= IntGetSysCursorInfo(InputWindowStation
);
438 wParam
= (WPARAM
)(CurInfo
->ButtonsDown
);
439 ObDereferenceObject(InputWindowStation
);
441 IntSendMessage(Msg
->hwnd
, WM_MOUSEMOVE
, wParam
, Msg
->lParam
);
442 IntSendMessage(Msg
->hwnd
, WM_SETCURSOR
, (WPARAM
)Msg
->hwnd
, MAKELPARAM(HTCLIENT
, Msg
->message
));
445 case WM_NCLBUTTONDOWN
:
446 case WM_NCMBUTTONDOWN
:
447 case WM_NCRBUTTONDOWN
:
448 case WM_NCXBUTTONDOWN
:
449 case WM_NCLBUTTONDBLCLK
:
450 case WM_NCMBUTTONDBLCLK
:
451 case WM_NCRBUTTONDBLCLK
:
452 case WM_NCXBUTTONDBLCLK
:
454 IntSendMessage(Msg
->hwnd
, WM_NCMOUSEMOVE
, (WPARAM
)Msg
->wParam
, Msg
->lParam
);
455 IntSendMessage(Msg
->hwnd
, WM_SETCURSOR
, (WPARAM
)Msg
->hwnd
, MAKELPARAM(Msg
->wParam
, Msg
->message
));
462 IntActivateWindowMouse(PUSER_MESSAGE_QUEUE ThreadQueue
, LPMSG Msg
, PWINDOW_OBJECT MsgWindow
,
467 if(*HitTest
== (USHORT
)HTTRANSPARENT
)
469 /* eat the message, search again! */
473 Result
= IntSendMessage(MsgWindow
->Self
, WM_MOUSEACTIVATE
, (WPARAM
)NtUserGetParent(MsgWindow
->Self
), (LPARAM
)MAKELONG(*HitTest
, Msg
->message
));
476 case MA_NOACTIVATEANDEAT
:
480 case MA_ACTIVATEANDEAT
:
481 IntMouseActivateWindow(MsgWindow
);
485 IntMouseActivateWindow(MsgWindow
);
493 IntTranslateMouseMessage(PUSER_MESSAGE_QUEUE ThreadQueue
, LPMSG Msg
, USHORT
*HitTest
, BOOL Remove
)
495 PWINDOW_OBJECT Window
;
497 if(!(Window
= IntGetWindowObject(Msg
->hwnd
)))
499 /* let's just eat the message?! */
503 if(ThreadQueue
== Window
->MessageQueue
&&
504 ThreadQueue
->CaptureWindow
!= Window
->Self
)
506 /* only send WM_NCHITTEST messages if we're not capturing the window! */
507 *HitTest
= IntSendMessage(Window
->Self
, WM_NCHITTEST
, 0,
508 MAKELONG(Msg
->pt
.x
, Msg
->pt
.y
));
510 if(*HitTest
== (USHORT
)HTTRANSPARENT
)
512 PWINDOW_OBJECT DesktopWindow
;
513 HWND hDesktop
= IntGetDesktopWindow();
515 if((DesktopWindow
= IntGetWindowObject(hDesktop
)))
519 WinPosWindowFromPoint(DesktopWindow
, Window
->MessageQueue
, &Msg
->pt
, &Wnd
);
524 /* post the message to the other window */
525 Msg
->hwnd
= Wnd
->Self
;
526 if(!(Wnd
->Status
& WINDOWSTATUS_DESTROYING
))
528 MsqPostMessage(Wnd
->MessageQueue
, Msg
, FALSE
,
529 Msg
->message
== WM_MOUSEMOVE
? QS_MOUSEMOVE
:
533 /* eat the message */
534 IntReleaseWindowObject(Wnd
);
535 IntReleaseWindowObject(Window
);
536 IntReleaseWindowObject(DesktopWindow
);
539 IntReleaseWindowObject(Wnd
);
542 IntReleaseWindowObject(DesktopWindow
);
551 if(IS_BTN_MESSAGE(Msg
->message
, DOWN
))
553 /* generate double click messages, if necessary */
554 if ((((*HitTest
) != HTCLIENT
) ||
555 (IntGetClassLong(Window
, GCL_STYLE
, FALSE
) & CS_DBLCLKS
)) &&
556 MsqIsDblClk(Msg
, Remove
))
558 Msg
->message
+= WM_LBUTTONDBLCLK
- WM_LBUTTONDOWN
;
562 if(Msg
->message
!= WM_MOUSEWHEEL
)
565 if ((*HitTest
) != HTCLIENT
)
567 Msg
->message
+= WM_NCMOUSEMOVE
- WM_MOUSEMOVE
;
568 if((Msg
->message
== WM_NCRBUTTONUP
) &&
569 (((*HitTest
) == HTCAPTION
) || ((*HitTest
) == HTSYSMENU
)))
571 Msg
->message
= WM_CONTEXTMENU
;
572 Msg
->wParam
= (WPARAM
)Window
->Self
;
576 Msg
->wParam
= *HitTest
;
578 Msg
->lParam
= MAKELONG(Msg
->pt
.x
, Msg
->pt
.y
);
580 else if(ThreadQueue
->MoveSize
== NULL
&&
581 ThreadQueue
->MenuOwner
== NULL
)
583 /* NOTE: Msg->pt should remain in screen coordinates. -- FiN */
584 Msg
->lParam
= MAKELONG(
585 Msg
->pt
.x
- (WORD
)Window
->ClientRect
.left
,
586 Msg
->pt
.y
- (WORD
)Window
->ClientRect
.top
);
590 IntReleaseWindowObject(Window
);
596 * Internal version of PeekMessage() doing all the work
599 IntPeekMessage(PUSER_MESSAGE Msg
,
605 LARGE_INTEGER LargeTickCount
;
606 PUSER_MESSAGE_QUEUE ThreadQueue
;
607 PUSER_MESSAGE Message
;
608 BOOL Present
, RemoveMessages
;
610 /* The queues and order in which they are checked are documented in the MSDN
611 article on GetMessage() */
613 ThreadQueue
= (PUSER_MESSAGE_QUEUE
)PsGetWin32Thread()->MessageQueue
;
615 /* Inspect RemoveMsg flags */
616 /* FIXME: The only flag we process is PM_REMOVE - processing of others must still be implemented */
617 RemoveMessages
= RemoveMsg
& PM_REMOVE
;
623 KeQueryTickCount(&LargeTickCount
);
624 ThreadQueue
->LastMsgRead
= LargeTickCount
.u
.LowPart
;
626 /* Dispatch sent messages here. */
627 while (MsqDispatchOneSentMessage(ThreadQueue
));
629 /* Now look for a quit message. */
631 if (ThreadQueue
->QuitPosted
)
633 /* According to the PSDK, WM_QUIT messages are always returned, regardless
634 of the filter specified */
635 Msg
->Msg
.hwnd
= NULL
;
636 Msg
->Msg
.message
= WM_QUIT
;
637 Msg
->Msg
.wParam
= ThreadQueue
->QuitExitCode
;
639 Msg
->FreeLParam
= FALSE
;
642 ThreadQueue
->QuitPosted
= FALSE
;
647 /* Now check for normal messages. */
648 Present
= MsqFindMessage(ThreadQueue
,
657 RtlCopyMemory(Msg
, Message
, sizeof(USER_MESSAGE
));
660 MsqDestroyMessage(Message
);
665 /* Check for hardware events. */
666 Present
= MsqFindMessage(ThreadQueue
,
675 RtlCopyMemory(Msg
, Message
, sizeof(USER_MESSAGE
));
678 MsqDestroyMessage(Message
);
683 /* Check for sent messages again. */
684 while (MsqDispatchOneSentMessage(ThreadQueue
));
686 /* Check for paint messages. */
687 if (IntGetPaintMessage(Wnd
, MsgFilterMin
, MsgFilterMax
, PsGetWin32Thread(), &Msg
->Msg
, RemoveMessages
))
689 Msg
->FreeLParam
= FALSE
;
693 /* Check for WM_(SYS)TIMER messages */
694 Present
= MsqGetTimerMessage(ThreadQueue
, Wnd
, MsgFilterMin
, MsgFilterMax
,
695 &Msg
->Msg
, RemoveMessages
);
698 Msg
->FreeLParam
= FALSE
;
708 PWINDOW_OBJECT MsgWindow
= NULL
;;
710 if(Msg
->Msg
.hwnd
&& (MsgWindow
= IntGetWindowObject(Msg
->Msg
.hwnd
)) &&
711 Msg
->Msg
.message
>= WM_MOUSEFIRST
&& Msg
->Msg
.message
<= WM_MOUSELAST
)
715 if(IntTranslateMouseMessage(ThreadQueue
, &Msg
->Msg
, &HitTest
, TRUE
))
716 /* FIXME - check message filter again, if the message doesn't match anymore,
719 IntReleaseWindowObject(MsgWindow
);
720 /* eat the message, search again */
723 if(ThreadQueue
->CaptureWindow
== NULL
)
725 IntSendHitTestMessages(ThreadQueue
, &Msg
->Msg
);
726 if((Msg
->Msg
.message
!= WM_MOUSEMOVE
&& Msg
->Msg
.message
!= WM_NCMOUSEMOVE
) &&
727 IS_BTN_MESSAGE(Msg
->Msg
.message
, DOWN
) &&
728 IntActivateWindowMouse(ThreadQueue
, &Msg
->Msg
, MsgWindow
, &HitTest
))
730 IntReleaseWindowObject(MsgWindow
);
731 /* eat the message, search again */
738 IntSendHitTestMessages(ThreadQueue
, &Msg
->Msg
);
743 IntReleaseWindowObject(MsgWindow
);
750 if((Msg
->Msg
.hwnd
&& Msg
->Msg
.message
>= WM_MOUSEFIRST
&& Msg
->Msg
.message
<= WM_MOUSELAST
) &&
751 IntTranslateMouseMessage(ThreadQueue
, &Msg
->Msg
, &HitTest
, FALSE
))
752 /* FIXME - check message filter again, if the message doesn't match anymore,
755 /* eat the message, search again */
766 NtUserPeekMessage(PNTUSERGETMESSAGEINFO UnsafeInfo
,
774 NTUSERGETMESSAGEINFO Info
;
775 PWINDOW_OBJECT Window
;
776 PMSGMEMORY MsgMemoryEntry
;
784 Window
= IntGetWindowObject(Wnd
);
791 IntReleaseWindowObject(Window
);
795 if (MsgFilterMax
< MsgFilterMin
)
801 Present
= IntPeekMessage(&Msg
, Wnd
, MsgFilterMin
, MsgFilterMax
, RemoveMsg
);
805 /* See if this message type is present in the table */
806 MsgMemoryEntry
= FindMsgMemory(Info
.Msg
.message
);
807 if (NULL
== MsgMemoryEntry
)
809 /* Not present, no copying needed */
814 /* Determine required size */
815 Size
= MsgMemorySize(MsgMemoryEntry
, Info
.Msg
.wParam
,
817 /* Allocate required amount of user-mode memory */
818 Info
.LParamSize
= Size
;
820 Status
= ZwAllocateVirtualMemory(NtCurrentProcess(), &UserMem
, 0,
821 &Info
.LParamSize
, MEM_COMMIT
, PAGE_READWRITE
);
822 if (! NT_SUCCESS(Status
))
824 SetLastNtError(Status
);
827 /* Transfer lParam data to user-mode mem */
828 Status
= MmCopyToCaller(UserMem
, (PVOID
) Info
.Msg
.lParam
, Size
);
829 if (! NT_SUCCESS(Status
))
831 ZwFreeVirtualMemory(NtCurrentProcess(), (PVOID
*) &UserMem
,
832 &Info
.LParamSize
, MEM_DECOMMIT
);
833 SetLastNtError(Status
);
836 Info
.Msg
.lParam
= (LPARAM
) UserMem
;
838 if (RemoveMsg
&& Msg
.FreeLParam
&& 0 != Msg
.Msg
.lParam
)
840 ExFreePool((void *) Msg
.Msg
.lParam
);
842 Status
= MmCopyToCaller(UnsafeInfo
, &Info
, sizeof(NTUSERGETMESSAGEINFO
));
843 if (! NT_SUCCESS(Status
))
845 SetLastNtError(Status
);
854 IntWaitMessage(HWND Wnd
,
858 PUSER_MESSAGE_QUEUE ThreadQueue
;
862 ThreadQueue
= (PUSER_MESSAGE_QUEUE
)PsGetWin32Thread()->MessageQueue
;
866 if (IntPeekMessage(&Msg
, Wnd
, MsgFilterMin
, MsgFilterMax
, PM_NOREMOVE
))
871 /* Nothing found. Wait for new messages. */
872 Status
= MsqWaitForNewMessages(ThreadQueue
, Wnd
, MsgFilterMin
, MsgFilterMax
);
874 while ((STATUS_WAIT_0
<= Status
&& Status
<= STATUS_WAIT_63
) || STATUS_TIMEOUT
== Status
);
876 SetLastNtError(Status
);
882 NtUserGetMessage(PNTUSERGETMESSAGEINFO UnsafeInfo
,
887 * FUNCTION: Get a message from the calling thread's message queue.
889 * UnsafeMsg - Pointer to the structure which receives the returned message.
890 * Wnd - Window whose messages are to be retrieved.
891 * MsgFilterMin - Integer value of the lowest message value to be
893 * MsgFilterMax - Integer value of the highest message value to be
898 NTUSERGETMESSAGEINFO Info
;
900 PWINDOW_OBJECT Window
;
901 PMSGMEMORY MsgMemoryEntry
;
909 Window
= IntGetWindowObject(Wnd
);
913 IntReleaseWindowObject(Window
);
915 if (MsgFilterMax
< MsgFilterMin
)
923 GotMessage
= IntPeekMessage(&Msg
, Wnd
, MsgFilterMin
, MsgFilterMax
, PM_REMOVE
);
927 /* See if this message type is present in the table */
928 MsgMemoryEntry
= FindMsgMemory(Info
.Msg
.message
);
929 if (NULL
== MsgMemoryEntry
)
931 /* Not present, no copying needed */
936 /* Determine required size */
937 Size
= MsgMemorySize(MsgMemoryEntry
, Info
.Msg
.wParam
,
939 /* Allocate required amount of user-mode memory */
940 Info
.LParamSize
= Size
;
942 Status
= ZwAllocateVirtualMemory(NtCurrentProcess(), &UserMem
, 0,
943 &Info
.LParamSize
, MEM_COMMIT
, PAGE_READWRITE
);
945 if (! NT_SUCCESS(Status
))
947 SetLastNtError(Status
);
950 /* Transfer lParam data to user-mode mem */
951 Status
= MmCopyToCaller(UserMem
, (PVOID
) Info
.Msg
.lParam
, Size
);
952 if (! NT_SUCCESS(Status
))
954 ZwFreeVirtualMemory(NtCurrentProcess(), (PVOID
*) &UserMem
,
955 &Info
.LParamSize
, MEM_DECOMMIT
);
956 SetLastNtError(Status
);
959 Info
.Msg
.lParam
= (LPARAM
) UserMem
;
961 if (Msg
.FreeLParam
&& 0 != Msg
.Msg
.lParam
)
963 ExFreePool((void *) Msg
.Msg
.lParam
);
965 Status
= MmCopyToCaller(UnsafeInfo
, &Info
, sizeof(NTUSERGETMESSAGEINFO
));
966 if (! NT_SUCCESS(Status
))
968 SetLastNtError(Status
);
972 else if (! IntWaitMessage(Wnd
, MsgFilterMin
, MsgFilterMax
))
977 while (! GotMessage
);
979 return WM_QUIT
!= Info
.Msg
.message
;
998 static NTSTATUS FASTCALL
999 CopyMsgToKernelMem(MSG
*KernelModeMsg
, MSG
*UserModeMsg
, PMSGMEMORY MsgMemoryEntry
)
1006 *KernelModeMsg
= *UserModeMsg
;
1008 /* See if this message type is present in the table */
1009 if (NULL
== MsgMemoryEntry
)
1011 /* Not present, no copying needed */
1012 return STATUS_SUCCESS
;
1015 /* Determine required size */
1016 Size
= MsgMemorySize(MsgMemoryEntry
, UserModeMsg
->wParam
, UserModeMsg
->lParam
);
1020 /* Allocate kernel mem */
1021 KernelMem
= ExAllocatePoolWithTag(PagedPool
, Size
, TAG_MSG
);
1022 if (NULL
== KernelMem
)
1024 DPRINT1("Not enough memory to copy message to kernel mem\n");
1025 return STATUS_NO_MEMORY
;
1027 KernelModeMsg
->lParam
= (LPARAM
) KernelMem
;
1029 /* Copy data if required */
1030 if (0 != (MsgMemoryEntry
->Flags
& MMS_FLAG_READ
))
1032 Status
= MmCopyFromCaller(KernelMem
, (PVOID
) UserModeMsg
->lParam
, Size
);
1033 if (! NT_SUCCESS(Status
))
1035 DPRINT1("Failed to copy message to kernel: invalid usermode buffer\n");
1036 ExFreePool(KernelMem
);
1042 /* Make sure we don't pass any secrets to usermode */
1043 RtlZeroMemory(KernelMem
, Size
);
1048 KernelModeMsg
->lParam
= 0;
1051 return STATUS_SUCCESS
;
1054 static NTSTATUS FASTCALL
1055 CopyMsgToUserMem(MSG
*UserModeMsg
, MSG
*KernelModeMsg
)
1058 PMSGMEMORY MsgMemoryEntry
;
1061 /* See if this message type is present in the table */
1062 MsgMemoryEntry
= FindMsgMemory(UserModeMsg
->message
);
1063 if (NULL
== MsgMemoryEntry
)
1065 /* Not present, no copying needed */
1066 return STATUS_SUCCESS
;
1069 /* Determine required size */
1070 Size
= MsgMemorySize(MsgMemoryEntry
, UserModeMsg
->wParam
, UserModeMsg
->lParam
);
1074 /* Copy data if required */
1075 if (0 != (MsgMemoryEntry
->Flags
& MMS_FLAG_WRITE
))
1077 Status
= MmCopyToCaller((PVOID
) UserModeMsg
->lParam
, (PVOID
) KernelModeMsg
->lParam
, Size
);
1078 if (! NT_SUCCESS(Status
))
1080 DPRINT1("Failed to copy message from kernel: invalid usermode buffer\n");
1081 ExFreePool((PVOID
) KernelModeMsg
->lParam
);
1086 ExFreePool((PVOID
) KernelModeMsg
->lParam
);
1089 return STATUS_SUCCESS
;
1093 NtUserPostMessage(HWND Wnd
,
1098 PWINDOW_OBJECT Window
;
1099 MSG UserModeMsg
, KernelModeMsg
;
1100 LARGE_INTEGER LargeTickCount
;
1102 PMSGMEMORY MsgMemoryEntry
;
1106 MsqPostQuitMessage(PsGetWin32Thread()->MessageQueue
, wParam
);
1108 else if (Wnd
== HWND_BROADCAST
)
1111 PWINDOW_OBJECT DesktopWindow
;
1114 DesktopWindow
= IntGetWindowObject(IntGetDesktopWindow());
1115 List
= IntWinListChildren(DesktopWindow
);
1116 IntReleaseWindowObject(DesktopWindow
);
1119 for (i
= 0; List
[i
]; i
++)
1120 NtUserPostMessage(List
[i
], Msg
, wParam
, lParam
);
1126 Window
= IntGetWindowObject(Wnd
);
1129 SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE
);
1132 if(Window
->Status
& WINDOWSTATUS_DESTROYING
)
1134 IntReleaseWindowObject(Window
);
1135 DPRINT1("Attempted to post message to window 0x%x that is being destroyed!\n", Wnd
);
1136 /* FIXME - last error code? */
1140 UserModeMsg
.hwnd
= Wnd
;
1141 UserModeMsg
.message
= Msg
;
1142 UserModeMsg
.wParam
= wParam
;
1143 UserModeMsg
.lParam
= lParam
;
1144 MsgMemoryEntry
= FindMsgMemory(UserModeMsg
.message
);
1145 Status
= CopyMsgToKernelMem(&KernelModeMsg
, &UserModeMsg
, MsgMemoryEntry
);
1146 if (! NT_SUCCESS(Status
))
1148 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1151 IntGetCursorLocation(PsGetWin32Thread()->Desktop
->WindowStation
,
1153 KeQueryTickCount(&LargeTickCount
);
1154 KernelModeMsg
.time
= LargeTickCount
.u
.LowPart
;
1155 MsqPostMessage(Window
->MessageQueue
, &KernelModeMsg
,
1156 NULL
!= MsgMemoryEntry
&& 0 != KernelModeMsg
.lParam
,
1158 IntReleaseWindowObject(Window
);
1165 NtUserPostThreadMessage(DWORD idThread
,
1170 MSG UserModeMsg
, KernelModeMsg
;
1174 PMSGMEMORY MsgMemoryEntry
;
1176 Status
= PsLookupThreadByThreadId((void *)idThread
,&peThread
);
1178 if( Status
== STATUS_SUCCESS
) {
1179 pThread
= peThread
->Tcb
.Win32Thread
;
1180 if( !pThread
|| !pThread
->MessageQueue
)
1182 ObDereferenceObject( peThread
);
1186 UserModeMsg
.hwnd
= NULL
;
1187 UserModeMsg
.message
= Msg
;
1188 UserModeMsg
.wParam
= wParam
;
1189 UserModeMsg
.lParam
= lParam
;
1190 MsgMemoryEntry
= FindMsgMemory(UserModeMsg
.message
);
1191 Status
= CopyMsgToKernelMem(&KernelModeMsg
, &UserModeMsg
, MsgMemoryEntry
);
1192 if (! NT_SUCCESS(Status
))
1194 ObDereferenceObject( peThread
);
1195 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1198 MsqPostMessage(pThread
->MessageQueue
, &KernelModeMsg
,
1199 NULL
!= MsgMemoryEntry
&& 0 != KernelModeMsg
.lParam
,
1201 ObDereferenceObject( peThread
);
1204 SetLastNtError( Status
);
1210 NtUserQuerySendMessage(DWORD Unknown0
)
1218 IntSendMessage(HWND hWnd
,
1223 ULONG_PTR Result
= 0;
1224 if(IntSendMessageTimeout(hWnd
, Msg
, wParam
, lParam
, SMTO_NORMAL
, 0, &Result
))
1226 return (LRESULT
)Result
;
1231 static LRESULT FASTCALL
1232 IntSendMessageTimeoutSingle(HWND hWnd
,
1242 PWINDOW_OBJECT Window
;
1243 PMSGMEMORY MsgMemoryEntry
;
1244 INT lParamBufferSize
;
1245 LPARAM lParamPacked
;
1246 PW32THREAD Win32Thread
;
1248 /* FIXME: Call hooks. */
1249 Window
= IntGetWindowObject(hWnd
);
1252 SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE
);
1256 Win32Thread
= PsGetWin32Thread();
1258 if (NULL
!= Win32Thread
&&
1259 Window
->MessageQueue
== Win32Thread
->MessageQueue
)
1261 if (Win32Thread
->IsExiting
)
1263 /* Never send messages to exiting threads */
1264 IntReleaseWindowObject(Window
);
1268 /* See if this message type is present in the table */
1269 MsgMemoryEntry
= FindMsgMemory(Msg
);
1270 if (NULL
== MsgMemoryEntry
)
1272 lParamBufferSize
= -1;
1276 lParamBufferSize
= MsgMemorySize(MsgMemoryEntry
, wParam
, lParam
);
1279 if (! NT_SUCCESS(PackParam(&lParamPacked
, Msg
, wParam
, lParam
)))
1281 IntReleaseWindowObject(Window
);
1282 DPRINT1("Failed to pack message parameters\n");
1285 if (0xFFFF0000 != ((DWORD
) Window
->WndProcW
& 0xFFFF0000))
1287 Result
= (ULONG_PTR
)IntCallWindowProc(Window
->WndProcW
, FALSE
, hWnd
, Msg
, wParam
,
1288 lParamPacked
,lParamBufferSize
);
1292 Result
= (ULONG_PTR
)IntCallWindowProc(Window
->WndProcA
, TRUE
, hWnd
, Msg
, wParam
,
1293 lParamPacked
,lParamBufferSize
);
1301 if (! NT_SUCCESS(UnpackParam(lParamPacked
, Msg
, wParam
, lParam
)))
1303 IntReleaseWindowObject(Window
);
1304 DPRINT1("Failed to unpack message parameters\n");
1308 IntReleaseWindowObject(Window
);
1312 if(uFlags
& SMTO_ABORTIFHUNG
&& MsqIsHung(Window
->MessageQueue
))
1314 IntReleaseWindowObject(Window
);
1315 /* FIXME - Set a LastError? */
1319 if(Window
->Status
& WINDOWSTATUS_DESTROYING
)
1321 IntReleaseWindowObject(Window
);
1322 /* FIXME - last error? */
1323 DPRINT1("Attempted to send message to window 0x%x that is being destroyed!\n", hWnd
);
1327 Status
= MsqSendMessage(Window
->MessageQueue
, hWnd
, Msg
, wParam
, lParam
,
1328 uTimeout
, (uFlags
& SMTO_BLOCK
), uResult
);
1329 IntReleaseWindowObject(Window
);
1330 if (STATUS_TIMEOUT
== Status
)
1332 /* MSDN says GetLastError() should return 0 after timeout */
1333 SetLastWin32Error(0);
1336 else if (! NT_SUCCESS(Status
))
1338 SetLastNtError(Status
);
1346 IntSendMessageTimeout(HWND hWnd
,
1354 PWINDOW_OBJECT DesktopWindow
;
1358 if (HWND_BROADCAST
!= hWnd
)
1360 return IntSendMessageTimeoutSingle(hWnd
, Msg
, wParam
, lParam
, uFlags
, uTimeout
, uResult
);
1363 DesktopWindow
= IntGetWindowObject(IntGetDesktopWindow());
1364 if (NULL
== DesktopWindow
)
1366 SetLastWin32Error(ERROR_INTERNAL_ERROR
);
1369 Children
= IntWinListChildren(DesktopWindow
);
1370 IntReleaseWindowObject(DesktopWindow
);
1371 if (NULL
== Children
)
1376 for (Child
= Children
; NULL
!= *Child
; Child
++)
1378 IntSendMessageTimeoutSingle(*Child
, Msg
, wParam
, lParam
, uFlags
, uTimeout
, uResult
);
1381 ExFreePool(Children
);
1383 return (LRESULT
) TRUE
;
1387 /* This function posts a message if the destination's message queue belongs to
1388 another thread, otherwise it sends the message. It does not support broadcast
1391 IntPostOrSendMessage(HWND hWnd
,
1397 PWINDOW_OBJECT Window
;
1399 if(hWnd
== HWND_BROADCAST
)
1404 Window
= IntGetWindowObject(hWnd
);
1407 SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE
);
1411 if(Window
->MessageQueue
!= PsGetWin32Thread()->MessageQueue
)
1413 Result
= NtUserPostMessage(hWnd
, Msg
, wParam
, lParam
);
1417 if(!IntSendMessageTimeoutSingle(hWnd
, Msg
, wParam
, lParam
, SMTO_NORMAL
, 0, &Result
))
1423 IntReleaseWindowObject(Window
);
1425 return (LRESULT
)Result
;
1429 IntDoSendMessage(HWND Wnd
,
1434 PNTUSERSENDMESSAGEINFO UnsafeInfo
)
1436 LRESULT Result
= TRUE
;
1438 PWINDOW_OBJECT Window
;
1439 NTUSERSENDMESSAGEINFO Info
;
1442 PMSGMEMORY MsgMemoryEntry
;
1444 RtlZeroMemory(&Info
, sizeof(NTUSERSENDMESSAGEINFO
));
1446 /* FIXME: Call hooks. */
1447 if (HWND_BROADCAST
!= Wnd
)
1449 Window
= IntGetWindowObject(Wnd
);
1452 /* Tell usermode to not touch this one */
1453 Info
.HandledByKernel
= TRUE
;
1454 MmCopyToCaller(UnsafeInfo
, &Info
, sizeof(NTUSERSENDMESSAGEINFO
));
1455 SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE
);
1460 /* FIXME: Check for an exiting window. */
1462 /* See if the current thread can handle the message */
1463 if (HWND_BROADCAST
!= Wnd
&& NULL
!= PsGetWin32Thread() &&
1464 Window
->MessageQueue
== PsGetWin32Thread()->MessageQueue
)
1466 /* Gather the information usermode needs to call the window proc directly */
1467 Info
.HandledByKernel
= FALSE
;
1468 if (0xFFFF0000 != ((DWORD
) Window
->WndProcW
& 0xFFFF0000))
1470 if (0xFFFF0000 != ((DWORD
) Window
->WndProcA
& 0xFFFF0000))
1472 /* Both Unicode and Ansi winprocs are real, see what usermode prefers */
1473 Status
= MmCopyFromCaller(&(Info
.Ansi
), &(UnsafeInfo
->Ansi
),
1475 if (! NT_SUCCESS(Status
))
1477 Info
.Ansi
= ! Window
->Unicode
;
1479 Info
.Proc
= (Info
.Ansi
? Window
->WndProcA
: Window
->WndProcW
);
1483 /* Real Unicode winproc */
1485 Info
.Proc
= Window
->WndProcW
;
1490 /* Must have real Ansi winproc */
1492 Info
.Proc
= Window
->WndProcA
;
1494 IntReleaseWindowObject(Window
);
1498 /* Must be handled by other thread */
1499 if (HWND_BROADCAST
!= Wnd
)
1501 IntReleaseWindowObject(Window
);
1503 Info
.HandledByKernel
= TRUE
;
1504 UserModeMsg
.hwnd
= Wnd
;
1505 UserModeMsg
.message
= Msg
;
1506 UserModeMsg
.wParam
= wParam
;
1507 UserModeMsg
.lParam
= lParam
;
1508 MsgMemoryEntry
= FindMsgMemory(UserModeMsg
.message
);
1509 Status
= CopyMsgToKernelMem(&KernelModeMsg
, &UserModeMsg
, MsgMemoryEntry
);
1510 if (! NT_SUCCESS(Status
))
1512 MmCopyToCaller(UnsafeInfo
, &Info
, sizeof(NTUSERSENDMESSAGEINFO
));
1513 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1514 return (dsm
? 0 : -1);
1518 Result
= IntSendMessage(KernelModeMsg
.hwnd
, KernelModeMsg
.message
,
1519 KernelModeMsg
.wParam
, KernelModeMsg
.lParam
);
1523 Result
= IntSendMessageTimeout(KernelModeMsg
.hwnd
, KernelModeMsg
.message
,
1524 KernelModeMsg
.wParam
, KernelModeMsg
.lParam
,
1525 dsm
->uFlags
, dsm
->uTimeout
, &dsm
->Result
);
1527 Status
= CopyMsgToUserMem(&UserModeMsg
, &KernelModeMsg
);
1528 if (! NT_SUCCESS(Status
))
1530 MmCopyToCaller(UnsafeInfo
, &Info
, sizeof(NTUSERSENDMESSAGEINFO
));
1531 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1532 return(dsm
? 0 : -1);
1536 Status
= MmCopyToCaller(UnsafeInfo
, &Info
, sizeof(NTUSERSENDMESSAGEINFO
));
1537 if (! NT_SUCCESS(Status
))
1539 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1542 return (LRESULT
)Result
;
1546 NtUserSendMessageTimeout(HWND hWnd
,
1553 PNTUSERSENDMESSAGEINFO UnsafeInfo
)
1558 dsm
.uFlags
= uFlags
;
1559 dsm
.uTimeout
= uTimeout
;
1560 Result
= IntDoSendMessage(hWnd
, Msg
, wParam
, lParam
, &dsm
, UnsafeInfo
);
1561 if(uResult
!= NULL
&& Result
!= 0)
1565 Status
= MmCopyToCaller(uResult
, &dsm
.Result
, sizeof(ULONG_PTR
));
1566 if(!NT_SUCCESS(Status
))
1568 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1576 NtUserSendMessage(HWND Wnd
,
1580 PNTUSERSENDMESSAGEINFO UnsafeInfo
)
1582 return IntDoSendMessage(Wnd
, Msg
, wParam
, lParam
, NULL
, UnsafeInfo
);
1586 NtUserSendMessageCallback(HWND hWnd
,
1590 SENDASYNCPROC lpCallBack
,
1599 NtUserSendNotifyMessage(HWND hWnd
,
1610 NtUserWaitMessage(VOID
)
1613 return IntWaitMessage(NULL
, 0, 0);
1617 NtUserGetQueueStatus(BOOL ClearChanges
)
1619 PUSER_MESSAGE_QUEUE Queue
;
1622 Queue
= PsGetWin32Thread()->MessageQueue
;
1624 IntLockMessageQueue(Queue
);
1626 Result
= MAKELONG(Queue
->QueueBits
, Queue
->ChangedBits
);
1629 Queue
->ChangedBits
= 0;
1632 IntUnLockMessageQueue(Queue
);
1638 IntInitMessagePumpHook()
1640 PsGetCurrentThread()->Tcb
.Win32Thread
->MessagePumpHookValue
++;
1645 IntUninitMessagePumpHook()
1647 if (PsGetCurrentThread()->Tcb
.Win32Thread
->MessagePumpHookValue
<= 0)
1651 PsGetCurrentThread()->Tcb
.Win32Thread
->MessagePumpHookValue
--;