https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fdd74eb97e79bd7ad62c0…
commit fdd74eb97e79bd7ad62c0fc2f26541db1ff1009c
Author:     Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Thu Jun 10 19:31:43 2021 +0200
Commit:     Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Fri Jun 11 02:21:47 2021 +0200
    [NTOS:IO/FSTUB] Fix the determination of 'SingleDisk' in
IoGetBootDiskInformation().
    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    | 8 +++++---
 ntoskrnl/io/iomgr/arcname.c | 4 ++--
 2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/ntoskrnl/fstub/fstubex.c b/ntoskrnl/fstub/fstubex.c
index 21a0dbd1561..1904d32339a 100644
--- a/ntoskrnl/fstub/fstubex.c
+++ b/ntoskrnl/fstub/fstubex.c
@@ -1866,13 +1866,15 @@ IoGetBootDiskInformation(IN OUT PBOOTDISK_INFORMATION
BootDiskInformation,
     /* 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;
-    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);
@@ -2147,7 +2149,7 @@ IoGetBootDiskInformation(IN OUT PBOOTDISK_INFORMATION
BootDiskInformation,
             }
         }
-        /* Finally, release drive layout structure */
+        /* Finally, release drive layout */
         ExFreePool(DriveLayout);
     }
diff --git a/ntoskrnl/io/iomgr/arcname.c b/ntoskrnl/io/iomgr/arcname.c
index bdb3e7b1324..3be5930ec69 100644
--- a/ntoskrnl/io/iomgr/arcname.c
+++ b/ntoskrnl/io/iomgr/arcname.c
@@ -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 */
-    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);