2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Win32k subsystem
5 * FILE: subsystems/win32/win32k/ntuser/desktop.c
6 * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
9 /* INCLUDES ******************************************************************/
12 DBG_DEFAULT_CHANNEL(UserDesktop
);
17 IN OUT PDESKTOP Desktop
20 /* GLOBALS *******************************************************************/
22 /* Currently active desktop */
23 PDESKTOP InputDesktop
= NULL
;
24 HDESK InputDesktopHandle
= NULL
;
25 HDC ScreenDeviceContext
= NULL
;
27 /* OBJECT CALLBACKS **********************************************************/
31 IntDesktopObjectParse(IN PVOID ParseObject
,
33 IN OUT PACCESS_STATE AccessState
,
34 IN KPROCESSOR_MODE AccessMode
,
36 IN OUT PUNICODE_STRING CompleteName
,
37 IN OUT PUNICODE_STRING RemainingName
,
38 IN OUT PVOID Context OPTIONAL
,
39 IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL
,
44 OBJECT_ATTRIBUTES ObjectAttributes
;
45 PLIST_ENTRY NextEntry
, ListHead
;
46 PWINSTATION_OBJECT WinStaObject
= (PWINSTATION_OBJECT
)ParseObject
;
47 PUNICODE_STRING DesktopName
;
48 PBOOLEAN pContext
= (PBOOLEAN
) Context
;
53 /* Set the list pointers and loop the window station */
54 ListHead
= &WinStaObject
->DesktopListHead
;
55 NextEntry
= ListHead
->Flink
;
56 while (NextEntry
!= ListHead
)
58 /* Get the current desktop */
59 Desktop
= CONTAINING_RECORD(NextEntry
, DESKTOP
, ListEntry
);
62 DesktopName
= GET_DESKTOP_NAME(Desktop
);
65 /* Compare the name */
66 if (RtlEqualUnicodeString(RemainingName
,
68 (Attributes
& OBJ_CASE_INSENSITIVE
)))
70 /* We found a match. Did this come from a create? */
73 /* Unless OPEN_IF was given, fail with an error */
74 if (!(Attributes
& OBJ_OPENIF
))
77 return STATUS_OBJECT_NAME_COLLISION
;
81 /* Otherwise, return with a warning only */
82 Status
= STATUS_OBJECT_NAME_EXISTS
;
87 /* This was a real open, so this is OK */
88 Status
= STATUS_SUCCESS
;
91 /* Reference the desktop and return it */
92 ObReferenceObject(Desktop
);
98 /* Go to the next desktop */
99 NextEntry
= NextEntry
->Flink
;
102 /* If we got here but this isn't a create, then fail */
103 if (!Context
) return STATUS_OBJECT_NAME_NOT_FOUND
;
105 /* Create the desktop object */
106 InitializeObjectAttributes(&ObjectAttributes
, RemainingName
, 0, NULL
, NULL
);
107 Status
= ObCreateObject(KernelMode
,
116 if (!NT_SUCCESS(Status
)) return Status
;
118 /* Initialize shell hook window list and set the parent */
119 RtlZeroMemory(Desktop
, sizeof(DESKTOP
));
120 InitializeListHead(&Desktop
->ShellHookWindows
);
121 Desktop
->rpwinstaParent
= (PWINSTATION_OBJECT
)ParseObject
;
123 /* Put the desktop on the window station's list of associated desktops */
124 InsertTailList(&Desktop
->rpwinstaParent
->DesktopListHead
,
125 &Desktop
->ListEntry
);
127 /* Set the desktop object and return success */
130 return STATUS_SUCCESS
;
134 IntDesktopObjectDelete(PWIN32_DELETEMETHOD_PARAMETERS Parameters
)
136 PDESKTOP Desktop
= (PDESKTOP
)Parameters
->Object
;
138 TRACE("Deleting desktop object 0x%x\n", Desktop
);
140 /* Remove the desktop from the window station's list of associcated desktops */
141 RemoveEntryList(&Desktop
->ListEntry
);
143 IntFreeDesktopHeap(Desktop
);
147 IntDesktopOkToClose(PWIN32_OKAYTOCLOSEMETHOD_PARAMETERS Parameters
)
151 pti
= PsGetCurrentThreadWin32Thread();
155 /* This happens when we leak desktop handles */
156 return STATUS_SUCCESS
;
159 /* Do not allow the current desktop or the initial desktop to be closed */
160 if( Parameters
->Handle
== pti
->ppi
->hdeskStartup
||
161 Parameters
->Handle
== pti
->hdesk
)
163 return STATUS_ACCESS_DENIED
;
166 return STATUS_SUCCESS
;
169 /* PRIVATE FUNCTIONS **********************************************************/
174 InitDesktopImpl(VOID
)
176 GENERIC_MAPPING IntDesktopMapping
= { DESKTOP_READ
,
181 /* Set Desktop Object Attributes */
182 ExDesktopObjectType
->TypeInfo
.DefaultNonPagedPoolCharge
= sizeof(DESKTOP
);
183 ExDesktopObjectType
->TypeInfo
.GenericMapping
= IntDesktopMapping
;
184 ExDesktopObjectType
->TypeInfo
.ValidAccessMask
= DESKTOP_ALL_ACCESS
;
185 return STATUS_SUCCESS
;
188 static int GetSystemVersionString(LPWSTR buffer
)
190 RTL_OSVERSIONINFOEXW versionInfo
;
193 versionInfo
.dwOSVersionInfoSize
= sizeof(RTL_OSVERSIONINFOEXW
);
195 if (!NT_SUCCESS(RtlGetVersion((PRTL_OSVERSIONINFOW
)&versionInfo
)))
198 if (versionInfo
.dwMajorVersion
<= 4)
199 len
= swprintf(buffer
,
200 L
"ReactOS Version %d.%d %s Build %d",
201 versionInfo
.dwMajorVersion
, versionInfo
.dwMinorVersion
,
202 versionInfo
.szCSDVersion
, versionInfo
.dwBuildNumber
&0xFFFF);
204 len
= swprintf(buffer
,
205 L
"ReactOS %s (Build %d)",
206 versionInfo
.szCSDVersion
, versionInfo
.dwBuildNumber
&0xFFFF);
213 IntParseDesktopPath(PEPROCESS Process
,
214 PUNICODE_STRING DesktopPath
,
218 OBJECT_ATTRIBUTES ObjectAttributes
;
219 UNICODE_STRING ObjectName
;
221 WCHAR wstrWinstaFullName
[MAX_PATH
], *pwstrWinsta
= NULL
, *pwstrDesktop
= NULL
;
230 if(DesktopPath
->Buffer
!= NULL
&& DesktopPath
->Length
> sizeof(WCHAR
))
233 * Parse the desktop path string which can be in the form "WinSta\Desktop"
234 * or just "Desktop". In latter case WinSta0 will be used.
237 pwstrDesktop
= wcschr(DesktopPath
->Buffer
, L
'\\');
238 if(pwstrDesktop
!= NULL
)
242 pwstrWinsta
= DesktopPath
->Buffer
;
246 pwstrDesktop
= DesktopPath
->Buffer
;
250 TRACE("IntParseDesktopPath pwstrWinsta:%S pwstrDesktop:%S\n", pwstrWinsta
, pwstrDesktop
);
254 /* Search the process handle table for (inherited) window station
255 handles, use a more appropriate one than WinSta0 if possible. */
256 if (!ObFindHandleForObject(Process
,
258 ExWindowStationObjectType
,
263 /* We had no luck searching for opened handles, use WinSta0 now */
265 pwstrWinsta
= L
"WinSta0";
269 /* Search the process handle table for (inherited) desktop
270 handles, use a more appropriate one than Default if possible. */
271 if (!ObFindHandleForObject(Process
,
278 /* We had no luck searching for opened handles, use Desktop now */
280 pwstrDesktop
= L
"Default";
285 swprintf(wstrWinstaFullName
, L
"%wZ\\%ws", &gustrWindowStationsDir
, pwstrWinsta
);
286 RtlInitUnicodeString( &ObjectName
, wstrWinstaFullName
);
288 TRACE("parsed initial winsta: %wZ\n", &ObjectName
);
290 /* Open the window station */
291 InitializeObjectAttributes(&ObjectAttributes
,
293 OBJ_CASE_INSENSITIVE
,
297 Status
= ObOpenObjectByName(&ObjectAttributes
,
298 ExWindowStationObjectType
,
305 if(!NT_SUCCESS(Status
))
307 SetLastNtError(Status
);
308 ERR("Failed to reference window station %wZ PID: %d!\n", &ObjectName
);
313 if(*hDesktop
== NULL
)
315 RtlInitUnicodeString(&ObjectName
, pwstrDesktop
);
317 TRACE("parsed initial desktop: %wZ\n", &ObjectName
);
319 /* Open the desktop object */
320 InitializeObjectAttributes(&ObjectAttributes
,
322 OBJ_CASE_INSENSITIVE
,
326 Status
= ObOpenObjectByName(&ObjectAttributes
,
334 if(!NT_SUCCESS(Status
))
339 SetLastNtError(Status
);
340 ERR("Failed to reference desktop %wZ PID: %d!\n", &ObjectName
);
344 return STATUS_SUCCESS
;
348 * IntValidateDesktopHandle
350 * Validates the desktop handle.
353 * If the function succeeds, the handle remains referenced. If the
354 * fucntion fails, last error is set.
358 IntValidateDesktopHandle(
360 KPROCESSOR_MODE AccessMode
,
361 ACCESS_MASK DesiredAccess
,
366 Status
= ObReferenceObjectByHandle(
374 TRACE("IntValidateDesktopHandle: handle:0x%x obj:0x%x access:0x%x Status:0x%x\n",
375 Desktop
, *Object
, DesiredAccess
, Status
);
377 if (!NT_SUCCESS(Status
))
378 SetLastNtError(Status
);
384 IntGetActiveDesktop(VOID
)
390 * Returns or creates a handle to the desktop object
393 IntGetDesktopObjectHandle(PDESKTOP DesktopObject
)
398 ASSERT(DesktopObject
);
400 if (!ObFindHandleForObject(PsGetCurrentProcess(),
406 Status
= ObOpenObjectByPointer(DesktopObject
,
413 if(!NT_SUCCESS(Status
))
415 /* Unable to create a handle */
416 ERR("Unable to create a desktop handle\n");
422 ERR("Got handle: %lx\n", Ret
);
428 PUSER_MESSAGE_QUEUE FASTCALL
429 IntGetFocusMessageQueue(VOID
)
431 PDESKTOP pdo
= IntGetActiveDesktop();
434 TRACE("No active desktop\n");
437 return (PUSER_MESSAGE_QUEUE
)pdo
->ActiveMessageQueue
;
441 IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue
)
443 PUSER_MESSAGE_QUEUE Old
;
444 PDESKTOP pdo
= IntGetActiveDesktop();
447 TRACE("No active desktop\n");
452 if(NewQueue
->Desktop
!= NULL
)
454 TRACE("Message Queue already attached to another desktop!\n");
457 IntReferenceMessageQueue(NewQueue
);
458 (void)InterlockedExchangePointer((PVOID
*)&NewQueue
->Desktop
, pdo
);
460 Old
= (PUSER_MESSAGE_QUEUE
)InterlockedExchangePointer((PVOID
*)&pdo
->ActiveMessageQueue
, NewQueue
);
463 (void)InterlockedExchangePointer((PVOID
*)&Old
->Desktop
, 0);
464 IntDereferenceMessageQueue(Old
);
468 HWND FASTCALL
IntGetDesktopWindow(VOID
)
470 PDESKTOP pdo
= IntGetActiveDesktop();
473 TRACE("No active desktop\n");
476 return pdo
->DesktopWindow
;
479 PWND FASTCALL
UserGetDesktopWindow(VOID
)
481 PDESKTOP pdo
= IntGetActiveDesktop();
485 TRACE("No active desktop\n");
489 return UserGetWindowObject(pdo
->DesktopWindow
);
492 HWND FASTCALL
IntGetMessageWindow(VOID
)
494 PDESKTOP pdo
= IntGetActiveDesktop();
498 TRACE("No active desktop\n");
501 return pdo
->spwndMessage
->head
.h
;
504 HWND FASTCALL
IntGetCurrentThreadDesktopWindow(VOID
)
506 PTHREADINFO pti
= PsGetCurrentThreadWin32Thread();
507 PDESKTOP pdo
= pti
->rpdesk
;
510 ERR("Thread doesn't have a desktop\n");
513 return pdo
->DesktopWindow
;
516 /* PUBLIC FUNCTIONS ***********************************************************/
519 UserGetDesktopDC(ULONG DcType
, BOOL EmptyDC
, BOOL ValidatehWnd
)
521 PWND DesktopObject
= 0;
524 if (DcType
== DC_TYPE_DIRECT
)
526 DesktopObject
= UserGetDesktopWindow();
527 DesktopHDC
= (HDC
)UserGetWindowDC(DesktopObject
);
531 PMONITOR pMonitor
= UserGetPrimaryMonitor();
532 DesktopHDC
= IntGdiCreateDisplayDC(pMonitor
->hDev
, DcType
, EmptyDC
);
544 Window
= UserGetDesktopWindow();
545 hRgn
= IntSysCreateRectRgnIndirect(&Window
->rcWindow
);
547 IntInvalidateWindows( Window
,
554 GreDeleteObject(hRgn
);
559 co_IntShowDesktop(PDESKTOP Desktop
, ULONG Width
, ULONG Height
)
561 CSR_API_MESSAGE Request
;
563 Request
.Type
= MAKE_CSR_API(SHOW_DESKTOP
, CSR_GUI
);
564 Request
.Data
.ShowDesktopRequest
.DesktopWindow
= Desktop
->DesktopWindow
;
565 Request
.Data
.ShowDesktopRequest
.Width
= Width
;
566 Request
.Data
.ShowDesktopRequest
.Height
= Height
;
568 return co_CsrNotify(&Request
);
572 IntHideDesktop(PDESKTOP Desktop
)
575 CSRSS_API_REQUEST Request
;
576 CSRSS_API_REPLY Reply
;
578 Request
.Type
= CSRSS_HIDE_DESKTOP
;
579 Request
.Data
.HideDesktopRequest
.DesktopWindow
= Desktop
->DesktopWindow
;
581 return NotifyCsrss(&Request
, &Reply
);
586 DesktopWnd
= IntGetWindowObject(Desktop
->DesktopWindow
);
589 return ERROR_INVALID_WINDOW_HANDLE
;
591 DesktopWnd
->style
&= ~WS_VISIBLE
;
593 return STATUS_SUCCESS
;
602 UserBuildShellHookHwndList(PDESKTOP Desktop
)
605 PSHELL_HOOK_WINDOW Current
;
608 /* FIXME: If we save nb elements in desktop, we dont have to loop to find nb entries */
609 LIST_FOR_EACH(Current
, &Desktop
->ShellHookWindows
, SHELL_HOOK_WINDOW
, ListEntry
)
612 if (!entries
) return NULL
;
614 list
= ExAllocatePoolWithTag(PagedPool
, sizeof(HWND
) * (entries
+ 1), USERTAG_WINDOWLIST
); /* alloc one extra for nullterm */
619 LIST_FOR_EACH(Current
, &Desktop
->ShellHookWindows
, SHELL_HOOK_WINDOW
, ListEntry
)
620 *cursor
++ = Current
->hWnd
;
622 *cursor
= NULL
; /* Nullterm list */
629 * Send the Message to the windows registered for ShellHook
630 * notifications. The lParam contents depend on the Message. See
631 * MSDN for more details (RegisterShellHookWindow)
633 VOID
co_IntShellHookNotify(WPARAM Message
, LPARAM lParam
)
635 PDESKTOP Desktop
= IntGetActiveDesktop();
638 if (!gpsi
->uiShellMsg
)
641 /* Too bad, this doesn't work. */
644 RtlInitUnicodeString(&Str
, L
"SHELLHOOK");
645 gpsi
->uiShellMsg
= UserRegisterWindowMessage(&Str
);
648 gpsi
->uiShellMsg
= IntAddAtom(L
"SHELLHOOK");
650 TRACE("MsgType = %x\n", gpsi
->uiShellMsg
);
651 if (!gpsi
->uiShellMsg
)
652 ERR("LastError: %x\n", EngGetLastError());
657 TRACE("IntShellHookNotify: No desktop!\n");
661 HwndList
= UserBuildShellHookHwndList(Desktop
);
664 HWND
* cursor
= HwndList
;
666 for (; *cursor
; cursor
++)
668 TRACE("Sending notify\n");
669 co_IntPostOrSendMessage(*cursor
,
675 ExFreePool(HwndList
);
681 * Add the window to the ShellHookWindows list. The windows
682 * on that list get notifications that are important to shell
685 * TODO: Validate the window? I'm not sure if sending these messages to
686 * an unsuspecting application that is not your own is a nice thing to do.
688 BOOL
IntRegisterShellHookWindow(HWND hWnd
)
690 PTHREADINFO pti
= PsGetCurrentThreadWin32Thread();
691 PDESKTOP Desktop
= pti
->rpdesk
;
692 PSHELL_HOOK_WINDOW Entry
;
694 TRACE("IntRegisterShellHookWindow\n");
696 /* First deregister the window, so we can be sure it's never twice in the
699 IntDeRegisterShellHookWindow(hWnd
);
701 Entry
= ExAllocatePoolWithTag(PagedPool
,
702 sizeof(SHELL_HOOK_WINDOW
),
710 InsertTailList(&Desktop
->ShellHookWindows
, &Entry
->ListEntry
);
716 * Remove the window from the ShellHookWindows list. The windows
717 * on that list get notifications that are important to shell
720 BOOL
IntDeRegisterShellHookWindow(HWND hWnd
)
722 PTHREADINFO pti
= PsGetCurrentThreadWin32Thread();
723 PDESKTOP Desktop
= pti
->rpdesk
;
724 PSHELL_HOOK_WINDOW Current
;
726 LIST_FOR_EACH(Current
, &Desktop
->ShellHookWindows
, SHELL_HOOK_WINDOW
, ListEntry
)
728 if (Current
->hWnd
== hWnd
)
730 RemoveEntryList(&Current
->ListEntry
);
740 IntFreeDesktopHeap(IN OUT PDESKTOP Desktop
)
742 if (Desktop
->hsectionDesktop
!= NULL
)
744 ObDereferenceObject(Desktop
->hsectionDesktop
);
745 Desktop
->hsectionDesktop
= NULL
;
748 /* SYSCALLS *******************************************************************/
751 * NtUserCreateDesktop
753 * Creates a new desktop.
760 * Name of the device.
769 * Requested type of access.
773 * If the function succeeds, the return value is a handle to the newly
774 * created desktop. If the specified desktop already exists, the function
775 * succeeds and returns a handle to the existing desktop. When you are
776 * finished using the handle, call the CloseDesktop function to close it.
777 * If the function fails, the return value is NULL.
785 POBJECT_ATTRIBUTES ObjectAttributes
,
786 PUNICODE_STRING lpszDesktopDevice
,
789 ACCESS_MASK dwDesiredAccess
)
791 PDESKTOP DesktopObject
;
792 UNICODE_STRING DesktopName
;
793 NTSTATUS Status
= STATUS_SUCCESS
;
795 CSR_API_MESSAGE Request
;
796 PVOID DesktopHeapSystemBase
= NULL
;
797 SIZE_T DesktopInfoSize
;
799 ULONG_PTR HeapSize
= 4 * 1024 * 1024; /* FIXME */
800 UNICODE_STRING ClassName
;
801 LARGE_STRING WindowName
;
802 BOOL NoHooks
= FALSE
;
806 PTHREADINFO ptiCurrent
;
807 DECLARE_RETURN(HDESK
);
809 TRACE("Enter NtUserCreateDesktop\n");
810 UserEnterExclusive();
812 ptiCurrent
= PsGetCurrentThreadWin32Thread();
815 /* Turn off hooks when calling any CreateWindowEx from inside win32k. */
816 NoHooks
= (ptiCurrent
->TIF_flags
& TIF_DISABLEHOOKS
);
817 ptiCurrent
->TIF_flags
|= TIF_DISABLEHOOKS
;
818 ptiCurrent
->pClientInfo
->dwTIFlags
= ptiCurrent
->TIF_flags
;
820 DesktopName
.Buffer
= NULL
;
823 * Try to open already existing desktop
826 Status
= ObOpenObjectByName(
834 if (!NT_SUCCESS(Status
)) RETURN(NULL
);
836 /* In case the object was not created (eg if it existed), return now */
837 if (Context
== FALSE
)
839 TRACE("NtUserCreateDesktop opened desktop %wZ\n", ObjectAttributes
->ObjectName
);
843 /* Capture desktop name */
846 ProbeForRead( ObjectAttributes
, sizeof(OBJECT_ATTRIBUTES
), 1);
848 Status
= IntSafeCopyUnicodeStringTerminateNULL(&DesktopName
, ObjectAttributes
->ObjectName
);
850 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
852 Status
= _SEH2_GetExceptionCode();
856 if (! NT_SUCCESS(Status
))
858 ERR("Failed reading Object Attributes from user space.\n");
859 SetLastNtError(Status
);
863 /* Reference the desktop */
864 Status
= ObReferenceObjectByHandle(Desktop
,
868 (PVOID
)&DesktopObject
,
870 if (!NT_SUCCESS(Status
))
872 ERR("Failed to reference desktop object\n");
876 TRACE("NtUserCreateDesktop created desktop 0x%x with name %wZ\n", DesktopObject
, &DesktopName
);
878 DesktopObject
->hsectionDesktop
= NULL
;
879 DesktopObject
->pheapDesktop
= UserCreateHeap(&DesktopObject
->hsectionDesktop
,
880 &DesktopHeapSystemBase
,
882 if (DesktopObject
->pheapDesktop
== NULL
)
884 ObDereferenceObject(DesktopObject
);
885 ERR("Failed to create desktop heap!\n");
889 DesktopInfoSize
= sizeof(DESKTOPINFO
) + DesktopName
.Length
+ sizeof(WCHAR
);
891 DesktopObject
->pDeskInfo
= RtlAllocateHeap(DesktopObject
->pheapDesktop
,
895 if (DesktopObject
->pDeskInfo
== NULL
)
897 ObDereferenceObject(DesktopObject
);
898 ERR("Failed to create the DESKTOP structure!\n");
902 RtlZeroMemory(DesktopObject
->pDeskInfo
,
905 DesktopObject
->pDeskInfo
->pvDesktopBase
= DesktopHeapSystemBase
;
906 DesktopObject
->pDeskInfo
->pvDesktopLimit
= (PVOID
)((ULONG_PTR
)DesktopHeapSystemBase
+ HeapSize
);
907 RtlCopyMemory(DesktopObject
->pDeskInfo
->szDesktopName
,
909 DesktopName
.Length
+ sizeof(WCHAR
));
911 /* Initialize some local (to win32k) desktop state. */
912 InitializeListHead(&DesktopObject
->PtiList
);
913 DesktopObject
->ActiveMessageQueue
= NULL
;
914 /* Setup Global Hooks. */
915 for (i
= 0; i
< NB_HOOKS
; i
++)
917 InitializeListHead(&DesktopObject
->pDeskInfo
->aphkStart
[i
]);
922 * Create a handle for CSRSS and notify CSRSS for Creating Desktop Window.
924 Request
.Type
= MAKE_CSR_API(CREATE_DESKTOP
, CSR_GUI
);
925 Status
= CsrInsertObject(Desktop
,
927 (HANDLE
*)&Request
.Data
.CreateDesktopRequest
.DesktopHandle
);
928 if (! NT_SUCCESS(Status
))
930 ERR("Failed to create desktop handle for CSRSS\n");
932 SetLastNtError(Status
);
936 Status
= co_CsrNotify(&Request
);
937 if (! NT_SUCCESS(Status
))
939 CsrCloseHandle(Request
.Data
.CreateDesktopRequest
.DesktopHandle
);
940 ERR("Failed to notify CSRSS about new desktop\n");
942 SetLastNtError(Status
);
945 #if 0 // Turn on when server side proc is ready.
947 // Create desktop window.
949 ClassName
.Buffer
= ((PWSTR
)((ULONG_PTR
)(WORD
)(gpsi
->atomSysClass
[ICLS_DESKTOP
])));
950 ClassName
.Length
= 0;
951 RtlZeroMemory(&WindowName
, sizeof(WindowName
));
953 RtlZeroMemory(&Cs
, sizeof(Cs
));
954 Cs
.x
= UserGetSystemMetrics(SM_XVIRTUALSCREEN
);
955 Cs
.y
= UserGetSystemMetrics(SM_YVIRTUALSCREEN
);
956 Cs
.cx
= UserGetSystemMetrics(SM_CXVIRTUALSCREEN
);
957 Cs
.cy
= UserGetSystemMetrics(SM_CYVIRTUALSCREEN
);
958 Cs
.style
= WS_POPUP
|WS_CLIPCHILDREN
;
959 Cs
.hInstance
= hModClient
; // Experimental mode... Move csr stuff to User32. hModuleWin; // Server side winproc!
960 Cs
.lpszName
= (LPCWSTR
) &WindowName
;
961 Cs
.lpszClass
= (LPCWSTR
) &ClassName
;
963 pWndDesktop
= co_UserCreateWindowEx(&Cs
, &ClassName
, &WindowName
, NULL
);
966 ERR("Failed to create Desktop window handle\n");
970 DesktopObject
->pDeskInfo
->spwnd
= pWndDesktop
;
974 if (!ptiCurrent
->rpdesk
) IntSetThreadDesktop(Desktop
,FALSE
);
977 Based on wine/server/window.c in get_desktop_window.
980 ClassName
.Buffer
= ((PWSTR
)((ULONG_PTR
)(WORD
)(gpsi
->atomSysClass
[ICLS_HWNDMESSAGE
])));
981 ClassName
.Length
= 0;
982 RtlZeroMemory(&WindowName
, sizeof(WindowName
));
984 RtlZeroMemory(&Cs
, sizeof(Cs
));
986 Cs
.style
= WS_POPUP
|WS_CLIPCHILDREN
;
987 Cs
.hInstance
= hModClient
; // hModuleWin; // Server side winproc! Leave it to Timo to not pass on notes!
988 Cs
.lpszName
= (LPCWSTR
) &WindowName
;
989 Cs
.lpszClass
= (LPCWSTR
) &ClassName
;
991 pWnd
= co_UserCreateWindowEx(&Cs
, &ClassName
, &WindowName
, NULL
);
994 ERR("Failed to create Message window handle\n");
998 DesktopObject
->spwndMessage
= pWnd
;
1002 if !(WinStaObject->Flags & WSF_NOIO) is (not set) for desktop input output mode (see wiki)
1003 Create Tooltip. Saved in DesktopObject->spwndTooltip.
1004 Tooltip dwExStyle: WS_EX_TOOLWINDOW|WS_EX_TOPMOST
1005 hWndParent are spwndMessage. Use hModuleWin for server side winproc!
1006 The rest is same as message window.
1007 http://msdn.microsoft.com/en-us/library/bb760250(VS.85).aspx
1012 if(DesktopName
.Buffer
!= NULL
)
1014 ExFreePoolWithTag(DesktopName
.Buffer
, TAG_STRING
);
1016 if (!NoHooks
&& ptiCurrent
)
1018 ptiCurrent
->TIF_flags
&= ~TIF_DISABLEHOOKS
;
1019 ptiCurrent
->pClientInfo
->dwTIFlags
= ptiCurrent
->TIF_flags
;
1021 TRACE("Leave NtUserCreateDesktop, ret=%i\n",_ret_
);
1029 * Opens an existing desktop.
1033 * Name of the existing desktop.
1036 * Interaction flags.
1039 * Requested type of access.
1042 * Handle to the desktop or zero on failure.
1050 POBJECT_ATTRIBUTES ObjectAttributes
,
1052 ACCESS_MASK dwDesiredAccess
)
1057 Status
= ObOpenObjectByName(
1059 ExDesktopObjectType
,
1066 if (!NT_SUCCESS(Status
))
1068 ERR("Failed to open desktop\n");
1069 SetLastNtError(Status
);
1073 TRACE("Opened desktop %S with handle 0x%x\n", ObjectAttributes
->ObjectName
->Buffer
, Desktop
);
1079 * NtUserOpenInputDesktop
1081 * Opens the input (interactive) desktop.
1085 * Interaction flags.
1088 * Inheritance option.
1091 * Requested type of access.
1094 * Handle to the input desktop or zero on failure.
1101 NtUserOpenInputDesktop(
1104 ACCESS_MASK dwDesiredAccess
)
1110 TRACE("Enter NtUserOpenInputDesktop\n");
1112 /* Get a pointer to the desktop object */
1113 Status
= IntValidateDesktopHandle(InputDesktopHandle
, UserMode
, 0, &pdesk
);
1114 if (!NT_SUCCESS(Status
))
1116 TRACE("Validation of input desktop handle (0x%X) failed\n", InputDesktop
);
1120 /* Create a new handle to the object */
1121 Status
= ObOpenObjectByPointer(
1126 ExDesktopObjectType
,
1130 ObDereferenceObject(pdesk
);
1132 if (!NT_SUCCESS(Status
))
1134 ERR("Failed to open input desktop object\n");
1135 SetLastNtError(Status
);
1139 TRACE("NtUserOpenInputDesktop returning 0x%x\n",hdesk
);
1144 * NtUserCloseDesktop
1146 * Closes a desktop handle.
1150 * Handle to the desktop.
1156 * The desktop handle can be created with NtUserCreateDesktop or
1157 * NtUserOpenDesktop. This function will fail if any thread in the calling
1158 * process is using the specified desktop handle or if the handle refers
1159 * to the initial desktop of the calling process.
1166 NtUserCloseDesktop(HDESK hDesktop
)
1171 DECLARE_RETURN(BOOL
);
1173 pti
= PsGetCurrentThreadWin32Thread();
1175 TRACE("NtUserCloseDesktop called (0x%x)\n", hDesktop
);
1176 UserEnterExclusive();
1178 if( hDesktop
== pti
->hdesk
|| hDesktop
== pti
->ppi
->hdeskStartup
)
1180 ERR("Attempted to close thread desktop\n");
1181 EngSetLastError(ERROR_BUSY
);
1185 Status
= IntValidateDesktopHandle( hDesktop
, UserMode
, 0, &pdesk
);
1186 if (!NT_SUCCESS(Status
))
1188 ERR("Validation of desktop handle (0x%X) failed\n", hDesktop
);
1192 ObDereferenceObject(pdesk
);
1194 Status
= ZwClose(hDesktop
);
1195 if (!NT_SUCCESS(Status
))
1197 ERR("Failed to close desktop handle 0x%x\n", hDesktop
);
1198 SetLastNtError(Status
);
1205 TRACE("Leave NtUserCloseDesktop, ret=%i\n",_ret_
);
1214 * NtUserPaintDesktop
1216 * The NtUserPaintDesktop function fills the clipping region in the
1217 * specified device context with the desktop pattern or wallpaper. The
1218 * function is provided primarily for shell desktops.
1222 * Handle to the device context.
1229 NtUserPaintDesktop(HDC hDC
)
1232 HBRUSH DesktopBrush
, PreviousBrush
;
1234 BOOL doPatBlt
= TRUE
;
1236 static WCHAR s_wszSafeMode
[] = L
"Safe Mode";
1241 DECLARE_RETURN(BOOL
);
1243 UserEnterExclusive();
1244 TRACE("Enter NtUserPaintDesktop\n");
1246 GdiGetClipBox(hDC
, &Rect
);
1248 hWndDesktop
= IntGetDesktopWindow();
1250 WndDesktop
= UserGetWindowObject(hWndDesktop
);
1256 if (!UserGetSystemMetrics(SM_CLEANBOOT
))
1258 DesktopBrush
= (HBRUSH
)WndDesktop
->pcls
->hbrBackground
;
1261 * Paint desktop background
1263 if (gspv
.hbmWallpaper
!= NULL
)
1269 sz
.cx
= WndDesktop
->rcWindow
.right
- WndDesktop
->rcWindow
.left
;
1270 sz
.cy
= WndDesktop
->rcWindow
.bottom
- WndDesktop
->rcWindow
.top
;
1272 if (gspv
.WallpaperMode
== wmStretch
||
1273 gspv
.WallpaperMode
== wmTile
)
1280 /* Find the upper left corner, can be negtive if the bitmap is bigger then the screen */
1281 x
= (sz
.cx
/ 2) - (gspv
.cxWallpaper
/ 2);
1282 y
= (sz
.cy
/ 2) - (gspv
.cyWallpaper
/ 2);
1285 hWallpaperDC
= NtGdiCreateCompatibleDC(hDC
);
1286 if(hWallpaperDC
!= NULL
)
1290 /* Fill in the area that the bitmap is not going to cover */
1293 /* FIXME: Clip out the bitmap
1294 can be replaced with "NtGdiPatBlt(hDC, x, y, WinSta->cxWallpaper, WinSta->cyWallpaper, PATCOPY | DSTINVERT);"
1295 once we support DSTINVERT */
1296 PreviousBrush
= NtGdiSelectBrush(hDC
, DesktopBrush
);
1297 NtGdiPatBlt(hDC
, Rect
.left
, Rect
.top
, Rect
.right
, Rect
.bottom
, PATCOPY
);
1298 NtGdiSelectBrush(hDC
, PreviousBrush
);
1301 /*Do not fill the background after it is painted no matter the size of the picture */
1304 hOldBitmap
= NtGdiSelectBitmap(hWallpaperDC
, gspv
.hbmWallpaper
);
1306 if (gspv
.WallpaperMode
== wmStretch
)
1308 if(Rect
.right
&& Rect
.bottom
)
1309 NtGdiStretchBlt(hDC
,
1323 else if (gspv
.WallpaperMode
== wmTile
)
1325 /* Paint the bitmap across the screen then down */
1326 for(y
= 0; y
< Rect
.bottom
; y
+= gspv
.cyWallpaper
)
1328 for(x
= 0; x
< Rect
.right
; x
+= gspv
.cxWallpaper
)
1358 NtGdiSelectBitmap(hWallpaperDC
, hOldBitmap
);
1359 NtGdiDeleteObjectApp(hWallpaperDC
);
1365 /* Black desktop background in Safe Mode */
1366 DesktopBrush
= StockObjects
[BLACK_BRUSH
];
1369 /* Back ground is set to none, clear the screen */
1372 PreviousBrush
= NtGdiSelectBrush(hDC
, DesktopBrush
);
1373 NtGdiPatBlt(hDC
, Rect
.left
, Rect
.top
, Rect
.right
, Rect
.bottom
, PATCOPY
);
1374 NtGdiSelectBrush(hDC
, PreviousBrush
);
1378 * Display system version on the desktop background
1381 if (g_PaintDesktopVersion
||UserGetSystemMetrics(SM_CLEANBOOT
))
1383 static WCHAR s_wszVersion
[256] = {0};
1388 len
= wcslen(s_wszVersion
);
1392 len
= GetSystemVersionString(s_wszVersion
);
1397 if (!UserSystemParametersInfo(SPI_GETWORKAREA
, 0, &rect
, 0))
1399 rect
.right
= UserGetSystemMetrics(SM_CXSCREEN
);
1400 rect
.bottom
= UserGetSystemMetrics(SM_CYSCREEN
);
1403 color_old
= IntGdiSetTextColor(hDC
, RGB(255,255,255));
1404 align_old
= IntGdiSetTextAlign(hDC
, TA_RIGHT
);
1405 mode_old
= IntGdiSetBkMode(hDC
, TRANSPARENT
);
1407 if(!UserGetSystemMetrics(SM_CLEANBOOT
))
1409 GreExtTextOutW(hDC
, rect
.right
-16, rect
.bottom
-48, 0, NULL
, s_wszVersion
, len
, NULL
, 0);
1414 /* Version information text in top center */
1415 IntGdiSetTextAlign(hDC
, TA_CENTER
|TA_TOP
);
1416 GreExtTextOutW(hDC
, (rect
.right
+rect
.left
)/2, rect
.top
, 0, NULL
, s_wszVersion
, len
, NULL
, 0);
1417 /* Safe Mode text in corners */
1418 len
= wcslen(s_wszSafeMode
);
1419 IntGdiSetTextAlign(hDC
, TA_RIGHT
|TA_TOP
);
1420 GreExtTextOutW(hDC
, rect
.right
, rect
.top
, 0, NULL
, s_wszSafeMode
, len
, NULL
, 0);
1421 IntGdiSetTextAlign(hDC
, TA_RIGHT
|TA_BASELINE
);
1422 GreExtTextOutW(hDC
, rect
.right
, rect
.bottom
, 0, NULL
, s_wszSafeMode
, len
, NULL
, 0);
1423 IntGdiSetTextAlign(hDC
, TA_LEFT
|TA_TOP
);
1424 GreExtTextOutW(hDC
, rect
.left
, rect
.top
, 0, NULL
, s_wszSafeMode
, len
, NULL
, 0);
1425 IntGdiSetTextAlign(hDC
, TA_LEFT
|TA_BASELINE
);
1426 GreExtTextOutW(hDC
, rect
.left
, rect
.bottom
, 0, NULL
, s_wszSafeMode
, len
, NULL
, 0);
1431 IntGdiSetBkMode(hDC
, mode_old
);
1432 IntGdiSetTextAlign(hDC
, align_old
);
1433 IntGdiSetTextColor(hDC
, color_old
);
1440 TRACE("Leave NtUserPaintDesktop, ret=%i\n",_ret_
);
1447 * NtUserSwitchDesktop
1449 * Sets the current input (interactive) desktop.
1453 * Handle to desktop.
1463 NtUserSwitchDesktop(HDESK hdesk
)
1467 DECLARE_RETURN(BOOL
);
1469 UserEnterExclusive();
1470 TRACE("Enter NtUserSwitchDesktop(0x%x)\n", hdesk
);
1472 Status
= IntValidateDesktopHandle( hdesk
, UserMode
, 0, &pdesk
);
1473 if (!NT_SUCCESS(Status
))
1475 ERR("Validation of desktop handle (0x%X) failed\n", hdesk
);
1480 * Don't allow applications switch the desktop if it's locked, unless the caller
1481 * is the logon application itself
1483 if((pdesk
->rpwinstaParent
->Flags
& WSS_LOCKED
) &&
1484 LogonProcess
!= PsGetCurrentProcessWin32Process())
1486 ObDereferenceObject(pdesk
);
1487 ERR("Switching desktop 0x%x denied because the window station is locked!\n", hdesk
);
1491 if(pdesk
->rpwinstaParent
!= InputWindowStation
)
1493 ObDereferenceObject(pdesk
);
1494 ERR("Switching desktop 0x%x denied because desktop doesn't belong to the interactive winsta!\n", hdesk
);
1498 /* FIXME: Fail if the process is associated with a secured
1499 desktop such as Winlogon or Screen-Saver */
1500 /* FIXME: Connect to input device */
1502 /* Set the active desktop in the desktop's window station. */
1503 InputWindowStation
->ActiveDesktop
= pdesk
;
1505 /* Set the global state. */
1506 InputDesktop
= pdesk
;
1507 InputDesktopHandle
= hdesk
;
1509 ObDereferenceObject(pdesk
);
1514 TRACE("Leave NtUserSwitchDesktop, ret=%i\n",_ret_
);
1520 * NtUserGetThreadDesktop
1527 NtUserGetThreadDesktop(DWORD dwThreadId
, DWORD Unknown1
)
1531 PDESKTOP DesktopObject
;
1532 HDESK Ret
, hThreadDesktop
;
1533 OBJECT_HANDLE_INFORMATION HandleInformation
;
1534 DECLARE_RETURN(HDESK
);
1536 UserEnterExclusive();
1537 TRACE("Enter NtUserGetThreadDesktop\n");
1541 EngSetLastError(ERROR_INVALID_PARAMETER
);
1545 Status
= PsLookupThreadByThreadId((HANDLE
)(DWORD_PTR
)dwThreadId
, &Thread
);
1546 if(!NT_SUCCESS(Status
))
1548 EngSetLastError(ERROR_INVALID_PARAMETER
);
1552 if(Thread
->ThreadsProcess
== PsGetCurrentProcess())
1554 /* Just return the handle, we queried the desktop handle of a thread running
1555 in the same context */
1556 Ret
= ((PTHREADINFO
)Thread
->Tcb
.Win32Thread
)->hdesk
;
1557 ObDereferenceObject(Thread
);
1561 /* Get the desktop handle and the desktop of the thread */
1562 if(!(hThreadDesktop
= ((PTHREADINFO
)Thread
->Tcb
.Win32Thread
)->hdesk
) ||
1563 !(DesktopObject
= ((PTHREADINFO
)Thread
->Tcb
.Win32Thread
)->rpdesk
))
1565 ObDereferenceObject(Thread
);
1566 ERR("Desktop information of thread 0x%x broken!?\n", dwThreadId
);
1570 /* We could just use DesktopObject instead of looking up the handle, but latter
1571 may be a bit safer (e.g. when the desktop is being destroyed */
1572 /* Switch into the context of the thread we're trying to get the desktop from,
1573 so we can use the handle */
1574 KeAttachProcess(&Thread
->ThreadsProcess
->Pcb
);
1575 Status
= ObReferenceObjectByHandle(hThreadDesktop
,
1577 ExDesktopObjectType
,
1579 (PVOID
*)&DesktopObject
,
1580 &HandleInformation
);
1583 /* The handle couldn't be found, there's nothing to get... */
1584 if(!NT_SUCCESS(Status
))
1586 ObDereferenceObject(Thread
);
1590 /* Lookup our handle table if we can find a handle to the desktop object,
1591 if not, create one */
1592 Ret
= IntGetDesktopObjectHandle(DesktopObject
);
1594 /* All done, we got a valid handle to the desktop */
1595 ObDereferenceObject(DesktopObject
);
1596 ObDereferenceObject(Thread
);
1600 TRACE("Leave NtUserGetThreadDesktop, ret=%i\n",_ret_
);
1606 IntUnmapDesktopView(IN PDESKTOP pdesk
)
1609 PW32HEAP_USER_MAPPING HeapMapping
, *PrevLink
;
1610 NTSTATUS Status
= STATUS_SUCCESS
;
1612 TRACE("IntUnmapDesktopView called for desktop object %p\n", pdesk
);
1614 ppi
= PsGetCurrentProcessWin32Process();
1615 PrevLink
= &ppi
->HeapMappings
.Next
;
1617 /* Unmap if we're the last thread using the desktop */
1618 HeapMapping
= *PrevLink
;
1619 while (HeapMapping
!= NULL
)
1621 if (HeapMapping
->KernelMapping
== (PVOID
)pdesk
->pheapDesktop
)
1623 if (--HeapMapping
->Count
== 0)
1625 *PrevLink
= HeapMapping
->Next
;
1627 TRACE("ppi 0x%x unmapped heap of desktop 0x%x\n", ppi
, pdesk
);
1628 Status
= MmUnmapViewOfSection(PsGetCurrentProcess(),
1629 HeapMapping
->UserMapping
);
1631 ObDereferenceObject(pdesk
);
1633 UserHeapFree(HeapMapping
);
1638 PrevLink
= &HeapMapping
->Next
;
1639 HeapMapping
= HeapMapping
->Next
;
1646 IntMapDesktopView(IN PDESKTOP pdesk
)
1649 PW32HEAP_USER_MAPPING HeapMapping
, *PrevLink
;
1650 PVOID UserBase
= NULL
;
1651 SIZE_T ViewSize
= 0;
1652 LARGE_INTEGER Offset
;
1655 TRACE("IntMapDesktopView called for desktop object 0x%x\n", pdesk
);
1657 ppi
= PsGetCurrentProcessWin32Process();
1658 PrevLink
= &ppi
->HeapMappings
.Next
;
1660 /* Find out if another thread already mapped the desktop heap */
1661 HeapMapping
= *PrevLink
;
1662 while (HeapMapping
!= NULL
)
1664 if (HeapMapping
->KernelMapping
== (PVOID
)pdesk
->pheapDesktop
)
1666 HeapMapping
->Count
++;
1667 return STATUS_SUCCESS
;
1670 PrevLink
= &HeapMapping
->Next
;
1671 HeapMapping
= HeapMapping
->Next
;
1674 /* We're the first, map the heap */
1675 Offset
.QuadPart
= 0;
1676 Status
= MmMapViewOfSection(pdesk
->hsectionDesktop
,
1677 PsGetCurrentProcess(),
1685 PAGE_EXECUTE_READ
); /* Would prefer PAGE_READONLY, but thanks to RTL heaps... */
1686 if (!NT_SUCCESS(Status
))
1688 ERR("Failed to map desktop\n");
1692 TRACE("ppi 0x%x mapped heap of desktop 0x%x\n", ppi
, pdesk
);
1694 /* Add the mapping */
1695 HeapMapping
= UserHeapAlloc(sizeof(W32HEAP_USER_MAPPING
));
1696 if (HeapMapping
== NULL
)
1698 MmUnmapViewOfSection(PsGetCurrentProcess(), UserBase
);
1699 ERR("UserHeapAlloc() failed!\n");
1700 return STATUS_NO_MEMORY
;
1703 HeapMapping
->Next
= NULL
;
1704 HeapMapping
->KernelMapping
= (PVOID
)pdesk
->pheapDesktop
;
1705 HeapMapping
->UserMapping
= UserBase
;
1706 HeapMapping
->Limit
= ViewSize
;
1707 HeapMapping
->Count
= 1;
1708 *PrevLink
= HeapMapping
;
1710 ObReferenceObject(pdesk
);
1712 return STATUS_SUCCESS
;
1716 IntSetThreadDesktop(IN HDESK hDesktop
,
1717 IN BOOL FreeOnFailure
)
1719 PDESKTOP pdesk
= NULL
, pdeskOld
;
1723 PCLIENTTHREADINFO pctiOld
, pctiNew
;
1726 ASSERT(NtCurrentTeb());
1728 TRACE("IntSetThreadDesktop hDesktop:0x%x, FOF:%d\n",hDesktop
, FreeOnFailure
);
1730 pti
= PsGetCurrentThreadWin32Thread();
1731 pci
= pti
->pClientInfo
;
1733 /* If the caller gave us a desktop, ensure it is valid */
1734 if(hDesktop
!= NULL
)
1736 /* Validate the new desktop. */
1737 Status
= IntValidateDesktopHandle( hDesktop
, UserMode
, 0, &pdesk
);
1738 if (!NT_SUCCESS(Status
))
1740 ERR("Validation of desktop handle (0x%X) failed\n", hDesktop
);
1744 if (pti
->rpdesk
== pdesk
)
1747 ObDereferenceObject(pdesk
);
1752 /* Make sure that we don't own any window in the current desktop */
1753 if (!IsListEmpty(&pti
->WindowListHead
))
1756 ObDereferenceObject(pdesk
);
1757 ERR("Attempted to change thread desktop although the thread has windows!\n");
1758 EngSetLastError(ERROR_BUSY
);
1762 /* Before doing the switch, map the new desktop heap and allocate the new pcti */
1765 Status
= IntMapDesktopView(pdesk
);
1766 if (!NT_SUCCESS(Status
))
1768 ERR("Failed to map desktop heap!\n");
1769 ObDereferenceObject(pdesk
);
1770 SetLastNtError(Status
);
1774 pctiNew
= DesktopHeapAlloc( pdesk
, sizeof(CLIENTTHREADINFO
));
1777 ERR("Failed to allocate new pcti\n");
1778 IntUnmapDesktopView(pdesk
);
1779 ObDereferenceObject(pdesk
);
1780 EngSetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1785 /* free all classes or move them to the shared heap */
1786 if(pti
->rpdesk
!= NULL
)
1788 if(!IntCheckProcessDesktopClasses(pti
->rpdesk
, FreeOnFailure
))
1790 ERR("Failed to move process classes to shared heap!\n");
1793 DesktopHeapFree(pdesk
, pctiNew
);
1794 IntUnmapDesktopView(pdesk
);
1795 ObDereferenceObject(pdesk
);
1801 pdeskOld
= pti
->rpdesk
;
1802 hdeskOld
= pti
->hdesk
;
1803 pctiOld
= pti
->pcti
;
1808 pti
->rpdesk
= pdesk
;
1809 pti
->hdesk
= hDesktop
;
1810 pti
->pDeskInfo
= pti
->rpdesk
->pDeskInfo
;
1811 pti
->pcti
= pctiNew
;
1813 pci
->ulClientDelta
= DesktopHeapGetUserDelta();
1814 pci
->pDeskInfo
= (PVOID
)((ULONG_PTR
)pti
->pDeskInfo
- pci
->ulClientDelta
);
1815 pci
->pClientThreadInfo
= (PVOID
)((ULONG_PTR
)pti
->pcti
- pci
->ulClientDelta
);
1817 /* initialize the new pcti */
1820 RtlCopyMemory(pctiNew
, pctiOld
, sizeof(CLIENTTHREADINFO
));
1824 RtlZeroMemory(pctiNew
, sizeof(CLIENTTHREADINFO
));
1831 pti
->pDeskInfo
= NULL
;
1833 pci
->ulClientDelta
= 0;
1834 pci
->pDeskInfo
= NULL
;
1835 pci
->pClientThreadInfo
= NULL
;
1838 /* clean up the old desktop */
1839 if(pdeskOld
!= NULL
)
1841 RemoveEntryList(&pti
->PtiLink
);
1842 DesktopHeapFree(pdeskOld
, pctiOld
);
1843 IntUnmapDesktopView(pdeskOld
);
1844 ObDereferenceObject(pdeskOld
);
1850 InsertTailList(&pdesk
->PtiList
, &pti
->PtiLink
);
1853 TRACE("IntSetThreadDesktop: pti 0x%x ppi 0x%x switched from object 0x%x to 0x%x\n", pti
, pti
->ppi
, pdeskOld
, pdesk
);
1859 * NtUserSetThreadDesktop
1866 NtUserSetThreadDesktop(HDESK hDesktop
)
1870 UserEnterExclusive();
1872 ret
= IntSetThreadDesktop(hDesktop
, FALSE
);