mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +00:00
[NTUSER] Fix a few tests related to desktops and window stations
- NtUserOpenInputDesktop: Don't crash if there is no input desktop yet - NtUserOpenInputDesktop: Fail if the process doesn't belong to the interactive window station - NtUserCreateWindowStation: Clear error on success - DesktopWindowProc: Use UserOpenInputDesktop to get a handle to the input desktop
This commit is contained in:
parent
a9124b412d
commit
60448f83fb
3 changed files with 48 additions and 21 deletions
|
@ -1471,7 +1471,7 @@ DesktopWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lRe
|
||||||
PWINDOWPOS pWindowPos = (PWINDOWPOS)lParam;
|
PWINDOWPOS pWindowPos = (PWINDOWPOS)lParam;
|
||||||
if ((pWindowPos->flags & SWP_SHOWWINDOW) != 0)
|
if ((pWindowPos->flags & SWP_SHOWWINDOW) != 0)
|
||||||
{
|
{
|
||||||
HDESK hdesk = IntGetDesktopObjectHandle(gpdeskInputDesktop);
|
HDESK hdesk = UserOpenInputDesktop(0, FALSE, DESKTOP_ALL_ACCESS);
|
||||||
IntSetThreadDesktop(hdesk, FALSE);
|
IntSetThreadDesktop(hdesk, FALSE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2569,6 +2569,48 @@ NtUserOpenDesktop(
|
||||||
return Desktop;
|
return Desktop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HDESK UserOpenInputDesktop(DWORD dwFlags,
|
||||||
|
BOOL fInherit,
|
||||||
|
ACCESS_MASK dwDesiredAccess)
|
||||||
|
{
|
||||||
|
PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
|
||||||
|
NTSTATUS Status;
|
||||||
|
ULONG HandleAttributes = 0;
|
||||||
|
HDESK hdesk = NULL;
|
||||||
|
|
||||||
|
if (!gpdeskInputDesktop)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pti->ppi->prpwinsta != InputWindowStation)
|
||||||
|
{
|
||||||
|
ERR("Tried to open input desktop from non interactive winsta!\n");
|
||||||
|
EngSetLastError(ERROR_INVALID_FUNCTION);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fInherit) HandleAttributes = OBJ_INHERIT;
|
||||||
|
|
||||||
|
/* Create a new handle to the object */
|
||||||
|
Status = ObOpenObjectByPointer(
|
||||||
|
gpdeskInputDesktop,
|
||||||
|
HandleAttributes,
|
||||||
|
NULL,
|
||||||
|
dwDesiredAccess,
|
||||||
|
ExDesktopObjectType,
|
||||||
|
UserMode,
|
||||||
|
(PHANDLE)&hdesk);
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ERR("Failed to open input desktop object\n");
|
||||||
|
SetLastNtError(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
return hdesk;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NtUserOpenInputDesktop
|
* NtUserOpenInputDesktop
|
||||||
*
|
*
|
||||||
|
@ -2597,30 +2639,12 @@ NtUserOpenInputDesktop(
|
||||||
BOOL fInherit,
|
BOOL fInherit,
|
||||||
ACCESS_MASK dwDesiredAccess)
|
ACCESS_MASK dwDesiredAccess)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
HDESK hdesk;
|
||||||
HDESK hdesk = NULL;
|
|
||||||
ULONG HandleAttributes = 0;
|
|
||||||
|
|
||||||
UserEnterExclusive();
|
UserEnterExclusive();
|
||||||
TRACE("Enter NtUserOpenInputDesktop gpdeskInputDesktop 0x%p\n",gpdeskInputDesktop);
|
TRACE("Enter NtUserOpenInputDesktop gpdeskInputDesktop 0x%p\n",gpdeskInputDesktop);
|
||||||
|
|
||||||
if (fInherit) HandleAttributes = OBJ_INHERIT;
|
hdesk = UserOpenInputDesktop(dwFlags, fInherit, dwDesiredAccess);
|
||||||
|
|
||||||
/* Create a new handle to the object */
|
|
||||||
Status = ObOpenObjectByPointer(
|
|
||||||
gpdeskInputDesktop,
|
|
||||||
HandleAttributes,
|
|
||||||
NULL,
|
|
||||||
dwDesiredAccess,
|
|
||||||
ExDesktopObjectType,
|
|
||||||
UserMode,
|
|
||||||
(PHANDLE)&hdesk);
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
ERR("Failed to open input desktop object\n");
|
|
||||||
SetLastNtError(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("NtUserOpenInputDesktop returning 0x%p\n",hdesk);
|
TRACE("NtUserOpenInputDesktop returning 0x%p\n",hdesk);
|
||||||
UserLeave();
|
UserLeave();
|
||||||
|
|
|
@ -357,5 +357,6 @@ BOOL FASTCALL IntPaintDesktop(HDC);
|
||||||
BOOL FASTCALL DesktopWindowProc(PWND, UINT, WPARAM, LPARAM, LRESULT *);
|
BOOL FASTCALL DesktopWindowProc(PWND, UINT, WPARAM, LPARAM, LRESULT *);
|
||||||
BOOL FASTCALL UserMessageWindowProc(PWND pwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult);
|
BOOL FASTCALL UserMessageWindowProc(PWND pwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult);
|
||||||
VOID NTAPI DesktopThreadMain(VOID);
|
VOID NTAPI DesktopThreadMain(VOID);
|
||||||
|
HDESK UserOpenInputDesktop(DWORD dwFlags, BOOL fInherit, ACCESS_MASK dwDesiredAccess);
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -521,6 +521,8 @@ IntCreateWindowStation(
|
||||||
ObjectAttributes->ObjectName, WindowStation, hWinSta);
|
ObjectAttributes->ObjectName, WindowStation, hWinSta);
|
||||||
|
|
||||||
*phWinSta = hWinSta;
|
*phWinSta = hWinSta;
|
||||||
|
EngSetLastError(ERROR_SUCCESS);
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue