mirror of
https://github.com/reactos/reactos.git
synced 2025-04-20 20:36:35 +00:00
- Formatting/comment fixes.
svn path=/trunk/; revision=22229
This commit is contained in:
parent
02d0bb9dbd
commit
137f145eb6
2 changed files with 84 additions and 89 deletions
|
@ -431,7 +431,7 @@ ObpAllocateObject(IN POBJECT_CREATE_INFORMATION ObjectCreateInfo,
|
|||
ULONG FinalSize = ObjectSize;
|
||||
ULONG Tag;
|
||||
PAGED_CODE();
|
||||
|
||||
|
||||
/* If we don't have an Object Type yet, force NonPaged */
|
||||
if (!ObjectType)
|
||||
{
|
||||
|
@ -443,14 +443,14 @@ ObpAllocateObject(IN POBJECT_CREATE_INFORMATION ObjectCreateInfo,
|
|||
PoolType = ObjectType->TypeInfo.PoolType;
|
||||
Tag = ObjectType->Key;
|
||||
}
|
||||
|
||||
|
||||
/* Check if the Object has a name */
|
||||
if (ObjectName->Buffer)
|
||||
{
|
||||
FinalSize += sizeof(OBJECT_HEADER_NAME_INFO);
|
||||
HasNameInfo = TRUE;
|
||||
}
|
||||
|
||||
|
||||
if (ObjectType)
|
||||
{
|
||||
/* Check if the Object maintains handle counts */
|
||||
|
@ -471,7 +471,7 @@ ObpAllocateObject(IN POBJECT_CREATE_INFORMATION ObjectCreateInfo,
|
|||
/* Allocate memory for the Object and Header */
|
||||
Header = ExAllocatePoolWithTag(PoolType, FinalSize, Tag);
|
||||
if (!Header) return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
||||
|
||||
/* Initialize Handle Info */
|
||||
if (HasHandleInfo)
|
||||
{
|
||||
|
@ -479,7 +479,7 @@ ObpAllocateObject(IN POBJECT_CREATE_INFORMATION ObjectCreateInfo,
|
|||
HandleInfo->SingleEntry.HandleCount = 0;
|
||||
Header = (POBJECT_HEADER)(HandleInfo + 1);
|
||||
}
|
||||
|
||||
|
||||
/* Initialize the Object Name Info */
|
||||
if (HasNameInfo)
|
||||
{
|
||||
|
@ -488,7 +488,7 @@ ObpAllocateObject(IN POBJECT_CREATE_INFORMATION ObjectCreateInfo,
|
|||
NameInfo->Directory = NULL;
|
||||
Header = (POBJECT_HEADER)(NameInfo + 1);
|
||||
}
|
||||
|
||||
|
||||
/* Initialize Creator Info */
|
||||
if (HasCreatorInfo)
|
||||
{
|
||||
|
@ -498,14 +498,14 @@ ObpAllocateObject(IN POBJECT_CREATE_INFORMATION ObjectCreateInfo,
|
|||
InitializeListHead(&CreatorInfo->TypeList);
|
||||
Header = (POBJECT_HEADER)(CreatorInfo + 1);
|
||||
}
|
||||
|
||||
|
||||
/* Initialize the object header */
|
||||
RtlZeroMemory(Header, ObjectSize);
|
||||
Header->PointerCount = 1;
|
||||
Header->Type = ObjectType;
|
||||
Header->Flags = OB_FLAG_CREATE_INFO;
|
||||
Header->ObjectCreateInfo = ObjectCreateInfo;
|
||||
|
||||
|
||||
/* Set the Offsets for the Info */
|
||||
if (HasHandleInfo)
|
||||
{
|
||||
|
@ -540,10 +540,10 @@ ObpAllocateObject(IN POBJECT_CREATE_INFORMATION ObjectCreateInfo,
|
|||
/* Set the kernel flag */
|
||||
Header->Flags |= OB_FLAG_KERNEL_MODE;
|
||||
}
|
||||
|
||||
|
||||
/* Increase the number of objects of this type */
|
||||
if (ObjectType) ObjectType->TotalNumberOfObjects++;
|
||||
|
||||
|
||||
/* Return Header */
|
||||
*ObjectHeader = Header;
|
||||
return STATUS_SUCCESS;
|
||||
|
@ -551,9 +551,9 @@ ObpAllocateObject(IN POBJECT_CREATE_INFORMATION ObjectCreateInfo,
|
|||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ObpCreateTypeObject(POBJECT_TYPE_INITIALIZER ObjectTypeInitializer,
|
||||
PUNICODE_STRING TypeName,
|
||||
POBJECT_TYPE *ObjectType)
|
||||
ObpCreateTypeObject(IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer,
|
||||
IN PUNICODE_STRING TypeName,
|
||||
OUT POBJECT_TYPE *ObjectType)
|
||||
{
|
||||
POBJECT_HEADER Header;
|
||||
POBJECT_TYPE LocalObjectType;
|
||||
|
@ -563,15 +563,15 @@ ObpCreateTypeObject(POBJECT_TYPE_INITIALIZER ObjectTypeInitializer,
|
|||
OBP_LOOKUP_CONTEXT Context;
|
||||
|
||||
/* Allocate the Object */
|
||||
Status = ObpAllocateObject(NULL,
|
||||
Status = ObpAllocateObject(NULL,
|
||||
TypeName,
|
||||
ObTypeObjectType,
|
||||
ObTypeObjectType,
|
||||
sizeof(OBJECT_TYPE) + sizeof(OBJECT_HEADER),
|
||||
KernelMode,
|
||||
(POBJECT_HEADER*)&Header);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
LocalObjectType = (POBJECT_TYPE)&Header->Body;
|
||||
|
||||
|
||||
/* Check if this is the first Object Type */
|
||||
if (!ObTypeObjectType)
|
||||
{
|
||||
|
@ -581,7 +581,7 @@ ObpCreateTypeObject(POBJECT_TYPE_INITIALIZER ObjectTypeInitializer,
|
|||
LocalObjectType->Key = TAG('O', 'b', 'j', 'T');
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
/* Set Tag */
|
||||
Tag[0] = TypeName->Buffer[0];
|
||||
Tag[1] = TypeName->Buffer[1];
|
||||
|
@ -589,7 +589,7 @@ ObpCreateTypeObject(POBJECT_TYPE_INITIALIZER ObjectTypeInitializer,
|
|||
Tag[3] = TypeName->Buffer[3];
|
||||
LocalObjectType->Key = *(PULONG)Tag;
|
||||
}
|
||||
|
||||
|
||||
/* Set it up */
|
||||
LocalObjectType->TypeInfo = *ObjectTypeInitializer;
|
||||
LocalObjectType->Name = *TypeName;
|
||||
|
@ -610,16 +610,18 @@ ObpCreateTypeObject(POBJECT_TYPE_INITIALIZER ObjectTypeInitializer,
|
|||
(ObjectTypeInitializer->MaintainHandleCount ?
|
||||
sizeof(OBJECT_HEADER_HANDLE_INFO) : 0);
|
||||
|
||||
/* Update the Pool Charges */
|
||||
/* Check the pool type */
|
||||
if (ObjectTypeInitializer->PoolType == NonPagedPool)
|
||||
{
|
||||
/* Update the NonPaged Pool charge */
|
||||
LocalObjectType->TypeInfo.DefaultNonPagedPoolCharge += HeaderSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Update the Paged Pool charge */
|
||||
LocalObjectType->TypeInfo.DefaultPagedPoolCharge += HeaderSize;
|
||||
}
|
||||
|
||||
|
||||
/* All objects types need a security procedure */
|
||||
if (!ObjectTypeInitializer->SecurityProcedure)
|
||||
{
|
||||
|
@ -635,10 +637,12 @@ ObpCreateTypeObject(POBJECT_TYPE_INITIALIZER ObjectTypeInitializer,
|
|||
/* Use the "Default Object", a simple event */
|
||||
LocalObjectType->DefaultObject = &ObpDefaultObject;
|
||||
}
|
||||
/* Special system objects get an optimized hack so they can be waited on */
|
||||
else if (TypeName->Length == 8 && !wcscmp(TypeName->Buffer, L"File"))
|
||||
/* The File Object gets an optimized hack so it can be waited on */
|
||||
else if ((TypeName->Length == 8) && !(wcscmp(TypeName->Buffer, L"File")))
|
||||
{
|
||||
LocalObjectType->DefaultObject = (PVOID)FIELD_OFFSET(FILE_OBJECT, Event);
|
||||
/* Wait on the File Object's event directly */
|
||||
LocalObjectType->DefaultObject = (PVOID)FIELD_OFFSET(FILE_OBJECT,
|
||||
Event);
|
||||
}
|
||||
/* FIXME: When LPC stops sucking, add a hack for Waitable Ports */
|
||||
else
|
||||
|
@ -651,9 +655,10 @@ ObpCreateTypeObject(POBJECT_TYPE_INITIALIZER ObjectTypeInitializer,
|
|||
ExInitializeResourceLite(&LocalObjectType->Mutex);
|
||||
InitializeListHead(&LocalObjectType->TypeList);
|
||||
|
||||
/* Insert it into the Object Directory */
|
||||
/* Check if we're actually creating the directory object itself */
|
||||
if (ObpTypeDirectoryObject)
|
||||
{
|
||||
/* Insert it into the Object Directory */
|
||||
Context.Directory = ObpTypeDirectoryObject;
|
||||
Context.DirectoryLocked = TRUE;
|
||||
ObpLookupEntryDirectory(ObpTypeDirectoryObject,
|
||||
|
@ -665,6 +670,7 @@ ObpCreateTypeObject(POBJECT_TYPE_INITIALIZER ObjectTypeInitializer,
|
|||
ObReferenceObject(ObpTypeDirectoryObject);
|
||||
}
|
||||
|
||||
/* Return the object type and creations tatus */
|
||||
*ObjectType = LocalObjectType;
|
||||
return Status;
|
||||
}
|
||||
|
|
|
@ -180,12 +180,12 @@ Next:
|
|||
Status = CurrentHeader->Type->TypeInfo.ParseProcedure(CurrentObject,
|
||||
CurrentHeader->Type,
|
||||
AccessState,
|
||||
ExGetPreviousMode(), // fixme: should be a parameter, since caller decides.
|
||||
PreviousMode,
|
||||
Attributes,
|
||||
&PathString,
|
||||
&CurrentUs,
|
||||
ParseContext,
|
||||
NULL, // fixme: where do we get this from? captured OBP?
|
||||
SecurityQos,
|
||||
&NextObject);
|
||||
current = CurrentUs.Buffer;
|
||||
if (Status == STATUS_REPARSE)
|
||||
|
@ -341,89 +341,74 @@ ObQueryNameString(IN PVOID Object,
|
|||
POBJECT_DIRECTORY ParentDirectory;
|
||||
ULONG NameSize;
|
||||
PWCH ObjectName;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("ObQueryNameString: %x, %x\n", Object, ObjectNameInfo);
|
||||
|
||||
/* Get the Kernel Meta-Structures */
|
||||
ObjectHeader = OBJECT_TO_OBJECT_HEADER(Object);
|
||||
LocalInfo = OBJECT_HEADER_TO_NAME_INFO(ObjectHeader);
|
||||
|
||||
/* Check if a Query Name Procedure is available */
|
||||
if (ObjectHeader->Type->TypeInfo.QueryNameProcedure)
|
||||
{
|
||||
if (ObjectHeader->Type->TypeInfo.QueryNameProcedure)
|
||||
{
|
||||
/* Call the procedure */
|
||||
DPRINT("Calling Object's Procedure\n");
|
||||
Status = ObjectHeader->Type->TypeInfo.QueryNameProcedure(Object,
|
||||
TRUE, //fixme
|
||||
ObjectNameInfo,
|
||||
Length,
|
||||
ReturnLength);
|
||||
|
||||
/* Return the status */
|
||||
return Status;
|
||||
return ObjectHeader->Type->TypeInfo.QueryNameProcedure(Object,
|
||||
TRUE, //fixme
|
||||
ObjectNameInfo,
|
||||
Length,
|
||||
ReturnLength);
|
||||
}
|
||||
|
||||
/* Check if the object doesn't even have a name */
|
||||
if (!LocalInfo || !LocalInfo->Name.Buffer)
|
||||
if (!LocalInfo || !LocalInfo->Name.Buffer)
|
||||
{
|
||||
/* We're returning the name structure */
|
||||
DPRINT("Nameless Object\n");
|
||||
*ReturnLength = sizeof(OBJECT_NAME_INFORMATION);
|
||||
|
||||
/* Check if we were given enough space */
|
||||
if (*ReturnLength > Length)
|
||||
{
|
||||
DPRINT1("Not enough buffer space\n");
|
||||
return STATUS_INFO_LENGTH_MISMATCH;
|
||||
}
|
||||
if (*ReturnLength > Length) return STATUS_INFO_LENGTH_MISMATCH;
|
||||
|
||||
/* Return an empty buffer */
|
||||
ObjectNameInfo->Name.Length = 0;
|
||||
ObjectNameInfo->Name.MaximumLength = 0;
|
||||
ObjectNameInfo->Name.Buffer = NULL;
|
||||
|
||||
RtlInitEmptyUnicodeString(&ObjectNameInfo->Name, NULL, 0);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Find the size needed for the name. We won't do
|
||||
* this during the Name Creation loop because we want
|
||||
* to let the caller know that the buffer isn't big
|
||||
* enough right at the beginning, not work our way through
|
||||
* and find out at the end
|
||||
*/
|
||||
if (Object == NameSpaceRoot)
|
||||
if (Object == NameSpaceRoot)
|
||||
{
|
||||
/* Size of the '\' string */
|
||||
DPRINT("Object is Root\n");
|
||||
NameSize = sizeof(OBJ_NAME_PATH_SEPARATOR);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Get the Object Directory and add name of Object */
|
||||
ParentDirectory = LocalInfo->Directory;
|
||||
NameSize = sizeof(OBJ_NAME_PATH_SEPARATOR) + LocalInfo->Name.Length;
|
||||
|
||||
/* Loop inside the directory to get the top-most one (meaning root) */
|
||||
while ((ParentDirectory != NameSpaceRoot) && (ParentDirectory))
|
||||
while ((ParentDirectory != NameSpaceRoot) && (ParentDirectory))
|
||||
{
|
||||
/* Get the Name Information */
|
||||
LocalInfo = OBJECT_HEADER_TO_NAME_INFO(OBJECT_TO_OBJECT_HEADER(ParentDirectory));
|
||||
LocalInfo = OBJECT_HEADER_TO_NAME_INFO(
|
||||
OBJECT_TO_OBJECT_HEADER(ParentDirectory));
|
||||
|
||||
/* Add the size of the Directory Name */
|
||||
if (LocalInfo && LocalInfo->Directory)
|
||||
if (LocalInfo && LocalInfo->Directory)
|
||||
{
|
||||
/* Size of the '\' string + Directory Name */
|
||||
NameSize += sizeof(OBJ_NAME_PATH_SEPARATOR) + LocalInfo->Name.Length;
|
||||
NameSize += sizeof(OBJ_NAME_PATH_SEPARATOR) +
|
||||
LocalInfo->Name.Length;
|
||||
|
||||
/* Move to next parent Directory */
|
||||
ParentDirectory = LocalInfo->Directory;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Directory with no name. We append "...\" */
|
||||
DPRINT("Nameless Directory\n");
|
||||
NameSize += sizeof(L"...") + sizeof(OBJ_NAME_PATH_SEPARATOR);
|
||||
break;
|
||||
}
|
||||
|
@ -431,17 +416,14 @@ ObQueryNameString(IN PVOID Object,
|
|||
}
|
||||
|
||||
/* Finally, add the name of the structure and the null char */
|
||||
*ReturnLength = NameSize + sizeof(OBJECT_NAME_INFORMATION) + sizeof(UNICODE_NULL);
|
||||
DPRINT("Final Length: %x\n", *ReturnLength);
|
||||
*ReturnLength = NameSize +
|
||||
sizeof(OBJECT_NAME_INFORMATION) +
|
||||
sizeof(UNICODE_NULL);
|
||||
|
||||
/* Check if we were given enough space */
|
||||
if (*ReturnLength > Length)
|
||||
{
|
||||
DPRINT1("Not enough buffer space\n");
|
||||
return STATUS_INFO_LENGTH_MISMATCH;
|
||||
}
|
||||
if (*ReturnLength > Length) return STATUS_INFO_LENGTH_MISMATCH;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Now we will actually create the name. We work backwards because
|
||||
* it's easier to start off from the Name we have and walk up the
|
||||
* parent directories. We use the same logic as Name Length calculation.
|
||||
|
@ -450,44 +432,51 @@ ObQueryNameString(IN PVOID Object,
|
|||
ObjectName = (PWCH)((ULONG_PTR)ObjectNameInfo + *ReturnLength);
|
||||
*--ObjectName = UNICODE_NULL;
|
||||
|
||||
if (Object == NameSpaceRoot)
|
||||
/* Check if the object is actually the Root directory */
|
||||
if (Object == NameSpaceRoot)
|
||||
{
|
||||
/* This is already the Root Directory, return "\\" */
|
||||
DPRINT("Returning Root Dir\n");
|
||||
*--ObjectName = OBJ_NAME_PATH_SEPARATOR;
|
||||
ObjectNameInfo->Name.Length = (USHORT)NameSize;
|
||||
ObjectNameInfo->Name.MaximumLength = (USHORT)(NameSize + sizeof(UNICODE_NULL));
|
||||
ObjectNameInfo->Name.MaximumLength = (USHORT)(NameSize +
|
||||
sizeof(UNICODE_NULL));
|
||||
ObjectNameInfo->Name.Buffer = ObjectName;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Start by adding the Object's Name */
|
||||
ObjectName = (PWCH)((ULONG_PTR)ObjectName - LocalInfo->Name.Length);
|
||||
RtlMoveMemory(ObjectName, LocalInfo->Name.Buffer, LocalInfo->Name.Length);
|
||||
ObjectName = (PWCH)((ULONG_PTR)ObjectName -
|
||||
LocalInfo->Name.Length);
|
||||
RtlMoveMemory(ObjectName,
|
||||
LocalInfo->Name.Buffer,
|
||||
LocalInfo->Name.Length);
|
||||
|
||||
/* Now parse the Parent directories until we reach the top */
|
||||
ParentDirectory = LocalInfo->Directory;
|
||||
while ((ParentDirectory != NameSpaceRoot) && (ParentDirectory))
|
||||
while ((ParentDirectory != NameSpaceRoot) && (ParentDirectory))
|
||||
{
|
||||
/* Get the name information */
|
||||
LocalInfo = OBJECT_HEADER_TO_NAME_INFO(OBJECT_TO_OBJECT_HEADER(ParentDirectory));
|
||||
LocalInfo = OBJECT_HEADER_TO_NAME_INFO(
|
||||
OBJECT_TO_OBJECT_HEADER(ParentDirectory));
|
||||
|
||||
/* Add the "\" */
|
||||
*(--ObjectName) = OBJ_NAME_PATH_SEPARATOR;
|
||||
|
||||
/* Add the Parent Directory's Name */
|
||||
if (LocalInfo && LocalInfo->Name.Buffer)
|
||||
if (LocalInfo && LocalInfo->Name.Buffer)
|
||||
{
|
||||
/* Add the name */
|
||||
ObjectName = (PWCH)((ULONG_PTR)ObjectName - LocalInfo->Name.Length);
|
||||
RtlMoveMemory(ObjectName, LocalInfo->Name.Buffer, LocalInfo->Name.Length);
|
||||
ObjectName = (PWCH)((ULONG_PTR)ObjectName -
|
||||
LocalInfo->Name.Length);
|
||||
RtlMoveMemory(ObjectName,
|
||||
LocalInfo->Name.Buffer,
|
||||
LocalInfo->Name.Length);
|
||||
|
||||
/* Move to next parent */
|
||||
ParentDirectory = LocalInfo->Directory;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Directory without a name, we add "..." */
|
||||
DPRINT("Nameless Directory\n");
|
||||
|
@ -499,13 +488,13 @@ ObQueryNameString(IN PVOID Object,
|
|||
|
||||
/* Add Root Directory Name */
|
||||
*(--ObjectName) = OBJ_NAME_PATH_SEPARATOR;
|
||||
DPRINT("Current Buffer: %S\n", ObjectName);
|
||||
ObjectNameInfo->Name.Length = (USHORT)NameSize;
|
||||
ObjectNameInfo->Name.MaximumLength = (USHORT)(NameSize + sizeof(UNICODE_NULL));
|
||||
ObjectNameInfo->Name.MaximumLength = (USHORT)(NameSize +
|
||||
sizeof(UNICODE_NULL));
|
||||
ObjectNameInfo->Name.Buffer = ObjectName;
|
||||
DPRINT("Complete: %wZ\n", ObjectNameInfo);
|
||||
}
|
||||
|
||||
/* Return success */
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue