[SETUPLIB] Partitioning code fixes and improvements.

CORE-7749

- Correctly insert discovered partitions in sorted order of StartSector,
  and verify that they do not overlap (-> check for broken partitioning).

May help for CORE-10898.

- Use the correct reported partition numbers that may be modified after
  partitioning changes, and that need to be used when opening
  \Device\Harddisk'M'\Partition'N' files. This is achieving by
  retrieving the returned value of the IOCTL_DISK_SET_DRIVE_LAYOUT call.

  Distinguish them from the "on-disk" partition numbers that are the ones
  that enumerate the partition in partition-table order (and is the order
  known by e.g. the BIOS), and that should be used to construct the
  destination ARC path.

May help for CORE-4870, CORE-13205.

- Simplify a lot of duplicated code by using helper functions.
This commit is contained in:
Hermès Bélusca-Maïto 2018-11-22 03:26:47 +01:00
parent 958ae44599
commit 7df9296692
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
3 changed files with 417 additions and 386 deletions

View file

@ -642,7 +642,7 @@ InitDestinationPaths(
RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
L"multi(0)disk(0)rdisk(%lu)partition(%lu)\\",
DiskEntry->BiosDiskNumber,
PartEntry->PartitionNumber);
PartEntry->OnDiskPartitionNumber);
ConcatPaths(PathBuffer, ARRAYSIZE(PathBuffer), 1, InstallationDir);
RtlCreateUnicodeString(&pSetupData->DestinationArcPath, PathBuffer);