2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
5 * FILE: subsystems/win32/win32k/ntuser/desktop.c
6 * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
8 * 06-06-2001 CSH Created
11 /* INCLUDES ******************************************************************/
24 IN OUT PDESKTOP Desktop
27 /* GLOBALS *******************************************************************/
29 /* Currently active desktop */
30 PDESKTOP InputDesktop
= NULL
;
31 HDESK InputDesktopHandle
= NULL
;
32 HDC ScreenDeviceContext
= NULL
;
33 BOOL g_PaintDesktopVersion
= FALSE
;
35 GENERIC_MAPPING IntDesktopMapping
=
37 STANDARD_RIGHTS_READ
| DESKTOP_ENUMERATE
|
39 STANDARD_RIGHTS_WRITE
| DESKTOP_CREATEMENU
|
40 DESKTOP_CREATEWINDOW
|
42 DESKTOP_JOURNALPLAYBACK
|
43 DESKTOP_JOURNALRECORD
|
45 STANDARD_RIGHTS_EXECUTE
| DESKTOP_SWITCHDESKTOP
,
46 STANDARD_RIGHTS_REQUIRED
| DESKTOP_CREATEMENU
|
47 DESKTOP_CREATEWINDOW
|
50 DESKTOP_JOURNALPLAYBACK
|
51 DESKTOP_JOURNALRECORD
|
53 DESKTOP_SWITCHDESKTOP
|
57 /* OBJECT CALLBACKS **********************************************************/
61 IntDesktopObjectParse(IN PVOID ParseObject
,
63 IN OUT PACCESS_STATE AccessState
,
64 IN KPROCESSOR_MODE AccessMode
,
66 IN OUT PUNICODE_STRING CompleteName
,
67 IN OUT PUNICODE_STRING RemainingName
,
68 IN OUT PVOID Context OPTIONAL
,
69 IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL
,
74 OBJECT_ATTRIBUTES ObjectAttributes
;
75 PLIST_ENTRY NextEntry
, ListHead
;
76 PWINSTATION_OBJECT WinStaObject
= (PWINSTATION_OBJECT
)ParseObject
;
77 PUNICODE_STRING DesktopName
;
79 /* Set the list pointers and loop the window station */
80 ListHead
= &WinStaObject
->DesktopListHead
;
81 NextEntry
= ListHead
->Flink
;
82 while (NextEntry
!= ListHead
)
84 /* Get the current desktop */
85 Desktop
= CONTAINING_RECORD(NextEntry
, DESKTOP
, ListEntry
);
88 DesktopName
= GET_DESKTOP_NAME(Desktop
);
91 /* Compare the name */
92 if (RtlEqualUnicodeString(RemainingName
,
94 (Attributes
& OBJ_CASE_INSENSITIVE
)))
96 /* We found a match. Did this come from a create? */
99 /* Unless OPEN_IF was given, fail with an error */
100 if (!(Attributes
& OBJ_OPENIF
))
103 return STATUS_OBJECT_NAME_COLLISION
;
107 /* Otherwise, return with a warning only */
108 Status
= STATUS_OBJECT_NAME_EXISTS
;
113 /* This was a real open, so this is OK */
114 Status
= STATUS_SUCCESS
;
117 /* Reference the desktop and return it */
118 ObReferenceObject(Desktop
);
124 /* Go to the next desktop */
125 NextEntry
= NextEntry
->Flink
;
128 /* If we got here but this isn't a create, then fail */
129 if (!Context
) return STATUS_OBJECT_NAME_NOT_FOUND
;
131 /* Create the desktop object */
132 InitializeObjectAttributes(&ObjectAttributes
, RemainingName
, 0, NULL
, NULL
);
133 Status
= ObCreateObject(KernelMode
,
142 if (!NT_SUCCESS(Status
)) return Status
;
144 /* Initialize shell hook window list and set the parent */
145 InitializeListHead(&Desktop
->ShellHookWindows
);
146 Desktop
->WindowStation
= (PWINSTATION_OBJECT
)ParseObject
;
148 /* Put the desktop on the window station's list of associated desktops */
149 InsertTailList(&Desktop
->WindowStation
->DesktopListHead
,
150 &Desktop
->ListEntry
);
152 /* Set the desktop object and return success */
154 return STATUS_SUCCESS
;
158 IntDesktopObjectDelete(PWIN32_DELETEMETHOD_PARAMETERS Parameters
)
160 PDESKTOP Desktop
= (PDESKTOP
)Parameters
->Object
;
162 DPRINT("Deleting desktop (0x%X)\n", Desktop
);
164 /* Remove the desktop from the window station's list of associcated desktops */
165 RemoveEntryList(&Desktop
->ListEntry
);
167 IntFreeDesktopHeap(Desktop
);
170 /* PRIVATE FUNCTIONS **********************************************************/
174 InitDesktopImpl(VOID
)
176 /* Set Desktop Object Attributes */
177 ExDesktopObjectType
->TypeInfo
.DefaultNonPagedPoolCharge
= sizeof(DESKTOP
);
178 ExDesktopObjectType
->TypeInfo
.GenericMapping
= IntDesktopMapping
;
179 return STATUS_SUCCESS
;
184 CleanupDesktopImpl(VOID
)
186 return STATUS_SUCCESS
;
189 static int GetSystemVersionString(LPWSTR buffer
)
191 RTL_OSVERSIONINFOEXW versionInfo
;
194 versionInfo
.dwOSVersionInfoSize
= sizeof(RTL_OSVERSIONINFOEXW
);
196 if (!NT_SUCCESS(RtlGetVersion((PRTL_OSVERSIONINFOW
)&versionInfo
)))
199 if (versionInfo
.dwMajorVersion
<= 4)
200 len
= swprintf(buffer
,
201 L
"ReactOS Version %d.%d %s Build %d",
202 versionInfo
.dwMajorVersion
, versionInfo
.dwMinorVersion
,
203 versionInfo
.szCSDVersion
, versionInfo
.dwBuildNumber
&0xFFFF);
205 len
= swprintf(buffer
,
206 L
"ReactOS %s (Build %d)",
207 versionInfo
.szCSDVersion
, versionInfo
.dwBuildNumber
&0xFFFF);
214 IntParseDesktopPath(PEPROCESS Process
,
215 PUNICODE_STRING DesktopPath
,
219 OBJECT_ATTRIBUTES ObjectAttributes
;
220 UNICODE_STRING WinSta
, Desktop
, FullName
;
221 BOOL DesktopPresent
= FALSE
;
222 BOOL WinStaPresent
= FALSE
;
234 RtlInitUnicodeString(&WinSta
, NULL
);
235 RtlInitUnicodeString(&Desktop
, NULL
);
237 if(DesktopPath
!= NULL
&& DesktopPath
->Buffer
!= NULL
&& DesktopPath
->Length
> sizeof(WCHAR
))
239 PWCHAR c
= DesktopPath
->Buffer
;
241 USHORT l
= DesktopPath
->Length
;
244 * Parse the desktop path string which can be in the form "WinSta\Desktop"
245 * or just "Desktop". In latter case WinSta0 will be used.
252 wl
= (ULONG_PTR
)c
- (ULONG_PTR
)DesktopPath
->Buffer
;
262 WinSta
.MaximumLength
= wl
+ sizeof(WCHAR
);
263 WinSta
.Buffer
= DesktopPath
->Buffer
;
265 WinStaPresent
= TRUE
;
269 Desktop
.Length
= DesktopPath
->Length
- wl
;
272 Desktop
.Length
-= sizeof(WCHAR
);
274 if(Desktop
.Length
> 0)
276 Desktop
.MaximumLength
= Desktop
.Length
+ sizeof(WCHAR
);
277 Desktop
.Buffer
= ((wl
> 0) ? c
: DesktopPath
->Buffer
);
278 DesktopPresent
= TRUE
;
285 /* search the process handle table for (inherited) window station
286 handles, use a more appropriate one than WinSta0 if possible. */
287 if (!ObFindHandleForObject(Process
,
289 ExWindowStationObjectType
,
294 /* we had no luck searching for opened handles, use WinSta0 now */
295 RtlInitUnicodeString(&WinSta
, L
"WinSta0");
299 if(!DesktopPresent
&& hDesktop
!= NULL
)
302 /* search the process handle table for (inherited) desktop
303 handles, use a more appropriate one than Default if possible. */
304 if (!ObFindHandleForObject(Process
,
311 /* we had no luck searching for opened handles, use Desktop now */
312 RtlInitUnicodeString(&Desktop
, L
"Default");
318 if(!IntGetFullWindowStationName(&FullName
, &WinSta
, NULL
))
320 return STATUS_INSUFFICIENT_RESOURCES
;
323 /* open the window station */
324 InitializeObjectAttributes(&ObjectAttributes
,
326 OBJ_CASE_INSENSITIVE
,
330 Status
= ObOpenObjectByName(&ObjectAttributes
,
331 ExWindowStationObjectType
,
338 ExFreePoolWithTag(FullName
.Buffer
, TAG_STRING
);
340 if(!NT_SUCCESS(Status
))
342 SetLastNtError(Status
);
343 DPRINT("Failed to reference window station %wZ PID: %d!\n", &WinSta
, PsGetCurrentProcessId());
348 if(hDesktop
!= NULL
&& *hDesktop
== NULL
)
350 if(!IntGetFullWindowStationName(&FullName
, &WinSta
, &Desktop
))
354 return STATUS_INSUFFICIENT_RESOURCES
;
357 /* open the desktop object */
358 InitializeObjectAttributes(&ObjectAttributes
,
360 OBJ_CASE_INSENSITIVE
,
364 Status
= ObOpenObjectByName(&ObjectAttributes
,
372 ExFreePoolWithTag(FullName
.Buffer
, TAG_STRING
);
374 if(!NT_SUCCESS(Status
))
379 SetLastNtError(Status
);
380 DPRINT("Failed to reference desktop %wZ PID: %d!\n", &Desktop
, PsGetCurrentProcessId());
385 return STATUS_SUCCESS
;
389 * IntValidateDesktopHandle
391 * Validates the desktop handle.
394 * If the function succeeds, the handle remains referenced. If the
395 * fucntion fails, last error is set.
399 IntValidateDesktopHandle(
401 KPROCESSOR_MODE AccessMode
,
402 ACCESS_MASK DesiredAccess
,
407 Status
= ObReferenceObjectByHandle(
415 if (!NT_SUCCESS(Status
))
416 SetLastNtError(Status
);
422 IntGetDesktopWorkArea(PDESKTOP Desktop
, RECTL
*Rect
)
428 Ret
= &Desktop
->WorkArea
;
429 if((Ret
->right
== -1) && ScreenDeviceContext
)
433 dc
= DC_LockDc(ScreenDeviceContext
);
434 /* FIXME - Handle dc == NULL!!!! */
435 psurf
= SURFACE_LockSurface(dc
->rosdc
.hBitmap
);
438 Ret
->right
= psurf
->SurfObj
.sizlBitmap
.cx
;
439 Ret
->bottom
= psurf
->SurfObj
.sizlBitmap
.cy
;
440 SURFACE_UnlockSurface(psurf
);
452 IntGetActiveDesktop(VOID
)
458 * returns or creates a handle to the desktop object
461 IntGetDesktopObjectHandle(PDESKTOP DesktopObject
)
466 ASSERT(DesktopObject
);
468 if (!ObFindHandleForObject(PsGetCurrentProcess(),
474 Status
= ObOpenObjectByPointer(DesktopObject
,
481 if(!NT_SUCCESS(Status
))
483 /* unable to create a handle */
484 DPRINT1("Unable to create a desktop handle\n");
490 DPRINT1("Got handle: %lx\n", Ret
);
496 PUSER_MESSAGE_QUEUE FASTCALL
497 IntGetFocusMessageQueue(VOID
)
499 PDESKTOP pdo
= IntGetActiveDesktop();
502 DPRINT("No active desktop\n");
505 return (PUSER_MESSAGE_QUEUE
)pdo
->ActiveMessageQueue
;
509 IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue
)
511 PUSER_MESSAGE_QUEUE Old
;
512 PDESKTOP pdo
= IntGetActiveDesktop();
515 DPRINT("No active desktop\n");
520 if(NewQueue
->Desktop
!= NULL
)
522 DPRINT("Message Queue already attached to another desktop!\n");
525 IntReferenceMessageQueue(NewQueue
);
526 (void)InterlockedExchangePointer((PVOID
*)&NewQueue
->Desktop
, pdo
);
528 Old
= (PUSER_MESSAGE_QUEUE
)InterlockedExchangePointer((PVOID
*)&pdo
->ActiveMessageQueue
, NewQueue
);
531 (void)InterlockedExchangePointer((PVOID
*)&Old
->Desktop
, 0);
532 IntDereferenceMessageQueue(Old
);
536 HWND FASTCALL
IntGetDesktopWindow(VOID
)
538 PDESKTOP pdo
= IntGetActiveDesktop();
541 DPRINT("No active desktop\n");
544 return pdo
->DesktopWindow
;
547 PWINDOW_OBJECT FASTCALL
UserGetDesktopWindow(VOID
)
549 PDESKTOP pdo
= IntGetActiveDesktop();
553 DPRINT("No active desktop\n");
557 return UserGetWindowObject(pdo
->DesktopWindow
);
561 HWND FASTCALL
IntGetCurrentThreadDesktopWindow(VOID
)
563 PTHREADINFO pti
= PsGetCurrentThreadWin32Thread();
564 PDESKTOP pdo
= pti
->Desktop
;
567 DPRINT1("Thread doesn't have a desktop\n");
570 return pdo
->DesktopWindow
;
573 BOOL FASTCALL
IntDesktopUpdatePerUserSettings(BOOL bEnable
)
577 RTL_QUERY_REGISTRY_TABLE QueryTable
[2];
580 RtlZeroMemory(QueryTable
, sizeof(QueryTable
));
582 QueryTable
[0].Flags
= RTL_QUERY_REGISTRY_DIRECT
;
583 QueryTable
[0].Name
= L
"PaintDesktopVersion";
584 QueryTable
[0].EntryContext
= &g_PaintDesktopVersion
;
586 /* Query the "PaintDesktopVersion" flag in the "Control Panel\Desktop" key */
587 Status
= RtlQueryRegistryValues(RTL_REGISTRY_USER
,
588 L
"Control Panel\\Desktop",
589 QueryTable
, NULL
, NULL
);
590 if (!NT_SUCCESS(Status
))
592 DPRINT1("RtlQueryRegistryValues failed for PaintDesktopVersion (%x)\n",
594 g_PaintDesktopVersion
= FALSE
;
598 DPRINT("PaintDesktopVersion = %d\n", g_PaintDesktopVersion
);
604 g_PaintDesktopVersion
= FALSE
;
609 /* PUBLIC FUNCTIONS ***********************************************************/
614 PWINDOW_OBJECT Window
= NULL
;
616 UserEnterExclusive();
618 Window
= UserGetDesktopWindow();
620 IntInvalidateWindows( Window
,
621 Window
->UpdateRegion
,
631 co_IntShowDesktop(PDESKTOP Desktop
, ULONG Width
, ULONG Height
)
633 CSR_API_MESSAGE Request
;
635 Request
.Type
= MAKE_CSR_API(SHOW_DESKTOP
, CSR_GUI
);
636 Request
.Data
.ShowDesktopRequest
.DesktopWindow
= Desktop
->DesktopWindow
;
637 Request
.Data
.ShowDesktopRequest
.Width
= Width
;
638 Request
.Data
.ShowDesktopRequest
.Height
= Height
;
640 return co_CsrNotify(&Request
);
644 IntHideDesktop(PDESKTOP Desktop
)
647 CSRSS_API_REQUEST Request
;
648 CSRSS_API_REPLY Reply
;
650 Request
.Type
= CSRSS_HIDE_DESKTOP
;
651 Request
.Data
.HideDesktopRequest
.DesktopWindow
= Desktop
->DesktopWindow
;
653 return NotifyCsrss(&Request
, &Reply
);
656 PWINDOW_OBJECT DesktopWindow
;
659 DesktopWindow
= IntGetWindowObject(Desktop
->DesktopWindow
);
662 return ERROR_INVALID_WINDOW_HANDLE
;
664 DesktopWnd
= DesktopWindow
->Wnd
;
665 DesktopWnd
->Style
&= ~WS_VISIBLE
;
667 return STATUS_SUCCESS
;
676 UserBuildShellHookHwndList(PDESKTOP Desktop
)
679 PSHELL_HOOK_WINDOW Current
;
682 /* fixme: if we save nb elements in desktop, we dont have to loop to find nb entries */
683 LIST_FOR_EACH(Current
, &Desktop
->ShellHookWindows
, SHELL_HOOK_WINDOW
, ListEntry
)
686 if (!entries
) return NULL
;
688 list
= ExAllocatePool(PagedPool
, sizeof(HWND
) * (entries
+ 1)); /* alloc one extra for nullterm */
693 LIST_FOR_EACH(Current
, &Desktop
->ShellHookWindows
, SHELL_HOOK_WINDOW
, ListEntry
)
694 *cursor
++ = Current
->hWnd
;
696 *cursor
= NULL
; /* nullterm list */
703 * Send the Message to the windows registered for ShellHook
704 * notifications. The lParam contents depend on the Message. See
705 * MSDN for more details (RegisterShellHookWindow)
707 VOID
co_IntShellHookNotify(WPARAM Message
, LPARAM lParam
)
709 PDESKTOP Desktop
= IntGetActiveDesktop();
712 static UINT MsgType
= 0;
717 /* Too bad, this doesn't work.*/
720 RtlInitUnicodeString(&Str
, L
"SHELLHOOK");
721 MsgType
= UserRegisterWindowMessage(&Str
);
724 MsgType
= IntAddAtom(L
"SHELLHOOK");
726 DPRINT("MsgType = %x\n", MsgType
);
728 DPRINT1("LastError: %x\n", GetLastNtError());
733 DPRINT("IntShellHookNotify: No desktop!\n");
737 HwndList
= UserBuildShellHookHwndList(Desktop
);
740 HWND
* cursor
= HwndList
;
742 for (; *cursor
; cursor
++)
744 DPRINT("Sending notify\n");
745 co_IntPostOrSendMessage(*cursor
,
751 ExFreePool(HwndList
);
757 * Add the window to the ShellHookWindows list. The windows
758 * on that list get notifications that are important to shell
761 * TODO: Validate the window? I'm not sure if sending these messages to
762 * an unsuspecting application that is not your own is a nice thing to do.
764 BOOL
IntRegisterShellHookWindow(HWND hWnd
)
766 PTHREADINFO pti
= PsGetCurrentThreadWin32Thread();
767 PDESKTOP Desktop
= pti
->Desktop
;
768 PSHELL_HOOK_WINDOW Entry
;
770 DPRINT("IntRegisterShellHookWindow\n");
772 /* First deregister the window, so we can be sure it's never twice in the
775 IntDeRegisterShellHookWindow(hWnd
);
777 Entry
= ExAllocatePoolWithTag(PagedPool
,
778 sizeof(SHELL_HOOK_WINDOW
),
786 InsertTailList(&Desktop
->ShellHookWindows
, &Entry
->ListEntry
);
792 * Remove the window from the ShellHookWindows list. The windows
793 * on that list get notifications that are important to shell
796 BOOL
IntDeRegisterShellHookWindow(HWND hWnd
)
798 PTHREADINFO pti
= PsGetCurrentThreadWin32Thread();
799 PDESKTOP Desktop
= pti
->Desktop
;
800 PSHELL_HOOK_WINDOW Current
;
802 LIST_FOR_EACH(Current
, &Desktop
->ShellHookWindows
, SHELL_HOOK_WINDOW
, ListEntry
)
804 if (Current
->hWnd
== hWnd
)
806 RemoveEntryList(&Current
->ListEntry
);
816 IntFreeDesktopHeap(IN OUT PDESKTOP Desktop
)
818 if (Desktop
->DesktopHeapSection
!= NULL
)
820 ObDereferenceObject(Desktop
->DesktopHeapSection
);
821 Desktop
->DesktopHeapSection
= NULL
;
824 /* SYSCALLS *******************************************************************/
828 * NtUserCreateDesktop
830 * Creates a new desktop.
834 * Name of the new desktop.
840 * Requested type of access.
843 * Security descriptor.
846 * Handle to window station on which to create the desktop.
849 * If the function succeeds, the return value is a handle to the newly
850 * created desktop. If the specified desktop already exists, the function
851 * succeeds and returns a handle to the existing desktop. When you are
852 * finished using the handle, call the CloseDesktop function to close it.
853 * If the function fails, the return value is NULL.
861 PUNICODE_STRING lpszDesktopName
,
863 ACCESS_MASK dwDesiredAccess
,
864 LPSECURITY_ATTRIBUTES lpSecurity
,
865 HWINSTA hWindowStation
)
867 OBJECT_ATTRIBUTES ObjectAttributes
;
868 PWINSTATION_OBJECT WinStaObject
;
869 PDESKTOP DesktopObject
;
870 UNICODE_STRING DesktopName
;
873 CSR_API_MESSAGE Request
;
874 PVOID DesktopHeapSystemBase
= NULL
;
875 SIZE_T DesktopInfoSize
;
876 UNICODE_STRING SafeDesktopName
;
878 ULONG_PTR HeapSize
= 4 * 1024 * 1024; /* FIXME */
879 DECLARE_RETURN(HDESK
);
882 DPRINT("Enter NtUserCreateDesktop: %wZ\n", lpszDesktopName
);
883 UserEnterExclusive();
885 Status
= IntValidateWindowStationHandle(
888 0, /* FIXME - WINSTA_CREATEDESKTOP */
891 if (! NT_SUCCESS(Status
))
893 DPRINT1("Failed validation of window station handle (0x%X), cannot create desktop %wZ\n",
894 hWindowStation
, lpszDesktopName
);
895 SetLastNtError(Status
);
898 if(lpszDesktopName
!= NULL
)
900 Status
= IntSafeCopyUnicodeString(&SafeDesktopName
, lpszDesktopName
);
901 if(!NT_SUCCESS(Status
))
903 SetLastNtError(Status
);
909 RtlInitUnicodeString(&SafeDesktopName
, NULL
);
912 if (! IntGetFullWindowStationName(&DesktopName
, &WinStaObject
->Name
,
915 SetLastNtError(STATUS_INSUFFICIENT_RESOURCES
);
916 ObDereferenceObject(WinStaObject
);
918 ExFreePoolWithTag(SafeDesktopName
.Buffer
, TAG_STRING
);
922 ExFreePoolWithTag(SafeDesktopName
.Buffer
, TAG_STRING
);
923 ObDereferenceObject(WinStaObject
);
926 * Try to open already existing desktop
929 DPRINT("Trying to open desktop (%wZ)\n", &DesktopName
);
931 /* Initialize ObjectAttributes for the desktop object */
932 InitializeObjectAttributes(
939 Status
= ObOpenObjectByName(
945 (PVOID
)&DummyContext
,
947 if (!NT_SUCCESS(Status
)) RETURN(NULL
);
948 if (Status
== STATUS_OBJECT_NAME_EXISTS
)
950 ExFreePoolWithTag(DesktopName
.Buffer
, TAG_STRING
);
954 /* Reference the desktop */
955 Status
= ObReferenceObjectByHandle(Desktop
,
959 (PVOID
)&DesktopObject
,
961 if (!NT_SUCCESS(Status
)) RETURN(NULL
);
963 DesktopObject
->DesktopHeapSection
= NULL
;
964 DesktopObject
->pheapDesktop
= UserCreateHeap(&DesktopObject
->DesktopHeapSection
,
965 &DesktopHeapSystemBase
,
967 if (DesktopObject
->pheapDesktop
== NULL
)
969 ObDereferenceObject(DesktopObject
);
970 DPRINT1("Failed to create desktop heap!\n");
974 DesktopInfoSize
= FIELD_OFFSET(DESKTOPINFO
,
975 szDesktopName
[(lpszDesktopName
->Length
/ sizeof(WCHAR
)) + 1]);
977 DesktopObject
->DesktopInfo
= RtlAllocateHeap(DesktopObject
->pheapDesktop
,
981 if (DesktopObject
->DesktopInfo
== NULL
)
983 ObDereferenceObject(DesktopObject
);
984 DPRINT1("Failed to create the DESKTOP structure!\n");
988 RtlZeroMemory(DesktopObject
->DesktopInfo
,
991 DesktopObject
->DesktopInfo
->pvDesktopBase
= DesktopHeapSystemBase
;
992 DesktopObject
->DesktopInfo
->pvDesktopLimit
= (PVOID
)((ULONG_PTR
)DesktopHeapSystemBase
+ HeapSize
);
993 RtlCopyMemory(DesktopObject
->DesktopInfo
->szDesktopName
,
994 lpszDesktopName
->Buffer
,
995 lpszDesktopName
->Length
);
998 DesktopObject
->WorkArea
.left
= 0;
999 DesktopObject
->WorkArea
.top
= 0;
1000 DesktopObject
->WorkArea
.right
= -1;
1001 DesktopObject
->WorkArea
.bottom
= -1;
1002 IntGetDesktopWorkArea(DesktopObject
, NULL
);
1004 /* Initialize some local (to win32k) desktop state. */
1005 InitializeListHead(&DesktopObject
->PtiList
);
1006 DesktopObject
->ActiveMessageQueue
= NULL
;
1007 ExFreePoolWithTag(DesktopName
.Buffer
, TAG_STRING
);
1009 if (! NT_SUCCESS(Status
))
1011 DPRINT1("Failed to create desktop handle\n");
1012 SetLastNtError(Status
);
1017 * Create a handle for CSRSS and notify CSRSS
1019 Request
.Type
= MAKE_CSR_API(CREATE_DESKTOP
, CSR_GUI
);
1020 Status
= CsrInsertObject(Desktop
,
1022 (HANDLE
*)&Request
.Data
.CreateDesktopRequest
.DesktopHandle
);
1023 if (! NT_SUCCESS(Status
))
1025 DPRINT1("Failed to create desktop handle for CSRSS\n");
1027 SetLastNtError(Status
);
1031 Status
= co_CsrNotify(&Request
);
1032 if (! NT_SUCCESS(Status
))
1034 CsrCloseHandle(Request
.Data
.CreateDesktopRequest
.DesktopHandle
);
1035 DPRINT1("Failed to notify CSRSS about new desktop\n");
1037 SetLastNtError(Status
);
1044 DPRINT("Leave NtUserCreateDesktop, ret=%i\n",_ret_
);
1052 * Opens an existing desktop.
1056 * Name of the existing desktop.
1059 * Interaction flags.
1062 * Requested type of access.
1065 * Handle to the desktop or zero on failure.
1073 PUNICODE_STRING lpszDesktopName
,
1075 ACCESS_MASK dwDesiredAccess
)
1077 OBJECT_ATTRIBUTES ObjectAttributes
;
1079 PWINSTATION_OBJECT WinStaObject
;
1080 UNICODE_STRING DesktopName
;
1081 UNICODE_STRING SafeDesktopName
;
1085 DECLARE_RETURN(HDESK
);
1087 DPRINT("Enter NtUserOpenDesktop: %wZ\n", lpszDesktopName
);
1088 UserEnterExclusive();
1091 * Validate the window station handle and compose the fully
1092 * qualified desktop name
1095 WinSta
= UserGetProcessWindowStation();
1096 Status
= IntValidateWindowStationHandle(
1102 if (!NT_SUCCESS(Status
))
1104 DPRINT1("Failed validation of window station handle (0x%X)\n", WinSta
);
1105 SetLastNtError(Status
);
1109 if(lpszDesktopName
!= NULL
)
1111 Status
= IntSafeCopyUnicodeString(&SafeDesktopName
, lpszDesktopName
);
1112 if(!NT_SUCCESS(Status
))
1114 SetLastNtError(Status
);
1120 RtlInitUnicodeString(&SafeDesktopName
, NULL
);
1123 Result
= IntGetFullWindowStationName(&DesktopName
, &WinStaObject
->Name
,
1126 if (lpszDesktopName
)
1127 ExFreePoolWithTag(SafeDesktopName
.Buffer
, TAG_STRING
);
1128 ObDereferenceObject(WinStaObject
);
1133 SetLastNtError(STATUS_INSUFFICIENT_RESOURCES
);
1138 DPRINT("Trying to open desktop (%wZ)\n", &DesktopName
);
1140 /* Initialize ObjectAttributes for the desktop object */
1141 InitializeObjectAttributes(
1148 Status
= ObOpenObjectByName(
1150 ExDesktopObjectType
,
1157 if (!NT_SUCCESS(Status
))
1159 SetLastNtError(Status
);
1160 ExFreePool(DesktopName
.Buffer
);
1164 DPRINT("Successfully opened desktop (%wZ)\n", &DesktopName
);
1165 ExFreePool(DesktopName
.Buffer
);
1170 DPRINT("Leave NtUserOpenDesktop, ret=%i\n",_ret_
);
1176 * NtUserOpenInputDesktop
1178 * Opens the input (interactive) desktop.
1182 * Interaction flags.
1185 * Inheritance option.
1188 * Requested type of access.
1191 * Handle to the input desktop or zero on failure.
1198 NtUserOpenInputDesktop(
1201 ACCESS_MASK dwDesiredAccess
)
1206 DECLARE_RETURN(HDESK
);
1208 DPRINT("Enter NtUserOpenInputDesktop\n");
1209 UserEnterExclusive();
1211 DPRINT("About to open input desktop\n");
1213 /* Get a pointer to the desktop object */
1215 Status
= IntValidateDesktopHandle(
1221 if (!NT_SUCCESS(Status
))
1223 DPRINT("Validation of input desktop handle (0x%X) failed\n", InputDesktop
);
1227 /* Create a new handle to the object */
1229 Status
= ObOpenObjectByPointer(
1234 ExDesktopObjectType
,
1238 ObDereferenceObject(Object
);
1240 if (NT_SUCCESS(Status
))
1242 DPRINT("Successfully opened input desktop\n");
1243 RETURN((HDESK
)Desktop
);
1246 SetLastNtError(Status
);
1250 DPRINT("Leave NtUserOpenInputDesktop, ret=%i\n",_ret_
);
1256 * NtUserCloseDesktop
1258 * Closes a desktop handle.
1262 * Handle to the desktop.
1268 * The desktop handle can be created with NtUserCreateDesktop or
1269 * NtUserOpenDesktop. This function will fail if any thread in the calling
1270 * process is using the specified desktop handle or if the handle refers
1271 * to the initial desktop of the calling process.
1278 NtUserCloseDesktop(HDESK hDesktop
)
1282 DECLARE_RETURN(BOOL
);
1284 DPRINT("Enter NtUserCloseDesktop\n");
1285 UserEnterExclusive();
1287 DPRINT("About to close desktop handle (0x%X)\n", hDesktop
);
1289 Status
= IntValidateDesktopHandle(
1295 if (!NT_SUCCESS(Status
))
1297 DPRINT("Validation of desktop handle (0x%X) failed\n", hDesktop
);
1301 ObDereferenceObject(Object
);
1303 DPRINT("Closing desktop handle (0x%X)\n", hDesktop
);
1305 Status
= ZwClose(hDesktop
);
1306 if (!NT_SUCCESS(Status
))
1308 SetLastNtError(Status
);
1315 DPRINT("Leave NtUserCloseDesktop, ret=%i\n",_ret_
);
1324 * NtUserPaintDesktop
1326 * The NtUserPaintDesktop function fills the clipping region in the
1327 * specified device context with the desktop pattern or wallpaper. The
1328 * function is provided primarily for shell desktops.
1332 * Handle to the device context.
1339 NtUserPaintDesktop(HDC hDC
)
1342 HBRUSH DesktopBrush
, PreviousBrush
;
1344 BOOL doPatBlt
= TRUE
;
1345 PWINDOW_OBJECT WndDesktop
;
1350 PTHREADINFO pti
= PsGetCurrentThreadWin32Thread();
1351 PWINSTATION_OBJECT WinSta
= pti
->Desktop
->WindowStation
;
1352 DECLARE_RETURN(BOOL
);
1354 UserEnterExclusive();
1355 DPRINT("Enter NtUserPaintDesktop\n");
1357 GdiGetClipBox(hDC
, &Rect
);
1359 hWndDesktop
= IntGetDesktopWindow();
1361 WndDesktop
= UserGetWindowObject(hWndDesktop
);
1367 DesktopBrush
= (HBRUSH
)UserGetClassLongPtr(WndDesktop
->Wnd
->Class
, GCL_HBRBACKGROUND
, FALSE
);
1371 * Paint desktop background
1374 if (WinSta
->hbmWallpaper
!= NULL
)
1376 PWINDOW_OBJECT DeskWin
;
1378 DeskWin
= UserGetWindowObject(hWndDesktop
);
1386 sz
.cx
= DeskWin
->Wnd
->WindowRect
.right
- DeskWin
->Wnd
->WindowRect
.left
;
1387 sz
.cy
= DeskWin
->Wnd
->WindowRect
.bottom
- DeskWin
->Wnd
->WindowRect
.top
;
1389 if (WinSta
->WallpaperMode
== wmStretch
||
1390 WinSta
->WallpaperMode
== wmTile
)
1397 /* Find the upper left corner, can be negtive if the bitmap is bigger then the screen */
1398 x
= (sz
.cx
/ 2) - (WinSta
->cxWallpaper
/ 2);
1399 y
= (sz
.cy
/ 2) - (WinSta
->cyWallpaper
/ 2);
1402 hWallpaperDC
= NtGdiCreateCompatibleDC(hDC
);
1403 if(hWallpaperDC
!= NULL
)
1407 /* fill in the area that the bitmap is not going to cover */
1410 /* FIXME - clip out the bitmap
1411 can be replaced with "NtGdiPatBlt(hDC, x, y, WinSta->cxWallpaper, WinSta->cyWallpaper, PATCOPY | DSTINVERT);"
1412 once we support DSTINVERT */
1413 PreviousBrush
= NtGdiSelectBrush(hDC
, DesktopBrush
);
1414 NtGdiPatBlt(hDC
, Rect
.left
, Rect
.top
, Rect
.right
, Rect
.bottom
, PATCOPY
);
1415 NtGdiSelectBrush(hDC
, PreviousBrush
);
1418 /*Do not fill the background after it is painted no matter the size of the picture */
1421 hOldBitmap
= NtGdiSelectBitmap(hWallpaperDC
, WinSta
->hbmWallpaper
);
1423 if (WinSta
->WallpaperMode
== wmStretch
)
1425 if(Rect
.right
&& Rect
.bottom
)
1426 NtGdiStretchBlt(hDC
,
1434 WinSta
->cxWallpaper
,
1435 WinSta
->cyWallpaper
,
1440 else if (WinSta
->WallpaperMode
== wmTile
)
1442 /* paint the bitmap across the screen then down */
1443 for(y
= 0; y
< Rect
.bottom
; y
+= WinSta
->cyWallpaper
)
1445 for(x
= 0; x
< Rect
.right
; x
+= WinSta
->cxWallpaper
)
1450 WinSta
->cxWallpaper
,
1451 WinSta
->cyWallpaper
,
1466 WinSta
->cxWallpaper
,
1467 WinSta
->cyWallpaper
,
1475 NtGdiSelectBitmap(hWallpaperDC
, hOldBitmap
);
1476 NtGdiDeleteObjectApp(hWallpaperDC
);
1481 /* Back ground is set to none, clear the screen */
1484 PreviousBrush
= NtGdiSelectBrush(hDC
, DesktopBrush
);
1485 NtGdiPatBlt(hDC
, Rect
.left
, Rect
.top
, Rect
.right
, Rect
.bottom
, PATCOPY
);
1486 NtGdiSelectBrush(hDC
, PreviousBrush
);
1490 * Display system version on the desktop background
1493 if (g_PaintDesktopVersion
)
1495 static WCHAR s_wszVersion
[256] = {0};
1500 len
= wcslen(s_wszVersion
);
1504 len
= GetSystemVersionString(s_wszVersion
);
1509 if (!UserSystemParametersInfo(SPI_GETWORKAREA
, 0, &rect
, 0))
1511 rect
.right
= UserGetSystemMetrics(SM_CXSCREEN
);
1512 rect
.bottom
= UserGetSystemMetrics(SM_CYSCREEN
);
1515 color_old
= IntGdiSetTextColor(hDC
, RGB(255,255,255));
1516 align_old
= IntGdiSetTextAlign(hDC
, TA_RIGHT
);
1517 mode_old
= IntGdiSetBkMode(hDC
, TRANSPARENT
);
1519 GreExtTextOutW(hDC
, rect
.right
-16, rect
.bottom
-48, 0, NULL
, s_wszVersion
, len
, NULL
, 0);
1521 IntGdiSetBkMode(hDC
, mode_old
);
1522 IntGdiSetTextAlign(hDC
, align_old
);
1523 IntGdiSetTextColor(hDC
, color_old
);
1530 DPRINT("Leave NtUserPaintDesktop, ret=%i\n",_ret_
);
1537 * NtUserSwitchDesktop
1539 * Sets the current input (interactive) desktop.
1543 * Handle to desktop.
1553 NtUserSwitchDesktop(HDESK hDesktop
)
1555 PDESKTOP DesktopObject
;
1557 DECLARE_RETURN(BOOL
);
1559 UserEnterExclusive();
1560 DPRINT("Enter NtUserSwitchDesktop\n");
1562 DPRINT("About to switch desktop (0x%X)\n", hDesktop
);
1564 Status
= IntValidateDesktopHandle(
1570 if (!NT_SUCCESS(Status
))
1572 DPRINT("Validation of desktop handle (0x%X) failed\n", hDesktop
);
1577 * Don't allow applications switch the desktop if it's locked, unless the caller
1578 * is the logon application itself
1580 if((DesktopObject
->WindowStation
->Flags
& WSS_LOCKED
) &&
1581 LogonProcess
!= NULL
&& LogonProcess
!= PsGetCurrentProcessWin32Process())
1583 ObDereferenceObject(DesktopObject
);
1584 DPRINT1("Switching desktop 0x%x denied because the work station is locked!\n", hDesktop
);
1588 /* FIXME: Fail if the desktop belong to an invisible window station */
1589 /* FIXME: Fail if the process is associated with a secured
1590 desktop such as Winlogon or Screen-Saver */
1591 /* FIXME: Connect to input device */
1593 /* Set the active desktop in the desktop's window station. */
1594 DesktopObject
->WindowStation
->ActiveDesktop
= DesktopObject
;
1596 /* Set the global state. */
1597 InputDesktop
= DesktopObject
;
1598 InputDesktopHandle
= hDesktop
;
1599 InputWindowStation
= DesktopObject
->WindowStation
;
1601 ObDereferenceObject(DesktopObject
);
1606 DPRINT("Leave NtUserSwitchDesktop, ret=%i\n",_ret_
);
1612 * NtUserResolveDesktopForWOW
1619 NtUserResolveDesktopForWOW(DWORD Unknown0
)
1626 * NtUserGetThreadDesktop
1633 NtUserGetThreadDesktop(DWORD dwThreadId
, DWORD Unknown1
)
1637 PDESKTOP DesktopObject
;
1638 HDESK Ret
, hThreadDesktop
;
1639 OBJECT_HANDLE_INFORMATION HandleInformation
;
1640 DECLARE_RETURN(HDESK
);
1642 UserEnterExclusive();
1643 DPRINT("Enter NtUserGetThreadDesktop\n");
1647 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1651 Status
= PsLookupThreadByThreadId((HANDLE
)(DWORD_PTR
)dwThreadId
, &Thread
);
1652 if(!NT_SUCCESS(Status
))
1654 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1658 if(Thread
->ThreadsProcess
== PsGetCurrentProcess())
1660 /* just return the handle, we queried the desktop handle of a thread running
1661 in the same context */
1662 Ret
= ((PTHREADINFO
)Thread
->Tcb
.Win32Thread
)->hDesktop
;
1663 ObDereferenceObject(Thread
);
1667 /* get the desktop handle and the desktop of the thread */
1668 if(!(hThreadDesktop
= ((PTHREADINFO
)Thread
->Tcb
.Win32Thread
)->hDesktop
) ||
1669 !(DesktopObject
= ((PTHREADINFO
)Thread
->Tcb
.Win32Thread
)->Desktop
))
1671 ObDereferenceObject(Thread
);
1672 DPRINT1("Desktop information of thread 0x%x broken!?\n", dwThreadId
);
1676 /* we could just use DesktopObject instead of looking up the handle, but latter
1677 may be a bit safer (e.g. when the desktop is being destroyed */
1678 /* switch into the context of the thread we're trying to get the desktop from,
1679 so we can use the handle */
1680 KeAttachProcess(&Thread
->ThreadsProcess
->Pcb
);
1681 Status
= ObReferenceObjectByHandle(hThreadDesktop
,
1683 ExDesktopObjectType
,
1685 (PVOID
*)&DesktopObject
,
1686 &HandleInformation
);
1689 /* the handle couldn't be found, there's nothing to get... */
1690 if(!NT_SUCCESS(Status
))
1692 ObDereferenceObject(Thread
);
1696 /* lookup our handle table if we can find a handle to the desktop object,
1697 if not, create one */
1698 Ret
= IntGetDesktopObjectHandle(DesktopObject
);
1700 /* all done, we got a valid handle to the desktop */
1701 ObDereferenceObject(DesktopObject
);
1702 ObDereferenceObject(Thread
);
1706 DPRINT("Leave NtUserGetThreadDesktop, ret=%i\n",_ret_
);
1712 IntUnmapDesktopView(IN PDESKTOP DesktopObject
)
1715 PW32PROCESS CurrentWin32Process
;
1716 PW32HEAP_USER_MAPPING HeapMapping
, *PrevLink
;
1717 NTSTATUS Status
= STATUS_SUCCESS
;
1721 CurrentWin32Process
= PsGetCurrentProcessWin32Process();
1722 PrevLink
= &CurrentWin32Process
->HeapMappings
.Next
;
1724 /* unmap if we're the last thread using the desktop */
1725 HeapMapping
= *PrevLink
;
1726 while (HeapMapping
!= NULL
)
1728 if (HeapMapping
->KernelMapping
== (PVOID
)DesktopObject
->pheapDesktop
)
1730 if (--HeapMapping
->Count
== 0)
1732 *PrevLink
= HeapMapping
->Next
;
1734 Status
= MmUnmapViewOfSection(PsGetCurrentProcess(),
1735 HeapMapping
->UserMapping
);
1737 ObDereferenceObject(DesktopObject
);
1739 UserHeapFree(HeapMapping
);
1744 PrevLink
= &HeapMapping
->Next
;
1745 HeapMapping
= HeapMapping
->Next
;
1748 ti
= GetW32ThreadInfo();
1751 if (ti
->pDeskInfo
== DesktopObject
->DesktopInfo
)
1753 ti
->pDeskInfo
= NULL
;
1755 GetWin32ClientInfo()->pDeskInfo
= NULL
;
1757 GetWin32ClientInfo()->ulClientDelta
= 0;
1763 IntMapDesktopView(IN PDESKTOP DesktopObject
)
1766 PW32PROCESS CurrentWin32Process
;
1767 PW32HEAP_USER_MAPPING HeapMapping
, *PrevLink
;
1768 PVOID UserBase
= NULL
;
1769 SIZE_T ViewSize
= 0;
1770 LARGE_INTEGER Offset
;
1773 CurrentWin32Process
= PsGetCurrentProcessWin32Process();
1774 PrevLink
= &CurrentWin32Process
->HeapMappings
.Next
;
1776 /* find out if another thread already mapped the desktop heap */
1777 HeapMapping
= *PrevLink
;
1778 while (HeapMapping
!= NULL
)
1780 if (HeapMapping
->KernelMapping
== (PVOID
)DesktopObject
->pheapDesktop
)
1782 HeapMapping
->Count
++;
1783 return STATUS_SUCCESS
;
1786 PrevLink
= &HeapMapping
->Next
;
1787 HeapMapping
= HeapMapping
->Next
;
1790 /* we're the first, map the heap */
1791 DPRINT("Noone mapped the desktop heap %p yet, so - map it!\n", DesktopObject
->pheapDesktop
);
1792 Offset
.QuadPart
= 0;
1793 Status
= MmMapViewOfSection(DesktopObject
->DesktopHeapSection
,
1794 PsGetCurrentProcess(),
1802 PAGE_EXECUTE_READ
); /* would prefer PAGE_READONLY, but thanks to RTL heaps... */
1803 if (!NT_SUCCESS(Status
))
1805 DPRINT1("Failed to map desktop\n");
1809 /* add the mapping */
1810 HeapMapping
= UserHeapAlloc(sizeof(W32HEAP_USER_MAPPING
));
1811 if (HeapMapping
== NULL
)
1813 MmUnmapViewOfSection(PsGetCurrentProcess(),
1815 DPRINT1("UserHeapAlloc() failed!\n");
1816 return STATUS_NO_MEMORY
;
1819 HeapMapping
->Next
= NULL
;
1820 HeapMapping
->KernelMapping
= (PVOID
)DesktopObject
->pheapDesktop
;
1821 HeapMapping
->UserMapping
= UserBase
;
1822 HeapMapping
->Limit
= ViewSize
;
1823 HeapMapping
->Count
= 1;
1824 *PrevLink
= HeapMapping
;
1826 ObReferenceObject(DesktopObject
);
1828 /* create a W32THREADINFO structure if not already done, or update it */
1829 ti
= GetW32ThreadInfo();
1830 GetWin32ClientInfo()->ulClientDelta
= DesktopHeapGetUserDelta();
1833 if (ti
->pDeskInfo
== NULL
)
1835 ti
->pDeskInfo
= DesktopObject
->DesktopInfo
;
1836 GetWin32ClientInfo()->pDeskInfo
=
1837 (PVOID
)((ULONG_PTR
)ti
->pDeskInfo
- GetWin32ClientInfo()->ulClientDelta
);
1841 return STATUS_SUCCESS
;
1845 IntSetThreadDesktop(IN PDESKTOP DesktopObject
,
1846 IN BOOL FreeOnFailure
)
1848 PDESKTOP OldDesktop
;
1849 PTHREADINFO W32Thread
;
1853 DPRINT("IntSetThreadDesktop() DO=%p, FOF=%d\n", DesktopObject
, FreeOnFailure
);
1854 MapHeap
= (PsGetCurrentProcess() != PsInitialSystemProcess
);
1855 W32Thread
= PsGetCurrentThreadWin32Thread();
1857 if (W32Thread
->Desktop
!= DesktopObject
)
1859 OldDesktop
= W32Thread
->Desktop
;
1861 if (!IsListEmpty(&W32Thread
->WindowListHead
))
1863 DPRINT1("Attempted to change thread desktop although the thread has windows!\n");
1864 SetLastWin32Error(ERROR_BUSY
);
1868 W32Thread
->Desktop
= DesktopObject
;
1870 if (MapHeap
&& DesktopObject
!= NULL
)
1872 Status
= IntMapDesktopView(DesktopObject
);
1873 if (!NT_SUCCESS(Status
))
1875 SetLastNtError(Status
);
1880 if (W32Thread
->Desktop
== NULL
)
1882 PW32THREADINFO ti
= GetW32ThreadInfo();
1885 ti
->pDeskInfo
= NULL
;
1889 /* Hack for system threads */
1892 PCLIENTINFO pci
= GetWin32ClientInfo();
1893 pci
->ulClientDelta
= DesktopHeapGetUserDelta();
1896 pci
->pDeskInfo
= (PVOID
)((ULONG_PTR
)DesktopObject
->DesktopInfo
- pci
->ulClientDelta
);
1900 if (OldDesktop
!= NULL
&&
1901 !IntCheckProcessDesktopClasses(OldDesktop
,
1904 DPRINT1("Failed to move process classes to shared heap!\n");
1906 /* failed to move desktop classes to the shared heap,
1907 unmap the view and return the error */
1908 if (MapHeap
&& DesktopObject
!= NULL
)
1909 IntUnmapDesktopView(DesktopObject
);
1914 /* Remove the thread from the old desktop's list */
1915 RemoveEntryList(&W32Thread
->PtiLink
);
1917 if (DesktopObject
!= NULL
)
1919 ObReferenceObject(DesktopObject
);
1920 /* Insert into new desktop's list */
1921 InsertTailList(&DesktopObject
->PtiList
, &W32Thread
->PtiLink
);
1924 if (OldDesktop
!= NULL
)
1928 IntUnmapDesktopView(OldDesktop
);
1931 ObDereferenceObject(OldDesktop
);
1939 * NtUserSetThreadDesktop
1946 NtUserSetThreadDesktop(HDESK hDesktop
)
1948 PDESKTOP DesktopObject
;
1950 DECLARE_RETURN(BOOL
);
1952 UserEnterExclusive();
1953 DPRINT("Enter NtUserSetThreadDesktop\n");
1955 /* Validate the new desktop. */
1956 Status
= IntValidateDesktopHandle(
1962 if (!NT_SUCCESS(Status
))
1964 DPRINT("Validation of desktop handle (0x%X) failed\n", hDesktop
);
1968 /* FIXME: Should check here to see if the thread has any windows. */
1970 if (!IntSetThreadDesktop(DesktopObject
,
1979 DPRINT("Leave NtUserSetThreadDesktop, ret=%i\n",_ret_
);