Synchronize with trunk's revision r57659.
[reactos.git] / win32ss / user / ntuser / desktop.c
index da90932..41f56ad 100644 (file)
@@ -26,8 +26,7 @@ IntFreeDesktopHeap(IN PDESKTOP pdesk);
 /* GLOBALS *******************************************************************/
 
 /* Currently active desktop */
 /* GLOBALS *******************************************************************/
 
 /* Currently active desktop */
-PDESKTOP InputDesktop = NULL;
-HDESK InputDesktopHandle = NULL;
+PDESKTOP gpdeskInputDesktop = NULL;
 HDC ScreenDeviceContext = NULL;
 PTHREADINFO gptiDesktopThread;
 HCURSOR gDesktopCursor = NULL;
 HDC ScreenDeviceContext = NULL;
 PTHREADINFO gptiDesktopThread;
 HCURSOR gDesktopCursor = NULL;
@@ -420,7 +419,7 @@ IntValidateDesktopHandle(
 PDESKTOP FASTCALL
 IntGetActiveDesktop(VOID)
 {
 PDESKTOP FASTCALL
 IntGetActiveDesktop(VOID)
 {
-   return InputDesktop;
+   return gpdeskInputDesktop;
 }
 
 /*
 }
 
 /*
@@ -1464,40 +1463,31 @@ NtUserOpenInputDesktop(
    BOOL fInherit,
    ACCESS_MASK dwDesiredAccess)
 {
    BOOL fInherit,
    ACCESS_MASK dwDesiredAccess)
 {
-   PDESKTOP pdesk;
    NTSTATUS Status;
    HDESK hdesk = NULL;
    NTSTATUS Status;
    HDESK hdesk = NULL;
+   ULONG HandleAttributes = 0;
 
    UserEnterExclusive();
 
    UserEnterExclusive();
-   TRACE("Enter NtUserOpenInputDesktop InputDesktopHandle 0x%p\n",InputDesktopHandle);
+   TRACE("Enter NtUserOpenInputDesktop gpdeskInputDesktop 0x%p\n",gpdeskInputDesktop);
 
 
-   /* Get a pointer to the desktop object */
-   Status = IntValidateDesktopHandle(InputDesktopHandle, UserMode, 0, &pdesk);
-   if (!NT_SUCCESS(Status))
-   {
-      ERR("Validation of input desktop handle (0x%p) failed\n", InputDesktopHandle);
-      goto Exit;
-   }
+   if(fInherit) HandleAttributes = OBJ_INHERIT;
 
    /* Create a new handle to the object */
    Status = ObOpenObjectByPointer(
 
    /* Create a new handle to the object */
    Status = ObOpenObjectByPointer(
-               pdesk,
-               0,
+               gpdeskInputDesktop,
+               HandleAttributes,
                NULL,
                dwDesiredAccess,
                ExDesktopObjectType,
                UserMode,
                (PHANDLE)&hdesk);
 
                NULL,
                dwDesiredAccess,
                ExDesktopObjectType,
                UserMode,
                (PHANDLE)&hdesk);
 
-   ObDereferenceObject(pdesk);
-
    if (!NT_SUCCESS(Status))
    {
        ERR("Failed to open input desktop object\n");
        SetLastNtError(Status);
    if (!NT_SUCCESS(Status))
    {
        ERR("Failed to open input desktop object\n");
        SetLastNtError(Status);
-       goto Exit;
    }
    }
-Exit:
+
    TRACE("NtUserOpenInputDesktop returning 0x%p\n",hdesk);
    UserLeave();
    return hdesk;
    TRACE("NtUserOpenInputDesktop returning 0x%p\n",hdesk);
    UserLeave();
    return hdesk;
@@ -1654,9 +1644,8 @@ NtUserSwitchDesktop(HDESK hdesk)
    InputWindowStation->ActiveDesktop = pdesk;
 
    /* Set the global state. */
    InputWindowStation->ActiveDesktop = pdesk;
 
    /* Set the global state. */
-   InputDesktop = pdesk;
-   InputDesktopHandle = hdesk;
-   TRACE("SwitchDesktop InputDesktopHandle 0x%p\n",InputDesktopHandle);
+   gpdeskInputDesktop = pdesk;
+   TRACE("SwitchDesktop gpdeskInputDesktop 0x%p\n",gpdeskInputDesktop);
    ObDereferenceObject(pdesk);
 
    RETURN(TRUE);
    ObDereferenceObject(pdesk);
 
    RETURN(TRUE);