[WIN32K:NTUSER] -IntSetThreadDesktop: Don't close the previous desktop handle. Fixes...
[reactos.git] / reactos / win32ss / user / ntuser / desktop.c
index 446e295..7464091 100644 (file)
@@ -932,6 +932,8 @@ UserGetDesktopDC(ULONG DcType, BOOL EmptyDC, BOOL ValidatehWnd)
     PWND DesktopObject = 0;
     HDC DesktopHDC = 0;
 
+    UserEnterExclusive();
+
     if (DcType == DC_TYPE_DIRECT)
     {
         DesktopObject = UserGetDesktopWindow();
@@ -943,6 +945,8 @@ UserGetDesktopDC(ULONG DcType, BOOL EmptyDC, BOOL ValidatehWnd)
         DesktopHDC = IntGdiCreateDisplayDC(pMonitor->hDev, DcType, EmptyDC);
     }
 
+    UserLeave();
+
     return DesktopHDC;
 }
 
@@ -1806,7 +1810,7 @@ NtUserOpenDesktop(
     {
         ERR("Failed to open desktop\n");
         SetLastNtError(Status);
-        return 0;
+        return NULL;
     }
 
     TRACE("Opened desktop %S with handle 0x%p\n", ObjectAttributes->ObjectName->Buffer, Desktop);
@@ -2374,7 +2378,6 @@ IntSetThreadDesktop(IN HDESK hDesktop,
                     IN BOOL FreeOnFailure)
 {
     PDESKTOP pdesk = NULL, pdeskOld;
-    HDESK hdeskOld;
     PTHREADINFO pti;
     NTSTATUS Status;
     PCLIENTTHREADINFO pctiOld, pctiNew = NULL;
@@ -2463,7 +2466,6 @@ IntSetThreadDesktop(IN HDESK hDesktop,
     }
 
     pdeskOld = pti->rpdesk;
-    hdeskOld = pti->hdesk;
     if (pti->pcti != &pti->cti)
         pctiOld = pti->pcti;
     else
@@ -2511,7 +2513,6 @@ IntSetThreadDesktop(IN HDESK hDesktop,
         if (pctiOld) DesktopHeapFree(pdeskOld, pctiOld);
         IntUnmapDesktopView(pdeskOld);
         ObDereferenceObject(pdeskOld);
-        ZwClose(hdeskOld);
     }
 
     if (pdesk)