diff --git a/reactos/win32ss/user/ntuser/winsta.c b/reactos/win32ss/user/ntuser/winsta.c index 64039cbfbce..13adc556057 100644 --- a/reactos/win32ss/user/ntuser/winsta.c +++ b/reactos/win32ss/user/ntuser/winsta.c @@ -526,7 +526,7 @@ NtUserCloseWindowStation( if (hWinSta == UserGetProcessWindowStation()) { - ERR("Attempted to close process window station"); + ERR("Attempted to close process window station\n"); return FALSE; } @@ -612,19 +612,13 @@ NtUserGetObjectInformation( /* try windowstation */ TRACE("Trying to open window station 0x%x\n", hObject); - Status = IntValidateWindowStationHandle( + Status = ObReferenceObjectByHandle( hObject, - UserMode, 0, - &WinStaObject); - - - if (!NT_SUCCESS(Status) && Status != STATUS_OBJECT_TYPE_MISMATCH) - { - TRACE("Failed: 0x%x\n", Status); - SetLastNtError(Status); - return FALSE; - } + ExWindowStationObjectType, + UserMode, + (PVOID*)&WinStaObject, + NULL); if (Status == STATUS_OBJECT_TYPE_MISMATCH) { @@ -635,13 +629,15 @@ NtUserGetObjectInformation( UserMode, 0, &DesktopObject); - if (!NT_SUCCESS(Status)) - { - TRACE("Failed: 0x%x\n", Status); - SetLastNtError(Status); - return FALSE; - } } + + if (!NT_SUCCESS(Status)) + { + ERR("Failed: 0x%x\n", Status); + SetLastNtError(Status); + return FALSE; + } + TRACE("WinSta or Desktop opened!!\n"); /* get data */ @@ -713,8 +709,13 @@ NtUserGetObjectInformation( if (DesktopObject != NULL) ObDereferenceObject(DesktopObject); - SetLastNtError(Status); - return NT_SUCCESS(Status); + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + return FALSE; + } + + return TRUE; } /* diff --git a/reactos/win32ss/user/user32/misc/object.c b/reactos/win32ss/user/user32/misc/object.c index 5c97e0a521c..a40eef27c83 100644 --- a/reactos/win32ss/user/user32/misc/object.c +++ b/reactos/win32ss/user/user32/misc/object.c @@ -48,7 +48,8 @@ GetUserObjectInformationA( LPDWORD lpnLengthNeeded) { LPWSTR buffer; - BOOL ret = TRUE; + BOOL ret = FALSE; + DWORD LengthNeeded; TRACE("GetUserObjectInformationA(%x %d %x %d %x)\n", hObj, nIndex, pvInfo, nLength, lpnLengthNeeded); @@ -65,17 +66,16 @@ GetUserObjectInformationA( } /* get unicode string */ - if (!GetUserObjectInformationW(hObj, nIndex, buffer, nLength*2, lpnLengthNeeded)) - ret = FALSE; - *lpnLengthNeeded /= 2; - - if (ret) + if (GetUserObjectInformationW(hObj, nIndex, buffer, nLength*2, lpnLengthNeeded)) { /* convert string */ - if (WideCharToMultiByte(CP_THREAD_ACP, 0, buffer, -1, - pvInfo, nLength, NULL, NULL) == 0) + LengthNeeded = WideCharToMultiByte(CP_THREAD_ACP, 0, buffer, -1, + pvInfo, nLength, NULL, NULL); + + if (LengthNeeded != 0) { - ret = FALSE; + *lpnLengthNeeded = LengthNeeded; + ret = TRUE; } }