[NTOS:IO/FSTUB] Fix the determination of 'SingleDisk' in IoGetBootDiskInformation().
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Thu, 10 Jun 2021 17:31:43 +0000 (19:31 +0200)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Fri, 11 Jun 2021 00:21:47 +0000 (02:21 +0200)
The purpose of 'SingleDisk' is the same as in the IopCreateArcNames()
function. It is an optimization for that when looking up the
firmware-recognized ARC disks list, in order to match one of these with
the current NT disk being analysed (see e.g. also in IopCreateArcNamesDisk()),
we avoid a possible IopVerifyDiskSignature() call and directly build a
corresponding ARC name NT symbolic link for it.

'SingleDisk' will actually be TRUE, whether the DiskSignatureListHead
list is empty or contains only one element: Indeed in only both these
cases, 'DiskSignatureListHead.Flink->Flink' will refer to the list head.
(If the list is empty but 'SingleDisk' is TRUE, this does not matter,
because the DiskSignatureListHead looking-up loop never starts.)

ntoskrnl/fstub/fstubex.c
ntoskrnl/io/iomgr/arcname.c

index 21a0dbd..1904d32 100644 (file)
@@ -1866,13 +1866,15 @@ IoGetBootDiskInformation(IN OUT PBOOTDISK_INFORMATION BootDiskInformation,
 
     /* Init some useful stuff:
      * Get ARC disks information
 
     /* Init some useful stuff:
      * Get ARC disks information
-     * Check whether we have a single disk
+     * Check whether we have a single disk on the machine
      * Check received structure size (extended or not?)
      * Init boot strings (system/boot)
      * Finaly, get disk count
      */
     ArcDiskInformation = IopLoaderBlock->ArcDiskInformation;
      * Check received structure size (extended or not?)
      * Init boot strings (system/boot)
      * Finaly, get disk count
      */
     ArcDiskInformation = IopLoaderBlock->ArcDiskInformation;
-    SingleDisk = IsListEmpty(&(ArcDiskInformation->DiskSignatureListHead));
+    SingleDisk = (ArcDiskInformation->DiskSignatureListHead.Flink->Flink ==
+                 &ArcDiskInformation->DiskSignatureListHead);
+
     IsBootDiskInfoEx = (Size >= sizeof(BOOTDISK_INFORMATION_EX));
     RtlInitAnsiString(&ArcBootString, IopLoaderBlock->ArcBootDeviceName);
     RtlInitAnsiString(&ArcSystemString, IopLoaderBlock->ArcHalDeviceName);
     IsBootDiskInfoEx = (Size >= sizeof(BOOTDISK_INFORMATION_EX));
     RtlInitAnsiString(&ArcBootString, IopLoaderBlock->ArcBootDeviceName);
     RtlInitAnsiString(&ArcSystemString, IopLoaderBlock->ArcHalDeviceName);
@@ -2147,7 +2149,7 @@ IoGetBootDiskInformation(IN OUT PBOOTDISK_INFORMATION BootDiskInformation,
             }
         }
 
             }
         }
 
-        /* Finally, release drive layout structure */
+        /* Finally, release drive layout */
         ExFreePool(DriveLayout);
     }
 
         ExFreePool(DriveLayout);
     }
 
index bdb3e7b..3be5930 100644 (file)
@@ -48,8 +48,8 @@ IopCreateArcNames(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
     ANSI_STRING ArcSystemString, ArcString, LanmanRedirector, LoaderPathNameA;
 
     /* Check if we only have one disk on the machine */
     ANSI_STRING ArcSystemString, ArcString, LanmanRedirector, LoaderPathNameA;
 
     /* Check if we only have one disk on the machine */
-    SingleDisk = ArcDiskInfo->DiskSignatureListHead.Flink->Flink ==
-                 (&ArcDiskInfo->DiskSignatureListHead);
+    SingleDisk = (ArcDiskInfo->DiskSignatureListHead.Flink->Flink ==
+                 &ArcDiskInfo->DiskSignatureListHead);
 
     /* Create the global HAL partition name */
     sprintf(Buffer, "\\ArcName\\%s", LoaderBlock->ArcHalDeviceName);
 
     /* Create the global HAL partition name */
     sprintf(Buffer, "\\ArcName\\%s", LoaderBlock->ArcHalDeviceName);