2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: NtUserCallXxx call stubs
5 * FILE: win32ss/user/ntuser/simplecall.c
6 * PROGRAMERS: Ge van Geldorp (ge@gse.nl)
7 * Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
12 DBG_DEFAULT_CHANNEL(UserMisc
);
14 /* Registered logon process ID */
18 co_IntRegisterLogonProcess(HANDLE ProcessId
, BOOL Register
)
23 Status
= PsLookupProcessByProcessId(ProcessId
, &Process
);
24 if (!NT_SUCCESS(Status
))
26 EngSetLastError(RtlNtStatusToDosError(Status
));
30 ProcessId
= Process
->UniqueProcessId
;
32 ObDereferenceObject(Process
);
36 /* Register the logon process */
40 gpidLogon
= ProcessId
;
44 /* Deregister the logon process */
45 if (gpidLogon
!= ProcessId
)
59 NtUserCallNoParam(DWORD Routine
)
63 TRACE("Enter NtUserCallNoParam\n");
68 case NOPARAM_ROUTINE_CREATEMENU
:
69 Result
= (DWORD_PTR
)UserCreateMenu(GetW32ThreadInfo()->rpdesk
, FALSE
);
72 case NOPARAM_ROUTINE_CREATEMENUPOPUP
:
73 Result
= (DWORD_PTR
)UserCreateMenu(GetW32ThreadInfo()->rpdesk
, TRUE
);
76 case NOPARAM_ROUTINE_DESTROY_CARET
:
77 Result
= (DWORD_PTR
)co_IntDestroyCaret(PsGetCurrentThread()->Tcb
.Win32Thread
);
80 case NOPARAM_ROUTINE_INIT_MESSAGE_PUMP
:
81 Result
= (DWORD_PTR
)IntInitMessagePumpHook();
84 case NOPARAM_ROUTINE_UNINIT_MESSAGE_PUMP
:
85 Result
= (DWORD_PTR
)IntUninitMessagePumpHook();
88 case NOPARAM_ROUTINE_MSQCLEARWAKEMASK
:
89 Result
= (DWORD_PTR
)IntMsqClearWakeMask();
92 case NOPARAM_ROUTINE_GETMSESSAGEPOS
:
94 PTHREADINFO pti
= PsGetCurrentThreadWin32Thread();
95 Result
= (DWORD_PTR
)MAKELONG(pti
->ptLast
.x
, pti
->ptLast
.y
);
99 case NOPARAM_ROUTINE_RELEASECAPTURE
:
100 Result
= (DWORD_PTR
)IntReleaseCapture();
103 case NOPARAM_ROUTINE_LOADUSERAPIHOOK
:
104 Result
= UserLoadApiHook();
107 case NOPARAM_ROUTINE_ZAPACTIVEANDFOUS
:
109 PTHREADINFO pti
= PsGetCurrentThreadWin32Thread();
110 TRACE("Zapping the Active and Focus window out of the Queue!\n");
111 pti
->MessageQueue
->spwndFocus
= NULL
;
112 pti
->MessageQueue
->spwndActive
= NULL
;
117 /* this is a ReactOS only case and is needed for gui-on-demand */
118 case NOPARAM_ROUTINE_ISCONSOLEMODE
:
119 Result
= (ScreenDeviceContext
== NULL
);
122 case NOPARAM_ROUTINE_UPDATEPERUSERIMMENABLING
:
123 gpsi
->dwSRVIFlags
|= SRVINFO_IMM32
; // Always set.
124 Result
= TRUE
; // Always return TRUE.
128 ERR("Calling invalid routine number 0x%x in NtUserCallNoParam\n", Routine
);
129 EngSetLastError(ERROR_INVALID_PARAMETER
);
133 TRACE("Leave NtUserCallNoParam, ret=%p\n",(PVOID
)Result
);
151 TRACE("Enter NtUserCallOneParam\n");
153 UserEnterExclusive();
157 case ONEPARAM_ROUTINE_POSTQUITMESSAGE
:
160 pti
= PsGetCurrentThreadWin32Thread();
161 MsqPostQuitMessage(pti
, Param
);
166 case ONEPARAM_ROUTINE_BEGINDEFERWNDPOS
:
170 INT count
= (INT
)Param
;
174 EngSetLastError(ERROR_INVALID_PARAMETER
);
179 /* Windows allows zero count, in which case it allocates context for 8 moves */
180 if (count
== 0) count
= 8;
182 psmwp
= (PSMWP
)UserCreateObject(gHandleTable
,
194 psmwp
->acvr
= ExAllocatePoolWithTag(PagedPool
, count
* sizeof(CVR
), USERTAG_SWP
);
197 UserDeleteObject(hDwp
, TYPE_SETWINDOWPOS
);
202 RtlZeroMemory(psmwp
->acvr
, count
* sizeof(CVR
));
203 psmwp
->bHandle
= TRUE
;
204 psmwp
->ccvr
= 0; // actualCount
205 psmwp
->ccvrAlloc
= count
; // suggestedCount
206 Result
= (DWORD_PTR
)hDwp
;
210 case ONEPARAM_ROUTINE_SHOWCURSOR
:
211 Result
= (DWORD_PTR
)UserShowCursor((BOOL
)Param
);
214 case ONEPARAM_ROUTINE_GETDESKTOPMAPPING
:
217 ti
= GetW32ThreadInfo();
220 /* Try convert the pointer to a user mode pointer if the desktop is
221 mapped into the process */
222 Result
= (DWORD_PTR
)DesktopHeapAddressToUser((PVOID
)Param
);
231 case ONEPARAM_ROUTINE_WINDOWFROMDC
:
232 Result
= (DWORD_PTR
)IntWindowFromDC((HDC
)Param
);
235 case ONEPARAM_ROUTINE_SWAPMOUSEBUTTON
:
237 Result
= gspv
.bMouseBtnSwap
;
238 gspv
.bMouseBtnSwap
= Param
? TRUE
: FALSE
;
239 gpsi
->aiSysMet
[SM_SWAPBUTTON
] = gspv
.bMouseBtnSwap
;
243 case ONEPARAM_ROUTINE_SETCARETBLINKTIME
:
244 Result
= (DWORD_PTR
)IntSetCaretBlinkTime((UINT
)Param
);
247 case ONEPARAM_ROUTINE_SETMESSAGEEXTRAINFO
:
248 Result
= (DWORD_PTR
)MsqSetMessageExtraInfo((LPARAM
)Param
);
251 case ONEPARAM_ROUTINE_CREATEEMPTYCUROBJECT
:
253 if (!(Result
= (DWORD_PTR
)IntCreateCurIconHandle((DWORD
)Param
)))
255 EngSetLastError(ERROR_NOT_ENOUGH_MEMORY
);
261 case ONEPARAM_ROUTINE_ENABLEPROCWNDGHSTING
:
264 PPROCESSINFO Process
= PsGetCurrentProcessWin32Process();
268 Enable
= (BOOL
)(Param
!= 0);
272 Process
->W32PF_flags
&= ~W32PF_NOWINDOWGHOSTING
;
276 Process
->W32PF_flags
|= W32PF_NOWINDOWGHOSTING
;
287 case ONEPARAM_ROUTINE_GETINPUTEVENT
:
288 Result
= (DWORD_PTR
)IntMsqSetWakeMask(Param
);
291 case ONEPARAM_ROUTINE_GETKEYBOARDTYPE
:
292 Result
= UserGetKeyboardType(Param
);
295 case ONEPARAM_ROUTINE_GETKEYBOARDLAYOUT
:
296 Result
= (DWORD_PTR
)UserGetKeyboardLayout(Param
);
299 case ONEPARAM_ROUTINE_RELEASEDC
:
300 Result
= UserReleaseDC(NULL
, (HDC
) Param
, FALSE
);
303 case ONEPARAM_ROUTINE_REALIZEPALETTE
:
304 Result
= UserRealizePalette((HDC
) Param
);
307 case ONEPARAM_ROUTINE_GETQUEUESTATUS
:
309 Result
= IntGetQueueStatus((DWORD
)Param
);
313 case ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS
:
314 /* FIXME: Should use UserEnterShared */
315 Result
= UserEnumClipboardFormats(Param
);
318 case ONEPARAM_ROUTINE_GETCURSORPOS
:
321 PTHREADINFO pti
= PsGetCurrentThreadWin32Thread();
323 if (pti
->rpdesk
!= IntGetActiveDesktop())
330 ProbeForWrite((POINT
*)Param
,sizeof(POINT
),1);
331 pptl
= (PPOINTL
)Param
;
332 *pptl
= gpsi
->ptCursor
;
334 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
342 case ONEPARAM_ROUTINE_SETPROCDEFLAYOUT
:
345 if (Param
& LAYOUT_ORIENTATIONMASK
|| Param
== LAYOUT_LTR
)
347 ppi
= PsGetCurrentProcessWin32Process();
348 ppi
->dwLayout
= Param
;
352 EngSetLastError(ERROR_INVALID_PARAMETER
);
357 case ONEPARAM_ROUTINE_GETPROCDEFLAYOUT
:
363 if (PsGetCurrentProcess() == gpepCSRSS
)
365 EngSetLastError(ERROR_INVALID_ACCESS
);
370 ppi
= PsGetCurrentProcessWin32Process();
373 pdwLayout
= (PDWORD
)Param
;
374 *pdwLayout
= ppi
->dwLayout
;
376 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
378 SetLastNtError(_SEH2_GetExceptionCode());
385 case ONEPARAM_ROUTINE_REPLYMESSAGE
:
386 Result
= co_MsqReplyMessage((LRESULT
)Param
);
389 case ONEPARAM_ROUTINE_MESSAGEBEEP
:
390 /* TODO: Implement sound sentry */
391 Result
= UserPostMessage(hwndSAS
, WM_LOGONNOTIFY
, LN_MESSAGE_BEEP
, Param
);
394 case ONEPARAM_ROUTINE_CREATESYSTEMTHREADS
:
395 Result
= UserSystemThreadProc(Param
);
398 case ONEPARAM_ROUTINE_LOCKFOREGNDWINDOW
:
399 Result
= (DWORD_PTR
)IntLockSetForegroundWindow(Param
);
402 case ONEPARAM_ROUTINE_ALLOWSETFOREGND
:
403 Result
= (DWORD_PTR
)IntAllowSetForegroundWindow(Param
);
407 ERR("Calling invalid routine number 0x%x in NtUserCallOneParam(), Param=0x%x\n",
409 EngSetLastError(ERROR_INVALID_PARAMETER
);
414 TRACE("Leave NtUserCallOneParam, ret=%p\n", (PVOID
)Result
);
433 TRACE("Enter NtUserCallTwoParam\n");
434 UserEnterExclusive();
438 case TWOPARAM_ROUTINE_REDRAWTITLE
:
440 Window
= UserGetWindowObject((HWND
)Param1
);
441 Ret
= (DWORD_PTR
)UserPaintCaption(Window
, (INT
)Param2
);
445 case TWOPARAM_ROUTINE_SETMENUBARHEIGHT
:
447 PMENU MenuObject
= IntGetMenuObject((HMENU
)Param1
);
456 Ret
= (MenuObject
->cyMenu
== (int)Param2
);
457 MenuObject
->cyMenu
= (int)Param2
;
460 Ret
= (DWORD_PTR
)MenuObject
->cyMenu
;
461 IntReleaseMenuObject(MenuObject
);
465 case TWOPARAM_ROUTINE_SETGUITHRDHANDLE
:
467 PTHREADINFO pti
= (PTHREADINFO
)PsGetCurrentThreadWin32Thread();
468 ASSERT(pti
->MessageQueue
);
469 Ret
= (DWORD_PTR
)MsqSetStateWindow(pti
, (ULONG
)Param1
, (HWND
)Param2
);
473 case TWOPARAM_ROUTINE_ENABLEWINDOW
:
474 Ret
= IntEnableWindow((HWND
)Param1
, (BOOL
)Param2
);
477 case TWOPARAM_ROUTINE_SHOWOWNEDPOPUPS
:
479 Window
= UserGetWindowObject((HWND
)Param1
);
486 Ret
= (DWORD_PTR
)IntShowOwnedPopups(Window
, (BOOL
)Param2
);
490 case TWOPARAM_ROUTINE_ROS_UPDATEUISTATE
:
493 Window
= UserGetWindowObject((HWND
)Param1
);
501 wParam
= MAKEWPARAM((Param2
>> 3) & 0x3,
502 Param2
& (UISF_HIDEFOCUS
| UISF_HIDEACCEL
| UISF_ACTIVE
));
504 Ret
= UserUpdateUiState(Window
, wParam
);
508 case TWOPARAM_ROUTINE_SWITCHTOTHISWINDOW
:
510 HWND hwnd
= (HWND
)Param1
;
511 BOOL fAltTab
= (BOOL
)Param2
;
513 Window
= UserGetWindowObject(hwnd
);
518 if (MsqIsHung(Window
->head
.pti
))
520 // TODO: Make the window ghosted and activate.
525 if (Window
->style
& WS_MINIMIZE
)
527 UserPostMessage(hwnd
, WM_SYSCOMMAND
, SC_RESTORE
, 0);
529 /* bring window to top and activate */
530 co_WinPosSetWindowPos(Window
, HWND_TOP
, 0, 0, 0, 0,
531 SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOSENDCHANGING
|
532 SWP_NOOWNERZORDER
| SWP_ASYNCWINDOWPOS
);
536 UserSetActiveWindow(Window
);
541 case TWOPARAM_ROUTINE_SETCARETPOS
:
542 Ret
= (DWORD_PTR
)co_IntSetCaretPos((int)Param1
, (int)Param2
);
545 case TWOPARAM_ROUTINE_REGISTERLOGONPROCESS
:
546 Ret
= (DWORD_PTR
)co_IntRegisterLogonProcess((HANDLE
)Param1
, (BOOL
)Param2
);
549 case TWOPARAM_ROUTINE_SETCURSORPOS
:
550 Ret
= (DWORD_PTR
)UserSetCursorPos((int)Param1
, (int)Param2
, 0, 0, FALSE
);
553 case TWOPARAM_ROUTINE_UNHOOKWINDOWSHOOK
:
554 Ret
= IntUnhookWindowsHook((int)Param1
, (HOOKPROC
)Param2
);
558 ERR("Calling invalid routine number 0x%x in NtUserCallTwoParam(), Param1=0x%x Parm2=0x%x\n",
559 Routine
, Param1
, Param2
);
560 EngSetLastError(ERROR_INVALID_PARAMETER
);
565 TRACE("Leave NtUserCallTwoParam, ret=%p\n", (PVOID
)Ret
);
583 USER_REFERENCE_ENTRY Ref
;
585 TRACE("Enter NtUserCallHwndLock\n");
586 UserEnterExclusive();
588 if (!(Window
= UserGetWindowObject(hWnd
)))
594 UserRefObjectCo(Window
, &Ref
);
596 /* FIXME: Routine can be 0x53 - 0x5E */
599 case HWNDLOCK_ROUTINE_ARRANGEICONICWINDOWS
:
600 co_WinPosArrangeIconicWindows(Window
);
603 case HWNDLOCK_ROUTINE_DRAWMENUBAR
:
605 TRACE("HWNDLOCK_ROUTINE_DRAWMENUBAR\n");
607 if ((Window
->style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
)
608 co_WinPosSetWindowPos(Window
,
619 case HWNDLOCK_ROUTINE_REDRAWFRAME
:
620 co_WinPosSetWindowPos(Window
,
631 case HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK
:
632 co_WinPosSetWindowPos(Window
,
640 if (!Window
->spwndOwner
&& !IntGetParent(Window
))
642 co_IntShellHookNotify(HSHELL_REDRAW
, (WPARAM
)hWnd
, FALSE
); // FIXME Flashing?
647 case HWNDLOCK_ROUTINE_SETFOREGROUNDWINDOW
:
648 TRACE("co_IntSetForegroundWindow 1 0x%p\n", hWnd
);
649 Ret
= co_IntSetForegroundWindow(Window
);
650 TRACE("co_IntSetForegroundWindow 2 0x%p\n", hWnd
);
653 case HWNDLOCK_ROUTINE_SETFOREGROUNDWINDOWMOUSE
:
654 TRACE("co_IntSetForegroundWindow M 1 0x%p\n", hWnd
);
655 Ret
= co_IntSetForegroundWindowMouse(Window
);
656 TRACE("co_IntSetForegroundWindow M 2 0x%p\n", hWnd
);
659 case HWNDLOCK_ROUTINE_UPDATEWINDOW
:
660 co_IntUpdateWindows(Window
, RDW_ALLCHILDREN
, FALSE
);
665 UserDerefObjectCo(Window
);
668 TRACE("Leave NtUserCallHwndLock, ret=%u\n", Ret
);
685 case HWNDOPT_ROUTINE_SETPROGMANWINDOW
:
686 GetW32ThreadInfo()->pDeskInfo
->hProgmanWindow
= hWnd
;
689 case HWNDOPT_ROUTINE_SETTASKMANWINDOW
:
690 GetW32ThreadInfo()->pDeskInfo
->hTaskManWindow
= hWnd
;
705 case HWND_ROUTINE_GETWNDCONTEXTHLPID
:
712 if (!(Window
= UserGetWindowObject(hWnd
)))
718 HelpId
= (DWORD
)(DWORD_PTR
)UserGetProp(Window
, gpsi
->atomContextHelpIdProp
, TRUE
);
724 case HWND_ROUTINE_REGISTERSHELLHOOKWINDOW
:
725 if (IntIsWindow(hWnd
))
726 return IntRegisterShellHookWindow(hWnd
);
730 case HWND_ROUTINE_DEREGISTERSHELLHOOKWINDOW
:
731 if (IntIsWindow(hWnd
))
732 return IntDeRegisterShellHookWindow(hWnd
);
735 case HWND_ROUTINE_SETMSGBOX
:
738 UserEnterExclusive();
739 if ((Window
= UserGetWindowObject(hWnd
)))
741 Window
->state
|= WNDS_MSGBOX
;
763 case HWNDPARAM_ROUTINE_KILLSYSTEMTIMER
:
764 return IntKillTimer(UserGetWindowObject(hWnd
), (UINT_PTR
)Param
, TRUE
);
766 case HWNDPARAM_ROUTINE_SETWNDCONTEXTHLPID
:
770 UserEnterExclusive();
771 if (!(Window
= UserGetWindowObject(hWnd
)))
778 UserSetProp(Window
, gpsi
->atomContextHelpIdProp
, (HANDLE
)Param
, TRUE
);
780 UserRemoveProp(Window
, gpsi
->atomContextHelpIdProp
, TRUE
);
786 case HWNDPARAM_ROUTINE_SETDIALOGPOINTER
:
789 USER_REFERENCE_ENTRY Ref
;
791 UserEnterExclusive();
793 if (!(pWnd
= UserGetWindowObject(hWnd
)))
798 UserRefObjectCo(pWnd
, &Ref
);
800 if (pWnd
->head
.pti
->ppi
== PsGetCurrentProcessWin32Process() &&
801 pWnd
->cbwndExtra
== DLGWINDOWEXTRA
&&
802 !(pWnd
->state
& WNDS_SERVERSIDEWINDOWPROC
))
806 if (!pWnd
->fnid
) pWnd
->fnid
= FNID_DIALOG
;
807 pWnd
->state
|= WNDS_DIALOGWINDOW
;
811 pWnd
->fnid
|= FNID_DESTROY
;
812 pWnd
->state
&= ~WNDS_DIALOGWINDOW
;
816 UserDerefObjectCo(pWnd
);
821 case HWNDPARAM_ROUTINE_ROS_NOTIFYWINEVENT
:
825 UserEnterExclusive();
826 pne
= (PNOTIFYEVENT
)Param
;
828 pWnd
= UserGetWindowObject(hWnd
);
831 IntNotifyWinEvent(pne
->event
, pWnd
, pne
->idObject
, pne
->idChild
, pne
->flags
);
836 case HWNDPARAM_ROUTINE_CLEARWINDOWSTATE
:
839 UserEnterExclusive();
840 pWnd
= UserGetWindowObject(hWnd
);
841 if (pWnd
) IntClearWindowState(pWnd
, (UINT
)Param
);
846 case HWNDPARAM_ROUTINE_SETWINDOWSTATE
:
849 UserEnterExclusive();
850 pWnd
= UserGetWindowObject(hWnd
);
851 if (pWnd
) IntSetWindowState(pWnd
, (UINT
)Param
);
864 NtUserCallHwndParamLock(
871 USER_REFERENCE_ENTRY Ref
;
873 TRACE("Enter NtUserCallHwndParamLock\n");
874 UserEnterExclusive();
876 if (!(Window
= UserGetWindowObject(hWnd
)))
882 UserRefObjectCo(Window
, &Ref
);
886 case TWOPARAM_ROUTINE_VALIDATERGN
:
888 PREGION Rgn
= REGION_LockRgn((HRGN
)Param
);
889 Ret
= (DWORD
)co_UserRedrawWindow(Window
, NULL
, Rgn
, RDW_VALIDATE
);
890 if (Rgn
) REGION_UnlockRgn(Rgn
);
895 UserDerefObjectCo(Window
);
899 TRACE("Leave NtUserCallHwndParamLock, ret=%lu\n", Ret
);