Skip to content

Commit

Permalink
Fixed a bug that prevented opening the root directory of the dvd drive
Browse files Browse the repository at this point in the history
  • Loading branch information
ergo720 committed Aug 11, 2024
1 parent be8d7c2 commit 0bac12a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions nboxkrnl/ob/obp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,16 @@ NTSTATUS ObpResolveRootHandlePath(POBJECT_ATTRIBUTES ObjectAttributes, POBJECT_D
NTSTATUS ObpReferenceObjectByName(POBJECT_ATTRIBUTES ObjectAttributes, POBJECT_TYPE ObjectType, PVOID ParseContext, PVOID *ReturnedObject)
{
*ReturnedObject = nullptr;
BOOLEAN HasBackslashAtEnd = FALSE;
OBJECT_STRING OriName = { 0, 0, nullptr };
if (ObjectAttributes->ObjectName) {
OriName = *ObjectAttributes->ObjectName;
}

if (OriName.Length && (OriName.Buffer[OriName.Length - 1] == OB_PATH_DELIMITER)) {
HasBackslashAtEnd = TRUE;
}

KIRQL OldIrql = ObLock();
POBJECT_DIRECTORY Directory;
if (NTSTATUS Status = ObpResolveRootHandlePath(ObjectAttributes, &Directory); !NT_SUCCESS(Status)) {
Expand Down Expand Up @@ -350,6 +355,13 @@ NTSTATUS ObpReferenceObjectByName(POBJECT_ATTRIBUTES ObjectAttributes, POBJECT_T
++Obj->PointerCount;
ObUnlock(OldIrql);

if (HasBackslashAtEnd && (RemainingName.Length == 0)) {
// Preserve the terminating backslash so that we can open the root directory of a volume
RemainingName.Buffer = &ObjectAttributes->ObjectName->Buffer[ObjectAttributes->ObjectName->Length - 1];
RemainingName.Length = 1;
RemainingName.MaximumLength = 1;
}

PVOID ParsedObject = nullptr;
NTSTATUS Status = Obj->Type->ParseProcedure(FoundObject, ObjectType,
ObjectAttributes->Attributes, ObjectAttributes->ObjectName, &RemainingName, ParseContext, &ParsedObject);
Expand Down

0 comments on commit 0bac12a

Please sign in to comment.