mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
[win32k]
- Improve the definition and simplify NtUserCreateDesktop, NtUserOpenDesktop, NtUserCreateWindowStation, NtUserOpenWindowStation svn path=/trunk/; revision=51082
This commit is contained in:
parent
bfb74cd0bc
commit
71201dea2c
5 changed files with 184 additions and 299 deletions
|
@ -564,13 +564,22 @@ OpenDesktopW(
|
||||||
ACCESS_MASK dwDesiredAccess)
|
ACCESS_MASK dwDesiredAccess)
|
||||||
{
|
{
|
||||||
UNICODE_STRING DesktopName;
|
UNICODE_STRING DesktopName;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
|
||||||
RtlInitUnicodeString(&DesktopName, lpszDesktop);
|
RtlInitUnicodeString(&DesktopName, lpszDesktop);
|
||||||
|
|
||||||
return NtUserOpenDesktop(
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
&DesktopName,
|
&DesktopName,
|
||||||
dwFlags,
|
OBJ_CASE_INSENSITIVE,
|
||||||
dwDesiredAccess);
|
GetProcessWindowStation(),
|
||||||
|
0);
|
||||||
|
|
||||||
|
if( fInherit == TRUE )
|
||||||
|
{
|
||||||
|
ObjectAttributes.Attributes |= OBJ_INHERIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NtUserOpenDesktop(&ObjectAttributes, dwFlags, dwDesiredAccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <user32.h>
|
#include <user32.h>
|
||||||
|
|
||||||
#include <wine/debug.h>
|
#include <wine/debug.h>
|
||||||
|
WINE_DEFAULT_DEBUG_CHANNEL(winsta);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -58,12 +59,50 @@ CreateWindowStationW(LPCWSTR lpwinsta,
|
||||||
LPSECURITY_ATTRIBUTES lpsa)
|
LPSECURITY_ATTRIBUTES lpsa)
|
||||||
{
|
{
|
||||||
UNICODE_STRING WindowStationName;
|
UNICODE_STRING WindowStationName;
|
||||||
|
UNICODE_STRING WindowStationsDir = RTL_CONSTANT_STRING(L"\\Windows\\WindowStations");
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
HANDLE hWindowStationsDir;
|
||||||
|
NTSTATUS Status;
|
||||||
|
HWINSTA hwinsta;
|
||||||
|
|
||||||
|
/* Open WindowStations directory */
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&WindowStationsDir,
|
||||||
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
0,
|
||||||
|
0);
|
||||||
|
|
||||||
|
Status = NtOpenDirectoryObject(&hWindowStationsDir,
|
||||||
|
DIRECTORY_CREATE_OBJECT,
|
||||||
|
&ObjectAttributes);
|
||||||
|
if(!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ERR("Failed to open WindowStations directory\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
RtlInitUnicodeString(&WindowStationName, lpwinsta);
|
RtlInitUnicodeString(&WindowStationName, lpwinsta);
|
||||||
|
|
||||||
return NtUserCreateWindowStation(&WindowStationName,
|
/* Create the window station object */
|
||||||
dwDesiredAccess,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
lpsa, 0, 0, 0, 0);
|
&WindowStationName,
|
||||||
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
hWindowStationsDir,
|
||||||
|
0);
|
||||||
|
|
||||||
|
/* Check if the handle should be inheritable */
|
||||||
|
if (lpsa && lpsa->bInheritHandle)
|
||||||
|
{
|
||||||
|
ObjectAttributes.Attributes |= OBJ_INHERIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
hwinsta = NtUserCreateWindowStation(&ObjectAttributes,
|
||||||
|
dwDesiredAccess,
|
||||||
|
0, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
NtClose(hWindowStationsDir);
|
||||||
|
|
||||||
|
return hwinsta;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -299,14 +338,51 @@ OpenWindowStationA(LPCSTR lpszWinSta,
|
||||||
*/
|
*/
|
||||||
HWINSTA WINAPI
|
HWINSTA WINAPI
|
||||||
OpenWindowStationW(LPCWSTR lpszWinSta,
|
OpenWindowStationW(LPCWSTR lpszWinSta,
|
||||||
BOOL fInherit,
|
BOOL fInherit,
|
||||||
ACCESS_MASK dwDesiredAccess)
|
ACCESS_MASK dwDesiredAccess)
|
||||||
{
|
{
|
||||||
UNICODE_STRING WindowStationName;
|
UNICODE_STRING WindowStationName;
|
||||||
|
UNICODE_STRING WindowStationsDir = RTL_CONSTANT_STRING(L"\\Windows\\WindowStations");
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
HANDLE hWindowStationsDir;
|
||||||
|
NTSTATUS Status;
|
||||||
|
HWINSTA hwinsta;
|
||||||
|
|
||||||
|
/* Open WindowStations directory */
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&WindowStationsDir,
|
||||||
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
0,
|
||||||
|
0);
|
||||||
|
|
||||||
|
Status = NtOpenDirectoryObject(&hWindowStationsDir,
|
||||||
|
DIRECTORY_TRAVERSE,
|
||||||
|
&ObjectAttributes);
|
||||||
|
if(!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ERR("Failed to open WindowStations directory\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Open the window station object */
|
||||||
RtlInitUnicodeString(&WindowStationName, lpszWinSta);
|
RtlInitUnicodeString(&WindowStationName, lpszWinSta);
|
||||||
|
|
||||||
return NtUserOpenWindowStation(&WindowStationName, dwDesiredAccess);
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&WindowStationName,
|
||||||
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
hWindowStationsDir,
|
||||||
|
0);
|
||||||
|
|
||||||
|
if( fInherit == TRUE )
|
||||||
|
{
|
||||||
|
ObjectAttributes.Attributes |= OBJ_INHERIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
hwinsta = NtUserOpenWindowStation(&ObjectAttributes, dwDesiredAccess);
|
||||||
|
|
||||||
|
NtClose(hWindowStationsDir);
|
||||||
|
|
||||||
|
return hwinsta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1462,7 +1462,7 @@ NtUserCreateLocalMemHandle(
|
||||||
HWND
|
HWND
|
||||||
NTAPI
|
NTAPI
|
||||||
NtUserCreateWindowEx(
|
NtUserCreateWindowEx(
|
||||||
DWORD dwExStyle, // |= 0x80000000 == Ansi used to set WNDS_ANSICREATOR
|
DWORD dwExStyle,
|
||||||
PLARGE_STRING plstrClassName,
|
PLARGE_STRING plstrClassName,
|
||||||
PLARGE_STRING plstrClsVersion,
|
PLARGE_STRING plstrClsVersion,
|
||||||
PLARGE_STRING plstrWindowName,
|
PLARGE_STRING plstrWindowName,
|
||||||
|
@ -1481,9 +1481,9 @@ NtUserCreateWindowEx(
|
||||||
HWINSTA
|
HWINSTA
|
||||||
NTAPI
|
NTAPI
|
||||||
NtUserCreateWindowStation(
|
NtUserCreateWindowStation(
|
||||||
PUNICODE_STRING lpszWindowStationName,
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
ACCESS_MASK dwDesiredAccess,
|
ACCESS_MASK dwDesiredAccess,
|
||||||
LPSECURITY_ATTRIBUTES lpSecurity,
|
DWORD Unknown2,
|
||||||
DWORD Unknown3,
|
DWORD Unknown3,
|
||||||
DWORD Unknown4,
|
DWORD Unknown4,
|
||||||
DWORD Unknown5,
|
DWORD Unknown5,
|
||||||
|
@ -2301,9 +2301,9 @@ NtUserOpenClipboard(
|
||||||
HDESK
|
HDESK
|
||||||
NTAPI
|
NTAPI
|
||||||
NtUserOpenDesktop(
|
NtUserOpenDesktop(
|
||||||
PUNICODE_STRING lpszDesktopName,
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
DWORD dwFlags,
|
DWORD dwFlags,
|
||||||
ACCESS_MASK dwDesiredAccess);
|
ACCESS_MASK dwDesiredAccess);
|
||||||
|
|
||||||
HDESK
|
HDESK
|
||||||
NTAPI
|
NTAPI
|
||||||
|
@ -2315,7 +2315,7 @@ NtUserOpenInputDesktop(
|
||||||
HWINSTA
|
HWINSTA
|
||||||
NTAPI
|
NTAPI
|
||||||
NtUserOpenWindowStation(
|
NtUserOpenWindowStation(
|
||||||
PUNICODE_STRING lpszWindowStationName,
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
ACCESS_MASK dwDesiredAccess);
|
ACCESS_MASK dwDesiredAccess);
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
|
|
|
@ -859,15 +859,12 @@ IntFreeDesktopHeap(IN OUT PDESKTOP Desktop)
|
||||||
|
|
||||||
HDESK APIENTRY
|
HDESK APIENTRY
|
||||||
NtUserCreateDesktop(
|
NtUserCreateDesktop(
|
||||||
POBJECT_ATTRIBUTES poa,
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
PUNICODE_STRING lpszDesktopDevice,
|
PUNICODE_STRING lpszDesktopDevice,
|
||||||
LPDEVMODEW lpdmw,
|
LPDEVMODEW lpdmw,
|
||||||
DWORD dwFlags,
|
DWORD dwFlags,
|
||||||
ACCESS_MASK dwDesiredAccess)
|
ACCESS_MASK dwDesiredAccess)
|
||||||
{
|
{
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
||||||
PTHREADINFO W32Thread;
|
|
||||||
PWINSTATION_OBJECT WinStaObject;
|
|
||||||
PDESKTOP DesktopObject;
|
PDESKTOP DesktopObject;
|
||||||
UNICODE_STRING DesktopName;
|
UNICODE_STRING DesktopName;
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
@ -875,12 +872,9 @@ NtUserCreateDesktop(
|
||||||
CSR_API_MESSAGE Request;
|
CSR_API_MESSAGE Request;
|
||||||
PVOID DesktopHeapSystemBase = NULL;
|
PVOID DesktopHeapSystemBase = NULL;
|
||||||
SIZE_T DesktopInfoSize;
|
SIZE_T DesktopInfoSize;
|
||||||
UNICODE_STRING SafeDesktopName;
|
|
||||||
ULONG DummyContext;
|
ULONG DummyContext;
|
||||||
ULONG_PTR HeapSize = 4 * 1024 * 1024; /* FIXME */
|
ULONG_PTR HeapSize = 4 * 1024 * 1024; /* FIXME */
|
||||||
HWINSTA hWindowStation = NULL ;
|
UNICODE_STRING ClassName;
|
||||||
PUNICODE_STRING lpszDesktopName = NULL;
|
|
||||||
UNICODE_STRING ClassName, MenuName;
|
|
||||||
LARGE_STRING WindowName;
|
LARGE_STRING WindowName;
|
||||||
BOOL NoHooks = FALSE;
|
BOOL NoHooks = FALSE;
|
||||||
PWND pWnd = NULL;
|
PWND pWnd = NULL;
|
||||||
|
@ -889,7 +883,7 @@ NtUserCreateDesktop(
|
||||||
PTHREADINFO ptiCurrent;
|
PTHREADINFO ptiCurrent;
|
||||||
DECLARE_RETURN(HDESK);
|
DECLARE_RETURN(HDESK);
|
||||||
|
|
||||||
DPRINT("Enter NtUserCreateDesktop: %wZ\n", lpszDesktopName);
|
DPRINT("Enter NtUserCreateDesktop\n");
|
||||||
UserEnterExclusive();
|
UserEnterExclusive();
|
||||||
|
|
||||||
ptiCurrent = PsGetCurrentThreadWin32Thread();
|
ptiCurrent = PsGetCurrentThreadWin32Thread();
|
||||||
|
@ -899,19 +893,38 @@ NtUserCreateDesktop(
|
||||||
NoHooks = (ptiCurrent->TIF_flags & TIF_DISABLEHOOKS);
|
NoHooks = (ptiCurrent->TIF_flags & TIF_DISABLEHOOKS);
|
||||||
ptiCurrent->TIF_flags |= TIF_DISABLEHOOKS;
|
ptiCurrent->TIF_flags |= TIF_DISABLEHOOKS;
|
||||||
}
|
}
|
||||||
|
DesktopName.Buffer = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Try to open already existing desktop
|
||||||
|
*/
|
||||||
|
|
||||||
|
DPRINT("Trying to open desktop (%wZ)\n", &DesktopName);
|
||||||
|
|
||||||
|
Status = ObOpenObjectByName(
|
||||||
|
ObjectAttributes,
|
||||||
|
ExDesktopObjectType,
|
||||||
|
UserMode,
|
||||||
|
NULL,
|
||||||
|
dwDesiredAccess,
|
||||||
|
(PVOID)&DummyContext,
|
||||||
|
(HANDLE*)&Desktop);
|
||||||
|
if (!NT_SUCCESS(Status)) RETURN(NULL);
|
||||||
|
if (Status == STATUS_OBJECT_NAME_EXISTS)
|
||||||
|
{
|
||||||
|
RETURN( Desktop);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Capture desktop name */
|
||||||
_SEH2_TRY
|
_SEH2_TRY
|
||||||
{
|
{
|
||||||
ProbeForRead( poa,
|
ProbeForRead( ObjectAttributes, sizeof(OBJECT_ATTRIBUTES), 1);
|
||||||
sizeof(OBJECT_ATTRIBUTES),
|
|
||||||
1);
|
|
||||||
|
|
||||||
hWindowStation = poa->RootDirectory;
|
Status = IntSafeCopyUnicodeString(&DesktopName, ObjectAttributes->ObjectName);
|
||||||
lpszDesktopName = poa->ObjectName;
|
|
||||||
}
|
}
|
||||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
Status =_SEH2_GetExceptionCode();
|
Status = _SEH2_GetExceptionCode();
|
||||||
}
|
}
|
||||||
_SEH2_END
|
_SEH2_END
|
||||||
|
|
||||||
|
@ -922,75 +935,6 @@ NtUserCreateDesktop(
|
||||||
RETURN( NULL);
|
RETURN( NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = IntValidateWindowStationHandle(
|
|
||||||
hWindowStation,
|
|
||||||
KernelMode,
|
|
||||||
0, /* FIXME - WINSTA_CREATEDESKTOP */
|
|
||||||
&WinStaObject);
|
|
||||||
|
|
||||||
if (! NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("Failed validation of window station handle (0x%X), cannot create desktop %wZ\n",
|
|
||||||
hWindowStation, lpszDesktopName);
|
|
||||||
SetLastNtError(Status);
|
|
||||||
RETURN( NULL);
|
|
||||||
}
|
|
||||||
if(lpszDesktopName != NULL)
|
|
||||||
{
|
|
||||||
Status = IntSafeCopyUnicodeString(&SafeDesktopName, lpszDesktopName);
|
|
||||||
if(!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
SetLastNtError(Status);
|
|
||||||
RETURN( NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RtlInitUnicodeString(&SafeDesktopName, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! IntGetFullWindowStationName(&DesktopName, &WinStaObject->Name,
|
|
||||||
&SafeDesktopName))
|
|
||||||
{
|
|
||||||
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
|
|
||||||
ObDereferenceObject(WinStaObject);
|
|
||||||
if (lpszDesktopName)
|
|
||||||
ExFreePoolWithTag(SafeDesktopName.Buffer, TAG_STRING);
|
|
||||||
RETURN( NULL);
|
|
||||||
}
|
|
||||||
if (lpszDesktopName)
|
|
||||||
ExFreePoolWithTag(SafeDesktopName.Buffer, TAG_STRING);
|
|
||||||
ObDereferenceObject(WinStaObject);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Try to open already existing desktop
|
|
||||||
*/
|
|
||||||
|
|
||||||
DPRINT("Trying to open desktop (%wZ)\n", &DesktopName);
|
|
||||||
|
|
||||||
/* Initialize ObjectAttributes for the desktop object */
|
|
||||||
InitializeObjectAttributes(
|
|
||||||
&ObjectAttributes,
|
|
||||||
&DesktopName,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
Status = ObOpenObjectByName(
|
|
||||||
&ObjectAttributes,
|
|
||||||
ExDesktopObjectType,
|
|
||||||
KernelMode,
|
|
||||||
NULL,
|
|
||||||
dwDesiredAccess,
|
|
||||||
(PVOID)&DummyContext,
|
|
||||||
(HANDLE*)&Desktop);
|
|
||||||
if (!NT_SUCCESS(Status)) RETURN(NULL);
|
|
||||||
if (Status == STATUS_OBJECT_NAME_EXISTS)
|
|
||||||
{
|
|
||||||
ExFreePoolWithTag(DesktopName.Buffer, TAG_STRING);
|
|
||||||
RETURN( Desktop);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reference the desktop */
|
/* Reference the desktop */
|
||||||
Status = ObReferenceObjectByHandle(Desktop,
|
Status = ObReferenceObjectByHandle(Desktop,
|
||||||
0,
|
0,
|
||||||
|
@ -1011,12 +955,11 @@ NtUserCreateDesktop(
|
||||||
RETURN(NULL);
|
RETURN(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
DesktopInfoSize = FIELD_OFFSET(DESKTOPINFO,
|
DesktopInfoSize = sizeof(DESKTOPINFO) + DesktopName.Length;
|
||||||
szDesktopName[(lpszDesktopName->Length / sizeof(WCHAR)) + 1]);
|
|
||||||
|
|
||||||
DesktopObject->pDeskInfo = RtlAllocateHeap(DesktopObject->pheapDesktop,
|
DesktopObject->pDeskInfo = RtlAllocateHeap(DesktopObject->pheapDesktop,
|
||||||
HEAP_NO_SERIALIZE,
|
HEAP_NO_SERIALIZE,
|
||||||
DesktopInfoSize);
|
DesktopInfoSize);
|
||||||
|
|
||||||
if (DesktopObject->pDeskInfo == NULL)
|
if (DesktopObject->pDeskInfo == NULL)
|
||||||
{
|
{
|
||||||
|
@ -1031,8 +974,8 @@ NtUserCreateDesktop(
|
||||||
DesktopObject->pDeskInfo->pvDesktopBase = DesktopHeapSystemBase;
|
DesktopObject->pDeskInfo->pvDesktopBase = DesktopHeapSystemBase;
|
||||||
DesktopObject->pDeskInfo->pvDesktopLimit = (PVOID)((ULONG_PTR)DesktopHeapSystemBase + HeapSize);
|
DesktopObject->pDeskInfo->pvDesktopLimit = (PVOID)((ULONG_PTR)DesktopHeapSystemBase + HeapSize);
|
||||||
RtlCopyMemory(DesktopObject->pDeskInfo->szDesktopName,
|
RtlCopyMemory(DesktopObject->pDeskInfo->szDesktopName,
|
||||||
lpszDesktopName->Buffer,
|
DesktopName.Buffer,
|
||||||
lpszDesktopName->Length);
|
DesktopName.Length);
|
||||||
|
|
||||||
/* Initialize some local (to win32k) desktop state. */
|
/* Initialize some local (to win32k) desktop state. */
|
||||||
InitializeListHead(&DesktopObject->PtiList);
|
InitializeListHead(&DesktopObject->PtiList);
|
||||||
|
@ -1042,7 +985,6 @@ NtUserCreateDesktop(
|
||||||
{
|
{
|
||||||
InitializeListHead(&DesktopObject->pDeskInfo->aphkStart[i]);
|
InitializeListHead(&DesktopObject->pDeskInfo->aphkStart[i]);
|
||||||
}
|
}
|
||||||
ExFreePoolWithTag(DesktopName.Buffer, TAG_STRING);
|
|
||||||
|
|
||||||
//// why is this here?
|
//// why is this here?
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -1090,7 +1032,6 @@ NtUserCreateDesktop(
|
||||||
//
|
//
|
||||||
ClassName.Buffer = ((PWSTR)((ULONG_PTR)(WORD)(gpsi->atomSysClass[ICLS_DESKTOP])));
|
ClassName.Buffer = ((PWSTR)((ULONG_PTR)(WORD)(gpsi->atomSysClass[ICLS_DESKTOP])));
|
||||||
ClassName.Length = 0;
|
ClassName.Length = 0;
|
||||||
RtlZeroMemory(&MenuName, sizeof(MenuName));
|
|
||||||
RtlZeroMemory(&WindowName, sizeof(WindowName));
|
RtlZeroMemory(&WindowName, sizeof(WindowName));
|
||||||
|
|
||||||
RtlZeroMemory(&Cs, sizeof(Cs));
|
RtlZeroMemory(&Cs, sizeof(Cs));
|
||||||
|
@ -1113,9 +1054,8 @@ NtUserCreateDesktop(
|
||||||
DesktopObject->pDeskInfo->spwnd = pWndDesktop;
|
DesktopObject->pDeskInfo->spwnd = pWndDesktop;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
W32Thread = PsGetCurrentThreadWin32Thread();
|
|
||||||
|
|
||||||
if (!W32Thread->rpdesk) IntSetThreadDesktop(DesktopObject,FALSE);
|
if (!ptiCurrent->rpdesk) IntSetThreadDesktop(DesktopObject,FALSE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Based on wine/server/window.c in get_desktop_window.
|
Based on wine/server/window.c in get_desktop_window.
|
||||||
|
@ -1123,7 +1063,6 @@ NtUserCreateDesktop(
|
||||||
|
|
||||||
ClassName.Buffer = ((PWSTR)((ULONG_PTR)(WORD)(gpsi->atomSysClass[ICLS_HWNDMESSAGE])));
|
ClassName.Buffer = ((PWSTR)((ULONG_PTR)(WORD)(gpsi->atomSysClass[ICLS_HWNDMESSAGE])));
|
||||||
ClassName.Length = 0;
|
ClassName.Length = 0;
|
||||||
RtlZeroMemory(&MenuName, sizeof(MenuName));
|
|
||||||
RtlZeroMemory(&WindowName, sizeof(WindowName));
|
RtlZeroMemory(&WindowName, sizeof(WindowName));
|
||||||
|
|
||||||
RtlZeroMemory(&Cs, sizeof(Cs));
|
RtlZeroMemory(&Cs, sizeof(Cs));
|
||||||
|
@ -1154,6 +1093,10 @@ NtUserCreateDesktop(
|
||||||
RETURN( Desktop);
|
RETURN( Desktop);
|
||||||
|
|
||||||
CLEANUP:
|
CLEANUP:
|
||||||
|
if(DesktopName.Buffer != NULL)
|
||||||
|
{
|
||||||
|
ExFreePoolWithTag(DesktopName.Buffer, TAG_STRING);
|
||||||
|
}
|
||||||
if (!NoHooks && ptiCurrent) ptiCurrent->TIF_flags &= ~TIF_DISABLEHOOKS;
|
if (!NoHooks && ptiCurrent) ptiCurrent->TIF_flags &= ~TIF_DISABLEHOOKS;
|
||||||
DPRINT("Leave NtUserCreateDesktop, ret=%i\n",_ret_);
|
DPRINT("Leave NtUserCreateDesktop, ret=%i\n",_ret_);
|
||||||
UserLeave();
|
UserLeave();
|
||||||
|
@ -1184,85 +1127,17 @@ CLEANUP:
|
||||||
|
|
||||||
HDESK APIENTRY
|
HDESK APIENTRY
|
||||||
NtUserOpenDesktop(
|
NtUserOpenDesktop(
|
||||||
PUNICODE_STRING lpszDesktopName,
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
DWORD dwFlags,
|
DWORD dwFlags,
|
||||||
ACCESS_MASK dwDesiredAccess)
|
ACCESS_MASK dwDesiredAccess)
|
||||||
{
|
{
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
||||||
HWINSTA WinSta;
|
|
||||||
PWINSTATION_OBJECT WinStaObject;
|
|
||||||
UNICODE_STRING DesktopName;
|
|
||||||
UNICODE_STRING SafeDesktopName;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
HDESK Desktop;
|
HDESK Desktop;
|
||||||
BOOL Result;
|
|
||||||
DECLARE_RETURN(HDESK);
|
|
||||||
|
|
||||||
DPRINT("Enter NtUserOpenDesktop: %wZ\n", lpszDesktopName);
|
|
||||||
UserEnterExclusive();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Validate the window station handle and compose the fully
|
|
||||||
* qualified desktop name
|
|
||||||
*/
|
|
||||||
|
|
||||||
WinSta = UserGetProcessWindowStation();
|
|
||||||
Status = IntValidateWindowStationHandle(
|
|
||||||
WinSta,
|
|
||||||
KernelMode,
|
|
||||||
0,
|
|
||||||
&WinStaObject);
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("Failed validation of window station handle (0x%X)\n", WinSta);
|
|
||||||
SetLastNtError(Status);
|
|
||||||
RETURN( 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(lpszDesktopName != NULL)
|
|
||||||
{
|
|
||||||
Status = IntSafeCopyUnicodeString(&SafeDesktopName, lpszDesktopName);
|
|
||||||
if(!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
SetLastNtError(Status);
|
|
||||||
RETURN( NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RtlInitUnicodeString(&SafeDesktopName, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
Result = IntGetFullWindowStationName(&DesktopName, &WinStaObject->Name,
|
|
||||||
&SafeDesktopName);
|
|
||||||
|
|
||||||
if (lpszDesktopName)
|
|
||||||
ExFreePoolWithTag(SafeDesktopName.Buffer, TAG_STRING);
|
|
||||||
ObDereferenceObject(WinStaObject);
|
|
||||||
|
|
||||||
|
|
||||||
if (!Result)
|
|
||||||
{
|
|
||||||
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
|
|
||||||
RETURN( 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DPRINT("Trying to open desktop (%wZ)\n", &DesktopName);
|
|
||||||
|
|
||||||
/* Initialize ObjectAttributes for the desktop object */
|
|
||||||
InitializeObjectAttributes(
|
|
||||||
&ObjectAttributes,
|
|
||||||
&DesktopName,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
Status = ObOpenObjectByName(
|
Status = ObOpenObjectByName(
|
||||||
&ObjectAttributes,
|
ObjectAttributes,
|
||||||
ExDesktopObjectType,
|
ExDesktopObjectType,
|
||||||
KernelMode,
|
UserMode,
|
||||||
NULL,
|
NULL,
|
||||||
dwDesiredAccess,
|
dwDesiredAccess,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -1271,19 +1146,10 @@ NtUserOpenDesktop(
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastNtError(Status);
|
SetLastNtError(Status);
|
||||||
ExFreePool(DesktopName.Buffer);
|
return 0;
|
||||||
RETURN( 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("Successfully opened desktop (%wZ)\n", &DesktopName);
|
return Desktop;
|
||||||
ExFreePool(DesktopName.Buffer);
|
|
||||||
|
|
||||||
RETURN( Desktop);
|
|
||||||
|
|
||||||
CLEANUP:
|
|
||||||
DPRINT("Leave NtUserOpenDesktop, ret=%i\n",_ret_);
|
|
||||||
UserLeave();
|
|
||||||
END_CLEANUP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -392,61 +392,23 @@ IntGetScreenDC(VOID)
|
||||||
|
|
||||||
HWINSTA APIENTRY
|
HWINSTA APIENTRY
|
||||||
NtUserCreateWindowStation(
|
NtUserCreateWindowStation(
|
||||||
PUNICODE_STRING lpszWindowStationName,
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
ACCESS_MASK dwDesiredAccess,
|
ACCESS_MASK dwDesiredAccess,
|
||||||
LPSECURITY_ATTRIBUTES lpSecurity,
|
DWORD Unknown2,
|
||||||
DWORD Unknown3,
|
DWORD Unknown3,
|
||||||
DWORD Unknown4,
|
DWORD Unknown4,
|
||||||
DWORD Unknown5,
|
DWORD Unknown5,
|
||||||
DWORD Unknown6)
|
DWORD Unknown6)
|
||||||
{
|
{
|
||||||
UNICODE_STRING WindowStationName;
|
UNICODE_STRING WindowStationName;
|
||||||
UNICODE_STRING FullWindowStationName;
|
|
||||||
PWINSTATION_OBJECT WindowStationObject;
|
PWINSTATION_OBJECT WindowStationObject;
|
||||||
HWINSTA WindowStation;
|
HWINSTA WindowStation;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
/*
|
|
||||||
* Generate full window station name
|
|
||||||
*/
|
|
||||||
Status = ProbeAndCaptureUnicodeString(&WindowStationName,
|
|
||||||
UserMode,
|
|
||||||
lpszWindowStationName);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("Failed to capture window station name (status 0x%08x)\n",
|
|
||||||
Status);
|
|
||||||
SetLastNtError(Status);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!IntGetFullWindowStationName(&FullWindowStationName,
|
|
||||||
&WindowStationName,
|
|
||||||
NULL))
|
|
||||||
{
|
|
||||||
ReleaseCapturedUnicodeString(&WindowStationName, UserMode);
|
|
||||||
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Try to open already existing window station
|
|
||||||
*/
|
|
||||||
|
|
||||||
DPRINT("Trying to open window station (%wZ)\n", &FullWindowStationName);
|
|
||||||
|
|
||||||
/* Initialize ObjectAttributes for the window station object */
|
|
||||||
InitializeObjectAttributes(
|
|
||||||
&ObjectAttributes,
|
|
||||||
&FullWindowStationName,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
Status = ObOpenObjectByName(
|
Status = ObOpenObjectByName(
|
||||||
&ObjectAttributes,
|
ObjectAttributes,
|
||||||
ExWindowStationObjectType,
|
ExWindowStationObjectType,
|
||||||
KernelMode,
|
UserMode,
|
||||||
NULL,
|
NULL,
|
||||||
dwDesiredAccess,
|
dwDesiredAccess,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -454,24 +416,39 @@ NtUserCreateWindowStation(
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Successfully opened window station (%wZ)\n",
|
|
||||||
FullWindowStationName);
|
|
||||||
ExFreePool(FullWindowStationName.Buffer);
|
|
||||||
ReleaseCapturedUnicodeString(&WindowStationName, UserMode);
|
|
||||||
return (HWINSTA)WindowStation;
|
return (HWINSTA)WindowStation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No existing window station found, try to create new one
|
* No existing window station found, try to create new one
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Capture window station name */
|
||||||
|
_SEH2_TRY
|
||||||
|
{
|
||||||
|
ProbeForRead( ObjectAttributes, sizeof(OBJECT_ATTRIBUTES), 1);
|
||||||
|
Status = IntSafeCopyUnicodeString(&WindowStationName, ObjectAttributes->ObjectName);
|
||||||
|
}
|
||||||
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
Status =_SEH2_GetExceptionCode();
|
||||||
|
}
|
||||||
|
_SEH2_END
|
||||||
|
|
||||||
DPRINT("Creating window station (%wZ)\n", &FullWindowStationName);
|
if (! NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("Failed reading capturing window station name\n");
|
||||||
|
SetLastNtError(Status);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create the window station object */
|
||||||
Status = ObCreateObject(
|
Status = ObCreateObject(
|
||||||
KernelMode,
|
UserMode,
|
||||||
ExWindowStationObjectType,
|
ExWindowStationObjectType,
|
||||||
&ObjectAttributes,
|
ObjectAttributes,
|
||||||
ExGetPreviousMode(),
|
UserMode,
|
||||||
NULL,
|
NULL,
|
||||||
sizeof(WINSTATION_OBJECT),
|
sizeof(WINSTATION_OBJECT),
|
||||||
0,
|
0,
|
||||||
|
@ -480,26 +457,11 @@ NtUserCreateWindowStation(
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("Failed creating window station (%wZ)\n", &FullWindowStationName);
|
ExFreePoolWithTag(WindowStationName.Buffer, TAG_STRING);
|
||||||
ExFreePool(FullWindowStationName.Buffer);
|
|
||||||
ReleaseCapturedUnicodeString(&WindowStationName, UserMode);
|
|
||||||
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
|
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Zero out the buffer */
|
|
||||||
RtlZeroMemory(WindowStationObject, sizeof(WINSTATION_OBJECT));
|
|
||||||
|
|
||||||
KeInitializeSpinLock(&WindowStationObject->Lock);
|
|
||||||
|
|
||||||
InitializeListHead(&WindowStationObject->DesktopListHead);
|
|
||||||
|
|
||||||
WindowStationObject->AtomTable = NULL;
|
|
||||||
Status = RtlCreateAtomTable(37, &WindowStationObject->AtomTable);
|
|
||||||
WindowStationObject->SystemMenuTemplate = (HANDLE)0;
|
|
||||||
|
|
||||||
WindowStationObject->Name = WindowStationName;
|
|
||||||
|
|
||||||
Status = ObInsertObject(
|
Status = ObInsertObject(
|
||||||
(PVOID)WindowStationObject,
|
(PVOID)WindowStationObject,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -510,20 +472,21 @@ NtUserCreateWindowStation(
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("Failed creating window station (%wZ)\n", &FullWindowStationName);
|
ExFreePoolWithTag(WindowStationName.Buffer, TAG_STRING);
|
||||||
ExFreePool(FullWindowStationName.Buffer);
|
|
||||||
ExFreePool(WindowStationName.Buffer);
|
|
||||||
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
|
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
|
||||||
ObDereferenceObject(WindowStationObject);
|
ObDereferenceObject(WindowStationObject);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Initialize the window station */
|
||||||
* Initialize the new window station object
|
RtlZeroMemory(WindowStationObject, sizeof(WINSTATION_OBJECT));
|
||||||
*/
|
|
||||||
|
|
||||||
|
KeInitializeSpinLock(&WindowStationObject->Lock);
|
||||||
|
InitializeListHead(&WindowStationObject->DesktopListHead);
|
||||||
|
Status = RtlCreateAtomTable(37, &WindowStationObject->AtomTable);
|
||||||
|
WindowStationObject->SystemMenuTemplate = (HANDLE)0;
|
||||||
|
WindowStationObject->Name = WindowStationName;
|
||||||
WindowStationObject->ScreenSaverRunning = FALSE;
|
WindowStationObject->ScreenSaverRunning = FALSE;
|
||||||
|
|
||||||
WindowStationObject->FlatMenu = FALSE;
|
WindowStationObject->FlatMenu = FALSE;
|
||||||
|
|
||||||
if (!IntSetupClipboard(WindowStationObject))
|
if (!IntSetupClipboard(WindowStationObject))
|
||||||
|
@ -538,8 +501,6 @@ NtUserCreateWindowStation(
|
||||||
InitCursorImpl();
|
InitCursorImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("Window station successfully created (%wZ)\n", &FullWindowStationName);
|
|
||||||
ExFreePool(FullWindowStationName.Buffer);
|
|
||||||
return WindowStation;
|
return WindowStation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -569,39 +530,16 @@ NtUserCreateWindowStation(
|
||||||
|
|
||||||
HWINSTA APIENTRY
|
HWINSTA APIENTRY
|
||||||
NtUserOpenWindowStation(
|
NtUserOpenWindowStation(
|
||||||
PUNICODE_STRING lpszWindowStationName,
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
ACCESS_MASK dwDesiredAccess)
|
ACCESS_MASK dwDesiredAccess)
|
||||||
{
|
{
|
||||||
UNICODE_STRING WindowStationName;
|
|
||||||
HWINSTA WindowStation;
|
HWINSTA WindowStation;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
/*
|
|
||||||
* Generate full window station name
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!IntGetFullWindowStationName(&WindowStationName, lpszWindowStationName,
|
|
||||||
NULL))
|
|
||||||
{
|
|
||||||
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("Trying to open window station (%wZ)\n", &WindowStationName);
|
|
||||||
|
|
||||||
/* Initialize ObjectAttributes for the window station object */
|
|
||||||
InitializeObjectAttributes(
|
|
||||||
&ObjectAttributes,
|
|
||||||
&WindowStationName,
|
|
||||||
OBJ_CASE_INSENSITIVE,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
Status = ObOpenObjectByName(
|
Status = ObOpenObjectByName(
|
||||||
&ObjectAttributes,
|
ObjectAttributes,
|
||||||
ExWindowStationObjectType,
|
ExWindowStationObjectType,
|
||||||
KernelMode,
|
UserMode,
|
||||||
NULL,
|
NULL,
|
||||||
dwDesiredAccess,
|
dwDesiredAccess,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -610,13 +548,9 @@ NtUserOpenWindowStation(
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastNtError(Status);
|
SetLastNtError(Status);
|
||||||
ExFreePool(WindowStationName.Buffer);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("Successfully opened window station (%wZ)\n", &WindowStationName);
|
|
||||||
ExFreePool(WindowStationName.Buffer);
|
|
||||||
|
|
||||||
return WindowStation;
|
return WindowStation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue