mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 23:52:57 +00:00
[WIN32K:NTUSER] Split NtUserCreateDesktop() into the part that captures the user-mode data and the internal worker IntCreateDesktop() function, which will also be used later.
This commit is contained in:
parent
7bc2ddd669
commit
1abeb905c3
2 changed files with 97 additions and 37 deletions
|
@ -1697,17 +1697,20 @@ UserInitializeDesktop(PDESKTOP pdesk, PUNICODE_STRING DesktopName, PWINSTATION_O
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
|
||||||
HDESK APIENTRY
|
NTSTATUS
|
||||||
NtUserCreateDesktop(
|
FASTCALL
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes,
|
IntCreateDesktop(
|
||||||
PUNICODE_STRING lpszDesktopDevice,
|
OUT HDESK* phDesktop,
|
||||||
LPDEVMODEW lpdmw,
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
DWORD dwFlags,
|
IN KPROCESSOR_MODE AccessMode,
|
||||||
ACCESS_MASK dwDesiredAccess)
|
IN PUNICODE_STRING lpszDesktopDevice OPTIONAL,
|
||||||
|
IN LPDEVMODEW lpdmw OPTIONAL,
|
||||||
|
IN DWORD dwFlags,
|
||||||
|
IN ACCESS_MASK dwDesiredAccess)
|
||||||
{
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
PDESKTOP pdesk = NULL;
|
PDESKTOP pdesk = NULL;
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
HDESK hDesk;
|
||||||
HDESK hdesk;
|
|
||||||
BOOLEAN Context = FALSE;
|
BOOLEAN Context = FALSE;
|
||||||
UNICODE_STRING ClassName;
|
UNICODE_STRING ClassName;
|
||||||
LARGE_STRING WindowName;
|
LARGE_STRING WindowName;
|
||||||
|
@ -1717,16 +1720,16 @@ NtUserCreateDesktop(
|
||||||
PTHREADINFO ptiCurrent;
|
PTHREADINFO ptiCurrent;
|
||||||
PCLS pcls;
|
PCLS pcls;
|
||||||
|
|
||||||
DECLARE_RETURN(HDESK);
|
TRACE("Enter IntCreateDesktop\n");
|
||||||
|
|
||||||
TRACE("Enter NtUserCreateDesktop\n");
|
ASSERT(phDesktop);
|
||||||
UserEnterExclusive();
|
*phDesktop = NULL;
|
||||||
|
|
||||||
ptiCurrent = PsGetCurrentThreadWin32Thread();
|
ptiCurrent = PsGetCurrentThreadWin32Thread();
|
||||||
ASSERT(ptiCurrent);
|
ASSERT(ptiCurrent);
|
||||||
ASSERT(gptiDesktopThread);
|
ASSERT(gptiDesktopThread);
|
||||||
|
|
||||||
/* Turn off hooks when calling any CreateWindowEx from inside win32k. */
|
/* Turn off hooks when calling any CreateWindowEx from inside win32k */
|
||||||
NoHooks = (ptiCurrent->TIF_flags & TIF_DISABLEHOOKS);
|
NoHooks = (ptiCurrent->TIF_flags & TIF_DISABLEHOOKS);
|
||||||
ptiCurrent->TIF_flags |= TIF_DISABLEHOOKS;
|
ptiCurrent->TIF_flags |= TIF_DISABLEHOOKS;
|
||||||
ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
|
ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
|
||||||
|
@ -1734,30 +1737,29 @@ NtUserCreateDesktop(
|
||||||
/*
|
/*
|
||||||
* Try to open already existing desktop
|
* Try to open already existing desktop
|
||||||
*/
|
*/
|
||||||
Status = ObOpenObjectByName(
|
Status = ObOpenObjectByName(ObjectAttributes,
|
||||||
ObjectAttributes,
|
ExDesktopObjectType,
|
||||||
ExDesktopObjectType,
|
AccessMode,
|
||||||
UserMode,
|
NULL,
|
||||||
NULL,
|
dwDesiredAccess,
|
||||||
dwDesiredAccess,
|
(PVOID)&Context,
|
||||||
(PVOID)&Context,
|
(PHANDLE)&hDesk);
|
||||||
(HANDLE*)&hdesk);
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
ERR("ObOpenObjectByName failed to open/create desktop\n");
|
ERR("ObOpenObjectByName failed to open/create desktop\n");
|
||||||
SetLastNtError(Status);
|
goto Quit;
|
||||||
RETURN(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* In case the object was not created (eg if it existed), return now */
|
/* In case the object was not created (eg if it existed), return now */
|
||||||
if (Context == FALSE)
|
if (Context == FALSE)
|
||||||
{
|
{
|
||||||
TRACE("NtUserCreateDesktop opened desktop %wZ\n", ObjectAttributes->ObjectName);
|
TRACE("NtUserCreateDesktop opened desktop %wZ\n", ObjectAttributes->ObjectName);
|
||||||
RETURN( hdesk);
|
Status = STATUS_SUCCESS;
|
||||||
|
goto Quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reference the desktop */
|
/* Reference the desktop */
|
||||||
Status = ObReferenceObjectByHandle(hdesk,
|
Status = ObReferenceObjectByHandle(hDesk,
|
||||||
0,
|
0,
|
||||||
ExDesktopObjectType,
|
ExDesktopObjectType,
|
||||||
KernelMode,
|
KernelMode,
|
||||||
|
@ -1766,8 +1768,7 @@ NtUserCreateDesktop(
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
ERR("Failed to reference desktop object\n");
|
ERR("Failed to reference desktop object\n");
|
||||||
SetLastNtError(Status);
|
goto Quit;
|
||||||
RETURN(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the desktop window class. The thread desktop does not belong to any desktop
|
/* Get the desktop window class. The thread desktop does not belong to any desktop
|
||||||
|
@ -1780,7 +1781,8 @@ NtUserCreateDesktop(
|
||||||
if (pcls == NULL)
|
if (pcls == NULL)
|
||||||
{
|
{
|
||||||
ASSERT(FALSE);
|
ASSERT(FALSE);
|
||||||
RETURN(NULL);
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
goto Quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlZeroMemory(&WindowName, sizeof(WindowName));
|
RtlZeroMemory(&WindowName, sizeof(WindowName));
|
||||||
|
@ -1794,12 +1796,13 @@ NtUserCreateDesktop(
|
||||||
Cs.lpszName = (LPCWSTR) &WindowName;
|
Cs.lpszName = (LPCWSTR) &WindowName;
|
||||||
Cs.lpszClass = (LPCWSTR) &ClassName;
|
Cs.lpszClass = (LPCWSTR) &ClassName;
|
||||||
|
|
||||||
/* Use IntCreateWindow instead of co_UserCreateWindowEx cause the later expects a thread with a desktop */
|
/* Use IntCreateWindow instead of co_UserCreateWindowEx because the later expects a thread with a desktop */
|
||||||
pWnd = IntCreateWindow(&Cs, &WindowName, pcls, NULL, NULL, NULL, pdesk);
|
pWnd = IntCreateWindow(&Cs, &WindowName, pcls, NULL, NULL, NULL, pdesk);
|
||||||
if (pWnd == NULL)
|
if (pWnd == NULL)
|
||||||
{
|
{
|
||||||
ERR("Failed to create desktop window for the new desktop\n");
|
ERR("Failed to create desktop window for the new desktop\n");
|
||||||
RETURN(NULL);
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
goto Quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
pdesk->dwSessionId = PsGetCurrentProcessSessionId();
|
pdesk->dwSessionId = PsGetCurrentProcessSessionId();
|
||||||
|
@ -1813,7 +1816,8 @@ NtUserCreateDesktop(
|
||||||
if (pcls == NULL)
|
if (pcls == NULL)
|
||||||
{
|
{
|
||||||
ASSERT(FALSE);
|
ASSERT(FALSE);
|
||||||
RETURN(NULL);
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
goto Quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlZeroMemory(&WindowName, sizeof(WindowName));
|
RtlZeroMemory(&WindowName, sizeof(WindowName));
|
||||||
|
@ -1827,7 +1831,8 @@ NtUserCreateDesktop(
|
||||||
if (pWnd == NULL)
|
if (pWnd == NULL)
|
||||||
{
|
{
|
||||||
ERR("Failed to create message window for the new desktop\n");
|
ERR("Failed to create message window for the new desktop\n");
|
||||||
RETURN(NULL);
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
goto Quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
pdesk->spwndMessage = pWnd;
|
pdesk->spwndMessage = pWnd;
|
||||||
|
@ -1841,23 +1846,67 @@ NtUserCreateDesktop(
|
||||||
The rest is same as message window.
|
The rest is same as message window.
|
||||||
http://msdn.microsoft.com/en-us/library/bb760250(VS.85).aspx
|
http://msdn.microsoft.com/en-us/library/bb760250(VS.85).aspx
|
||||||
*/
|
*/
|
||||||
RETURN( hdesk);
|
Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
CLEANUP:
|
Quit:
|
||||||
if (pdesk != NULL)
|
if (pdesk != NULL)
|
||||||
{
|
{
|
||||||
ObDereferenceObject(pdesk);
|
ObDereferenceObject(pdesk);
|
||||||
}
|
}
|
||||||
if (_ret_ == NULL && hdesk != NULL)
|
if (!NT_SUCCESS(Status) && hDesk != NULL)
|
||||||
{
|
{
|
||||||
ObCloseHandle(hdesk, UserMode);
|
ObCloseHandle(hDesk, AccessMode);
|
||||||
|
hDesk = NULL;
|
||||||
}
|
}
|
||||||
if (!NoHooks)
|
if (!NoHooks)
|
||||||
{
|
{
|
||||||
ptiCurrent->TIF_flags &= ~TIF_DISABLEHOOKS;
|
ptiCurrent->TIF_flags &= ~TIF_DISABLEHOOKS;
|
||||||
ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
|
ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
|
||||||
}
|
}
|
||||||
TRACE("Leave NtUserCreateDesktop, ret=%p\n",_ret_);
|
|
||||||
|
TRACE("Leave IntCreateDesktop, Status 0x%08lx\n", Status);
|
||||||
|
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
*phDesktop = hDesk;
|
||||||
|
else
|
||||||
|
SetLastNtError(Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
HDESK APIENTRY
|
||||||
|
NtUserCreateDesktop(
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
PUNICODE_STRING lpszDesktopDevice,
|
||||||
|
LPDEVMODEW lpdmw,
|
||||||
|
DWORD dwFlags,
|
||||||
|
ACCESS_MASK dwDesiredAccess)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
HDESK hDesk;
|
||||||
|
|
||||||
|
DECLARE_RETURN(HDESK);
|
||||||
|
|
||||||
|
TRACE("Enter NtUserCreateDesktop\n");
|
||||||
|
UserEnterExclusive();
|
||||||
|
|
||||||
|
Status = IntCreateDesktop(&hDesk,
|
||||||
|
ObjectAttributes,
|
||||||
|
UserMode,
|
||||||
|
lpszDesktopDevice,
|
||||||
|
lpdmw,
|
||||||
|
dwFlags,
|
||||||
|
dwDesiredAccess);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ERR("IntCreateDesktop failed, Status 0x%08lx\n", Status);
|
||||||
|
// SetLastNtError(Status);
|
||||||
|
RETURN(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN(hDesk);
|
||||||
|
|
||||||
|
CLEANUP:
|
||||||
|
TRACE("Leave NtUserCreateDesktop, ret=0x%p\n", _ret_);
|
||||||
UserLeave();
|
UserLeave();
|
||||||
END_CLEANUP;
|
END_CLEANUP;
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,6 +168,17 @@ IntValidateDesktopHandle(
|
||||||
ACCESS_MASK DesiredAccess,
|
ACCESS_MASK DesiredAccess,
|
||||||
PDESKTOP *Object);
|
PDESKTOP *Object);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
FASTCALL
|
||||||
|
IntCreateDesktop(
|
||||||
|
OUT HDESK* phDesktop,
|
||||||
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
IN KPROCESSOR_MODE AccessMode,
|
||||||
|
IN PUNICODE_STRING lpszDesktopDevice OPTIONAL,
|
||||||
|
IN LPDEVMODEW lpdmw OPTIONAL,
|
||||||
|
IN DWORD dwFlags,
|
||||||
|
IN ACCESS_MASK dwDesiredAccess);
|
||||||
|
|
||||||
NTSTATUS FASTCALL
|
NTSTATUS FASTCALL
|
||||||
IntParseDesktopPath(PEPROCESS Process,
|
IntParseDesktopPath(PEPROCESS Process,
|
||||||
PUNICODE_STRING DesktopPath,
|
PUNICODE_STRING DesktopPath,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue