diff --git a/reactos/ntoskrnl/ob/obdir.c b/reactos/ntoskrnl/ob/obdir.c index b5b4929dca9..663b112ff93 100644 --- a/reactos/ntoskrnl/ob/obdir.c +++ b/reactos/ntoskrnl/ob/obdir.c @@ -185,7 +185,8 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory, /* Check if the directory is already locked */ if (!Context->DirectoryLocked) { - + /* Lock it */ + ObpAcquireDirectoryLockShared(Directory, Context); } /* Start looping */ @@ -222,6 +223,8 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory, /* Check if the directory was locked */ if (!Context->DirectoryLocked) { + /* Convert the lock from shared to exclusive */ + ExConvertPushLockSharedToExclusive(&Directory->Lock); } /* Set the Current Entry */ @@ -241,6 +244,11 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory, /* Get the object name information */ ObjectHeader = OBJECT_TO_OBJECT_HEADER(FoundObject); HeaderNameInfo = OBJECT_HEADER_TO_NAME_INFO(ObjectHeader); + if (HeaderNameInfo) + { + /* Add a query reference */ + //ObpIncrementQueryReference(ObjectHeader, HeaderNameInfo); + } /* Reference the object being looked up */ //ObReferenceObject(FoundObject); @@ -248,6 +256,8 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory, /* Check if the directory was locked */ if (!Context->DirectoryLocked) { + /* Release the lock */ + ObpReleaseDirectoryLock(Directory, Context); } } else @@ -255,6 +265,8 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory, /* Check if the directory was locked */ if (!Context->DirectoryLocked) { + /* Release the lock */ + ObpReleaseDirectoryLock(Directory, Context); } /* Check if we should scan the shadow directory */ diff --git a/reactos/ntoskrnl/ob/obhandle.c b/reactos/ntoskrnl/ob/obhandle.c index 7a435c43dcc..6edecde180d 100644 --- a/reactos/ntoskrnl/ob/obhandle.c +++ b/reactos/ntoskrnl/ob/obhandle.c @@ -2030,6 +2030,7 @@ ObOpenObjectByName(IN POBJECT_ATTRIBUTES ObjectAttributes, if (!NT_SUCCESS(Status)) { /* Cleanup after lookup */ + //ObpCleanupDirectoryLookup(&TempBuffer->LookupContext, TRUE); TempBuffer->LookupContext.Object = NULL; goto Cleanup; } @@ -2062,7 +2063,9 @@ ObOpenObjectByName(IN POBJECT_ATTRIBUTES ObjectAttributes, { /* Set failure code */ Status = STATUS_INVALID_PARAMETER; - TempBuffer->LookupContext.Object = NULL; + + /* Cleanup after lookup */ + //ObpCleanupDirectoryLookup(&TempBuffer->LookupContext, TRUE); } else { @@ -2440,12 +2443,13 @@ ObInsertObject(IN PVOID Object, if (!NT_SUCCESS(Status)) { /* Fail */ + if (ObjectNameInfo) ObpDecrementQueryReference(ObjectNameInfo); ObDereferenceObject(Object); return Status; } /* Setup a lookup context */ - Context.Object = NULL; + ObpInitializeDirectoryLookup(&Context); InsertObject = Object; OpenReason = ObCreateHandle; diff --git a/reactos/ntoskrnl/ob/obinit.c b/reactos/ntoskrnl/ob/obinit.c index f34fcfd33ff..f7e6ab93d88 100644 --- a/reactos/ntoskrnl/ob/obinit.c +++ b/reactos/ntoskrnl/ob/obinit.c @@ -278,9 +278,17 @@ ObPostPhase0: Status = NtClose(Handle); if (!NT_SUCCESS(Status)) return FALSE; - Context.Object = NULL; + /* Initialize lookup context */ + ObpInitializeDirectoryLookup(&Context); + + /* Lock it */ + //ObpAcquireDirectoryLockExclusive(ObpTypeDirectoryObject, &Context); + + /* Setup directory */ + // FIXME: ObpSetLookupDirectory(Dir);? Context.Directory = ObpTypeDirectoryObject; Context.DirectoryLocked = TRUE; + Context.LockStateSignature = 0xCCCC1234; /* Loop the object types */ ListHead = &ObTypeObjectType->TypeList; @@ -317,6 +325,8 @@ ObPostPhase0: NextEntry = NextEntry->Flink; } + /* Cleanup after lookup */ + //ObpCleanupDirectoryLookup(&Context, TRUE); Context.Object = NULL; /* Initialize DOS Devices Directory and related Symbolic Links */ diff --git a/reactos/ntoskrnl/ob/obref.c b/reactos/ntoskrnl/ob/obref.c index d0f51d131ee..7c7b86fdd8b 100644 --- a/reactos/ntoskrnl/ob/obref.c +++ b/reactos/ntoskrnl/ob/obref.c @@ -428,6 +428,9 @@ ObReferenceObjectByName(IN PUNICODE_STRING ObjectPath, PassedAccessState, &Context, &Object); + + /* Cleanup after lookup */ + //ObpCleanupDirectoryLookup(&Context, TRUE); Context.Object = NULL; /* Check if the lookup succeeded */