From fd4752450f9453aa9c635d87bed6b7a340fd1713 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 2 Jun 2019 21:44:45 +0200 Subject: [PATCH] [NTOSKRNL] Add support for global DOS directory in ObpLookupEntryDirectory If any exists, we'll loop over in that directory, trying to find the object --- ntoskrnl/ob/obdir.c | 47 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/ntoskrnl/ob/obdir.c b/ntoskrnl/ob/obdir.c index f8e3a36a06a..83d05d4beb9 100644 --- a/ntoskrnl/ob/obdir.c +++ b/ntoskrnl/ob/obdir.c @@ -92,6 +92,42 @@ ObpInsertEntryDirectory(IN POBJECT_DIRECTORY Parent, return TRUE; } +/*++ +* @name ObpGetShadowDirectory +* +* The ObpGetShadowDirectory routine . +* +* @param Directory +* . +* +* @return Pointer to the global DOS directory if any, or NULL otherwise. +* +* @remarks None. +* +*--*/ +POBJECT_DIRECTORY +NTAPI +ObpGetShadowDirectory(IN POBJECT_DIRECTORY Directory) +{ + PDEVICE_MAP DeviceMap; + POBJECT_DIRECTORY GlobalDosDirectory = NULL; + + /* Acquire the device map lock */ + KeAcquireGuardedMutex(&ObpDeviceMapLock); + + /* Get the global DOS directory if any */ + DeviceMap = Directory->DeviceMap; + if (DeviceMap != NULL) + { + GlobalDosDirectory = DeviceMap->GlobalDosDevicesDirectory; + } + + /* Release the devicemap lock */ + KeReleaseGuardedMutex(&ObpDeviceMapLock); + + return GlobalDosDirectory; +} + /*++ * @name ObpLookupEntryDirectory * @@ -137,6 +173,7 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory, POBJECT_DIRECTORY_ENTRY CurrentEntry; PVOID FoundObject = NULL; PWSTR Buffer; + POBJECT_DIRECTORY ShadowDirectory; PAGED_CODE(); /* Check if we should search the shadow directory */ @@ -181,6 +218,7 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory, AllocatedEntry = &Directory->HashBuckets[HashIndex]; LookupBucket = AllocatedEntry; +DoItAgain: /* Check if the directory is already locked */ if (!Context->DirectoryLocked) { @@ -250,8 +288,13 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory, /* Check if we should scan the shadow directory */ if ((SearchShadow) && (Directory->DeviceMap)) { - /* FIXME: We don't support this yet */ - ASSERT(FALSE); + ShadowDirectory = ObpGetShadowDirectory(Directory); + /* A global DOS directory was found, loop it again */ + if (ShadowDirectory != NULL) + { + Directory = ShadowDirectory; + goto DoItAgain; + } } } -- 2.17.1