3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * PURPOSE: Misc User funcs
6 * FILE: subsys/win32k/ntuser/misc.c
7 * PROGRAMER: Ge van Geldorp (ge@gse.nl)
17 /* registered Logon process */
18 PW32PROCESS LogonProcess
= NULL
;
20 VOID
W32kRegisterPrimitiveMessageQueue(VOID
)
22 extern PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue
;
23 if( !pmPrimitiveMessageQueue
)
26 pThread
= PsGetCurrentThreadWin32Thread();
27 if( pThread
&& pThread
->MessageQueue
)
29 pmPrimitiveMessageQueue
= pThread
->MessageQueue
;
30 IntReferenceMessageQueue(pmPrimitiveMessageQueue
);
31 DPRINT( "Installed primitive input queue.\n" );
36 DPRINT1( "Alert! Someone is trying to steal the primitive queue.\n" );
40 VOID
W32kUnregisterPrimitiveMessageQueue(VOID
)
42 extern PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue
;
43 IntDereferenceMessageQueue(pmPrimitiveMessageQueue
);
44 pmPrimitiveMessageQueue
= NULL
;
47 PUSER_MESSAGE_QUEUE
W32kGetPrimitiveMessageQueue()
49 extern PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue
;
50 return pmPrimitiveMessageQueue
;
54 co_IntRegisterLogonProcess(HANDLE ProcessId
, BOOL Register
)
58 CSR_API_MESSAGE Request
;
60 Status
= PsLookupProcessByProcessId(ProcessId
,
62 if (!NT_SUCCESS(Status
))
64 SetLastWin32Error(RtlNtStatusToDosError(Status
));
70 /* Register the logon process */
71 if (LogonProcess
!= NULL
)
73 ObDereferenceObject(Process
);
77 LogonProcess
= (PW32PROCESS
)Process
->Win32Process
;
81 /* Deregister the logon process */
82 if (LogonProcess
!= (PW32PROCESS
)Process
->Win32Process
)
84 ObDereferenceObject(Process
);
91 ObDereferenceObject(Process
);
93 Request
.Type
= MAKE_CSR_API(REGISTER_LOGON_PROCESS
, CSR_GUI
);
94 Request
.Data
.RegisterLogonProcessRequest
.ProcessId
= ProcessId
;
95 Request
.Data
.RegisterLogonProcessRequest
.Register
= Register
;
97 Status
= co_CsrNotify(&Request
);
98 if (! NT_SUCCESS(Status
))
100 DPRINT1("Failed to register logon process with CSRSS\n");
112 NtUserCallNoParam(DWORD Routine
)
115 DECLARE_RETURN(DWORD
);
117 DPRINT("Enter NtUserCallNoParam\n");
118 UserEnterExclusive();
122 case NOPARAM_ROUTINE_REGISTER_PRIMITIVE
:
123 W32kRegisterPrimitiveMessageQueue();
124 Result
= (DWORD
)TRUE
;
127 case NOPARAM_ROUTINE_DESTROY_CARET
:
128 Result
= (DWORD
)co_IntDestroyCaret(PsGetCurrentThread()->Tcb
.Win32Thread
);
131 case NOPARAM_ROUTINE_INIT_MESSAGE_PUMP
:
132 Result
= (DWORD
)IntInitMessagePumpHook();
135 case NOPARAM_ROUTINE_UNINIT_MESSAGE_PUMP
:
136 Result
= (DWORD
)IntUninitMessagePumpHook();
139 case NOPARAM_ROUTINE_GETMESSAGEEXTRAINFO
:
140 Result
= (DWORD
)MsqGetMessageExtraInfo();
143 case NOPARAM_ROUTINE_ANYPOPUP
:
144 Result
= (DWORD
)IntAnyPopup();
147 case NOPARAM_ROUTINE_CSRSS_INITIALIZED
:
148 Result
= (DWORD
)CsrInit();
151 case NOPARAM_ROUTINE_MSQCLEARWAKEMASK
:
152 RETURN( (DWORD
)IntMsqClearWakeMask());
155 DPRINT1("Calling invalid routine number 0x%x in NtUserCallNoParam\n", Routine
);
156 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
162 DPRINT("Leave NtUserCallNoParam, ret=%i\n",_ret_
);
177 DECLARE_RETURN(DWORD
);
180 DPRINT("Enter NtUserCallOneParam\n");
183 if (Routine
== ONEPARAM_ROUTINE_SHOWCURSOR
)
185 PWINSTATION_OBJECT WinSta
= PsGetCurrentThreadWin32Thread()->Desktop
->WindowStation
;
186 PSYSTEM_CURSORINFO CurInfo
;
191 BITMAPOBJ
*BitmapObj
;
196 if(!(Screen
= IntGetScreenDC()))
198 return showpointer
; /* No mouse */
201 dc
= DC_LockDc(Screen
);
205 return showpointer
; /* No mouse */
208 dcbmp
= dc
->w
.hBitmap
;
211 BitmapObj
= BITMAPOBJ_LockBitmap(dcbmp
);
214 BITMAPOBJ_UnlockBitmap(BitmapObj
);
215 return showpointer
; /* No Mouse */
218 SurfObj
= &BitmapObj
->SurfObj
;
221 BITMAPOBJ_UnlockBitmap(BitmapObj
);
222 return showpointer
; /* No mouse */
225 ppdev
= GDIDEV(SurfObj
);
229 BITMAPOBJ_UnlockBitmap(BitmapObj
);
230 return showpointer
; /* No mouse */
233 pgp
= &ppdev
->Pointer
;
235 CurInfo
= IntGetSysCursorInfo(WinSta
);
240 showpointer
= pgp
->ShowPointer
;
242 if (showpointer
>= 0)
244 //ppdev->SafetyRemoveCount = 1;
245 //ppdev->SafetyRemoveLevel = 1;
246 EngMovePointer(SurfObj
,-1,-1,NULL
);
247 CurInfo
->ShowingCursor
= 0;
254 showpointer
= pgp
->ShowPointer
;
259 //ppdev->SafetyRemoveCount = 0;
260 //ppdev->SafetyRemoveLevel = 0;
261 EngMovePointer(SurfObj
,-1,-1,NULL
);
262 CurInfo
->ShowingCursor
= CURSOR_SHOWING
;
266 BITMAPOBJ_UnlockBitmap(BitmapObj
);
271 UserEnterExclusive();
275 case ONEPARAM_ROUTINE_GETMENU
:
277 PWINDOW_OBJECT Window
;
280 if(!(Window
= UserGetWindowObject((HWND
)Param
)))
285 Result
= (DWORD
)Window
->IDMenu
;
290 case ONEPARAM_ROUTINE_ISWINDOWUNICODE
:
292 PWINDOW_OBJECT Window
;
295 Window
= UserGetWindowObject((HWND
)Param
);
300 Result
= Window
->Unicode
;
304 case ONEPARAM_ROUTINE_WINDOWFROMDC
:
305 RETURN( (DWORD
)IntWindowFromDC((HDC
)Param
));
307 case ONEPARAM_ROUTINE_GETWNDCONTEXTHLPID
:
309 PWINDOW_OBJECT Window
;
312 Window
= UserGetWindowObject((HWND
)Param
);
318 Result
= Window
->ContextHelpId
;
323 case ONEPARAM_ROUTINE_SWAPMOUSEBUTTON
:
325 PWINSTATION_OBJECT WinSta
;
329 Status
= IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation
,
333 if (!NT_SUCCESS(Status
))
334 RETURN( (DWORD
)FALSE
);
337 Result = (DWORD)IntSwapMouseButton(WinStaObject, (BOOL)Param); */
340 ObDereferenceObject(WinSta
);
344 case ONEPARAM_ROUTINE_SWITCHCARETSHOWING
:
345 RETURN( (DWORD
)IntSwitchCaretShowing((PVOID
)Param
));
347 case ONEPARAM_ROUTINE_SETCARETBLINKTIME
:
348 RETURN( (DWORD
)IntSetCaretBlinkTime((UINT
)Param
));
350 case ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS
:
351 RETURN( (DWORD
)IntEnumClipboardFormats((UINT
)Param
));
353 case ONEPARAM_ROUTINE_GETWINDOWINSTANCE
:
355 PWINDOW_OBJECT Window
;
358 if(!(Window
= UserGetWindowObject((HWND
)Param
)))
363 Result
= (DWORD
)Window
->Instance
;
367 case ONEPARAM_ROUTINE_SETMESSAGEEXTRAINFO
:
368 RETURN( (DWORD
)MsqSetMessageExtraInfo((LPARAM
)Param
));
370 case ONEPARAM_ROUTINE_GETCURSORPOSITION
:
372 PWINSTATION_OBJECT WinSta
;
377 RETURN( (DWORD
)FALSE
);
378 Status
= IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation
,
382 if (!NT_SUCCESS(Status
))
383 RETURN( (DWORD
)FALSE
);
385 /* FIXME - check if process has WINSTA_READATTRIBUTES */
386 IntGetCursorLocation(WinSta
, &Pos
);
388 Status
= MmCopyToCaller((PPOINT
)Param
, &Pos
, sizeof(POINT
));
389 if(!NT_SUCCESS(Status
))
391 ObDereferenceObject(WinSta
);
392 SetLastNtError(Status
);
396 ObDereferenceObject(WinSta
);
398 RETURN( (DWORD
)TRUE
);
401 case ONEPARAM_ROUTINE_ISWINDOWINDESTROY
:
403 PWINDOW_OBJECT Window
;
406 if(!(Window
= UserGetWindowObject((HWND
)Param
)))
411 Result
= (DWORD
)IntIsWindowInDestroy(Window
);
416 case ONEPARAM_ROUTINE_ENABLEPROCWNDGHSTING
:
419 PW32PROCESS Process
= PsGetCurrentProcessWin32Process();
423 Enable
= (BOOL
)(Param
!= 0);
427 Process
->Flags
&= ~W32PF_NOWINDOWGHOSTING
;
431 Process
->Flags
|= W32PF_NOWINDOWGHOSTING
;
440 case ONEPARAM_ROUTINE_MSQSETWAKEMASK
:
441 RETURN( (DWORD
)IntMsqSetWakeMask(Param
));
443 case ONEPARAM_ROUTINE_GETKEYBOARDTYPE
:
444 RETURN( UserGetKeyboardType(Param
));
446 case ONEPARAM_ROUTINE_GETKEYBOARDLAYOUT
:
447 RETURN( (DWORD
)UserGetKeyboardLayout(Param
));
449 DPRINT1("Calling invalid routine number 0x%x in NtUserCallOneParam(), Param=0x%x\n",
451 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
455 DPRINT("Leave NtUserCallOneParam, ret=%i\n",_ret_
);
472 PWINDOW_OBJECT Window
;
473 DECLARE_RETURN(DWORD
);
475 DPRINT("Enter NtUserCallTwoParam\n");
476 UserEnterExclusive();
480 case TWOPARAM_ROUTINE_SETDCPENCOLOR
:
482 RETURN( (DWORD
)IntSetDCColor((HDC
)Param1
, OBJ_PEN
, (COLORREF
)Param2
));
484 case TWOPARAM_ROUTINE_SETDCBRUSHCOLOR
:
486 RETURN( (DWORD
)IntSetDCColor((HDC
)Param1
, OBJ_BRUSH
, (COLORREF
)Param2
));
488 case TWOPARAM_ROUTINE_GETDCCOLOR
:
490 RETURN( (DWORD
)IntGetDCColor((HDC
)Param1
, (ULONG
)Param2
));
492 case TWOPARAM_ROUTINE_GETWINDOWRGNBOX
:
496 Window
= UserGetWindowObject((HWND
)Param1
);
497 if (!Window
) RETURN(ERROR
);
499 Ret
= (DWORD
)IntGetWindowRgnBox(Window
, &rcRect
);
500 Status
= MmCopyToCaller((PVOID
)Param2
, &rcRect
, sizeof(RECT
));
501 if(!NT_SUCCESS(Status
))
503 SetLastNtError(Status
);
508 case TWOPARAM_ROUTINE_GETWINDOWRGN
:
510 Window
= UserGetWindowObject((HWND
)Param1
);
511 if (!Window
) RETURN(ERROR
);
513 RETURN( (DWORD
)IntGetWindowRgn(Window
, (HRGN
)Param2
));
515 case TWOPARAM_ROUTINE_SETMENUBARHEIGHT
:
518 PMENU_OBJECT MenuObject
= IntGetMenuObject((HMENU
)Param1
);
524 Ret
= (MenuObject
->MenuInfo
.Height
== (int)Param2
);
525 MenuObject
->MenuInfo
.Height
= (int)Param2
;
528 Ret
= (DWORD
)MenuObject
->MenuInfo
.Height
;
529 IntReleaseMenuObject(MenuObject
);
532 case TWOPARAM_ROUTINE_SETMENUITEMRECT
:
535 SETMENUITEMRECT smir
;
536 PMENU_OBJECT MenuObject
= IntGetMenuObject((HMENU
)Param1
);
540 if(!NT_SUCCESS(MmCopyFromCaller(&smir
, (PVOID
)Param2
, sizeof(SETMENUITEMRECT
))))
542 IntReleaseMenuObject(MenuObject
);
546 Ret
= IntSetMenuItemRect(MenuObject
, smir
.uItem
, smir
.fByPosition
, &smir
.rcRect
);
548 IntReleaseMenuObject(MenuObject
);
552 case TWOPARAM_ROUTINE_SETGUITHRDHANDLE
:
554 PUSER_MESSAGE_QUEUE MsgQueue
= ((PW32THREAD
)PsGetCurrentThread()->Tcb
.Win32Thread
)->MessageQueue
;
557 RETURN( (DWORD
)MsqSetStateWindow(MsgQueue
, (ULONG
)Param1
, (HWND
)Param2
));
560 case TWOPARAM_ROUTINE_ENABLEWINDOW
:
564 case TWOPARAM_ROUTINE_UNKNOWN
:
568 case TWOPARAM_ROUTINE_SHOWOWNEDPOPUPS
:
570 Window
= UserGetWindowObject((HWND
)Param1
);
571 if (!Window
) RETURN(0);
573 RETURN( (DWORD
)IntShowOwnedPopups(Window
, (BOOL
) Param2
));
576 case TWOPARAM_ROUTINE_ROS_SHOWWINDOW
:
578 #define WIN_NEEDS_SHOW_OWNEDPOPUP (0x00000040)
579 DPRINT1("ROS_SHOWWINDOW\n");
581 if (!(Window
= UserGetWindowObject((HWND
)Param1
)))
588 if (!(Window
->Flags
& WIN_NEEDS_SHOW_OWNEDPOPUP
))
592 Window
->Flags
&= ~WIN_NEEDS_SHOW_OWNEDPOPUP
;
595 Window
->Flags
|= WIN_NEEDS_SHOW_OWNEDPOPUP
;
597 DPRINT1("ROS_SHOWWINDOW ---> 0x%x\n",Window
->Flags
);
601 case TWOPARAM_ROUTINE_SWITCHTOTHISWINDOW
:
605 case TWOPARAM_ROUTINE_SETWNDCONTEXTHLPID
:
607 if(!(Window
= UserGetWindowObject((HWND
)Param1
)))
609 RETURN( (DWORD
)FALSE
);
612 Window
->ContextHelpId
= Param2
;
614 RETURN( (DWORD
)TRUE
);
616 case TWOPARAM_ROUTINE_SETCARETPOS
:
617 RETURN( (DWORD
)co_IntSetCaretPos((int)Param1
, (int)Param2
));
619 case TWOPARAM_ROUTINE_GETWINDOWINFO
:
624 if(!(Window
= UserGetWindowObject((HWND
)Param1
)))
631 * According to WINE, Windows' doesn't check the cbSize field
634 Status
= MmCopyFromCaller(&wi
.cbSize
, (PVOID
)Param2
, sizeof(wi
.cbSize
));
635 if(!NT_SUCCESS(Status
))
637 SetLastNtError(Status
);
641 if(wi
.cbSize
!= sizeof(WINDOWINFO
))
643 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
648 if((Ret
= (DWORD
)IntGetWindowInfo(Window
, &wi
)))
650 Status
= MmCopyToCaller((PVOID
)Param2
, &wi
, sizeof(WINDOWINFO
));
651 if(!NT_SUCCESS(Status
))
653 SetLastNtError(Status
);
661 case TWOPARAM_ROUTINE_REGISTERLOGONPROC
:
662 RETURN( (DWORD
)co_IntRegisterLogonProcess((HANDLE
)Param1
, (BOOL
)Param2
));
664 case TWOPARAM_ROUTINE_SETSYSCOLORS
:
675 /* FIXME - we should make use of SEH here... */
677 Status
= MmCopyFromCaller(&ChangeSysColors
, (PVOID
)Param1
, sizeof(ChangeSysColors
));
678 if(!NT_SUCCESS(Status
))
680 SetLastNtError(Status
);
684 Buffer
= ExAllocatePool(PagedPool
, (Param2
* sizeof(INT
)) + (Param2
* sizeof(COLORREF
)));
687 INT
*Elements
= (INT
*)Buffer
;
688 COLORREF
*Colors
= (COLORREF
*)Buffer
+ Param2
;
690 Status
= MmCopyFromCaller(Elements
, ChangeSysColors
.Elements
, Param2
* sizeof(INT
));
691 if(NT_SUCCESS(Status
))
693 Status
= MmCopyFromCaller(Colors
, ChangeSysColors
.Colors
, Param2
* sizeof(COLORREF
));
694 if(NT_SUCCESS(Status
))
696 Ret
= (DWORD
)IntSetSysColors((UINT
)Param2
, Elements
, Colors
);
699 SetLastNtError(Status
);
702 SetLastNtError(Status
);
711 case TWOPARAM_ROUTINE_GETSYSCOLORBRUSHES
:
712 case TWOPARAM_ROUTINE_GETSYSCOLORPENS
:
713 case TWOPARAM_ROUTINE_GETSYSCOLORS
:
724 /* FIXME - we should make use of SEH here... */
726 Buffer
.Pointer
= ExAllocatePool(PagedPool
, Param2
* sizeof(HANDLE
));
727 if(Buffer
.Pointer
!= NULL
)
731 case TWOPARAM_ROUTINE_GETSYSCOLORBRUSHES
:
732 Ret
= (DWORD
)IntGetSysColorBrushes(Buffer
.Brushes
, (UINT
)Param2
);
734 case TWOPARAM_ROUTINE_GETSYSCOLORPENS
:
735 Ret
= (DWORD
)IntGetSysColorPens(Buffer
.Pens
, (UINT
)Param2
);
737 case TWOPARAM_ROUTINE_GETSYSCOLORS
:
738 Ret
= (DWORD
)IntGetSysColors(Buffer
.Colors
, (UINT
)Param2
);
747 Status
= MmCopyToCaller((PVOID
)Param1
, Buffer
.Pointer
, Param2
* sizeof(HANDLE
));
748 if(!NT_SUCCESS(Status
))
750 SetLastNtError(Status
);
755 ExFreePool(Buffer
.Pointer
);
761 DPRINT1("Calling invalid routine number 0x%x in NtUserCallTwoParam(), Param1=0x%x Parm2=0x%x\n",
762 Routine
, Param1
, Param2
);
763 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
767 DPRINT("Leave NtUserCallTwoParam, ret=%i\n",_ret_
);
783 PWINDOW_OBJECT Window
;
784 USER_REFERENCE_ENTRY Ref
;
785 DECLARE_RETURN(BOOLEAN
);
787 DPRINT("Enter NtUserCallHwndLock\n");
788 UserEnterExclusive();
790 if (!(Window
= UserGetWindowObject(hWnd
)))
794 UserRefObjectCo(Window
, &Ref
);
796 /* FIXME: Routine can be 0x53 - 0x5E */
799 case HWNDLOCK_ROUTINE_ARRANGEICONICWINDOWS
:
800 co_WinPosArrangeIconicWindows(Window
);
803 case HWNDLOCK_ROUTINE_DRAWMENUBAR
:
806 DPRINT("HWNDLOCK_ROUTINE_DRAWMENUBAR\n");
808 if (!((Window
->Style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
))
811 if(!(Menu
= UserGetMenuObject((HMENU
) Window
->IDMenu
)))
814 Menu
->MenuInfo
.WndOwner
= hWnd
;
815 Menu
->MenuInfo
.Height
= 0;
817 co_WinPosSetWindowPos(Window
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
818 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
824 case HWNDLOCK_ROUTINE_REDRAWFRAME
:
828 case HWNDLOCK_ROUTINE_SETFOREGROUNDWINDOW
:
829 Ret
= co_IntSetForegroundWindow(Window
);
832 case HWNDLOCK_ROUTINE_UPDATEWINDOW
:
837 UserDerefObjectCo(Window
);
842 DPRINT("Leave NtUserCallHwndLock, ret=%i\n",_ret_
);
858 case HWNDOPT_ROUTINE_SETPROGMANWINDOW
:
859 GetW32ThreadInfo()->Desktop
->hProgmanWindow
= Param
;
862 case HWNDOPT_ROUTINE_SETTASKMANWINDOW
:
863 GetW32ThreadInfo()->Desktop
->hTaskManWindow
= Param
;
874 NtUserGetThreadState(
877 DECLARE_RETURN(DWORD
);
879 DPRINT("Enter NtUserGetThreadState\n");
880 if (Routine
!= THREADSTATE_GETTHREADINFO
)
886 UserEnterExclusive();
891 case THREADSTATE_GETTHREADINFO
:
895 case THREADSTATE_FOCUSWINDOW
:
896 RETURN( (DWORD
)IntGetThreadFocusWindow());
897 case THREADSTATE_PROGMANWINDOW
:
898 RETURN( (DWORD
)GetW32ThreadInfo()->Desktop
->hProgmanWindow
);
899 case THREADSTATE_TASKMANWINDOW
:
900 RETURN( (DWORD
)GetW32ThreadInfo()->Desktop
->hTaskManWindow
);
905 DPRINT("Leave NtUserGetThreadState, ret=%i\n",_ret_
);
911 IntGetFontMetricSetting(LPWSTR lpValueName
, PLOGFONTW font
)
913 RTL_QUERY_REGISTRY_TABLE QueryTable
[2];
915 /* Firefox 1.0.7 depends on the lfHeight value being negative */
916 static LOGFONTW DefaultFont
= {
917 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
918 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
922 RtlZeroMemory(&QueryTable
, sizeof(QueryTable
));
924 QueryTable
[0].Name
= lpValueName
;
925 QueryTable
[0].Flags
= RTL_QUERY_REGISTRY_DIRECT
| RTL_QUERY_REGISTRY_REQUIRED
;
926 QueryTable
[0].EntryContext
= font
;
928 Status
= RtlQueryRegistryValues(
930 L
"Control Panel\\Desktop\\WindowMetrics",
935 if (!NT_SUCCESS(Status
))
937 RtlCopyMemory(font
, &DefaultFont
, sizeof(LOGFONTW
));
942 IntSystemParametersInfo(
948 PWINSTATION_OBJECT WinStaObject
;
951 static BOOL bInitialized
= FALSE
;
952 static LOGFONTW IconFont
;
953 static NONCLIENTMETRICSW pMetrics
;
954 static BOOL GradientCaptions
= TRUE
;
955 static UINT FocusBorderHeight
= 1;
956 static UINT FocusBorderWidth
= 1;
960 RtlZeroMemory(&IconFont
, sizeof(LOGFONTW
));
961 RtlZeroMemory(&pMetrics
, sizeof(NONCLIENTMETRICSW
));
963 IntGetFontMetricSetting(L
"CaptionFont", &pMetrics
.lfCaptionFont
);
964 IntGetFontMetricSetting(L
"SmCaptionFont", &pMetrics
.lfSmCaptionFont
);
965 IntGetFontMetricSetting(L
"MenuFont", &pMetrics
.lfMenuFont
);
966 IntGetFontMetricSetting(L
"StatusFont", &pMetrics
.lfStatusFont
);
967 IntGetFontMetricSetting(L
"MessageFont", &pMetrics
.lfMessageFont
);
968 IntGetFontMetricSetting(L
"IconFont", &IconFont
);
970 pMetrics
.iBorderWidth
= 1;
971 pMetrics
.iScrollWidth
= UserGetSystemMetrics(SM_CXVSCROLL
);
972 pMetrics
.iScrollHeight
= UserGetSystemMetrics(SM_CYHSCROLL
);
973 pMetrics
.iCaptionWidth
= UserGetSystemMetrics(SM_CXSIZE
);
974 pMetrics
.iCaptionHeight
= UserGetSystemMetrics(SM_CYSIZE
);
975 pMetrics
.iSmCaptionWidth
= UserGetSystemMetrics(SM_CXSMSIZE
);
976 pMetrics
.iSmCaptionHeight
= UserGetSystemMetrics(SM_CYSMSIZE
);
977 pMetrics
.iMenuWidth
= UserGetSystemMetrics(SM_CXMENUSIZE
);
978 pMetrics
.iMenuHeight
= UserGetSystemMetrics(SM_CYMENUSIZE
);
979 pMetrics
.cbSize
= sizeof(NONCLIENTMETRICSW
);
986 case SPI_SETDOUBLECLKWIDTH
:
987 case SPI_SETDOUBLECLKHEIGHT
:
988 case SPI_SETDOUBLECLICKTIME
:
989 case SPI_SETDESKWALLPAPER
:
990 case SPI_GETDESKWALLPAPER
:
991 case SPI_GETWHEELSCROLLLINES
:
992 case SPI_GETWHEELSCROLLCHARS
:
993 case SPI_SETSCREENSAVERRUNNING
:
994 case SPI_GETSCREENSAVERRUNNING
:
995 case SPI_GETSCREENSAVETIMEOUT
:
996 case SPI_SETSCREENSAVETIMEOUT
:
997 case SPI_GETFLATMENU
:
998 case SPI_SETFLATMENU
:
1000 PSYSTEM_CURSORINFO CurInfo
;
1002 Status
= IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation
,
1006 if(!NT_SUCCESS(Status
))
1008 SetLastNtError(Status
);
1009 return (DWORD
)FALSE
;
1014 case SPI_GETFLATMENU
:
1015 if (pvParam
!= NULL
) *((UINT
*)pvParam
) = WinStaObject
->FlatMenu
;
1018 case SPI_SETFLATMENU
:
1019 WinStaObject
->FlatMenu
= uiParam
;
1021 case SPI_GETSCREENSAVETIMEOUT
:
1022 if (pvParam
!= NULL
) *((UINT
*)pvParam
) = WinStaObject
->ScreenSaverTimeOut
;
1025 case SPI_SETSCREENSAVETIMEOUT
:
1026 WinStaObject
->ScreenSaverTimeOut
= uiParam
;
1028 case SPI_GETSCREENSAVERRUNNING
:
1029 if (pvParam
!= NULL
) *((BOOL
*)pvParam
) = WinStaObject
->ScreenSaverRunning
;
1032 case SPI_SETSCREENSAVERRUNNING
:
1033 if (pvParam
!= NULL
) *((BOOL
*)pvParam
) = WinStaObject
->ScreenSaverRunning
;
1034 WinStaObject
->ScreenSaverRunning
= uiParam
;
1036 case SPI_GETWHEELSCROLLLINES
:
1037 CurInfo
= IntGetSysCursorInfo(WinStaObject
);
1038 if (pvParam
!= NULL
) *((UINT
*)pvParam
) = CurInfo
->WheelScroLines
;
1039 /* FIXME add this value to scroll list as scroll value ?? */
1042 case SPI_GETWHEELSCROLLCHARS
:
1043 CurInfo
= IntGetSysCursorInfo(WinStaObject
);
1044 if (pvParam
!= NULL
) *((UINT
*)pvParam
) = CurInfo
->WheelScroChars
;
1045 // FIXME add this value to scroll list as scroll value ??
1048 case SPI_SETDOUBLECLKWIDTH
:
1049 CurInfo
= IntGetSysCursorInfo(WinStaObject
);
1050 /* FIXME limit the maximum value? */
1051 CurInfo
->DblClickWidth
= uiParam
;
1053 case SPI_SETDOUBLECLKHEIGHT
:
1054 CurInfo
= IntGetSysCursorInfo(WinStaObject
);
1055 /* FIXME limit the maximum value? */
1056 CurInfo
->DblClickHeight
= uiParam
;
1058 case SPI_SETDOUBLECLICKTIME
:
1059 CurInfo
= IntGetSysCursorInfo(WinStaObject
);
1060 /* FIXME limit the maximum time to 1000 ms? */
1061 CurInfo
->DblClickSpeed
= uiParam
;
1063 case SPI_SETDESKWALLPAPER
:
1065 /* This function expects different parameters than the user mode version!
1067 We let the user mode code load the bitmap, it passed the handle to
1068 the bitmap. We'll change it's ownership to system and replace it with
1069 the current wallpaper bitmap */
1070 HBITMAP hOldBitmap
, hNewBitmap
;
1071 UNICODE_STRING Key
= RTL_CONSTANT_STRING(L
"Control Panel\\Desktop");
1072 UNICODE_STRING Tile
= RTL_CONSTANT_STRING(L
"TileWallpaper");
1073 UNICODE_STRING Style
= RTL_CONSTANT_STRING(L
"WallpaperStyle");
1074 UNICODE_STRING KeyPath
;
1075 OBJECT_ATTRIBUTES KeyAttributes
;
1076 OBJECT_ATTRIBUTES ObjectAttributes
;
1078 HANDLE CurrentUserKey
= NULL
;
1079 HANDLE KeyHandle
= NULL
;
1080 PKEY_VALUE_PARTIAL_INFORMATION KeyValuePartialInfo
;
1082 ULONG ResLength
= 0;
1087 hNewBitmap
= *(HBITMAP
*)pvParam
;
1088 if(hNewBitmap
!= NULL
)
1091 /* try to get the size of the wallpaper */
1092 if(!(bmp
= BITMAPOBJ_LockBitmap(hNewBitmap
)))
1094 ObDereferenceObject(WinStaObject
);
1097 WinStaObject
->cxWallpaper
= bmp
->SurfObj
.sizlBitmap
.cx
;
1098 WinStaObject
->cyWallpaper
= bmp
->SurfObj
.sizlBitmap
.cy
;
1100 BITMAPOBJ_UnlockBitmap(bmp
);
1102 /* change the bitmap's ownership */
1103 GDIOBJ_SetOwnership(GdiHandleTable
, hNewBitmap
, NULL
);
1105 hOldBitmap
= (HBITMAP
)InterlockedExchange((LONG
*)&WinStaObject
->hbmWallpaper
, (LONG
)hNewBitmap
);
1106 if(hOldBitmap
!= NULL
)
1108 /* delete the old wallpaper */
1109 NtGdiDeleteObject(hOldBitmap
);
1114 /*default value is center */
1115 WinStaObject
->WallpaperMode
= wmCenter
;
1119 /* Get a handle to the current users settings */
1120 RtlFormatCurrentUserKeyPath(&KeyPath
);
1121 InitializeObjectAttributes(&ObjectAttributes
,&KeyPath
,OBJ_CASE_INSENSITIVE
,NULL
,NULL
);
1122 ZwOpenKey(&CurrentUserKey
, KEY_READ
, &ObjectAttributes
);
1123 RtlFreeUnicodeString(&KeyPath
);
1125 /* open up the settings to read the values */
1126 InitializeObjectAttributes(&KeyAttributes
, &Key
, OBJ_CASE_INSENSITIVE
,
1127 CurrentUserKey
, NULL
);
1128 ZwOpenKey(&KeyHandle
, KEY_READ
, &KeyAttributes
);
1129 ZwClose(CurrentUserKey
);
1131 /* read the tile value in the registry */
1132 Status
= ZwQueryValueKey(KeyHandle
, &Tile
, KeyValuePartialInformation
,
1135 /* fall back to .DEFAULT if we didnt find values */
1136 if(Status
== STATUS_INVALID_HANDLE
)
1138 RtlInitUnicodeString (&KeyPath
,L
"\\Registry\\User\\.Default\\Control Panel\\Desktop");
1139 InitializeObjectAttributes(&KeyAttributes
, &KeyPath
, OBJ_CASE_INSENSITIVE
,
1141 ZwOpenKey(&KeyHandle
, KEY_READ
, &KeyAttributes
);
1142 ZwQueryValueKey(KeyHandle
, &Tile
, KeyValuePartialInformation
,
1146 ResLength
+= sizeof(KEY_VALUE_PARTIAL_INFORMATION
);
1147 KeyValuePartialInfo
= ExAllocatePoolWithTag(PagedPool
, ResLength
, TAG_STRING
);
1150 if(!KeyValuePartialInfo
)
1156 Status
= ZwQueryValueKey(KeyHandle
, &Tile
, KeyValuePartialInformation
,
1157 (PVOID
)KeyValuePartialInfo
, Length
, &ResLength
);
1158 if(!NT_SUCCESS(Status
) || (KeyValuePartialInfo
->Type
!= REG_SZ
))
1161 ExFreePool(KeyValuePartialInfo
);
1165 Tile
.Length
= KeyValuePartialInfo
->DataLength
;
1166 Tile
.MaximumLength
= KeyValuePartialInfo
->DataLength
;
1167 Tile
.Buffer
= (PWSTR
)KeyValuePartialInfo
->Data
;
1169 Status
= RtlUnicodeStringToInteger(&Tile
, 0, &TileNum
);
1170 if(!NT_SUCCESS(Status
))
1174 ExFreePool(KeyValuePartialInfo
);
1176 /* start over again and look for the style*/
1178 Status
= ZwQueryValueKey(KeyHandle
, &Style
, KeyValuePartialInformation
,
1181 ResLength
+= sizeof(KEY_VALUE_PARTIAL_INFORMATION
);
1182 KeyValuePartialInfo
= ExAllocatePoolWithTag(PagedPool
, ResLength
, TAG_STRING
);
1185 if(!KeyValuePartialInfo
)
1191 Status
= ZwQueryValueKey(KeyHandle
, &Style
, KeyValuePartialInformation
,
1192 (PVOID
)KeyValuePartialInfo
, Length
, &ResLength
);
1193 if(!NT_SUCCESS(Status
) || (KeyValuePartialInfo
->Type
!= REG_SZ
))
1196 ExFreePool(KeyValuePartialInfo
);
1200 Style
.Length
= KeyValuePartialInfo
->DataLength
;
1201 Style
.MaximumLength
= KeyValuePartialInfo
->DataLength
;
1202 Style
.Buffer
= (PWSTR
)KeyValuePartialInfo
->Data
;
1204 Status
= RtlUnicodeStringToInteger(&Style
, 0, &StyleNum
);
1205 if(!NT_SUCCESS(Status
))
1209 ExFreePool(KeyValuePartialInfo
);
1211 /* Check the values we found in the registry */
1212 if(TileNum
&& !StyleNum
)
1214 WinStaObject
->WallpaperMode
= wmTile
;
1216 else if(!TileNum
&& StyleNum
== 2)
1218 WinStaObject
->WallpaperMode
= wmStretch
;
1224 case SPI_GETDESKWALLPAPER
:
1225 /* This function expects different parameters than the user mode version!
1227 We basically return the current wallpaper handle - if any. The user
1228 mode version should load the string from the registry and return it
1229 without calling this function */
1231 *(HBITMAP
*)pvParam
= (HBITMAP
)WinStaObject
->hbmWallpaper
;
1235 /* FIXME save the value to the registry */
1237 ObDereferenceObject(WinStaObject
);
1240 case SPI_SETWORKAREA
:
1243 PDESKTOP_OBJECT Desktop
= PsGetCurrentThreadWin32Thread()->Desktop
;
1247 /* FIXME - Set last error */
1252 rc
= (RECT
*)pvParam
;
1253 Desktop
->WorkArea
= *rc
;
1257 case SPI_GETWORKAREA
:
1259 PDESKTOP_OBJECT Desktop
= PsGetCurrentThreadWin32Thread()->Desktop
;
1263 /* FIXME - Set last error */
1268 IntGetDesktopWorkArea(Desktop
, (PRECT
)pvParam
);
1272 case SPI_SETGRADIENTCAPTIONS
:
1274 GradientCaptions
= (pvParam
!= NULL
);
1275 /* FIXME - should be checked if the color depth is higher than 8bpp? */
1278 case SPI_GETGRADIENTCAPTIONS
:
1281 BOOL Ret
= GradientCaptions
;
1283 hDC
= IntGetScreenDC();
1286 Ret
= (NtGdiGetDeviceCaps(hDC
, BITSPIXEL
) > 8) && Ret
;
1289 *((PBOOL
)pvParam
) = Ret
;
1294 case SPI_SETFONTSMOOTHING
:
1296 IntEnableFontRendering(uiParam
!= 0);
1299 case SPI_GETFONTSMOOTHING
:
1302 *((BOOL
*)pvParam
) = IntIsFontRenderingEnabled();
1305 case SPI_GETICONTITLELOGFONT
:
1308 *((LOGFONTW
*)pvParam
) = IconFont
;
1311 case SPI_GETNONCLIENTMETRICS
:
1314 *((NONCLIENTMETRICSW
*)pvParam
) = pMetrics
;
1317 case SPI_GETFOCUSBORDERHEIGHT
:
1320 *((UINT
*)pvParam
) = FocusBorderHeight
;
1323 case SPI_GETFOCUSBORDERWIDTH
:
1326 *((UINT
*)pvParam
) = FocusBorderWidth
;
1329 case SPI_SETFOCUSBORDERHEIGHT
:
1331 FocusBorderHeight
= (UINT
)pvParam
;
1334 case SPI_SETFOCUSBORDERWIDTH
:
1336 FocusBorderWidth
= (UINT
)pvParam
;
1342 DPRINT1("SystemParametersInfo: Unsupported Action 0x%x (uiParam: 0x%x, pvParam: 0x%x, fWinIni: 0x%x)\n",
1343 uiAction
, uiParam
, pvParam
, fWinIni
);
1354 UserSystemParametersInfo(
1364 case SPI_SETDOUBLECLKWIDTH
:
1365 case SPI_SETDOUBLECLKHEIGHT
:
1366 case SPI_SETDOUBLECLICKTIME
:
1367 case SPI_SETGRADIENTCAPTIONS
:
1368 case SPI_SETFONTSMOOTHING
:
1369 case SPI_SETFOCUSBORDERHEIGHT
:
1370 case SPI_SETFOCUSBORDERWIDTH
:
1372 return (DWORD
)IntSystemParametersInfo(uiAction
, uiParam
, pvParam
, fWinIni
);
1374 case SPI_SETWORKAREA
:
1377 Status
= MmCopyFromCaller(&rc
, (PRECT
)pvParam
, sizeof(RECT
));
1378 if(!NT_SUCCESS(Status
))
1380 SetLastNtError(Status
);
1383 return( (DWORD
)IntSystemParametersInfo(uiAction
, uiParam
, &rc
, fWinIni
));
1385 case SPI_GETWORKAREA
:
1389 if(!IntSystemParametersInfo(uiAction
, uiParam
, &rc
, fWinIni
))
1394 Status
= MmCopyToCaller((PRECT
)pvParam
, &rc
, sizeof(RECT
));
1395 if(!NT_SUCCESS(Status
))
1397 SetLastNtError(Status
);
1402 case SPI_GETFONTSMOOTHING
:
1403 case SPI_GETGRADIENTCAPTIONS
:
1404 case SPI_GETFOCUSBORDERHEIGHT
:
1405 case SPI_GETFOCUSBORDERWIDTH
:
1406 case SPI_GETWHEELSCROLLLINES
:
1407 case SPI_GETWHEELSCROLLCHARS
:
1408 case SPI_GETSCREENSAVERRUNNING
:
1409 case SPI_SETSCREENSAVERRUNNING
:
1410 case SPI_GETSCREENSAVETIMEOUT
:
1411 case SPI_SETSCREENSAVETIMEOUT
:
1412 case SPI_GETFLATMENU
:
1413 case SPI_SETFLATMENU
:
1417 if(!IntSystemParametersInfo(uiAction
, uiParam
, &Ret
, fWinIni
))
1422 Status
= MmCopyToCaller(pvParam
, &Ret
, sizeof(BOOL
));
1423 if(!NT_SUCCESS(Status
))
1425 SetLastNtError(Status
);
1430 case SPI_SETDESKWALLPAPER
:
1432 /* !!! As opposed to the user mode version this version accepts a handle
1434 HBITMAP hbmWallpaper
;
1436 Status
= MmCopyFromCaller(&hbmWallpaper
, pvParam
, sizeof(HBITMAP
));
1437 if(!NT_SUCCESS(Status
))
1439 SetLastNtError(Status
);
1442 return( IntSystemParametersInfo(SPI_SETDESKWALLPAPER
, 0, &hbmWallpaper
, fWinIni
));
1444 case SPI_GETDESKWALLPAPER
:
1446 /* !!! As opposed to the user mode version this version returns a handle
1448 HBITMAP hbmWallpaper
;
1451 Ret
= IntSystemParametersInfo(SPI_GETDESKWALLPAPER
, 0, &hbmWallpaper
, fWinIni
);
1453 Status
= MmCopyToCaller(pvParam
, &hbmWallpaper
, sizeof(HBITMAP
));
1454 if(!NT_SUCCESS(Status
))
1456 SetLastNtError(Status
);
1461 case SPI_GETICONTITLELOGFONT
:
1465 if(!IntSystemParametersInfo(uiAction
, uiParam
, &IconFont
, fWinIni
))
1470 Status
= MmCopyToCaller(pvParam
, &IconFont
, sizeof(LOGFONTW
));
1471 if(!NT_SUCCESS(Status
))
1473 SetLastNtError(Status
);
1478 case SPI_GETNONCLIENTMETRICS
:
1480 NONCLIENTMETRICSW metrics
;
1482 Status
= MmCopyFromCaller(&metrics
.cbSize
, pvParam
, sizeof(UINT
));
1483 if(!NT_SUCCESS(Status
))
1485 SetLastNtError(Status
);
1488 if(metrics
.cbSize
!= sizeof(NONCLIENTMETRICSW
))
1490 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1494 if(!IntSystemParametersInfo(uiAction
, uiParam
, &metrics
, fWinIni
))
1499 Status
= MmCopyToCaller(pvParam
, &metrics
.cbSize
, sizeof(NONCLIENTMETRICSW
));
1500 if(!NT_SUCCESS(Status
))
1502 SetLastNtError(Status
);
1509 DPRINT1("UserSystemParametersInfo : uiAction = %x \n",uiAction
);
1524 NtUserSystemParametersInfo(
1530 DECLARE_RETURN(BOOLEAN
);
1532 DPRINT("Enter NtUserSystemParametersInfo\n");
1533 UserEnterExclusive();
1535 RETURN( UserSystemParametersInfo(uiAction
, uiParam
, pvParam
, fWinIni
));
1538 DPRINT("Leave NtUserSystemParametersInfo, ret=%i\n",_ret_
);
1547 NtUserGetDoubleClickTime(VOID
)
1551 PWINSTATION_OBJECT WinStaObject
;
1552 PSYSTEM_CURSORINFO CurInfo
;
1553 DECLARE_RETURN(UINT
);
1555 DPRINT("Enter NtUserGetDoubleClickTime\n");
1558 Status
= IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation
,
1562 if (!NT_SUCCESS(Status
))
1563 RETURN( (DWORD
)FALSE
);
1565 CurInfo
= IntGetSysCursorInfo(WinStaObject
);
1566 Result
= CurInfo
->DblClickSpeed
;
1568 ObDereferenceObject(WinStaObject
);
1572 DPRINT("Leave NtUserGetDoubleClickTime, ret=%i\n",_ret_
);
1579 NtUserGetGUIThreadInfo(
1580 DWORD idThread
, /* if NULL use foreground thread */
1581 LPGUITHREADINFO lpgui
)
1584 PTHRDCARETINFO CaretInfo
;
1585 GUITHREADINFO SafeGui
;
1586 PDESKTOP_OBJECT Desktop
;
1587 PUSER_MESSAGE_QUEUE MsgQueue
;
1588 PETHREAD Thread
= NULL
;
1589 DECLARE_RETURN(BOOLEAN
);
1591 DPRINT("Enter NtUserGetGUIThreadInfo\n");
1594 Status
= MmCopyFromCaller(&SafeGui
, lpgui
, sizeof(DWORD
));
1595 if(!NT_SUCCESS(Status
))
1597 SetLastNtError(Status
);
1601 if(SafeGui
.cbSize
!= sizeof(GUITHREADINFO
))
1603 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1609 Status
= PsLookupThreadByThreadId((HANDLE
)idThread
, &Thread
);
1610 if(!NT_SUCCESS(Status
))
1612 SetLastWin32Error(ERROR_ACCESS_DENIED
);
1615 Desktop
= ((PW32THREAD
)Thread
->Tcb
.Win32Thread
)->Desktop
;
1619 /* get the foreground thread */
1620 PW32THREAD W32Thread
= (PW32THREAD
)PsGetCurrentThread()->Tcb
.Win32Thread
;
1621 Desktop
= W32Thread
->Desktop
;
1624 MsgQueue
= Desktop
->ActiveMessageQueue
;
1627 Thread
= MsgQueue
->Thread
;
1632 if(!Thread
|| !Desktop
)
1634 if(idThread
&& Thread
)
1635 ObDereferenceObject(Thread
);
1636 SetLastWin32Error(ERROR_ACCESS_DENIED
);
1640 MsgQueue
= (PUSER_MESSAGE_QUEUE
)Desktop
->ActiveMessageQueue
;
1641 CaretInfo
= MsgQueue
->CaretInfo
;
1643 SafeGui
.flags
= (CaretInfo
->Visible
? GUI_CARETBLINKING
: 0);
1644 if(MsgQueue
->MenuOwner
)
1645 SafeGui
.flags
|= GUI_INMENUMODE
| MsgQueue
->MenuState
;
1646 if(MsgQueue
->MoveSize
)
1647 SafeGui
.flags
|= GUI_INMOVESIZE
;
1649 /* FIXME add flag GUI_16BITTASK */
1651 SafeGui
.hwndActive
= MsgQueue
->ActiveWindow
;
1652 SafeGui
.hwndFocus
= MsgQueue
->FocusWindow
;
1653 SafeGui
.hwndCapture
= MsgQueue
->CaptureWindow
;
1654 SafeGui
.hwndMenuOwner
= MsgQueue
->MenuOwner
;
1655 SafeGui
.hwndMoveSize
= MsgQueue
->MoveSize
;
1656 SafeGui
.hwndCaret
= CaretInfo
->hWnd
;
1658 SafeGui
.rcCaret
.left
= CaretInfo
->Pos
.x
;
1659 SafeGui
.rcCaret
.top
= CaretInfo
->Pos
.y
;
1660 SafeGui
.rcCaret
.right
= SafeGui
.rcCaret
.left
+ CaretInfo
->Size
.cx
;
1661 SafeGui
.rcCaret
.bottom
= SafeGui
.rcCaret
.top
+ CaretInfo
->Size
.cy
;
1664 ObDereferenceObject(Thread
);
1666 Status
= MmCopyToCaller(lpgui
, &SafeGui
, sizeof(GUITHREADINFO
));
1667 if(!NT_SUCCESS(Status
))
1669 SetLastNtError(Status
);
1676 DPRINT("Leave NtUserGetGUIThreadInfo, ret=%i\n",_ret_
);
1684 NtUserGetGuiResources(
1689 PW32PROCESS W32Process
;
1692 DECLARE_RETURN(DWORD
);
1694 DPRINT("Enter NtUserGetGuiResources\n");
1697 Status
= ObReferenceObjectByHandle(hProcess
,
1698 PROCESS_QUERY_INFORMATION
,
1700 ExGetPreviousMode(),
1704 if(!NT_SUCCESS(Status
))
1706 SetLastNtError(Status
);
1710 W32Process
= (PW32PROCESS
)Process
->Win32Process
;
1713 ObDereferenceObject(Process
);
1714 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1722 Ret
= (DWORD
)W32Process
->GDIObjects
;
1725 case GR_USEROBJECTS
:
1727 Ret
= (DWORD
)W32Process
->UserObjects
;
1732 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1737 ObDereferenceObject(Process
);
1742 DPRINT("Leave NtUserGetGuiResources, ret=%i\n",_ret_
);
1748 IntSafeCopyUnicodeString(PUNICODE_STRING Dest
,
1749 PUNICODE_STRING Source
)
1754 Status
= MmCopyFromCaller(Dest
, Source
, sizeof(UNICODE_STRING
));
1755 if(!NT_SUCCESS(Status
))
1760 if(Dest
->Length
> 0x4000)
1762 return STATUS_UNSUCCESSFUL
;
1766 Dest
->Buffer
= NULL
;
1768 if(Dest
->Length
> 0 && Src
)
1770 Dest
->MaximumLength
= Dest
->Length
;
1771 Dest
->Buffer
= ExAllocatePoolWithTag(PagedPool
, Dest
->MaximumLength
, TAG_STRING
);
1774 return STATUS_NO_MEMORY
;
1777 Status
= MmCopyFromCaller(Dest
->Buffer
, Src
, Dest
->Length
);
1778 if(!NT_SUCCESS(Status
))
1780 ExFreePool(Dest
->Buffer
);
1781 Dest
->Buffer
= NULL
;
1786 return STATUS_SUCCESS
;
1789 /* string is empty */
1790 return STATUS_SUCCESS
;
1794 IntSafeCopyUnicodeStringTerminateNULL(PUNICODE_STRING Dest
,
1795 PUNICODE_STRING Source
)
1800 Status
= MmCopyFromCaller(Dest
, Source
, sizeof(UNICODE_STRING
));
1801 if(!NT_SUCCESS(Status
))
1806 if(Dest
->Length
> 0x4000)
1808 return STATUS_UNSUCCESSFUL
;
1812 Dest
->Buffer
= NULL
;
1814 if(Dest
->Length
> 0 && Src
)
1816 Dest
->MaximumLength
= Dest
->Length
+ sizeof(WCHAR
);
1817 Dest
->Buffer
= ExAllocatePoolWithTag(PagedPool
, Dest
->MaximumLength
, TAG_STRING
);
1820 return STATUS_NO_MEMORY
;
1823 Status
= MmCopyFromCaller(Dest
->Buffer
, Src
, Dest
->Length
);
1824 if(!NT_SUCCESS(Status
))
1826 ExFreePool(Dest
->Buffer
);
1827 Dest
->Buffer
= NULL
;
1831 /* make sure the string is null-terminated */
1832 Src
= (PWSTR
)((PBYTE
)Dest
->Buffer
+ Dest
->Length
);
1835 return STATUS_SUCCESS
;
1838 /* string is empty */
1839 return STATUS_SUCCESS
;
1843 IntUnicodeStringToNULLTerminated(PWSTR
*Dest
, PUNICODE_STRING Src
)
1845 if (Src
->Length
+ sizeof(WCHAR
) <= Src
->MaximumLength
1846 && L
'\0' == Src
->Buffer
[Src
->Length
/ sizeof(WCHAR
)])
1848 /* The unicode_string is already nul terminated. Just reuse it. */
1849 *Dest
= Src
->Buffer
;
1850 return STATUS_SUCCESS
;
1853 *Dest
= ExAllocatePoolWithTag(PagedPool
, Src
->Length
+ sizeof(WCHAR
), TAG_STRING
);
1856 return STATUS_NO_MEMORY
;
1858 RtlCopyMemory(*Dest
, Src
->Buffer
, Src
->Length
);
1859 (*Dest
)[Src
->Length
/ 2] = L
'\0';
1861 return STATUS_SUCCESS
;
1865 IntFreeNULLTerminatedFromUnicodeString(PWSTR NullTerminated
, PUNICODE_STRING UnicodeString
)
1867 if (NullTerminated
!= UnicodeString
->Buffer
)
1869 ExFreePool(NullTerminated
);
1874 NtUserUpdatePerUserSystemParameters(
1879 DECLARE_RETURN(BOOLEAN
);
1881 DPRINT("Enter NtUserUpdatePerUserSystemParameters\n");
1882 UserEnterExclusive();
1884 Result
&= IntDesktopUpdatePerUserSettings(bEnable
);
1888 DPRINT("Leave NtUserUpdatePerUserSystemParameters, ret=%i\n",_ret_
);
1894 GetW32ProcessInfo(VOID
)
1897 PW32PROCESS W32Process
= PsGetCurrentProcessWin32Process();
1899 if (W32Process
== NULL
)
1901 /* FIXME - temporary hack for system threads... */
1905 if (W32Process
->ProcessInfo
== NULL
)
1907 pi
= UserHeapAlloc(sizeof(W32PROCESSINFO
));
1911 sizeof(W32PROCESSINFO
));
1914 pi
->UserHandleTable
= gHandleTable
;
1916 if (InterlockedCompareExchangePointer(&W32Process
->ProcessInfo
,
1925 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
1929 return W32Process
->ProcessInfo
;
1933 GetW32ThreadInfo(VOID
)
1937 PW32THREAD W32Thread
= PsGetCurrentThreadWin32Thread();
1939 if (W32Thread
== NULL
)
1941 /* FIXME - temporary hack for system threads... */
1945 /* allocate a W32THREAD structure if neccessary */
1946 if (W32Thread
->ThreadInfo
== NULL
)
1948 ti
= UserHeapAlloc(sizeof(W32THREADINFO
));
1952 sizeof(W32THREADINFO
));
1955 ti
->kpi
= GetW32ProcessInfo();
1956 ti
->pi
= UserHeapAddressToUser(ti
->kpi
);
1957 if (W32Thread
->Desktop
!= NULL
)
1959 ti
->Desktop
= W32Thread
->Desktop
->DesktopInfo
;
1960 ti
->DesktopHeapDelta
= DesktopHeapGetUserDelta();
1965 ti
->DesktopHeapDelta
= 0;
1968 W32Thread
->ThreadInfo
= ti
;
1969 /* update the TEB */
1970 Teb
= NtCurrentTeb();
1977 Teb
->Win32ThreadInfo
= UserHeapAddressToUser(W32Thread
->ThreadInfo
);
1981 SetLastNtError(_SEH_GetExceptionCode());
1987 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
1991 return W32Thread
->ThreadInfo
;