Author: ion
Date: Thu May 25 23:30:09 2006
New Revision: 22041
URL:
http://svn.reactos.ru/svn/reactos?rev=22041&view=rev
Log:
- Rewrite Desktop/WindowsStation parsing to follow the NT Object Model, with some minor
hacks to respect ROS's current parsing semantics.
- Thanks to this, the long-lasting ExpDesktopCreate hack is gone, and so is
OB_ROS_FIND_METHOD and OB_ROS_CREATE_METHOD in win32k. Next patch can fully remove
WIN32_CALLOUT_DATA and use the NT type instead.
- Add official OBJECT_ macros in obtypes.h
Modified:
trunk/reactos/include/ndk/obtypes.h
trunk/reactos/include/reactos/win32k/callout.h
trunk/reactos/ntoskrnl/ex/win32k.c
trunk/reactos/ntoskrnl/include/internal/ob.h
trunk/reactos/ntoskrnl/ob/obhandle.c
trunk/reactos/ntoskrnl/ob/obname.c
trunk/reactos/ntoskrnl/ps/win32.c
trunk/reactos/subsystems/win32/win32k/include/desktop.h
trunk/reactos/subsystems/win32/win32k/main/dllmain.c
trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c
trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c
Modified: trunk/reactos/include/ndk/obtypes.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/include/ndk/obtypes.h?rev=2…
==============================================================================
--- trunk/reactos/include/ndk/obtypes.h (original)
+++ trunk/reactos/include/ndk/obtypes.h Thu May 25 23:30:09 2006
@@ -86,6 +86,22 @@
#define OB_FLAG_PERMANENT 0x10
#define OB_FLAG_SECURITY 0x20
#define OB_FLAG_SINGLE_PROCESS 0x40
+
+#define OBJECT_TO_OBJECT_HEADER(o) \
+ CONTAINING_RECORD((o), OBJECT_HEADER, Body)
+
+#define OBJECT_HEADER_TO_NAME_INFO(h) \
+ ((POBJECT_HEADER_NAME_INFO)(!(h)->NameInfoOffset ? \
+ NULL: ((PCHAR)(h) - (h)->NameInfoOffset)))
+
+#define OBJECT_HEADER_TO_HANDLE_INFO(h) \
+ ((POBJECT_HEADER_HANDLE_INFO)(!(h)->HandleInfoOffset ? \
+ NULL: ((PCHAR)(h) - (h)->HandleInfoOffset)))
+
+#define OBJECT_HEADER_TO_CREATOR_INFO(h) \
+ ((POBJECT_HEADER_CREATOR_INFO)(!((h)->Flags & \
+ OB_FLAG_CREATOR_INFO) ? NULL: ((PCHAR)(h) - \
+ sizeof(OBJECT_HEADER_CREATOR_INFO))))
//
// Reasons for Open Callback
Modified: trunk/reactos/include/reactos/win32k/callout.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/include/reactos/win32k/call…
==============================================================================
--- trunk/reactos/include/reactos/win32k/callout.h (original)
+++ trunk/reactos/include/reactos/win32k/callout.h Thu May 25 23:30:09 2006
@@ -12,8 +12,7 @@
OB_DELETE_METHOD WinStaDelete;
OB_PARSE_METHOD WinStaParse;
OB_OPEN_METHOD WinStaOpen;
- OB_ROS_FIND_METHOD WinStaFind;
- OB_ROS_CREATE_METHOD DesktopCreate;
+ OB_PARSE_METHOD DesktopParse;
} W32_CALLOUT_DATA, *PW32_CALLOUT_DATA;
#endif
Modified: trunk/reactos/ntoskrnl/ex/win32k.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ex/win32k.c?rev=22…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/win32k.c (original)
+++ trunk/reactos/ntoskrnl/ex/win32k.c Thu May 25 23:30:09 2006
@@ -38,8 +38,7 @@
OB_OPEN_METHOD ExpWindowStationObjectOpen = NULL;
OB_PARSE_METHOD ExpWindowStationObjectParse = NULL;
OB_DELETE_METHOD ExpWindowStationObjectDelete = NULL;
-OB_ROS_FIND_METHOD ExpWindowStationObjectFind = NULL;
-OB_ROS_CREATE_METHOD ExpDesktopObjectCreate = NULL;
+OB_PARSE_METHOD ExpDesktopObjectParse = NULL;
OB_DELETE_METHOD ExpDesktopObjectDelete = NULL;
/* FUNCTIONS ****************************************************************/
@@ -47,17 +46,17 @@
NTSTATUS
STDCALL
ExpWinStaObjectOpen(OB_OPEN_REASON Reason,
+ PEPROCESS Process,
PVOID ObjectBody,
- PEPROCESS Process,
- ULONG HandleCount,
- ACCESS_MASK GrantedAccess)
+ ACCESS_MASK GrantedAccess,
+ ULONG HandleCount)
{
/* Call the Registered Callback */
return ExpWindowStationObjectOpen(Reason,
+ Process,
ObjectBody,
- Process,
- HandleCount,
- GrantedAccess);
+ GrantedAccess,
+ HandleCount);
}
VOID
@@ -66,18 +65,6 @@
{
/* Call the Registered Callback */
ExpWindowStationObjectDelete(DeletedObject);
-}
-
-PVOID
-STDCALL
-ExpWinStaObjectFind(PVOID WinStaObject,
- PWSTR Name,
- ULONG Attributes)
-{
- /* Call the Registered Callback */
- return ExpWindowStationObjectFind(WinStaObject,
- Name,
- Attributes);
}
NTSTATUS
@@ -105,21 +92,6 @@
SecurityQos,
Object);
}
-
-NTSTATUS
-STDCALL
-ExpDesktopCreate(PVOID ObjectBody,
- PVOID Parent,
- PWSTR RemainingPath,
- POBJECT_ATTRIBUTES ObjectAttributes)
-{
- /* Call the Registered Callback */
- return ExpDesktopObjectCreate(ObjectBody,
- Parent,
- RemainingPath,
- ObjectAttributes);
-}
-
VOID
STDCALL
ExpDesktopDelete(PVOID DeletedObject)
@@ -143,9 +115,9 @@
ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
ObjectTypeInitializer.GenericMapping = ExpWindowStationMapping;
ObjectTypeInitializer.PoolType = NonPagedPool;
- ObjectTypeInitializer.OpenProcedure = (OB_OPEN_METHOD)ExpWinStaObjectOpen;
+ ObjectTypeInitializer.OpenProcedure = ExpWinStaObjectOpen;
ObjectTypeInitializer.DeleteProcedure = ExpWinStaObjectDelete;
- ObjectTypeInitializer.ParseProcedure = (OB_PARSE_METHOD)ExpWinStaObjectParse;
+ ObjectTypeInitializer.ParseProcedure = ExpWinStaObjectParse;
ObpCreateTypeObject(&ObjectTypeInitializer,
&Name,
&ExWindowStationObjectType);
Modified: trunk/reactos/ntoskrnl/include/internal/ob.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/include/internal/o…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ob.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/ob.h Thu May 25 23:30:09 2006
@@ -53,13 +53,6 @@
struct _OBJECT_ATTRIBUTES* ObjectAttributes
);
-typedef PVOID
-(NTAPI *OB_ROS_FIND_METHOD)(
- PVOID WinStaObject,
- PWSTR Name,
- ULONG Attributes
-);
-
BOOLEAN
NTAPI
ObpDeleteEntryDirectory(POBP_LOOKUP_CONTEXT Context);
Modified: trunk/reactos/ntoskrnl/ob/obhandle.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ob/obhandle.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ob/obhandle.c (original)
+++ trunk/reactos/ntoskrnl/ob/obhandle.c Thu May 25 23:30:09 2006
@@ -18,14 +18,6 @@
#include <internal/debug.h>
PHANDLE_TABLE ObpKernelHandleTable = NULL;
-
-/* TEMPORARY HACK. DO NOT REMOVE -- Alex */
-NTSTATUS
-STDCALL
-ExpDesktopCreate(PVOID ObjectBody,
- PVOID Parent,
- PWSTR RemainingPath,
- POBJECT_CREATE_INFORMATION ObjectCreateInformation);
/* PRIVATE FUNCTIONS *********************************************************/
@@ -1012,7 +1004,6 @@
}
if ((Header->Type == IoFileObjectType) ||
- (Header->Type == ExDesktopObjectType) ||
(Header->Type->TypeInfo.OpenProcedure != NULL))
{
DPRINT("About to call Open Routine\n");
@@ -1026,15 +1017,6 @@
ObjectCreateInfo);
DPRINT("Called IopCreateFile: %x\n", Status);
- }
- else if (Header->Type == ExDesktopObjectType)
- {
- /* TEMPORARY HACK. DO NOT TOUCH -- Alex */
- DPRINT("Calling ExpDesktopCreate\n");
- Status = ExpDesktopCreate(&Header->Body,
- FoundObject,
- RemainingPath.Buffer,
- ObjectCreateInfo);
}
else if (Header->Type->TypeInfo.OpenProcedure != NULL)
{
Modified: trunk/reactos/ntoskrnl/ob/obname.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ob/obname.c?rev=22…
==============================================================================
--- trunk/reactos/ntoskrnl/ob/obname.c (original)
+++ trunk/reactos/ntoskrnl/ob/obname.c Thu May 25 23:30:09 2006
@@ -176,13 +176,13 @@
RtlInitUnicodeString(&CurrentUs, current);
Status = CurrentHeader->Type->TypeInfo.ParseProcedure(CurrentObject,
CurrentHeader->Type,
- NULL,
- ExGetPreviousMode(),
+ AccessState,
+ ExGetPreviousMode(), // fixme: should be a parameter, since caller decides.
Attributes,
&PathString,
&CurrentUs,
- NULL,
- NULL,
+ ParseContext,
+ NULL, // fixme: where do we get this from? captured OBP?
&NextObject);
current = CurrentUs.Buffer;
if (Status == STATUS_REPARSE)
Modified: trunk/reactos/ntoskrnl/ps/win32.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ps/win32.c?rev=220…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/win32.c (original)
+++ trunk/reactos/ntoskrnl/ps/win32.c Thu May 25 23:30:09 2006
@@ -23,8 +23,7 @@
extern OB_OPEN_METHOD ExpWindowStationObjectOpen;
extern OB_PARSE_METHOD ExpWindowStationObjectParse;
extern OB_DELETE_METHOD ExpWindowStationObjectDelete;
-extern OB_ROS_FIND_METHOD ExpWindowStationObjectFind;
-extern OB_ROS_CREATE_METHOD ExpDesktopObjectCreate;
+extern OB_PARSE_METHOD ExpDesktopObjectParse;
extern OB_DELETE_METHOD ExpDesktopObjectDelete;
#ifndef ALEX_CB_REWRITE
@@ -64,8 +63,7 @@
ExpWindowStationObjectOpen = CalloutData->WinStaOpen;
ExpWindowStationObjectParse = CalloutData->WinStaParse;
ExpWindowStationObjectDelete = CalloutData->WinStaDelete;
- ExpWindowStationObjectFind = CalloutData->WinStaFind;
- ExpDesktopObjectCreate = CalloutData->DesktopCreate;
+ ExpDesktopObjectParse = CalloutData->DesktopParse;
ExpDesktopObjectDelete = CalloutData->DesktopDelete;
}
Modified: trunk/reactos/subsystems/win32/win32k/include/desktop.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/desktop.h (original)
+++ trunk/reactos/subsystems/win32/win32k/include/desktop.h Thu May 25 23:30:09 2006
@@ -10,7 +10,6 @@
CSHORT Size;
LIST_ENTRY ListEntry;
- UNICODE_STRING Name;
/* Pointer to the associated window station. */
struct _WINSTATION_OBJECT *WindowStation;
/* Pointer to the active queue. */
@@ -48,11 +47,18 @@
NTSTATUS FASTCALL
CleanupDesktopImpl(VOID);
-NTSTATUS STDCALL
-IntDesktopObjectCreate(PVOID ObjectBody,
- PVOID Parent,
- PWSTR RemainingPath,
- struct _OBJECT_ATTRIBUTES* ObjectAttributes);
+NTSTATUS
+STDCALL
+IntDesktopObjectParse(IN PVOID ParseObject,
+ IN PVOID ObjectType,
+ IN OUT PACCESS_STATE AccessState,
+ IN KPROCESSOR_MODE AccessMode,
+ IN ULONG Attributes,
+ IN OUT PUNICODE_STRING CompleteName,
+ IN OUT PUNICODE_STRING RemainingName,
+ IN OUT PVOID Context OPTIONAL,
+ IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
+ OUT PVOID *Object);
VOID STDCALL
IntDesktopObjectDelete(PVOID DeletedObject);
@@ -119,6 +125,12 @@
#define IntIsActiveDesktop(Desktop) \
((Desktop)->WindowStation->ActiveDesktop == (Desktop))
+
+#define GET_DESKTOP_NAME(d) \
+ OBJECT_HEADER_TO_NAME_INFO(OBJECT_TO_OBJECT_HEADER(d)) ? \
+ &(OBJECT_HEADER_TO_NAME_INFO(OBJECT_TO_OBJECT_HEADER(d))->Name) : \
+ NULL
+
static __inline PVOID
DesktopHeapAlloc(IN PDESKTOP Desktop,
Modified: trunk/reactos/subsystems/win32/win32k/main/dllmain.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/mai…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/main/dllmain.c (original)
+++ trunk/reactos/subsystems/win32/win32k/main/dllmain.c Thu May 25 23:30:09 2006
@@ -384,8 +384,7 @@
CalloutData.WinStaOpen = IntWinStaObjectOpen;
CalloutData.WinStaParse = IntWinStaObjectParse;
CalloutData.WinStaDelete = IntWinStaObjectDelete;
- CalloutData.WinStaFind = IntWinStaObjectFind;
- CalloutData.DesktopCreate = IntDesktopObjectCreate;
+ CalloutData.DesktopParse = IntDesktopObjectParse;
CalloutData.DesktopDelete = IntDesktopObjectDelete;
CalloutData.W32ProcessCallout = Win32kProcessCallback;
CalloutData.W32ThreadCallout = Win32kThreadCallback;
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c Thu May 25 23:30:09 2006
@@ -34,82 +34,143 @@
#define NDEBUG
#include <debug.h>
+static
+VOID
+IntFreeDesktopHeap(
+ IN OUT PDESKTOP_OBJECT Desktop
+);
+
/* GLOBALS *******************************************************************/
/* Currently active desktop */
PDESKTOP_OBJECT InputDesktop = NULL;
HDESK InputDesktopHandle = NULL;
HDC ScreenDeviceContext = NULL;
-
BOOL g_PaintDesktopVersion = FALSE;
-static VOID IntFreeDesktopHeap(IN OUT PDESKTOP_OBJECT Desktop);
-
-/* INITALIZATION FUNCTIONS ****************************************************/
-
-static GENERIC_MAPPING IntDesktopMapping =
- {
- STANDARD_RIGHTS_READ | DESKTOP_ENUMERATE | DESKTOP_READOBJECTS,
- STANDARD_RIGHTS_WRITE | DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |
DESKTOP_HOOKCONTROL |
- DESKTOP_JOURNALPLAYBACK | DESKTOP_JOURNALRECORD | DESKTOP_WRITEOBJECTS,
+GENERIC_MAPPING IntDesktopMapping =
+{
+ STANDARD_RIGHTS_READ | DESKTOP_ENUMERATE |
+ DESKTOP_READOBJECTS,
+ STANDARD_RIGHTS_WRITE | DESKTOP_CREATEMENU |
+ DESKTOP_CREATEWINDOW |
+ DESKTOP_HOOKCONTROL |
+ DESKTOP_JOURNALPLAYBACK |
+ DESKTOP_JOURNALRECORD |
+ DESKTOP_WRITEOBJECTS,
STANDARD_RIGHTS_EXECUTE | DESKTOP_SWITCHDESKTOP,
- STANDARD_RIGHTS_REQUIRED | DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |
DESKTOP_ENUMERATE |
- DESKTOP_HOOKCONTROL | DESKTOP_JOURNALPLAYBACK | DESKTOP_JOURNALRECORD |
- DESKTOP_READOBJECTS | DESKTOP_SWITCHDESKTOP | DESKTOP_WRITEOBJECTS
- };
-
-NTSTATUS FASTCALL
-InitDesktopImpl(VOID)
-{
- /* Set Desktop Object Attributes */
- ExDesktopObjectType->TypeInfo.DefaultNonPagedPoolCharge = sizeof(DESKTOP_OBJECT);
- ExDesktopObjectType->TypeInfo.GenericMapping = IntDesktopMapping;
-
- return STATUS_SUCCESS;
-}
-
-NTSTATUS FASTCALL
-CleanupDesktopImpl(VOID)
-{
- return STATUS_SUCCESS;
-}
+ STANDARD_RIGHTS_REQUIRED | DESKTOP_CREATEMENU |
+ DESKTOP_CREATEWINDOW |
+ DESKTOP_ENUMERATE |
+ DESKTOP_HOOKCONTROL |
+ DESKTOP_JOURNALPLAYBACK |
+ DESKTOP_JOURNALRECORD |
+ DESKTOP_READOBJECTS |
+ DESKTOP_SWITCHDESKTOP |
+ DESKTOP_WRITEOBJECTS
+};
/* OBJECT CALLBACKS **********************************************************/
-NTSTATUS STDCALL
-IntDesktopObjectCreate(PVOID ObjectBody,
- PVOID Parent,
- PWSTR RemainingPath,
- struct _OBJECT_ATTRIBUTES* ObjectAttributes)
-{
- PDESKTOP_OBJECT Desktop = (PDESKTOP_OBJECT)ObjectBody;
- UNICODE_STRING UnicodeString;
-
- DPRINT("Creating desktop (0x%X) Name (%S)\n", Desktop, RemainingPath);
- if (RemainingPath == NULL)
- {
- return STATUS_SUCCESS;
- }
-
- if (wcschr((RemainingPath + 1), '\\') != NULL)
- {
- return STATUS_UNSUCCESSFUL;
- }
-
- RtlInitUnicodeString(&UnicodeString, (RemainingPath + 1));
-
- InitializeListHead(&Desktop->ShellHookWindows);
-
- Desktop->WindowStation = (PWINSTATION_OBJECT)Parent;
-
- /* Put the desktop on the window station's list of associcated desktops */
-// ExInterlocked
- InsertTailList(
- &Desktop->WindowStation->DesktopListHead,
- &Desktop->ListEntry);//,
-// &Desktop->WindowStation->Lock);
-
- return RtlCreateUnicodeString(&Desktop->Name, UnicodeString.Buffer);
+NTSTATUS
+NTAPI
+IntDesktopObjectParse(IN PVOID ParseObject,
+ IN PVOID ObjectType,
+ IN OUT PACCESS_STATE AccessState,
+ IN KPROCESSOR_MODE AccessMode,
+ IN ULONG Attributes,
+ IN OUT PUNICODE_STRING CompleteName,
+ IN OUT PUNICODE_STRING RemainingName,
+ IN OUT PVOID Context OPTIONAL,
+ IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
+ OUT PVOID *Object)
+{
+ NTSTATUS Status;
+ PDESKTOP_OBJECT Desktop;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ PLIST_ENTRY NextEntry, ListHead;
+ PWINSTATION_OBJECT WinStaObject = (PWINSTATION_OBJECT)ParseObject;
+ PUNICODE_STRING DesktopName;
+
+ /* Set the list pointers and loop the window station */
+ DPRINT1("Creating desktop(%wZ)\n", RemainingName);
+ ListHead = &WinStaObject->DesktopListHead;
+ NextEntry = ListHead->Flink;
+ while (NextEntry != ListHead)
+ {
+ /* Get the current desktop */
+ Desktop = CONTAINING_RECORD(NextEntry, DESKTOP_OBJECT, ListEntry);
+
+ /* Get its name */
+ DesktopName = GET_DESKTOP_NAME(Desktop);
+ if (DesktopName)
+ {
+ /* Compare the name */
+ if (RtlEqualUnicodeString(RemainingName,
+ DesktopName,
+ (Attributes & OBJ_CASE_INSENSITIVE)))
+ {
+ /* We found a match. Did this come from a create? */
+ if (Context)
+ {
+ /* Unless OPEN_IF was given, fail with an error */
+ if (!(Attributes & OBJ_OPENIF))
+ {
+ /* Name collision */
+ return STATUS_OBJECT_NAME_COLLISION;
+ }
+ else
+ {
+ /* Otherwise, return with a warning only */
+ Status = STATUS_OBJECT_NAME_EXISTS;
+ }
+ }
+ else
+ {
+ /* This was a real open, so this is OK */
+ Status = STATUS_SUCCESS;
+ }
+
+ /* Reference the desktop and return it */
+ ObReferenceObject(Desktop);
+ *Object = Desktop;
+ RemainingName->Buffer = NULL; // => ROS Parse routines need to do
this
+ return Status;
+ }
+ }
+
+ /* Go to the next desktop */
+ NextEntry = NextEntry->Flink;
+ }
+
+ /* If we got here but this isn't a create, then fail */
+ if (!Context) return STATUS_OBJECT_NAME_NOT_FOUND;
+
+ /* Create the desktop object */
+ InitializeObjectAttributes(&ObjectAttributes, RemainingName, 0, NULL, NULL);
+ Status = ObCreateObject(KernelMode,
+ ExDesktopObjectType,
+ &ObjectAttributes,
+ UserMode,
+ NULL,
+ sizeof(DESKTOP_OBJECT),
+ 0,
+ 0,
+ (PVOID)&Desktop);
+ if (!NT_SUCCESS(Status)) return Status;
+
+ /* Initialize shell hook window list and set the parent */
+ InitializeListHead(&Desktop->ShellHookWindows);
+ Desktop->WindowStation = (PWINSTATION_OBJECT)ParseObject;
+
+ /* Put the desktop on the window station's list of associated desktops */
+ InsertTailList(&Desktop->WindowStation->DesktopListHead,
+ &Desktop->ListEntry);
+
+ /* Set the desktop object and return success */
+ *Object = Desktop;
+ RemainingName->Buffer = NULL; // => ROS Parse routines need to do this
+ return STATUS_SUCCESS;
}
VOID STDCALL
@@ -122,12 +183,27 @@
/* Remove the desktop from the window station's list of associcated desktops */
RemoveEntryList(&Desktop->ListEntry);
- RtlFreeUnicodeString(&Desktop->Name);
-
IntFreeDesktopHeap(Desktop);
}
/* PRIVATE FUNCTIONS **********************************************************/
+
+NTSTATUS
+FASTCALL
+InitDesktopImpl(VOID)
+{
+ /* Set Desktop Object Attributes */
+ ExDesktopObjectType->TypeInfo.DefaultNonPagedPoolCharge = sizeof(DESKTOP_OBJECT);
+ ExDesktopObjectType->TypeInfo.GenericMapping = IntDesktopMapping;
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+FASTCALL
+CleanupDesktopImpl(VOID)
+{
+ return STATUS_SUCCESS;
+}
static int GetSystemVersionString(LPWSTR buffer)
{
@@ -736,8 +812,6 @@
Desktop->DesktopHeapSection = NULL;
}
}
-
-
/* SYSCALLS *******************************************************************/
@@ -791,6 +865,7 @@
PVOID DesktopHeapSystemBase = NULL;
SIZE_T DesktopInfoSize;
UNICODE_STRING SafeDesktopName;
+ ULONG DummyContext;
DECLARE_RETURN(HDESK);
@@ -839,7 +914,7 @@
* Try to open already existing desktop
*/
- DPRINT1("Trying to open desktop (%wZ)\n", &DesktopName);
+ DPRINT("Trying to open desktop (%wZ)\n", &DesktopName);
/* Initialize ObjectAttributes for the desktop object */
InitializeObjectAttributes(
@@ -852,41 +927,26 @@
Status = ObOpenObjectByName(
&ObjectAttributes,
ExDesktopObjectType,
- NULL,
+ (PVOID)&DummyContext,
KernelMode,
dwDesiredAccess,
NULL,
(HANDLE*)&Desktop);
-
- if (NT_SUCCESS(Status))
- {
- DPRINT("Successfully opened desktop (%wZ)\n", &DesktopName);
+ if (!NT_SUCCESS(Status)) RETURN(NULL);
+ if (Status == STATUS_OBJECT_NAME_EXISTS)
+ {
ExFreePool(DesktopName.Buffer);
RETURN( Desktop);
}
- /*
- * No existing desktop found, try to create new one
- */
-
- Status = ObCreateObject(
- KernelMode,
- ExDesktopObjectType,
- &ObjectAttributes,
- ExGetPreviousMode(),
- NULL,
- sizeof(DESKTOP_OBJECT),
- 0,
- 0,
- (PVOID*)&DesktopObject);
-
- if (! NT_SUCCESS(Status))
- {
- DPRINT1("Failed creating desktop (%wZ)\n", &DesktopName);
- ExFreePool(DesktopName.Buffer);
- SetLastNtError(STATUS_UNSUCCESSFUL);
- RETURN( NULL);
- }
+ /* Reference the desktop */
+ Status = ObReferenceObjectByHandle(Desktop,
+ 0,
+ ExDesktopObjectType,
+ KernelMode,
+ (PVOID)&DesktopObject,
+ NULL);
+ if (!NT_SUCCESS(Status)) RETURN(NULL);
DesktopObject->DesktopHeapSection = NULL;
DesktopObject->hDesktopHeap =
UserCreateHeap(&DesktopObject->DesktopHeapSection,
@@ -930,16 +990,6 @@
/* Initialize some local (to win32k) desktop state. */
DesktopObject->ActiveMessageQueue = NULL;
-
- Status = ObInsertObject(
- (PVOID)DesktopObject,
- NULL,
- STANDARD_RIGHTS_REQUIRED,
- 0,
- NULL,
- (HANDLE*)&Desktop);
-
- ObDereferenceObject(DesktopObject);
ExFreePool(DesktopName.Buffer);
if (! NT_SUCCESS(Status))
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c Thu May 25 23:30:09 2006
@@ -105,7 +105,6 @@
PWINSTATION_OBJECT WinSta = (PWINSTATION_OBJECT)ObjectBody;
NTSTATUS Status;
-DPRINT1("IntWinStaObjectOpen\n");
if (Reason == ObCreateHandle)
{
@@ -115,10 +114,8 @@
InitializeListHead(&WinSta->DesktopListHead);
-DPRINT1("Create winsta atomtable\n");
WinSta->AtomTable = NULL;
Status = RtlCreateAtomTable(37, &WinSta->AtomTable);
-if (!NT_SUCCESS(Status)) DPRINT1("Error creating atom table\n");
WinSta->SystemMenuTemplate = (HANDLE)0;
DPRINT("Window station successfully created.\n");
@@ -137,51 +134,6 @@
RtlDestroyAtomTable(WinSta->AtomTable);
RtlFreeUnicodeString(&WinSta->Name);
-}
-
-PVOID STDCALL
-IntWinStaObjectFind(PVOID Object,
- PWSTR Name,
- ULONG Attributes)
-{
- PLIST_ENTRY Current;
- PDESKTOP_OBJECT CurrentObject;
- PWINSTATION_OBJECT WinStaObject = (PWINSTATION_OBJECT)Object;
-
- DPRINT("WinStaObject (0x%X) Name (%wS)\n", WinStaObject, Name);
-
- if (Name[0] == 0)
- {
- return NULL;
- }
-
- Current = WinStaObject->DesktopListHead.Flink;
- while (Current != &WinStaObject->DesktopListHead)
- {
- CurrentObject = CONTAINING_RECORD(Current, DESKTOP_OBJECT, ListEntry);
- DPRINT("Scanning %wZ for %wS\n", &CurrentObject->Name, Name);
- if (Attributes & OBJ_CASE_INSENSITIVE)
- {
- if (_wcsicmp(CurrentObject->Name.Buffer, Name) == 0)
- {
- DPRINT("Found desktop at (0x%X)\n", CurrentObject);
- return CurrentObject;
- }
- }
- else
- {
- if (wcscmp(CurrentObject->Name.Buffer, Name) == 0)
- {
- DPRINT("Found desktop at (0x%X)\n", CurrentObject);
- return CurrentObject;
- }
- }
- Current = Current->Flink;
- }
-
- DPRINT("Returning NULL\n");
-
- return NULL;
}
NTSTATUS
@@ -197,44 +149,65 @@
IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
OUT PVOID *NextObject)
{
- PWSTR *Path = &RemainingName->Buffer;
- PVOID FoundObject;
- NTSTATUS Status;
- PWSTR End;
-
- DPRINT("Object (0x%X) Path (0x%X) *Path (%wS)\n", Object, Path, *Path);
-
- *NextObject = NULL;
-
- if ((Path == NULL) || ((*Path) == NULL))
- {
- return STATUS_SUCCESS;
- }
-
- End = wcschr((*Path) + 1, '\\');
- if (End != NULL)
- {
- DPRINT("Name contains illegal characters\n");
- return STATUS_UNSUCCESSFUL;
- }
-
- FoundObject = IntWinStaObjectFind(Object, (*Path) + 1, Attributes);
- if (FoundObject == NULL)
- {
- DPRINT("Name was not found\n");
- return STATUS_UNSUCCESSFUL;
- }
-
- Status = ObReferenceObjectByPointer(
- FoundObject,
- STANDARD_RIGHTS_REQUIRED,
- NULL,
- UserMode);
-
- *NextObject = FoundObject;
- *Path = NULL;
-
- return Status;
+ DPRINT("Object (0x%X) Path (0x%X) *Path (%wZ)\n", Object, RemainingName,
RemainingName);
+
+ /* Assume we don't find anything */
+ *NextObject = NULL;
+
+ /* Check for an empty name */
+ if (!RemainingName->Length)
+ {
+ /* Make sure this is a window station, can't parse a desktop now */
+ if (ObjectType != ExWindowStationObjectType)
+ {
+ /* Fail */
+ return STATUS_OBJECT_TYPE_MISMATCH;
+ }
+
+ /* Reference the window station and return */
+ //ObReferenceObject(Object);
+ //*NextObject = Object; => ROS Parse routines don't need to do this
+ return STATUS_SUCCESS;
+ }
+
+ /* Check for leading slash */
+ if (RemainingName->Buffer[0] == OBJ_NAME_PATH_SEPARATOR)
+ {
+ /* Skip it */
+ RemainingName->Buffer++;
+ RemainingName->Length -= sizeof(WCHAR);
+ RemainingName->MaximumLength -= sizeof(WCHAR);
+ }
+
+ /* Check if there is still a slash */
+ if (wcschr(RemainingName->Buffer, OBJ_NAME_PATH_SEPARATOR))
+ {
+ /* In this case, fail */
+ return STATUS_OBJECT_PATH_INVALID;
+ }
+
+ /*
+ * Check if we are parsing a desktop.
+ * FIXME: ROS Sends the wrong Object Type. The parsed object's type
+ * should be sent, not the parsed parent's.
+ */
+ if (ObjectType == ExWindowStationObjectType)
+ {
+ /* Then call the desktop parse routine */
+ return IntDesktopObjectParse(Object,
+ ObjectType,
+ AccessState,
+ AccessMode,
+ Attributes,
+ FullPath,
+ RemainingName,
+ Context,
+ SecurityQos,
+ NextObject);
+ }
+
+ /* Should hopefully never get here */
+ return STATUS_OBJECT_TYPE_MISMATCH;
}
/* PRIVATE FUNCTIONS **********************************************************/
@@ -824,14 +797,14 @@
case UOI_NAME:
if (WinStaObject != NULL)
{
- pvData = WinStaObject->Name.Buffer;
- nDataSize = WinStaObject->Name.Length+2;
+ pvData = ((PUNICODE_STRING)GET_DESKTOP_NAME(WinStaObject))->Buffer;
+ nDataSize = ((PUNICODE_STRING)GET_DESKTOP_NAME(WinStaObject))->Length +
2;
Status = STATUS_SUCCESS;
}
else if (DesktopObject != NULL)
{
- pvData = DesktopObject->Name.Buffer;
- nDataSize = DesktopObject->Name.Length+2;
+ pvData = ((PUNICODE_STRING)GET_DESKTOP_NAME(DesktopObject))->Buffer;
+ nDataSize = ((PUNICODE_STRING)GET_DESKTOP_NAME(DesktopObject))->Length +
2;
Status = STATUS_SUCCESS;
}
else
@@ -1407,7 +1380,7 @@
DesktopEntry = DesktopEntry->Flink)
{
DesktopObject = CONTAINING_RECORD(DesktopEntry, DESKTOP_OBJECT, ListEntry);
- ReturnLength += DesktopObject->Name.Length + sizeof(WCHAR);
+ ReturnLength += ((PUNICODE_STRING)GET_DESKTOP_NAME(DesktopObject))->Length +
sizeof(WCHAR);
EntryCount++;
}
DPRINT("Required size: %d Entry count: %d\n", ReturnLength, EntryCount);
@@ -1450,14 +1423,14 @@
DesktopEntry = DesktopEntry->Flink)
{
DesktopObject = CONTAINING_RECORD(DesktopEntry, DESKTOP_OBJECT, ListEntry);
- Status = MmCopyToCaller(lpBuffer, DesktopObject->Name.Buffer,
DesktopObject->Name.Length);
+ Status = MmCopyToCaller(lpBuffer,
((PUNICODE_STRING)GET_DESKTOP_NAME(DesktopObject))->Buffer,
((PUNICODE_STRING)GET_DESKTOP_NAME(DesktopObject))->Length);
if (! NT_SUCCESS(Status))
{
KeReleaseSpinLock(&WindowStation->Lock, OldLevel);
ObDereferenceObject(WindowStation);
return Status;
}
- lpBuffer = (PVOID) ((PCHAR) lpBuffer + DesktopObject->Name.Length);
+ lpBuffer = (PVOID) ((PCHAR) lpBuffer +
((PUNICODE_STRING)GET_DESKTOP_NAME(DesktopObject))->Length);
Status = MmCopyToCaller(lpBuffer, &NullWchar, sizeof(WCHAR));
if (! NT_SUCCESS(Status))
{