[NTOSKRNL] Add support for global DOS directory in ObpLookupEntryDirectory
authorPierre Schweitzer <pierre@reactos.org>
Sun, 2 Jun 2019 19:44:45 +0000 (21:44 +0200)
committerPierre Schweitzer <pierre@reactos.org>
Sun, 2 Jun 2019 19:46:35 +0000 (21:46 +0200)
If any exists, we'll loop over in that directory, trying to find the object

ntoskrnl/ob/obdir.c

index f8e3a36..83d05d4 100644 (file)
@@ -92,6 +92,42 @@ ObpInsertEntryDirectory(IN POBJECT_DIRECTORY Parent,
     return TRUE;
 }
 
     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
 *
 /*++
 * @name ObpLookupEntryDirectory
 *
@@ -137,6 +173,7 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory,
     POBJECT_DIRECTORY_ENTRY CurrentEntry;
     PVOID FoundObject = NULL;
     PWSTR Buffer;
     POBJECT_DIRECTORY_ENTRY CurrentEntry;
     PVOID FoundObject = NULL;
     PWSTR Buffer;
+    POBJECT_DIRECTORY ShadowDirectory;
     PAGED_CODE();
 
     /* Check if we should search the shadow directory */
     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;
 
     AllocatedEntry = &Directory->HashBuckets[HashIndex];
     LookupBucket = AllocatedEntry;
 
+DoItAgain:
     /* Check if the directory is already locked */
     if (!Context->DirectoryLocked)
     {
     /* 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))
         {
         /* 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;
+            }
         }
     }
 
         }
     }