-/*
+/* $Id$
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ob/namespc.c
* PURPOSE: Manages the system namespace
- * PROGRAMMER: David Welch (welch@mcmail.com)
- * UPDATE HISTORY:
- * 22/05/98: Created
+ *
+ * PROGRAMMERS: David Welch (welch@mcmail.com)
*/
/* INCLUDES ***************************************************************/
-#include <windows.h>
-#include <ddk/ntddk.h>
-#include <internal/objmgr.h>
-#include <internal/string.h>
-#include <internal/kernel.h>
-#include <wstring.h>
-
+#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
+
/* GLOBALS ****************************************************************/
-OBJECT_TYPE DirectoryObjectType = {{0,0,NULL},
- 0,
- 0,
- ULONG_MAX,
- ULONG_MAX,
- sizeof(DEVICE_OBJECT),
- 0,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- };
-
-static struct
-{
- OBJECT_HEADER hdr;
-// DIRECTORY_OBJECT directory;
- LIST_ENTRY head;
-} namespc_root;
+POBJECT_TYPE ObDirectoryType = NULL;
+POBJECT_TYPE ObTypeObjectType = NULL;
-/* FUNCTIONS **************************************************************/
+PDIRECTORY_OBJECT NameSpaceRoot = NULL;
+ /* FIXME: Move this somewhere else once devicemap support is in */
+PDEVICE_MAP ObSystemDeviceMap = NULL;
-void ObjNamespcInit(void)
-/*
- * FUNCTION: Initialize the object manager namespace
- */
-{
- ANSI_STRING ansi_str;
-
- ObInitializeObjectHeader(OBJTYP_DIRECTORY,NULL,&namespc_root.hdr);
- InitializeListHead(&namespc_root.head);
-
- RtlInitAnsiString(&ansi_str,"Directory");
- RtlAnsiStringToUnicodeString(&DirectoryObjectType.TypeName,&ansi_str,
- TRUE);
- ObRegisterType(OBJTYP_DIRECTORY,&DirectoryObjectType);
-}
+static GENERIC_MAPPING ObpDirectoryMapping = {
+ STANDARD_RIGHTS_READ|DIRECTORY_QUERY|DIRECTORY_TRAVERSE,
+ STANDARD_RIGHTS_WRITE|DIRECTORY_CREATE_OBJECT|DIRECTORY_CREATE_SUBDIRECTORY,
+ STANDARD_RIGHTS_EXECUTE|DIRECTORY_QUERY|DIRECTORY_TRAVERSE,
+ DIRECTORY_ALL_ACCESS};
+
+static GENERIC_MAPPING ObpTypeMapping = {
+ STANDARD_RIGHTS_READ,
+ STANDARD_RIGHTS_WRITE,
+ STANDARD_RIGHTS_EXECUTE,
+ 0x000F0001};
+
+/* FUNCTIONS **************************************************************/
-NTSTATUS ZwCreateDirectoryObject(PHANDLE DirectoryHandle,
- ACCESS_MASK DesiredAccess,
- POBJECT_ATTRIBUTES ObjectAttributes)
/*
- * FUNCTION: Creates or opens a directory object (a container for other
- * objects)
- * ARGUMENTS:
- * DirectoryHandle (OUT) = Caller supplied storage for the handle
- * of the directory
- * DesiredAccess = Access desired to the directory
- * ObjectAttributes = Object attributes initialized with
- * InitializeObjectAttributes
- * RETURNS: Status
+ * @implemented
*/
+NTSTATUS STDCALL
+ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
+ ULONG Attributes,
+ PACCESS_STATE PassedAccessState,
+ ACCESS_MASK DesiredAccess,
+ POBJECT_TYPE ObjectType,
+ KPROCESSOR_MODE AccessMode,
+ PVOID ParseContext,
+ PVOID* ObjectPtr)
{
- PDIRECTORY_OBJECT dir;
-
- dir = ObGenericCreateObject(DirectoryHandle,DesiredAccess,ObjectAttributes,
- OBJTYP_DIRECTORY);
+ PVOID Object = NULL;
+ UNICODE_STRING RemainingPath;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ NTSTATUS Status;
- /*
- * Initialize the object body
- */
- InitializeListHead(&dir->head);
+ PAGED_CODE();
- return(STATUS_SUCCESS);
-}
+ InitializeObjectAttributes(&ObjectAttributes,
+ ObjectPath,
+ Attributes | OBJ_OPENIF,
+ NULL,
+ NULL);
+ Status = ObFindObject(&ObjectAttributes,
+ &Object,
+ &RemainingPath,
+ ObjectType);
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+CHECKPOINT;
+DPRINT("RemainingPath.Buffer '%S' Object %p\n", RemainingPath.Buffer, Object);
-PWSTR Rtlstrrchr(PUNICODE_STRING string, WCHAR c)
-{
- int i;
- DPRINT("string->Length %d\n",string->Length);
- for (i=(string->Length-1);i>=0;i--)
+ if (RemainingPath.Buffer != NULL || Object == NULL)
{
- if (string->Buffer[i]==c)
- {
- return(&string->Buffer[i]);
- }
+CHECKPOINT;
+DPRINT("Object %p\n", Object);
+ *ObjectPtr = NULL;
+ RtlFreeUnicodeString (&RemainingPath);
+ return(STATUS_OBJECT_NAME_NOT_FOUND);
}
- return(NULL);
+ *ObjectPtr = Object;
+ RtlFreeUnicodeString (&RemainingPath);
+ return(STATUS_SUCCESS);
}
-VOID InitializeObjectAttributes(POBJECT_ATTRIBUTES InitializedAttributes,
- PUNICODE_STRING ObjectName,
- ULONG Attributes,
- HANDLE RootDirectory,
- PSECURITY_DESCRIPTOR SecurityDescriptor)
-/*
- * FUNCTION: Sets up a parameter of type OBJECT_ATTRIBUTES for a
- * subsequent call to ZwCreateXXX or ZwOpenXXX
- * ARGUMENTS:
- * InitializedAttributes (OUT) = Caller supplied storage for the
- * object attributes
- * ObjectName = Full path name for object
- * Attributes = Attributes for the object
- * RootDirectory = Where the object should be placed or NULL
- * SecurityDescriptor = Ignored
- *
- * NOTE:
- * Either ObjectName is a fully qualified pathname or a path relative
- * to RootDirectory
+
+/**********************************************************************
+ * NAME EXPORTED
+ * ObOpenObjectByName
+ *
+ * DESCRIPTION
+ * Obtain a handle to an existing object.
+ *
+ * ARGUMENTS
+ * ObjectAttributes
+ * ...
+ * ObjectType
+ * ...
+ * ParseContext
+ * ...
+ * AccessMode
+ * ...
+ * DesiredAccess
+ * ...
+ * PassedAccessState
+ * ...
+ * Handle
+ * Handle to close.
+ *
+ * RETURN VALUE
+ * Status.
+ *
+ * @implemented
*/
+NTSTATUS STDCALL
+ObOpenObjectByName(IN POBJECT_ATTRIBUTES ObjectAttributes,
+ IN POBJECT_TYPE ObjectType,
+ IN OUT PVOID ParseContext,
+ IN KPROCESSOR_MODE AccessMode,
+ IN ACCESS_MASK DesiredAccess,
+ IN PACCESS_STATE PassedAccessState,
+ OUT PHANDLE Handle)
{
- UNICODE_STRING path;
- PWSTR name = NULL;
- PDIRECTORY_OBJECT parent_dir;
-
- DPRINT("InitalizeObjectAttributes(ObjectName %w)\n",ObjectName->Buffer);
+ UNICODE_STRING RemainingPath;
+ PVOID Object = NULL;
+ NTSTATUS Status;
- if (RootDirectory!=NULL)
- {
- ObReferenceObjectByHandle(RootDirectory,DIRECTORY_TRAVERSE,NULL,
- UserMode,(PVOID*)&parent_dir,NULL);
- }
- else
+ PAGED_CODE();
+
+ DPRINT("ObOpenObjectByName(...)\n");
+
+ Status = ObFindObject(ObjectAttributes,
+ &Object,
+ &RemainingPath,
+ ObjectType);
+ if (!NT_SUCCESS(Status))
{
- parent_dir = HEADER_TO_BODY((POBJECT_HEADER)&namespc_root);
+ DPRINT("ObFindObject() failed (Status %lx)\n", Status);
+ return Status;
}
-
- ASSERT_IRQL(PASSIVE_LEVEL);
-
- path.Buffer = ExAllocatePool(NonPagedPool,
- ObjectName->Length*sizeof(WCHAR));
- path.MaximumLength = ObjectName->Length;
- RtlCopyUnicodeString(&path,ObjectName);
-
- /*
- * Seperate the path into the name of the object and the name of its
- * direct parent directory
- */
- name = Rtlstrrchr(&path,'\\');
- *name=0;
-
- /*
- * Find the objects parent directory
- */
- DPRINT("parent_dir %x\n",&(parent_dir->Type));
- parent_dir=(PDIRECTORY_OBJECT)ObLookupObject(parent_dir,&path);
- if (parent_dir==NULL)
+
+ if (RemainingPath.Buffer != NULL ||
+ Object == NULL)
{
- return;
+ RtlFreeUnicodeString(&RemainingPath);
+ return STATUS_UNSUCCESSFUL;
}
- /*
- * Make sure the parent directory doesn't disappear
- */
- ObReferenceObjectByPointer(parent_dir,DIRECTORY_CREATE_OBJECT,NULL,
- UserMode);
+ Status = ObCreateHandle(PsGetCurrentProcess(),
+ Object,
+ DesiredAccess,
+ FALSE,
+ Handle);
- InitializedAttributes->Attributes = Attributes;
- InitializedAttributes->parent = parent_dir;
- RtlInitUnicodeString(&InitializedAttributes->name,name+1);
- InitializedAttributes->path = path;
-}
+ ObDereferenceObject(Object);
+ RtlFreeUnicodeString(&RemainingPath);
-int _wcscmp(wchar_t* str1, wchar_t* str2)
-{
- while ( (*str1)==(*str2) )
- {
- str1++;
- str2++;
- if ( (*str1)==((wchar_t)0) && (*str1)==((wchar_t)0) )
- {
- return(0);
- }
- }
- return( (*str1) - (*str2) );
+ return Status;
}
-static PVOID ObDirLookup(PDIRECTORY_OBJECT dir, PWSTR name)
+VOID
+STDCALL
+ObQueryDeviceMapInformation(PEPROCESS Process,
+ PPROCESS_DEVICEMAP_INFORMATION DeviceMapInfo)
+{
+ //KIRQL OldIrql ;
+
+ /*
+ * FIXME: This is an ugly hack for now, to always return the System Device Map
+ * instead of returning the Process Device Map. Not important yet since we don't use it
+ */
+
+ /* FIXME: Acquire the DeviceMap Spinlock */
+ // KeAcquireSpinLock(DeviceMap->Lock, &OldIrql);
+
+ /* Make a copy */
+ DeviceMapInfo->Query.DriveMap = ObSystemDeviceMap->DriveMap;
+ RtlMoveMemory(DeviceMapInfo->Query.DriveType, ObSystemDeviceMap->DriveType, sizeof(ObSystemDeviceMap->DriveType));
+
+ /* FIXME: Release the DeviceMap Spinlock */
+ // KeReleasepinLock(DeviceMap->Lock, OldIrql);
+}
+
+VOID
+ObpAddEntryDirectory(PDIRECTORY_OBJECT Parent,
+ POBJECT_HEADER Header,
+ PWSTR Name)
/*
- * FUNCTION: Looks up an entry within a namespace directory
+ * FUNCTION: Add an entry to a namespace directory
* ARGUMENTS:
- * dir = Directory to lookup in
- * name = Entry name to find
- * RETURNS: A pointer to the object body if found
- * NULL otherwise
+ * Parent = directory to add in
+ * Header = Header of the object to add the entry for
+ * Name = Name to give the entry
*/
{
- LIST_ENTRY* current = ((PDIRECTORY_OBJECT)dir)->head.Flink;
- POBJECT_HEADER current_obj;
- DPRINT("ObDirLookup(dir %x, name %w\n",dir,name);
- while (current!=NULL)
- {
- current_obj = CONTAINING_RECORD(current,OBJECT_HEADER,entry);
- DPRINT("current_obj->name %w\n",current_obj->name.Buffer);
- if ( _wcscmp(current_obj->name.Buffer, name)==0)
- {
- return(current_obj);
- }
- current = current->Flink;
- }
- return(NULL);
+ KIRQL oldlvl;
+
+ RtlpCreateUnicodeString(&Header->Name, Name, NonPagedPool);
+ Header->Parent = Parent;
+
+ KeAcquireSpinLock(&Parent->Lock, &oldlvl);
+ InsertTailList(&Parent->head, &Header->Entry);
+ KeReleaseSpinLock(&Parent->Lock, oldlvl);
}
-VOID ObCreateEntry(PDIRECTORY_OBJECT parent,POBJECT_HEADER Object)
+VOID
+ObpRemoveEntryDirectory(POBJECT_HEADER Header)
/*
- * FUNCTION: Add an entry to a namespace directory
+ * FUNCTION: Remove an entry from a namespace directory
* ARGUMENTS:
- * parent = directory to add in
- * name = Name to give the entry
- * Object = Header of the object to add the entry for
+ * Header = Header of the object to remove
*/
{
- DPRINT("ObjCreateEntry(%x,%x,%x,%w)\n",parent,Object,Object->name.Buffer,
- Object->name.Buffer);
- DPRINT("root type %d\n",namespc_root.hdr.Type);
- DPRINT("%x\n",&(namespc_root.hdr.Type));
- DPRINT("type %x\n",&(parent->Type));
- DPRINT("type %x\n",&(BODY_TO_HEADER(parent)->Type));
- DPRINT("type %d\n",parent->Type);
- assert(parent->Type == OBJTYP_DIRECTORY);
-
- /*
- * Insert ourselves in our parents list
- */
- InsertTailList(&parent->head,&Object->entry);
-}
+ KIRQL oldlvl;
-wchar_t* _wcschr(wchar_t* str, wchar_t ch)
-{
- while ((*str)!=((wchar_t)0))
- {
- if ((*str)==ch)
- {
- return(str);
- }
- str++;
- }
- return(NULL);
+ DPRINT("ObpRemoveEntryDirectory(Header %x)\n",Header);
+
+ KeAcquireSpinLock(&(Header->Parent->Lock),&oldlvl);
+ RemoveEntryList(&(Header->Entry));
+ KeReleaseSpinLock(&(Header->Parent->Lock),oldlvl);
}
-PVOID ObLookupObject(PDIRECTORY_OBJECT root, PUNICODE_STRING _string)
-/*
- * FUNCTION: Lookup an object within the system namespc
- * ARGUMENTS:
- * root = Directory to start lookup from
- * _string = Pathname to lookup
- * RETURNS: On success a pointer to the object body
- * On failure NULL
- */
+
+PVOID
+ObpFindEntryDirectory(PDIRECTORY_OBJECT DirectoryObject,
+ PWSTR Name,
+ ULONG Attributes)
{
- PWSTR current;
- PWSTR next;
- PDIRECTORY_OBJECT current_dir = root;
- POBJECT_HEADER current_hdr;
- PWSTR string;
-
- DPRINT("root %x string %w\n",root,_string->Buffer);
+ PLIST_ENTRY current = DirectoryObject->head.Flink;
+ POBJECT_HEADER current_obj;
+
+ DPRINT("ObFindEntryDirectory(dir %x, name %S)\n",DirectoryObject, Name);
- if (root==NULL)
+ if (Name[0]==0)
{
- current_dir = HEADER_TO_BODY(&(namespc_root.hdr));
+ return(DirectoryObject);
}
-
- /*
- * Bit of a hack this
- */
- if (_string->Buffer[0]==0)
- {
- DPRINT("current_dir %x\n",current_dir);
- DPRINT("type %d\n",current_dir->Type);
- return(current_dir);
- }
-
- string=(PWSTR)ExAllocatePool(NonPagedPool,(_string->Length+1)*2);
- wcscpy(string,_string->Buffer);
-
- DPRINT("string = %w\n",string);
-
- if (string[0]!='\\')
+ if (Name[0]=='.' && Name[1]==0)
{
- printk("(%s:%d) Non absolute pathname passed to %s\n",__FILE__,
- __LINE__,__FUNCTION__);
- return(NULL);
+ return(DirectoryObject);
}
-
- current = string+1;
- DPRINT("current %w\n",current);
- next = _wcschr(string+1,'\\');
- if (next!=NULL)
+ if (Name[0]=='.' && Name[1]=='.' && Name[2]==0)
{
- *next=0;
+ return(BODY_TO_HEADER(DirectoryObject)->Parent);
}
- DPRINT("next %x\n",next);
-
- while (next!=NULL)
+ while (current!=(&(DirectoryObject->head)))
{
- DPRINT("Scanning %w next %w current %x\n",current,next+1,
- current_dir);
-
- /*
- * Check the current object is a directory
- */
- if (current_dir->Type!=OBJTYP_DIRECTORY)
+ current_obj = CONTAINING_RECORD(current,OBJECT_HEADER,Entry);
+ DPRINT(" Scanning: %S for: %S\n",current_obj->Name.Buffer, Name);
+ if (Attributes & OBJ_CASE_INSENSITIVE)
{
- printk("(%s:%d) Bad path component\n",__FILE__,
- __LINE__);
- ExFreePool(string);
- return(NULL);
+ if (_wcsicmp(current_obj->Name.Buffer, Name)==0)
+ {
+ DPRINT("Found it %x\n",HEADER_TO_BODY(current_obj));
+ return(HEADER_TO_BODY(current_obj));
+ }
}
-
- /*
- * Lookup the next component of the path in the directory
- */
- current_hdr=(PDIRECTORY_OBJECT)ObDirLookup(current_dir,current);
- if (current_hdr==NULL)
+ else
{
- printk("(%s:%d) Path component not found\n",__FILE__,
- __LINE__);
- ExFreePool(string);
- return(NULL);
- }
- current_dir = HEADER_TO_BODY(current_hdr);
-
- current = next+1;
- next = _wcschr(next+1,'\\');
- if (next!=NULL)
- {
- *next=0;
+ if ( wcscmp(current_obj->Name.Buffer, Name)==0)
+ {
+ DPRINT("Found it %x\n",HEADER_TO_BODY(current_obj));
+ return(HEADER_TO_BODY(current_obj));
+ }
}
+ current = current->Flink;
}
-
- DPRINT("current_dir %x current %x\n",current_dir,current);
- DPRINT("current %w\n",current);
- current_hdr = ObDirLookup(current_dir,current);
- if (current_hdr==NULL)
- {
- ExFreePool(string);
- return(NULL);
- }
- DPRINT("Returning %x %x\n",current_hdr,HEADER_TO_BODY(current_hdr));
- ExFreePool(string);
- return(HEADER_TO_BODY(current_hdr));
+ DPRINT(" Not Found: %s() = NULL\n",__FUNCTION__);
+ return(NULL);
+}
+
+
+NTSTATUS STDCALL
+ObpParseDirectory(PVOID Object,
+ PVOID * NextObject,
+ PUNICODE_STRING FullPath,
+ PWSTR * Path,
+ ULONG Attributes)
+{
+ PWSTR Start;
+ PWSTR End;
+ PVOID FoundObject;
+
+ DPRINT("ObpParseDirectory(Object %x, Path %x, *Path %S)\n",
+ Object,Path,*Path);
+
+ *NextObject = NULL;
+
+ if ((*Path) == NULL)
+ {
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ Start = *Path;
+ if (*Start == L'\\')
+ Start++;
+
+ End = wcschr(Start, L'\\');
+ if (End != NULL)
+ {
+ *End = 0;
+ }
+
+ FoundObject = ObpFindEntryDirectory(Object, Start, Attributes);
+ if (FoundObject == NULL)
+ {
+ if (End != NULL)
+ {
+ *End = L'\\';
+ }
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ ObReferenceObjectByPointer(FoundObject,
+ STANDARD_RIGHTS_REQUIRED,
+ NULL,
+ UserMode);
+
+ if (End != NULL)
+ {
+ *End = L'\\';
+ *Path = End;
+ }
+ else
+ {
+ *Path = NULL;
+ }
+
+ *NextObject = FoundObject;
+
+ return STATUS_SUCCESS;
+}
+
+
+NTSTATUS STDCALL
+ObpCreateDirectory(PVOID ObjectBody,
+ PVOID Parent,
+ PWSTR RemainingPath,
+ POBJECT_ATTRIBUTES ObjectAttributes)
+{
+ PDIRECTORY_OBJECT DirectoryObject = (PDIRECTORY_OBJECT)ObjectBody;
+
+ DPRINT("ObpCreateDirectory(ObjectBody %x, Parent %x, RemainingPath %S)\n",
+ ObjectBody, Parent, RemainingPath);
+
+ if (RemainingPath != NULL && wcschr(RemainingPath+1, '\\') != NULL)
+ {
+ return(STATUS_UNSUCCESSFUL);
+ }
+
+ InitializeListHead(&DirectoryObject->head);
+ KeInitializeSpinLock(&DirectoryObject->Lock);
+
+ return(STATUS_SUCCESS);
+}
+
+
+VOID INIT_FUNCTION
+ObInit(VOID)
+/*
+ * FUNCTION: Initialize the object manager namespace
+ */
+{
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING Name;
+ SECURITY_DESCRIPTOR SecurityDescriptor;
+
+ /* Initialize the security descriptor cache */
+ ObpInitSdCache();
+
+ /* create 'directory' object type */
+ ObDirectoryType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE));
+
+ ObDirectoryType->Tag = TAG('D', 'I', 'R', 'T');
+ ObDirectoryType->TotalObjects = 0;
+ ObDirectoryType->TotalHandles = 0;
+ ObDirectoryType->PeakObjects = 0;
+ ObDirectoryType->PeakHandles = 0;
+ ObDirectoryType->PagedPoolCharge = 0;
+ ObDirectoryType->NonpagedPoolCharge = sizeof(DIRECTORY_OBJECT);
+ ObDirectoryType->Mapping = &ObpDirectoryMapping;
+ ObDirectoryType->Dump = NULL;
+ ObDirectoryType->Open = NULL;
+ ObDirectoryType->Close = NULL;
+ ObDirectoryType->Delete = NULL;
+ ObDirectoryType->Parse = ObpParseDirectory;
+ ObDirectoryType->Security = NULL;
+ ObDirectoryType->QueryName = NULL;
+ ObDirectoryType->OkayToClose = NULL;
+ ObDirectoryType->Create = ObpCreateDirectory;
+ ObDirectoryType->DuplicationNotify = NULL;
+
+ RtlInitUnicodeString(&ObDirectoryType->TypeName,
+ L"Directory");
+
+ /* create 'type' object type*/
+ ObTypeObjectType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE));
+
+ ObTypeObjectType->Tag = TAG('T', 'y', 'p', 'T');
+ ObTypeObjectType->TotalObjects = 0;
+ ObTypeObjectType->TotalHandles = 0;
+ ObTypeObjectType->PeakObjects = 0;
+ ObTypeObjectType->PeakHandles = 0;
+ ObTypeObjectType->PagedPoolCharge = 0;
+ ObTypeObjectType->NonpagedPoolCharge = sizeof(TYPE_OBJECT);
+ ObTypeObjectType->Mapping = &ObpTypeMapping;
+ ObTypeObjectType->Dump = NULL;
+ ObTypeObjectType->Open = NULL;
+ ObTypeObjectType->Close = NULL;
+ ObTypeObjectType->Delete = NULL;
+ ObTypeObjectType->Parse = NULL;
+ ObTypeObjectType->Security = NULL;
+ ObTypeObjectType->QueryName = NULL;
+ ObTypeObjectType->OkayToClose = NULL;
+ ObTypeObjectType->Create = NULL;
+ ObTypeObjectType->DuplicationNotify = NULL;
+
+ RtlInitUnicodeString(&ObTypeObjectType->TypeName,
+ L"ObjectType");
+
+ /* Create security descriptor */
+ RtlCreateSecurityDescriptor(&SecurityDescriptor,
+ SECURITY_DESCRIPTOR_REVISION1);
+
+ RtlSetOwnerSecurityDescriptor(&SecurityDescriptor,
+ SeAliasAdminsSid,
+ FALSE);
+
+ RtlSetGroupSecurityDescriptor(&SecurityDescriptor,
+ SeLocalSystemSid,
+ FALSE);
+
+ RtlSetDaclSecurityDescriptor(&SecurityDescriptor,
+ TRUE,
+ SePublicDefaultDacl,
+ FALSE);
+
+ /* Create root directory */
+ InitializeObjectAttributes(&ObjectAttributes,
+ NULL,
+ OBJ_PERMANENT,
+ NULL,
+ &SecurityDescriptor);
+ ObCreateObject(KernelMode,
+ ObDirectoryType,
+ &ObjectAttributes,
+ KernelMode,
+ NULL,
+ sizeof(DIRECTORY_OBJECT),
+ 0,
+ 0,
+ (PVOID*)&NameSpaceRoot);
+
+ /* Create '\ObjectTypes' directory */
+ RtlRosInitUnicodeStringFromLiteral(&Name,
+ L"\\ObjectTypes");
+ InitializeObjectAttributes(&ObjectAttributes,
+ &Name,
+ OBJ_PERMANENT,
+ NULL,
+ &SecurityDescriptor);
+ ObCreateObject(KernelMode,
+ ObDirectoryType,
+ &ObjectAttributes,
+ KernelMode,
+ NULL,
+ sizeof(DIRECTORY_OBJECT),
+ 0,
+ 0,
+ NULL);
+
+ ObpCreateTypeObject(ObDirectoryType);
+ ObpCreateTypeObject(ObTypeObjectType);
+
+ /* Create 'symbolic link' object type */
+ ObInitSymbolicLinkImplementation();
+
+ /* FIXME: Hack Hack! */
+ ObSystemDeviceMap = ExAllocatePoolWithTag(NonPagedPool, sizeof(*ObSystemDeviceMap), TAG('O', 'b', 'D', 'm'));
+ RtlZeroMemory(ObSystemDeviceMap, sizeof(*ObSystemDeviceMap));
}
-
+
+
+NTSTATUS
+ObpCreateTypeObject(POBJECT_TYPE ObjectType)
+{
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ WCHAR NameString[120];
+ PTYPE_OBJECT TypeObject = NULL;
+ UNICODE_STRING Name;
+ NTSTATUS Status;
+
+ DPRINT("ObpCreateTypeObject(ObjectType: %wZ)\n", &ObjectType->TypeName);
+ wcscpy(NameString, L"\\ObjectTypes\\");
+ wcscat(NameString, ObjectType->TypeName.Buffer);
+ RtlInitUnicodeString(&Name,
+ NameString);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &Name,
+ OBJ_PERMANENT,
+ NULL,
+ NULL);
+ Status = ObCreateObject(KernelMode,
+ ObTypeObjectType,
+ &ObjectAttributes,
+ KernelMode,
+ NULL,
+ sizeof(TYPE_OBJECT),
+ 0,
+ 0,
+ (PVOID*)&TypeObject);
+ if (NT_SUCCESS(Status))
+ {
+ TypeObject->ObjectType = ObjectType;
+ }
+
+ return(STATUS_SUCCESS);
+}
+
+/* EOF */