2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: NtUserCallXxx call stubs
5 * FILE: subsystem/win32/win32k/ntuser/simplecall.c
6 * PROGRAMER: Ge van Geldorp (ge@gse.nl)
11 DBG_DEFAULT_CHANNEL(UserMisc
);
13 /* Registered logon process ID */
17 co_IntRegisterLogonProcess(HANDLE ProcessId
, BOOL Register
)
22 Status
= PsLookupProcessByProcessId(ProcessId
, &Process
);
23 if (!NT_SUCCESS(Status
))
25 EngSetLastError(RtlNtStatusToDosError(Status
));
29 ProcessId
= Process
->UniqueProcessId
;
31 ObDereferenceObject(Process
);
35 /* Register the logon process */
39 gpidLogon
= ProcessId
;
43 /* Deregister the logon process */
44 if (gpidLogon
!= ProcessId
)
58 NtUserCallNoParam(DWORD Routine
)
61 DECLARE_RETURN(DWORD_PTR
);
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 RETURN( (DWORD_PTR
)IntMsqClearWakeMask());
91 case NOPARAM_ROUTINE_GETMSESSAGEPOS
:
93 PTHREADINFO pti
= PsGetCurrentThreadWin32Thread();
94 RETURN( (DWORD_PTR
)MAKELONG(pti
->ptLast
.x
, pti
->ptLast
.y
));
97 case NOPARAM_ROUTINE_RELEASECAPTURE
:
98 RETURN( (DWORD_PTR
)IntReleaseCapture());
100 case NOPARAM_ROUTINE_LOADUSERAPIHOOK
:
101 RETURN(UserLoadApiHook());
103 case NOPARAM_ROUTINE_ZAPACTIVEANDFOUS
:
105 PTHREADINFO pti
= PsGetCurrentThreadWin32Thread();
106 TRACE("Zapping the Active and Focus window out of the Queue!\n");
107 pti
->MessageQueue
->spwndFocus
= NULL
;
108 pti
->MessageQueue
->spwndActive
= NULL
;
112 /* this is a Reactos only case and is needed for gui-on-demand */
113 case NOPARAM_ROUTINE_ISCONSOLEMODE
:
114 RETURN( ScreenDeviceContext
== NULL
);
117 ERR("Calling invalid routine number 0x%x in NtUserCallNoParam\n", Routine
);
118 EngSetLastError(ERROR_INVALID_PARAMETER
);
124 TRACE("Leave NtUserCallNoParam, ret=%p\n",(PVOID
)_ret_
);
139 DECLARE_RETURN(DWORD_PTR
);
141 TRACE("Enter NtUserCallOneParam\n");
143 UserEnterExclusive();
147 case ONEPARAM_ROUTINE_POSTQUITMESSAGE
:
150 pti
= PsGetCurrentThreadWin32Thread();
151 MsqPostQuitMessage(pti
, Param
);
155 case ONEPARAM_ROUTINE_BEGINDEFERWNDPOS
:
159 INT count
= (INT
)Param
;
163 EngSetLastError(ERROR_INVALID_PARAMETER
);
166 /* Windows allows zero count, in which case it allocates context for 8 moves */
167 if (count
== 0) count
= 8;
169 psmwp
= (PSMWP
) UserCreateObject( gHandleTable
,
175 if (!psmwp
) RETURN(0);
176 psmwp
->acvr
= ExAllocatePoolWithTag(PagedPool
, count
* sizeof(CVR
), USERTAG_SWP
);
179 UserDeleteObject(hDwp
, TYPE_SETWINDOWPOS
);
182 RtlZeroMemory(psmwp
->acvr
, count
* sizeof(CVR
));
183 psmwp
->bHandle
= TRUE
;
184 psmwp
->ccvr
= 0; // actualCount
185 psmwp
->ccvrAlloc
= count
; // suggestedCount
186 RETURN((DWORD_PTR
)hDwp
);
189 case ONEPARAM_ROUTINE_SHOWCURSOR
:
190 RETURN( (DWORD_PTR
)UserShowCursor((BOOL
)Param
) );
192 case ONEPARAM_ROUTINE_GETDESKTOPMAPPING
:
195 ti
= GetW32ThreadInfo();
198 /* Try convert the pointer to a user mode pointer if the desktop is
199 mapped into the process */
200 RETURN((DWORD_PTR
)DesktopHeapAddressToUser((PVOID
)Param
));
208 case ONEPARAM_ROUTINE_WINDOWFROMDC
:
209 RETURN( (DWORD_PTR
)IntWindowFromDC((HDC
)Param
));
211 case ONEPARAM_ROUTINE_SWAPMOUSEBUTTON
:
215 Result
= gspv
.bMouseBtnSwap
;
216 gspv
.bMouseBtnSwap
= Param
? TRUE
: FALSE
;
217 gpsi
->aiSysMet
[SM_SWAPBUTTON
] = gspv
.bMouseBtnSwap
;
221 case ONEPARAM_ROUTINE_SWITCHCARETSHOWING
:
222 RETURN( (DWORD_PTR
)IntSwitchCaretShowing((PVOID
)Param
));
224 case ONEPARAM_ROUTINE_SETCARETBLINKTIME
:
225 RETURN( (DWORD_PTR
)IntSetCaretBlinkTime((UINT
)Param
));
227 case ONEPARAM_ROUTINE_SETMESSAGEEXTRAINFO
:
228 RETURN( (DWORD_PTR
)MsqSetMessageExtraInfo((LPARAM
)Param
));
230 case ONEPARAM_ROUTINE_CREATEEMPTYCUROBJECT
:
234 if (!(Result
= (DWORD_PTR
)IntCreateCurIconHandle((DWORD
)Param
)))
236 EngSetLastError(ERROR_NOT_ENOUGH_MEMORY
);
242 case ONEPARAM_ROUTINE_ENABLEPROCWNDGHSTING
:
245 PPROCESSINFO Process
= PsGetCurrentProcessWin32Process();
249 Enable
= (BOOL
)(Param
!= 0);
253 Process
->W32PF_flags
&= ~W32PF_NOWINDOWGHOSTING
;
257 Process
->W32PF_flags
|= W32PF_NOWINDOWGHOSTING
;
266 case ONEPARAM_ROUTINE_GETINPUTEVENT
:
267 RETURN( (DWORD_PTR
)IntMsqSetWakeMask(Param
));
269 case ONEPARAM_ROUTINE_GETKEYBOARDTYPE
:
270 RETURN( UserGetKeyboardType(Param
));
272 case ONEPARAM_ROUTINE_GETKEYBOARDLAYOUT
:
273 RETURN( (DWORD_PTR
)UserGetKeyboardLayout(Param
));
275 case ONEPARAM_ROUTINE_RELEASEDC
:
276 RETURN (UserReleaseDC(NULL
, (HDC
) Param
, FALSE
));
278 case ONEPARAM_ROUTINE_REALIZEPALETTE
:
279 RETURN (UserRealizePalette((HDC
) Param
));
281 case ONEPARAM_ROUTINE_GETQUEUESTATUS
:
283 RETURN (IntGetQueueStatus((DWORD
)Param
));
285 case ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS
:
286 /* FIXME: Should use UserEnterShared */
287 RETURN(UserEnumClipboardFormats(Param
));
289 case ONEPARAM_ROUTINE_GETCURSORPOS
:
293 PTHREADINFO pti
= PsGetCurrentThreadWin32Thread();
294 if (pti
->rpdesk
!= IntGetActiveDesktop()) RETURN(FALSE
);
297 ProbeForWrite((POINT
*)Param
,sizeof(POINT
),1);
298 pptl
= (PPOINTL
)Param
;
299 *pptl
= gpsi
->ptCursor
;
301 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
308 case ONEPARAM_ROUTINE_SETPROCDEFLAYOUT
:
311 if (Param
& LAYOUT_ORIENTATIONMASK
)
313 ppi
= PsGetCurrentProcessWin32Process();
314 ppi
->dwLayout
= Param
;
317 EngSetLastError(ERROR_INVALID_PARAMETER
);
320 case ONEPARAM_ROUTINE_GETPROCDEFLAYOUT
:
325 if ( PsGetCurrentProcess() == gpepCSRSS
)
327 EngSetLastError(ERROR_INVALID_ACCESS
);
330 ppi
= PsGetCurrentProcessWin32Process();
333 pdwLayout
= (PDWORD
)Param
;
334 *pdwLayout
= ppi
->dwLayout
;
336 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
338 SetLastNtError(_SEH2_GetExceptionCode());
344 case ONEPARAM_ROUTINE_REPLYMESSAGE
:
345 RETURN (co_MsqReplyMessage((LRESULT
) Param
));
346 case ONEPARAM_ROUTINE_MESSAGEBEEP
:
347 /* TODO: Implement sound sentry */
348 RETURN ( UserPostMessage(hwndSAS
, WM_LOGONNOTIFY
, LN_MESSAGE_BEEP
, Param
) );
349 case ONEPARAM_ROUTINE_CREATESYSTEMTHREADS
:
350 RETURN(CreateSystemThreads(Param
));
351 case ONEPARAM_ROUTINE_LOCKFOREGNDWINDOW
:
352 RETURN( (DWORD_PTR
)IntLockSetForegroundWindow(Param
));
353 case ONEPARAM_ROUTINE_ALLOWSETFOREGND
:
354 RETURN( (DWORD_PTR
)IntAllowSetForegroundWindow(Param
));
356 ERR("Calling invalid routine number 0x%x in NtUserCallOneParam(), Param=0x%x\n",
358 EngSetLastError(ERROR_INVALID_PARAMETER
);
362 TRACE("Leave NtUserCallOneParam, ret=%p\n", (PVOID
)_ret_
);
379 DECLARE_RETURN(DWORD_PTR
);
381 TRACE("Enter NtUserCallTwoParam\n");
382 UserEnterExclusive();
386 case TWOPARAM_ROUTINE_SETMENUBARHEIGHT
:
389 PMENU MenuObject
= IntGetMenuObject((HMENU
)Param1
);
395 Ret
= (MenuObject
->cyMenu
== (int)Param2
);
396 MenuObject
->cyMenu
= (int)Param2
;
399 Ret
= (DWORD_PTR
)MenuObject
->cyMenu
;
400 IntReleaseMenuObject(MenuObject
);
404 case TWOPARAM_ROUTINE_SETGUITHRDHANDLE
:
406 PTHREADINFO pti
= (PTHREADINFO
)PsGetCurrentThreadWin32Thread();
407 ASSERT(pti
->MessageQueue
);
408 RETURN( (DWORD_PTR
)MsqSetStateWindow(pti
, (ULONG
)Param1
, (HWND
)Param2
));
411 case TWOPARAM_ROUTINE_ENABLEWINDOW
:
412 RETURN( IntEnableWindow((HWND
)Param1
, (BOOL
)Param2
));
414 case TWOPARAM_ROUTINE_SHOWOWNEDPOPUPS
:
416 Window
= UserGetWindowObject((HWND
)Param1
);
417 if (!Window
) RETURN(0);
419 RETURN( (DWORD_PTR
)IntShowOwnedPopups(Window
, (BOOL
) Param2
));
422 case TWOPARAM_ROUTINE_ROS_UPDATEUISTATE
:
425 Window
= UserGetWindowObject((HWND
)Param1
);
426 if (!Window
) RETURN(0);
429 wParam
= MAKEWPARAM((Param2
>> 3) & 0x3,
430 Param2
& (UISF_HIDEFOCUS
| UISF_HIDEACCEL
| UISF_ACTIVE
));
432 RETURN( UserUpdateUiState(Window
, wParam
) );
435 case TWOPARAM_ROUTINE_SWITCHTOTHISWINDOW
:
439 case TWOPARAM_ROUTINE_SETCARETPOS
:
440 RETURN( (DWORD_PTR
)co_IntSetCaretPos((int)Param1
, (int)Param2
));
442 case TWOPARAM_ROUTINE_REGISTERLOGONPROCESS
:
443 RETURN( (DWORD_PTR
)co_IntRegisterLogonProcess((HANDLE
)Param1
, (BOOL
)Param2
));
445 case TWOPARAM_ROUTINE_SETCURSORPOS
:
446 RETURN( (DWORD_PTR
)UserSetCursorPos((int)Param1
, (int)Param2
, 0, 0, FALSE
));
448 case TWOPARAM_ROUTINE_UNHOOKWINDOWSHOOK
:
449 RETURN( IntUnhookWindowsHook((int)Param1
, (HOOKPROC
)Param2
));
451 ERR("Calling invalid routine number 0x%x in NtUserCallTwoParam(), Param1=0x%x Parm2=0x%x\n",
452 Routine
, Param1
, Param2
);
453 EngSetLastError(ERROR_INVALID_PARAMETER
);
457 TRACE("Leave NtUserCallTwoParam, ret=%p\n", (PVOID
)_ret_
);
474 USER_REFERENCE_ENTRY Ref
;
475 DECLARE_RETURN(BOOLEAN
);
477 TRACE("Enter NtUserCallHwndLock\n");
478 UserEnterExclusive();
480 if (!(Window
= UserGetWindowObject(hWnd
)))
484 UserRefObjectCo(Window
, &Ref
);
486 /* FIXME: Routine can be 0x53 - 0x5E */
489 case HWNDLOCK_ROUTINE_ARRANGEICONICWINDOWS
:
490 co_WinPosArrangeIconicWindows(Window
);
493 case HWNDLOCK_ROUTINE_DRAWMENUBAR
:
495 TRACE("HWNDLOCK_ROUTINE_DRAWMENUBAR\n");
497 if ((Window
->style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
)
498 co_WinPosSetWindowPos( Window
,
509 case HWNDLOCK_ROUTINE_REDRAWFRAME
:
510 co_WinPosSetWindowPos( Window
,
521 case HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK
:
522 co_WinPosSetWindowPos( Window
,
530 if (!Window
->spwndOwner
&& !IntGetParent(Window
))
532 co_IntShellHookNotify(HSHELL_REDRAW
, (WPARAM
) hWnd
, FALSE
); // FIXME Flashing?
537 case HWNDLOCK_ROUTINE_SETFOREGROUNDWINDOW
:
538 TRACE("co_IntSetForegroundWindow 1 0x%p\n",hWnd
);
539 Ret
= co_IntSetForegroundWindow(Window
);
540 TRACE("co_IntSetForegroundWindow 2 0x%p\n",hWnd
);
543 case HWNDLOCK_ROUTINE_SETFOREGROUNDWINDOWMOUSE
:
544 TRACE("co_IntSetForegroundWindow M 1 0x%p\n",hWnd
);
545 Ret
= co_IntSetForegroundWindowMouse(Window
);
546 TRACE("co_IntSetForegroundWindow M 2 0x%p\n",hWnd
);
549 case HWNDLOCK_ROUTINE_UPDATEWINDOW
:
550 Ret
= co_UserRedrawWindow( Window
, NULL
, 0, RDW_UPDATENOW
| RDW_ALLCHILDREN
);
554 UserDerefObjectCo(Window
);
559 TRACE("Leave NtUserCallHwndLock, ret=%u\n",_ret_
);
575 case HWNDOPT_ROUTINE_SETPROGMANWINDOW
:
576 GetW32ThreadInfo()->pDeskInfo
->hProgmanWindow
= hWnd
;
579 case HWNDOPT_ROUTINE_SETTASKMANWINDOW
:
580 GetW32ThreadInfo()->pDeskInfo
->hTaskManWindow
= hWnd
;
595 case HWND_ROUTINE_GETWNDCONTEXTHLPID
:
599 USER_REFERENCE_ENTRY Ref
;
601 UserEnterExclusive();
603 if (!(Window
= UserGetWindowObject(hWnd
)))
608 UserRefObjectCo(Window
, &Ref
);
610 HelpId
= IntGetProp(Window
, gpsi
->atomContextHelpIdProp
);
612 UserDerefObjectCo(Window
);
614 return (DWORD
)HelpId
->Data
;
616 case HWND_ROUTINE_REGISTERSHELLHOOKWINDOW
:
617 if (IntIsWindow(hWnd
))
618 return IntRegisterShellHookWindow(hWnd
);
621 case HWND_ROUTINE_DEREGISTERSHELLHOOKWINDOW
:
622 if (IntIsWindow(hWnd
))
623 return IntDeRegisterShellHookWindow(hWnd
);
625 case HWND_ROUTINE_SETMSGBOX
:
628 UserEnterExclusive();
629 if ((Window
= UserGetWindowObject(hWnd
)))
631 Window
->state
|= WNDS_MSGBOX
;
652 case HWNDPARAM_ROUTINE_KILLSYSTEMTIMER
:
653 return IntKillTimer(UserGetWindowObject(hWnd
), (UINT_PTR
)Param
, TRUE
);
655 case HWNDPARAM_ROUTINE_SETWNDCONTEXTHLPID
:
659 UserEnterExclusive();
660 if(!(Window
= UserGetWindowObject(hWnd
)))
667 IntSetProp(Window
, gpsi
->atomContextHelpIdProp
, (HANDLE
)Param
);
669 IntRemoveProp(Window
, gpsi
->atomContextHelpIdProp
);
675 case HWNDPARAM_ROUTINE_SETDIALOGPOINTER
:
678 USER_REFERENCE_ENTRY Ref
;
680 UserEnterExclusive();
682 if (!(pWnd
= UserGetWindowObject(hWnd
)))
687 UserRefObjectCo(pWnd
, &Ref
);
689 if (pWnd
->head
.pti
->ppi
== PsGetCurrentProcessWin32Process() &&
690 pWnd
->cbwndExtra
== DLGWINDOWEXTRA
&&
691 !(pWnd
->state
& WNDS_SERVERSIDEWINDOWPROC
))
695 if (!pWnd
->fnid
) pWnd
->fnid
= FNID_DIALOG
;
696 pWnd
->state
|= WNDS_DIALOGWINDOW
;
700 pWnd
->fnid
|= FNID_DESTROY
;
701 pWnd
->state
&= ~WNDS_DIALOGWINDOW
;
705 UserDerefObjectCo(pWnd
);
710 case HWNDPARAM_ROUTINE_ROS_NOTIFYWINEVENT
:
714 UserEnterExclusive();
715 pne
= (PNOTIFYEVENT
)Param
;
717 pWnd
= UserGetWindowObject(hWnd
);
720 IntNotifyWinEvent(pne
->event
, pWnd
, pne
->idObject
, pne
->idChild
, pne
->flags
);
724 case HWNDPARAM_ROUTINE_CLEARWINDOWSTATE
:
727 UserEnterExclusive();
728 pWnd
= UserGetWindowObject(hWnd
);
729 if (pWnd
) IntClearWindowState(pWnd
, (UINT
)Param
);
733 case HWNDPARAM_ROUTINE_SETWINDOWSTATE
:
736 UserEnterExclusive();
737 pWnd
= UserGetWindowObject(hWnd
);
738 if (pWnd
) IntSetWindowState(pWnd
, (UINT
)Param
);
751 NtUserCallHwndParamLock(
758 USER_REFERENCE_ENTRY Ref
;
759 DECLARE_RETURN(DWORD
);
761 TRACE("Enter NtUserCallHwndParamLock\n");
762 UserEnterExclusive();
764 if (!(Window
= UserGetWindowObject(hWnd
)))
768 UserRefObjectCo(Window
, &Ref
);
772 case TWOPARAM_ROUTINE_VALIDATERGN
:
774 PREGION Rgn
= REGION_LockRgn((HRGN
)Param
);
777 Ret
= (DWORD
)co_UserRedrawWindow( Window
, NULL
, Rgn
, RDW_VALIDATE
);
778 REGION_UnlockRgn(Rgn
);
784 UserDerefObjectCo(Window
);
789 TRACE("Leave NtUserCallHwndParamLock, ret=%lu\n",_ret_
);