[NTOSKRNL] Add support for global DOS directory in ObpLookupEntryDirectory
[reactos.git] / ntoskrnl / ob / obdir.c
index f8e3a36..83d05d4 100644 (file)
@@ -92,6 +92,42 @@ ObpInsertEntryDirectory(IN POBJECT_DIRECTORY Parent,
     return TRUE;
 }
 
+/*++
+* @name ObpGetShadowDirectory
+*
+*     The ObpGetShadowDirectory routine <FILLMEIN>.
+*
+* @param Directory
+*        <FILLMEIN>.
+*
+* @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;
+            }
         }
     }