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
:
861 * Nothing too hard...validate the hWnd and save it in the Desktop Info
863 DPRINT1("HWNDOPT_ROUTINE_SETPROGMANWINDOW UNIMPLEMENTED\n");
866 case HWNDOPT_ROUTINE_SETTASKMANWINDOW
:
869 * Nothing too hard...validate the hWnd and save it in the Desktop Info
871 DPRINT1("HWNDOPT_ROUTINE_SETTASKMANWINDOW UNIMPLEMENTED\n");
882 NtUserGetThreadState(
885 DECLARE_RETURN(DWORD
);
887 DPRINT("Enter NtUserGetThreadState\n");
888 if (Routine
!= THREADSTATE_GETTHREADINFO
)
894 UserEnterExclusive();
899 case THREADSTATE_GETTHREADINFO
:
903 case THREADSTATE_FOCUSWINDOW
:
904 RETURN( (DWORD
)IntGetThreadFocusWindow());
909 DPRINT("Leave NtUserGetThreadState, ret=%i\n",_ret_
);
915 IntGetFontMetricSetting(LPWSTR lpValueName
, PLOGFONTW font
)
917 RTL_QUERY_REGISTRY_TABLE QueryTable
[2];
919 /* Firefox 1.0.7 depends on the lfHeight value being negative */
920 static LOGFONTW DefaultFont
= {
921 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
922 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
923 L
"Bitstream Vera Sans"
926 RtlZeroMemory(&QueryTable
, sizeof(QueryTable
));
928 QueryTable
[0].Name
= lpValueName
;
929 QueryTable
[0].Flags
= RTL_QUERY_REGISTRY_DIRECT
| RTL_QUERY_REGISTRY_REQUIRED
;
930 QueryTable
[0].EntryContext
= font
;
932 Status
= RtlQueryRegistryValues(
934 L
"Control Panel\\Desktop\\WindowMetrics",
939 if (!NT_SUCCESS(Status
))
941 RtlCopyMemory(font
, &DefaultFont
, sizeof(LOGFONTW
));
946 IntSystemParametersInfo(
952 PWINSTATION_OBJECT WinStaObject
;
955 static BOOL bInitialized
= FALSE
;
956 static LOGFONTW IconFont
;
957 static NONCLIENTMETRICSW pMetrics
;
958 static BOOL GradientCaptions
= TRUE
;
959 static UINT FocusBorderHeight
= 1;
960 static UINT FocusBorderWidth
= 1;
964 RtlZeroMemory(&IconFont
, sizeof(LOGFONTW
));
965 RtlZeroMemory(&pMetrics
, sizeof(NONCLIENTMETRICSW
));
967 IntGetFontMetricSetting(L
"CaptionFont", &pMetrics
.lfCaptionFont
);
968 IntGetFontMetricSetting(L
"SmCaptionFont", &pMetrics
.lfSmCaptionFont
);
969 IntGetFontMetricSetting(L
"MenuFont", &pMetrics
.lfMenuFont
);
970 IntGetFontMetricSetting(L
"StatusFont", &pMetrics
.lfStatusFont
);
971 IntGetFontMetricSetting(L
"MessageFont", &pMetrics
.lfMessageFont
);
972 IntGetFontMetricSetting(L
"IconFont", &IconFont
);
974 pMetrics
.iBorderWidth
= 1;
975 pMetrics
.iScrollWidth
= UserGetSystemMetrics(SM_CXVSCROLL
);
976 pMetrics
.iScrollHeight
= UserGetSystemMetrics(SM_CYHSCROLL
);
977 pMetrics
.iCaptionWidth
= UserGetSystemMetrics(SM_CXSIZE
);
978 pMetrics
.iCaptionHeight
= UserGetSystemMetrics(SM_CYSIZE
);
979 pMetrics
.iSmCaptionWidth
= UserGetSystemMetrics(SM_CXSMSIZE
);
980 pMetrics
.iSmCaptionHeight
= UserGetSystemMetrics(SM_CYSMSIZE
);
981 pMetrics
.iMenuWidth
= UserGetSystemMetrics(SM_CXMENUSIZE
);
982 pMetrics
.iMenuHeight
= UserGetSystemMetrics(SM_CYMENUSIZE
);
983 pMetrics
.cbSize
= sizeof(NONCLIENTMETRICSW
);
990 case SPI_SETDOUBLECLKWIDTH
:
991 case SPI_SETDOUBLECLKHEIGHT
:
992 case SPI_SETDOUBLECLICKTIME
:
993 case SPI_SETDESKWALLPAPER
:
994 case SPI_GETDESKWALLPAPER
:
995 case SPI_GETWHEELSCROLLLINES
:
996 case SPI_GETWHEELSCROLLCHARS
:
997 case SPI_SETSCREENSAVERRUNNING
:
998 case SPI_GETSCREENSAVERRUNNING
:
999 case SPI_GETSCREENSAVETIMEOUT
:
1000 case SPI_SETSCREENSAVETIMEOUT
:
1001 case SPI_GETFLATMENU
:
1002 case SPI_SETFLATMENU
:
1004 PSYSTEM_CURSORINFO CurInfo
;
1006 Status
= IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation
,
1010 if(!NT_SUCCESS(Status
))
1012 SetLastNtError(Status
);
1013 return (DWORD
)FALSE
;
1018 case SPI_GETFLATMENU
:
1019 if (pvParam
!= NULL
) *((UINT
*)pvParam
) = WinStaObject
->FlatMenu
;
1022 case SPI_SETFLATMENU
:
1023 WinStaObject
->FlatMenu
= uiParam
;
1025 case SPI_GETSCREENSAVETIMEOUT
:
1026 if (pvParam
!= NULL
) *((UINT
*)pvParam
) = WinStaObject
->ScreenSaverTimeOut
;
1029 case SPI_SETSCREENSAVETIMEOUT
:
1030 WinStaObject
->ScreenSaverTimeOut
= uiParam
;
1032 case SPI_GETSCREENSAVERRUNNING
:
1033 if (pvParam
!= NULL
) *((BOOL
*)pvParam
) = WinStaObject
->ScreenSaverRunning
;
1036 case SPI_SETSCREENSAVERRUNNING
:
1037 if (pvParam
!= NULL
) *((BOOL
*)pvParam
) = WinStaObject
->ScreenSaverRunning
;
1038 WinStaObject
->ScreenSaverRunning
= uiParam
;
1040 case SPI_GETWHEELSCROLLLINES
:
1041 CurInfo
= IntGetSysCursorInfo(WinStaObject
);
1042 if (pvParam
!= NULL
) *((UINT
*)pvParam
) = CurInfo
->WheelScroLines
;
1043 /* FIXME add this value to scroll list as scroll value ?? */
1046 case SPI_GETWHEELSCROLLCHARS
:
1047 CurInfo
= IntGetSysCursorInfo(WinStaObject
);
1048 if (pvParam
!= NULL
) *((UINT
*)pvParam
) = CurInfo
->WheelScroChars
;
1049 // FIXME add this value to scroll list as scroll value ??
1052 case SPI_SETDOUBLECLKWIDTH
:
1053 CurInfo
= IntGetSysCursorInfo(WinStaObject
);
1054 /* FIXME limit the maximum value? */
1055 CurInfo
->DblClickWidth
= uiParam
;
1057 case SPI_SETDOUBLECLKHEIGHT
:
1058 CurInfo
= IntGetSysCursorInfo(WinStaObject
);
1059 /* FIXME limit the maximum value? */
1060 CurInfo
->DblClickHeight
= uiParam
;
1062 case SPI_SETDOUBLECLICKTIME
:
1063 CurInfo
= IntGetSysCursorInfo(WinStaObject
);
1064 /* FIXME limit the maximum time to 1000 ms? */
1065 CurInfo
->DblClickSpeed
= uiParam
;
1067 case SPI_SETDESKWALLPAPER
:
1069 /* This function expects different parameters than the user mode version!
1071 We let the user mode code load the bitmap, it passed the handle to
1072 the bitmap. We'll change it's ownership to system and replace it with
1073 the current wallpaper bitmap */
1074 HBITMAP hOldBitmap
, hNewBitmap
;
1075 UNICODE_STRING Key
= RTL_CONSTANT_STRING(L
"Control Panel\\Desktop");
1076 UNICODE_STRING Tile
= RTL_CONSTANT_STRING(L
"TileWallpaper");
1077 UNICODE_STRING Style
= RTL_CONSTANT_STRING(L
"WallpaperStyle");
1078 UNICODE_STRING KeyPath
;
1079 OBJECT_ATTRIBUTES KeyAttributes
;
1080 OBJECT_ATTRIBUTES ObjectAttributes
;
1082 HANDLE CurrentUserKey
= NULL
;
1083 HANDLE KeyHandle
= NULL
;
1084 PKEY_VALUE_PARTIAL_INFORMATION KeyValuePartialInfo
;
1086 ULONG ResLength
= 0;
1091 hNewBitmap
= *(HBITMAP
*)pvParam
;
1092 if(hNewBitmap
!= NULL
)
1095 /* try to get the size of the wallpaper */
1096 if(!(bmp
= BITMAPOBJ_LockBitmap(hNewBitmap
)))
1098 ObDereferenceObject(WinStaObject
);
1101 WinStaObject
->cxWallpaper
= bmp
->SurfObj
.sizlBitmap
.cx
;
1102 WinStaObject
->cyWallpaper
= bmp
->SurfObj
.sizlBitmap
.cy
;
1104 BITMAPOBJ_UnlockBitmap(bmp
);
1106 /* change the bitmap's ownership */
1107 GDIOBJ_SetOwnership(GdiHandleTable
, hNewBitmap
, NULL
);
1109 hOldBitmap
= (HBITMAP
)InterlockedExchange((LONG
*)&WinStaObject
->hbmWallpaper
, (LONG
)hNewBitmap
);
1110 if(hOldBitmap
!= NULL
)
1112 /* delete the old wallpaper */
1113 NtGdiDeleteObject(hOldBitmap
);
1118 /*default value is center */
1119 WinStaObject
->WallpaperMode
= wmCenter
;
1123 /* Get a handle to the current users settings */
1124 RtlFormatCurrentUserKeyPath(&KeyPath
);
1125 InitializeObjectAttributes(&ObjectAttributes
,&KeyPath
,OBJ_CASE_INSENSITIVE
,NULL
,NULL
);
1126 ZwOpenKey(&CurrentUserKey
, KEY_READ
, &ObjectAttributes
);
1127 RtlFreeUnicodeString(&KeyPath
);
1129 /* open up the settings to read the values */
1130 InitializeObjectAttributes(&KeyAttributes
, &Key
, OBJ_CASE_INSENSITIVE
,
1131 CurrentUserKey
, NULL
);
1132 ZwOpenKey(&KeyHandle
, KEY_READ
, &KeyAttributes
);
1133 ZwClose(CurrentUserKey
);
1135 /* read the tile value in the registry */
1136 Status
= ZwQueryValueKey(KeyHandle
, &Tile
, KeyValuePartialInformation
,
1139 /* fall back to .DEFAULT if we didnt find values */
1140 if(Status
== STATUS_INVALID_HANDLE
)
1142 RtlInitUnicodeString (&KeyPath
,L
"\\Registry\\User\\.Default\\Control Panel\\Desktop");
1143 InitializeObjectAttributes(&KeyAttributes
, &KeyPath
, OBJ_CASE_INSENSITIVE
,
1145 ZwOpenKey(&KeyHandle
, KEY_READ
, &KeyAttributes
);
1146 ZwQueryValueKey(KeyHandle
, &Tile
, KeyValuePartialInformation
,
1150 ResLength
+= sizeof(KEY_VALUE_PARTIAL_INFORMATION
);
1151 KeyValuePartialInfo
= ExAllocatePoolWithTag(PagedPool
, ResLength
, TAG_STRING
);
1154 if(!KeyValuePartialInfo
)
1160 Status
= ZwQueryValueKey(KeyHandle
, &Tile
, KeyValuePartialInformation
,
1161 (PVOID
)KeyValuePartialInfo
, Length
, &ResLength
);
1162 if(!NT_SUCCESS(Status
) || (KeyValuePartialInfo
->Type
!= REG_SZ
))
1165 ExFreePool(KeyValuePartialInfo
);
1169 Tile
.Length
= KeyValuePartialInfo
->DataLength
;
1170 Tile
.MaximumLength
= KeyValuePartialInfo
->DataLength
;
1171 Tile
.Buffer
= (PWSTR
)KeyValuePartialInfo
->Data
;
1173 Status
= RtlUnicodeStringToInteger(&Tile
, 0, &TileNum
);
1174 if(!NT_SUCCESS(Status
))
1178 ExFreePool(KeyValuePartialInfo
);
1180 /* start over again and look for the style*/
1182 Status
= ZwQueryValueKey(KeyHandle
, &Style
, KeyValuePartialInformation
,
1185 ResLength
+= sizeof(KEY_VALUE_PARTIAL_INFORMATION
);
1186 KeyValuePartialInfo
= ExAllocatePoolWithTag(PagedPool
, ResLength
, TAG_STRING
);
1189 if(!KeyValuePartialInfo
)
1195 Status
= ZwQueryValueKey(KeyHandle
, &Style
, KeyValuePartialInformation
,
1196 (PVOID
)KeyValuePartialInfo
, Length
, &ResLength
);
1197 if(!NT_SUCCESS(Status
) || (KeyValuePartialInfo
->Type
!= REG_SZ
))
1200 ExFreePool(KeyValuePartialInfo
);
1204 Style
.Length
= KeyValuePartialInfo
->DataLength
;
1205 Style
.MaximumLength
= KeyValuePartialInfo
->DataLength
;
1206 Style
.Buffer
= (PWSTR
)KeyValuePartialInfo
->Data
;
1208 Status
= RtlUnicodeStringToInteger(&Style
, 0, &StyleNum
);
1209 if(!NT_SUCCESS(Status
))
1213 ExFreePool(KeyValuePartialInfo
);
1215 /* Check the values we found in the registry */
1216 if(TileNum
&& !StyleNum
)
1218 WinStaObject
->WallpaperMode
= wmTile
;
1220 else if(!TileNum
&& StyleNum
== 2)
1222 WinStaObject
->WallpaperMode
= wmStretch
;
1228 case SPI_GETDESKWALLPAPER
:
1229 /* This function expects different parameters than the user mode version!
1231 We basically return the current wallpaper handle - if any. The user
1232 mode version should load the string from the registry and return it
1233 without calling this function */
1235 *(HBITMAP
*)pvParam
= (HBITMAP
)WinStaObject
->hbmWallpaper
;
1239 /* FIXME save the value to the registry */
1241 ObDereferenceObject(WinStaObject
);
1244 case SPI_SETWORKAREA
:
1247 PDESKTOP_OBJECT Desktop
= PsGetCurrentThreadWin32Thread()->Desktop
;
1251 /* FIXME - Set last error */
1256 rc
= (RECT
*)pvParam
;
1257 Desktop
->WorkArea
= *rc
;
1261 case SPI_GETWORKAREA
:
1263 PDESKTOP_OBJECT Desktop
= PsGetCurrentThreadWin32Thread()->Desktop
;
1267 /* FIXME - Set last error */
1272 IntGetDesktopWorkArea(Desktop
, (PRECT
)pvParam
);
1276 case SPI_SETGRADIENTCAPTIONS
:
1278 GradientCaptions
= (pvParam
!= NULL
);
1279 /* FIXME - should be checked if the color depth is higher than 8bpp? */
1282 case SPI_GETGRADIENTCAPTIONS
:
1285 BOOL Ret
= GradientCaptions
;
1287 hDC
= IntGetScreenDC();
1290 Ret
= (NtGdiGetDeviceCaps(hDC
, BITSPIXEL
) > 8) && Ret
;
1293 *((PBOOL
)pvParam
) = Ret
;
1298 case SPI_SETFONTSMOOTHING
:
1300 IntEnableFontRendering(uiParam
!= 0);
1303 case SPI_GETFONTSMOOTHING
:
1306 *((BOOL
*)pvParam
) = IntIsFontRenderingEnabled();
1309 case SPI_GETICONTITLELOGFONT
:
1312 *((LOGFONTW
*)pvParam
) = IconFont
;
1315 case SPI_GETNONCLIENTMETRICS
:
1318 *((NONCLIENTMETRICSW
*)pvParam
) = pMetrics
;
1321 case SPI_GETFOCUSBORDERHEIGHT
:
1324 *((UINT
*)pvParam
) = FocusBorderHeight
;
1327 case SPI_GETFOCUSBORDERWIDTH
:
1330 *((UINT
*)pvParam
) = FocusBorderWidth
;
1333 case SPI_SETFOCUSBORDERHEIGHT
:
1335 FocusBorderHeight
= (UINT
)pvParam
;
1338 case SPI_SETFOCUSBORDERWIDTH
:
1340 FocusBorderWidth
= (UINT
)pvParam
;
1346 DPRINT1("SystemParametersInfo: Unsupported Action 0x%x (uiParam: 0x%x, pvParam: 0x%x, fWinIni: 0x%x)\n",
1347 uiAction
, uiParam
, pvParam
, fWinIni
);
1358 UserSystemParametersInfo(
1368 case SPI_SETDOUBLECLKWIDTH
:
1369 case SPI_SETDOUBLECLKHEIGHT
:
1370 case SPI_SETDOUBLECLICKTIME
:
1371 case SPI_SETGRADIENTCAPTIONS
:
1372 case SPI_SETFONTSMOOTHING
:
1373 case SPI_SETFOCUSBORDERHEIGHT
:
1374 case SPI_SETFOCUSBORDERWIDTH
:
1376 return (DWORD
)IntSystemParametersInfo(uiAction
, uiParam
, pvParam
, fWinIni
);
1378 case SPI_SETWORKAREA
:
1381 Status
= MmCopyFromCaller(&rc
, (PRECT
)pvParam
, sizeof(RECT
));
1382 if(!NT_SUCCESS(Status
))
1384 SetLastNtError(Status
);
1387 return( (DWORD
)IntSystemParametersInfo(uiAction
, uiParam
, &rc
, fWinIni
));
1389 case SPI_GETWORKAREA
:
1393 if(!IntSystemParametersInfo(uiAction
, uiParam
, &rc
, fWinIni
))
1398 Status
= MmCopyToCaller((PRECT
)pvParam
, &rc
, sizeof(RECT
));
1399 if(!NT_SUCCESS(Status
))
1401 SetLastNtError(Status
);
1406 case SPI_GETFONTSMOOTHING
:
1407 case SPI_GETGRADIENTCAPTIONS
:
1408 case SPI_GETFOCUSBORDERHEIGHT
:
1409 case SPI_GETFOCUSBORDERWIDTH
:
1410 case SPI_GETWHEELSCROLLLINES
:
1411 case SPI_GETWHEELSCROLLCHARS
:
1412 case SPI_GETSCREENSAVERRUNNING
:
1413 case SPI_SETSCREENSAVERRUNNING
:
1414 case SPI_GETSCREENSAVETIMEOUT
:
1415 case SPI_SETSCREENSAVETIMEOUT
:
1416 case SPI_GETFLATMENU
:
1417 case SPI_SETFLATMENU
:
1421 if(!IntSystemParametersInfo(uiAction
, uiParam
, &Ret
, fWinIni
))
1426 Status
= MmCopyToCaller(pvParam
, &Ret
, sizeof(BOOL
));
1427 if(!NT_SUCCESS(Status
))
1429 SetLastNtError(Status
);
1434 case SPI_SETDESKWALLPAPER
:
1436 /* !!! As opposed to the user mode version this version accepts a handle
1438 HBITMAP hbmWallpaper
;
1440 Status
= MmCopyFromCaller(&hbmWallpaper
, pvParam
, sizeof(HBITMAP
));
1441 if(!NT_SUCCESS(Status
))
1443 SetLastNtError(Status
);
1446 return( IntSystemParametersInfo(SPI_SETDESKWALLPAPER
, 0, &hbmWallpaper
, fWinIni
));
1448 case SPI_GETDESKWALLPAPER
:
1450 /* !!! As opposed to the user mode version this version returns a handle
1452 HBITMAP hbmWallpaper
;
1455 Ret
= IntSystemParametersInfo(SPI_GETDESKWALLPAPER
, 0, &hbmWallpaper
, fWinIni
);
1457 Status
= MmCopyToCaller(pvParam
, &hbmWallpaper
, sizeof(HBITMAP
));
1458 if(!NT_SUCCESS(Status
))
1460 SetLastNtError(Status
);
1465 case SPI_GETICONTITLELOGFONT
:
1469 if(!IntSystemParametersInfo(uiAction
, uiParam
, &IconFont
, fWinIni
))
1474 Status
= MmCopyToCaller(pvParam
, &IconFont
, sizeof(LOGFONTW
));
1475 if(!NT_SUCCESS(Status
))
1477 SetLastNtError(Status
);
1482 case SPI_GETNONCLIENTMETRICS
:
1484 NONCLIENTMETRICSW metrics
;
1486 Status
= MmCopyFromCaller(&metrics
.cbSize
, pvParam
, sizeof(UINT
));
1487 if(!NT_SUCCESS(Status
))
1489 SetLastNtError(Status
);
1492 if(metrics
.cbSize
!= sizeof(NONCLIENTMETRICSW
))
1494 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1498 if(!IntSystemParametersInfo(uiAction
, uiParam
, &metrics
, fWinIni
))
1503 Status
= MmCopyToCaller(pvParam
, &metrics
.cbSize
, sizeof(NONCLIENTMETRICSW
));
1504 if(!NT_SUCCESS(Status
))
1506 SetLastNtError(Status
);
1513 DPRINT1("UserSystemParametersInfo : uiAction = %x \n",uiAction
);
1528 NtUserSystemParametersInfo(
1534 DECLARE_RETURN(BOOLEAN
);
1536 DPRINT("Enter NtUserSystemParametersInfo\n");
1537 UserEnterExclusive();
1539 RETURN( UserSystemParametersInfo(uiAction
, uiParam
, pvParam
, fWinIni
));
1542 DPRINT("Leave NtUserSystemParametersInfo, ret=%i\n",_ret_
);
1551 NtUserGetDoubleClickTime(VOID
)
1555 PWINSTATION_OBJECT WinStaObject
;
1556 PSYSTEM_CURSORINFO CurInfo
;
1557 DECLARE_RETURN(UINT
);
1559 DPRINT("Enter NtUserGetDoubleClickTime\n");
1562 Status
= IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation
,
1566 if (!NT_SUCCESS(Status
))
1567 RETURN( (DWORD
)FALSE
);
1569 CurInfo
= IntGetSysCursorInfo(WinStaObject
);
1570 Result
= CurInfo
->DblClickSpeed
;
1572 ObDereferenceObject(WinStaObject
);
1576 DPRINT("Leave NtUserGetDoubleClickTime, ret=%i\n",_ret_
);
1583 NtUserGetGUIThreadInfo(
1584 DWORD idThread
, /* if NULL use foreground thread */
1585 LPGUITHREADINFO lpgui
)
1588 PTHRDCARETINFO CaretInfo
;
1589 GUITHREADINFO SafeGui
;
1590 PDESKTOP_OBJECT Desktop
;
1591 PUSER_MESSAGE_QUEUE MsgQueue
;
1592 PETHREAD Thread
= NULL
;
1593 DECLARE_RETURN(BOOLEAN
);
1595 DPRINT("Enter NtUserGetGUIThreadInfo\n");
1598 Status
= MmCopyFromCaller(&SafeGui
, lpgui
, sizeof(DWORD
));
1599 if(!NT_SUCCESS(Status
))
1601 SetLastNtError(Status
);
1605 if(SafeGui
.cbSize
!= sizeof(GUITHREADINFO
))
1607 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1613 Status
= PsLookupThreadByThreadId((HANDLE
)idThread
, &Thread
);
1614 if(!NT_SUCCESS(Status
))
1616 SetLastWin32Error(ERROR_ACCESS_DENIED
);
1619 Desktop
= ((PW32THREAD
)Thread
->Tcb
.Win32Thread
)->Desktop
;
1623 /* get the foreground thread */
1624 PW32THREAD W32Thread
= (PW32THREAD
)PsGetCurrentThread()->Tcb
.Win32Thread
;
1625 Desktop
= W32Thread
->Desktop
;
1628 MsgQueue
= Desktop
->ActiveMessageQueue
;
1631 Thread
= MsgQueue
->Thread
;
1636 if(!Thread
|| !Desktop
)
1638 if(idThread
&& Thread
)
1639 ObDereferenceObject(Thread
);
1640 SetLastWin32Error(ERROR_ACCESS_DENIED
);
1644 MsgQueue
= (PUSER_MESSAGE_QUEUE
)Desktop
->ActiveMessageQueue
;
1645 CaretInfo
= MsgQueue
->CaretInfo
;
1647 SafeGui
.flags
= (CaretInfo
->Visible
? GUI_CARETBLINKING
: 0);
1648 if(MsgQueue
->MenuOwner
)
1649 SafeGui
.flags
|= GUI_INMENUMODE
| MsgQueue
->MenuState
;
1650 if(MsgQueue
->MoveSize
)
1651 SafeGui
.flags
|= GUI_INMOVESIZE
;
1653 /* FIXME add flag GUI_16BITTASK */
1655 SafeGui
.hwndActive
= MsgQueue
->ActiveWindow
;
1656 SafeGui
.hwndFocus
= MsgQueue
->FocusWindow
;
1657 SafeGui
.hwndCapture
= MsgQueue
->CaptureWindow
;
1658 SafeGui
.hwndMenuOwner
= MsgQueue
->MenuOwner
;
1659 SafeGui
.hwndMoveSize
= MsgQueue
->MoveSize
;
1660 SafeGui
.hwndCaret
= CaretInfo
->hWnd
;
1662 SafeGui
.rcCaret
.left
= CaretInfo
->Pos
.x
;
1663 SafeGui
.rcCaret
.top
= CaretInfo
->Pos
.y
;
1664 SafeGui
.rcCaret
.right
= SafeGui
.rcCaret
.left
+ CaretInfo
->Size
.cx
;
1665 SafeGui
.rcCaret
.bottom
= SafeGui
.rcCaret
.top
+ CaretInfo
->Size
.cy
;
1668 ObDereferenceObject(Thread
);
1670 Status
= MmCopyToCaller(lpgui
, &SafeGui
, sizeof(GUITHREADINFO
));
1671 if(!NT_SUCCESS(Status
))
1673 SetLastNtError(Status
);
1680 DPRINT("Leave NtUserGetGUIThreadInfo, ret=%i\n",_ret_
);
1688 NtUserGetGuiResources(
1693 PW32PROCESS W32Process
;
1696 DECLARE_RETURN(DWORD
);
1698 DPRINT("Enter NtUserGetGuiResources\n");
1701 Status
= ObReferenceObjectByHandle(hProcess
,
1702 PROCESS_QUERY_INFORMATION
,
1704 ExGetPreviousMode(),
1708 if(!NT_SUCCESS(Status
))
1710 SetLastNtError(Status
);
1714 W32Process
= (PW32PROCESS
)Process
->Win32Process
;
1717 ObDereferenceObject(Process
);
1718 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1726 Ret
= (DWORD
)W32Process
->GDIObjects
;
1729 case GR_USEROBJECTS
:
1731 Ret
= (DWORD
)W32Process
->UserObjects
;
1736 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1741 ObDereferenceObject(Process
);
1746 DPRINT("Leave NtUserGetGuiResources, ret=%i\n",_ret_
);
1752 IntSafeCopyUnicodeString(PUNICODE_STRING Dest
,
1753 PUNICODE_STRING Source
)
1758 Status
= MmCopyFromCaller(Dest
, Source
, sizeof(UNICODE_STRING
));
1759 if(!NT_SUCCESS(Status
))
1764 if(Dest
->Length
> 0x4000)
1766 return STATUS_UNSUCCESSFUL
;
1770 Dest
->Buffer
= NULL
;
1772 if(Dest
->Length
> 0 && Src
)
1774 Dest
->MaximumLength
= Dest
->Length
;
1775 Dest
->Buffer
= ExAllocatePoolWithTag(PagedPool
, Dest
->MaximumLength
, TAG_STRING
);
1778 return STATUS_NO_MEMORY
;
1781 Status
= MmCopyFromCaller(Dest
->Buffer
, Src
, Dest
->Length
);
1782 if(!NT_SUCCESS(Status
))
1784 ExFreePool(Dest
->Buffer
);
1785 Dest
->Buffer
= NULL
;
1790 return STATUS_SUCCESS
;
1793 /* string is empty */
1794 return STATUS_SUCCESS
;
1798 IntSafeCopyUnicodeStringTerminateNULL(PUNICODE_STRING Dest
,
1799 PUNICODE_STRING Source
)
1804 Status
= MmCopyFromCaller(Dest
, Source
, sizeof(UNICODE_STRING
));
1805 if(!NT_SUCCESS(Status
))
1810 if(Dest
->Length
> 0x4000)
1812 return STATUS_UNSUCCESSFUL
;
1816 Dest
->Buffer
= NULL
;
1818 if(Dest
->Length
> 0 && Src
)
1820 Dest
->MaximumLength
= Dest
->Length
+ sizeof(WCHAR
);
1821 Dest
->Buffer
= ExAllocatePoolWithTag(PagedPool
, Dest
->MaximumLength
, TAG_STRING
);
1824 return STATUS_NO_MEMORY
;
1827 Status
= MmCopyFromCaller(Dest
->Buffer
, Src
, Dest
->Length
);
1828 if(!NT_SUCCESS(Status
))
1830 ExFreePool(Dest
->Buffer
);
1831 Dest
->Buffer
= NULL
;
1835 /* make sure the string is null-terminated */
1836 Src
= (PWSTR
)((PBYTE
)Dest
->Buffer
+ Dest
->Length
);
1839 return STATUS_SUCCESS
;
1842 /* string is empty */
1843 return STATUS_SUCCESS
;
1847 IntUnicodeStringToNULLTerminated(PWSTR
*Dest
, PUNICODE_STRING Src
)
1849 if (Src
->Length
+ sizeof(WCHAR
) <= Src
->MaximumLength
1850 && L
'\0' == Src
->Buffer
[Src
->Length
/ sizeof(WCHAR
)])
1852 /* The unicode_string is already nul terminated. Just reuse it. */
1853 *Dest
= Src
->Buffer
;
1854 return STATUS_SUCCESS
;
1857 *Dest
= ExAllocatePoolWithTag(PagedPool
, Src
->Length
+ sizeof(WCHAR
), TAG_STRING
);
1860 return STATUS_NO_MEMORY
;
1862 RtlCopyMemory(*Dest
, Src
->Buffer
, Src
->Length
);
1863 (*Dest
)[Src
->Length
/ 2] = L
'\0';
1865 return STATUS_SUCCESS
;
1869 IntFreeNULLTerminatedFromUnicodeString(PWSTR NullTerminated
, PUNICODE_STRING UnicodeString
)
1871 if (NullTerminated
!= UnicodeString
->Buffer
)
1873 ExFreePool(NullTerminated
);
1878 NtUserUpdatePerUserSystemParameters(
1883 DECLARE_RETURN(BOOLEAN
);
1885 DPRINT("Enter NtUserUpdatePerUserSystemParameters\n");
1886 UserEnterExclusive();
1888 Result
&= IntDesktopUpdatePerUserSettings(bEnable
);
1892 DPRINT("Leave NtUserUpdatePerUserSystemParameters, ret=%i\n",_ret_
);
1898 GetW32ProcessInfo(VOID
)
1901 PW32PROCESS W32Process
= PsGetCurrentProcessWin32Process();
1903 if (W32Process
== NULL
)
1905 /* FIXME - temporary hack for system threads... */
1909 if (W32Process
->ProcessInfo
== NULL
)
1911 pi
= UserHeapAlloc(sizeof(W32PROCESSINFO
));
1915 sizeof(W32PROCESSINFO
));
1918 pi
->UserHandleTable
= gHandleTable
;
1920 if (InterlockedCompareExchangePointer(&W32Process
->ProcessInfo
,
1929 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
1933 return W32Process
->ProcessInfo
;
1937 GetW32ThreadInfo(VOID
)
1941 PW32THREAD W32Thread
= PsGetCurrentThreadWin32Thread();
1943 if (W32Thread
== NULL
)
1945 /* FIXME - temporary hack for system threads... */
1949 /* allocate a W32THREAD structure if neccessary */
1950 if (W32Thread
->ThreadInfo
== NULL
)
1952 ti
= UserHeapAlloc(sizeof(W32THREADINFO
));
1956 sizeof(W32THREADINFO
));
1959 ti
->kpi
= GetW32ProcessInfo();
1960 ti
->pi
= UserHeapAddressToUser(ti
->kpi
);
1961 if (W32Thread
->Desktop
!= NULL
)
1963 ti
->Desktop
= W32Thread
->Desktop
->DesktopInfo
;
1964 ti
->DesktopHeapDelta
= DesktopHeapGetUserDelta();
1969 ti
->DesktopHeapDelta
= 0;
1972 W32Thread
->ThreadInfo
= ti
;
1973 /* update the TEB */
1974 Teb
= NtCurrentTeb();
1981 Teb
->Win32ThreadInfo
= UserHeapAddressToUser(W32Thread
->ThreadInfo
);
1985 SetLastNtError(_SEH_GetExceptionCode());
1991 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
1995 return W32Thread
->ThreadInfo
;