[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.)
This commit is contained in:
Hermès Bélusca-Maïto 2021-06-10 19:31:43 +02:00
parent 99078646c3
commit fdd74eb97e
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 7 additions and 5 deletions

View file

@ -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);
}

View 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 */
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);