[WIN32K:NTUSER]
[reactos.git] / reactos / win32ss / user / ntuser / winsta.c
index 18aebda..d906a0e 100644 (file)
@@ -45,7 +45,7 @@ InitWindowStationImpl(VOID)
 
 NTSTATUS
 NTAPI
-UserCreateWinstaDirectory()
+UserCreateWinstaDirectory(VOID)
 {
     PPEB Peb;
     NTSTATUS Status;
@@ -297,6 +297,9 @@ co_IntInitializeDesktopGraphics(VOID)
    /* Setup the icons */
    co_IntSetWndIcons();
 
+   /* Setup Menu */
+   MenuInit();
+
    /* Show the desktop */
    pdesk = IntGetActiveDesktop();
    ASSERT(pdesk);
@@ -487,7 +490,7 @@ NtUserCreateWindowStation(
 
    if (InputWindowStation == NULL)
    {
-      ERR("Initializeing input window station\n");
+      ERR("Initializing input window station\n");
       InputWindowStation = WindowStationObject;
 
       WindowStationObject->Flags &= ~WSS_NOIO;
@@ -669,7 +672,7 @@ NtUserGetObjectInformation(
    DWORD nLength,
    PDWORD nLengthNeeded)
 {
-   PWINSTATION_OBJECT WinStaObject = NULL;
+   PWINSTATION_OBJECT WinStaObject;
    PDESKTOP DesktopObject = NULL;
    NTSTATUS Status;
    PVOID pvData = NULL;
@@ -702,6 +705,7 @@ NtUserGetObjectInformation(
    {
       /* try desktop */
       TRACE("Trying to open desktop %p\n", hObject);
+      WinStaObject = NULL;
       Status = IntValidateDesktopHandle(
                   hObject,
                   UserMode,
@@ -934,7 +938,7 @@ UserSetProcessWindowStation(HWINSTA hWindowStation)
    ppi->prpwinsta = NewWinSta;
    ppi->hwinsta = hWindowStation;
    ppi->amwinsta = hWindowStation != NULL ? ObjectHandleInfo.GrantedAccess : 0;
-   ERR("WS : Granted Access %p\n",ppi->amwinsta);
+   TRACE("WS : Granted Access 0x%08lx\n",ppi->amwinsta);
 
    if (RtlAreAllAccessesGranted(ppi->amwinsta, WINSTA_READSCREEN))
    {
@@ -1099,7 +1103,7 @@ BuildWindowStationNameList(
    InitializeObjectAttributes(
       &ObjectAttributes,
       &gustrWindowStationsDir,
-      OBJ_CASE_INSENSITIVE,
+      OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
       NULL,
       NULL);
 
@@ -1133,17 +1137,18 @@ BuildWindowStationNameList(
       /* Need a larger buffer, check how large exactly */
       Status = ZwQueryDirectoryObject(DirectoryHandle, NULL, 0, FALSE, TRUE, &Context,
                                       &ReturnLength);
-      if (STATUS_BUFFER_TOO_SMALL == Status)
+      if (!NT_SUCCESS(Status))
       {
-         ObDereferenceObject(DirectoryHandle);
-         return STATUS_NO_MEMORY;
+         ERR("ZwQueryDirectoryObject failed\n");
+         ZwClose(DirectoryHandle);
+         return Status;
       }
 
       BufferSize = ReturnLength;
       Buffer = ExAllocatePoolWithTag(PagedPool, BufferSize, TAG_WINSTA);
       if (NULL == Buffer)
       {
-         ObDereferenceObject(DirectoryHandle);
+         ZwClose(DirectoryHandle);
          return STATUS_NO_MEMORY;
       }
 
@@ -1157,7 +1162,7 @@ BuildWindowStationNameList(
       {
          /* Something went wrong, maybe someone added a directory entry? Just give up. */
          ExFreePoolWithTag(Buffer, TAG_WINSTA);
-         ObDereferenceObject(DirectoryHandle);
+         ZwClose(DirectoryHandle);
          return NT_SUCCESS(Status) ? STATUS_INTERNAL_ERROR : Status;
       }
    }
@@ -1367,12 +1372,12 @@ BuildDesktopNameList(
  *       Size of buffer passed by caller.
  *
  *    lpBuffer
- *       Buffer passed by caller. If the function succedes, the buffer is
+ *       Buffer passed by caller. If the function succeeds, the buffer is
  *       filled with window station/desktop count (in first DWORD) and
  *       NULL-terminated window station/desktop names.
  *
  *    pRequiredSize
- *       If the function suceedes, this is the number of bytes copied.
+ *       If the function succeeds, this is the number of bytes copied.
  *       Otherwise it's size of buffer needed for function to succeed.
  *
  * Status
@@ -1493,7 +1498,7 @@ NtUserSetWindowStationUser(
 
    if (!NT_SUCCESS(Status))
    {
-      ExFreePoolWithTag(WindowStation->psidUser, 0);
+      ExFreePoolWithTag(WindowStation->psidUser, USERTAG_SECURITY);
       WindowStation->psidUser = 0;
       goto Leave;
    }