- Validate lookup context in ObpInsertEntryDirectory.

- Read actual ObpLUIDDeviceMapsEnable variable do determine if shadow-searching is enabled in ObpLookupEntryDirectory.
- Currently disable all directory locking code (it was never used anyways) in ObpLookupEntryDirectory.
- Update ObpLookupEntryDirectory with placeholder code/branches for future patch implementing directory locks.

svn path=/trunk/; revision=25370
This commit is contained in:
Alex Ionescu 2007-01-08 07:53:50 +00:00
parent d107f7d0f4
commit 569e9458d6

View file

@ -13,11 +13,11 @@
/* INCLUDES ***************************************************************/ /* INCLUDES ***************************************************************/
#define NTDDI_VERSION NTDDI_WS03
#include <ntoskrnl.h> #include <ntoskrnl.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <debug.h>
BOOLEAN ObpLUIDDeviceMapsEnabled;
POBJECT_TYPE ObDirectoryType = NULL; POBJECT_TYPE ObDirectoryType = NULL;
/* PRIVATE FUNCTIONS ******************************************************/ /* PRIVATE FUNCTIONS ******************************************************/
@ -54,6 +54,18 @@ ObpInsertEntryDirectory(IN POBJECT_DIRECTORY Parent,
/* Make sure we have a name */ /* Make sure we have a name */
ASSERT(ObjectHeader->NameInfoOffset != 0); ASSERT(ObjectHeader->NameInfoOffset != 0);
/* Validate the context */
if ((Context->Object) ||
!(Context->DirectoryLocked) ||
(Parent != Context->Directory))
{
/* Invalid context */
DPRINT1("OB: ObpInsertEntryDirectory - invalid context %p %ld\n",
Context, Context->DirectoryLocked);
KEBUGCHECK(0);
return FALSE;
}
/* Allocate a new Directory Entry */ /* Allocate a new Directory Entry */
NewEntry = ExAllocatePoolWithTag(PagedPool, NewEntry = ExAllocatePoolWithTag(PagedPool,
sizeof(OBJECT_DIRECTORY_ENTRY), sizeof(OBJECT_DIRECTORY_ENTRY),
@ -116,6 +128,7 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory,
{ {
BOOLEAN CaseInsensitive = FALSE; BOOLEAN CaseInsensitive = FALSE;
POBJECT_HEADER_NAME_INFO HeaderNameInfo; POBJECT_HEADER_NAME_INFO HeaderNameInfo;
POBJECT_HEADER ObjectHeader;
ULONG HashValue; ULONG HashValue;
ULONG HashIndex; ULONG HashIndex;
LONG TotalChars; LONG TotalChars;
@ -127,8 +140,8 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory,
PWSTR Buffer; PWSTR Buffer;
PAGED_CODE(); PAGED_CODE();
/* Always disable this until we have DOS Device Maps */ /* Check if we should search the shadow directory */
SearchShadow = FALSE; if (!ObpLUIDDeviceMapsEnabled) SearchShadow = FALSE;
/* Fail if we don't have a directory or name */ /* Fail if we don't have a directory or name */
if (!(Directory) || !(Name)) goto Quickie; if (!(Directory) || !(Name)) goto Quickie;
@ -137,12 +150,12 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory,
TotalChars = Name->Length / sizeof(WCHAR); TotalChars = Name->Length / sizeof(WCHAR);
Buffer = Name->Buffer; Buffer = Name->Buffer;
/* Fail if the name is empty */
if (!(Buffer) || !(TotalChars)) goto Quickie;
/* Set up case-sensitivity */ /* Set up case-sensitivity */
if (Attributes & OBJ_CASE_INSENSITIVE) CaseInsensitive = TRUE; if (Attributes & OBJ_CASE_INSENSITIVE) CaseInsensitive = TRUE;
/* Fail if the name is empty */
if (!(Buffer) || !(TotalChars)) goto Quickie;
/* Create the Hash */ /* Create the Hash */
for (HashValue = 0; TotalChars; TotalChars--) for (HashValue = 0; TotalChars; TotalChars--)
{ {
@ -172,9 +185,7 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory,
/* Check if the directory is already locked */ /* Check if the directory is already locked */
if (!Context->DirectoryLocked) if (!Context->DirectoryLocked)
{ {
/* Lock it */
KeEnterCriticalRegion();
ExAcquireResourceSharedLite(&Directory->Lock, TRUE);
} }
/* Start looping */ /* Start looping */
@ -184,10 +195,11 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory,
if (CurrentEntry->HashValue == HashValue) if (CurrentEntry->HashValue == HashValue)
{ {
/* Make sure that it has a name */ /* Make sure that it has a name */
ASSERT(OBJECT_TO_OBJECT_HEADER(CurrentEntry->Object)->NameInfoOffset != 0); ObjectHeader = OBJECT_TO_OBJECT_HEADER(CurrentEntry->Object);
/* Get the name information */ /* Get the name information */
HeaderNameInfo = OBJECT_HEADER_TO_NAME_INFO(OBJECT_TO_OBJECT_HEADER(CurrentEntry->Object)); ASSERT(ObjectHeader->NameInfoOffset != 0);
HeaderNameInfo = OBJECT_HEADER_TO_NAME_INFO(ObjectHeader);
/* Do the names match? */ /* Do the names match? */
if ((Name->Length == HeaderNameInfo->Name.Length) && if ((Name->Length == HeaderNameInfo->Name.Length) &&
@ -207,6 +219,11 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory,
/* Set this entry as the first, to speed up incoming insertion */ /* Set this entry as the first, to speed up incoming insertion */
if (AllocatedEntry != LookupBucket) if (AllocatedEntry != LookupBucket)
{ {
/* Check if the directory was locked */
if (!Context->DirectoryLocked)
{
}
/* Set the Current Entry */ /* Set the Current Entry */
*AllocatedEntry = CurrentEntry->ChainLink; *AllocatedEntry = CurrentEntry->ChainLink;
@ -220,17 +237,42 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory,
/* Save the found object */ /* Save the found object */
FoundObject = CurrentEntry->Object; FoundObject = CurrentEntry->Object;
if (!FoundObject) goto Quickie; if (!FoundObject) goto Quickie;
}
/* Check if the directory was unlocked (which means we locked it) */ /* Get the object name information */
if (!Context->DirectoryLocked) ObjectHeader = OBJECT_TO_OBJECT_HEADER(FoundObject);
HeaderNameInfo = OBJECT_HEADER_TO_NAME_INFO(ObjectHeader);
/* Reference the object being looked up */
//ObReferenceObject(FoundObject);
/* Check if the directory was locked */
if (!Context->DirectoryLocked)
{
}
}
else
{ {
/* Lock it */ /* Check if the directory was locked */
ExReleaseResourceLite(&Directory->Lock); if (!Context->DirectoryLocked)
KeLeaveCriticalRegion(); {
}
/* Check if we should scan the shadow directory */
if ((SearchShadow) && (Directory->DeviceMap))
{
/* FIXME: We don't support this yet */
KEBUGCHECK(0);
}
} }
Quickie: Quickie:
/* Check if we found an object already */
if (Context->Object)
{
/* We already did a lookup, so remove this object's query reference */
//ObpRemoveQueryReference(Context->Object);
}
/* Return the object we found */ /* Return the object we found */
Context->Object = FoundObject; Context->Object = FoundObject;
return FoundObject; return FoundObject;