From d462152e6dec87d726c4217bf2a62d4e7bf0ac44 Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Mon, 17 May 2004 20:20:17 +0000 Subject: [PATCH] - Fixed the calculation of the start for a partition within an extended partition. svn path=/trunk/; revision=9430 --- freeldr/freeldr/disk/partition.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/freeldr/freeldr/disk/partition.c b/freeldr/freeldr/disk/partition.c index 58a7c2810da..ea20c11bd9f 100644 --- a/freeldr/freeldr/disk/partition.c +++ b/freeldr/freeldr/disk/partition.c @@ -81,7 +81,7 @@ BOOL DiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABL MASTER_BOOT_RECORD MasterBootRecord; PARTITION_TABLE_ENTRY ExtendedPartitionTableEntry; U32 ExtendedPartitionNumber; - U32 ExtendedPartitionRelativeOffset; + U32 ExtendedPartitionOffset; U32 Index; // Read master boot record @@ -113,7 +113,7 @@ BOOL DiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABL // Set the initial relative starting sector to 0 // This is because extended partition starting // sectors a numbered relative to their parent - ExtendedPartitionRelativeOffset = 0; + ExtendedPartitionOffset = 0; for (Index=0; Index<=ExtendedPartitionNumber; Index++) { @@ -124,10 +124,14 @@ BOOL DiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABL } // Adjust the relative starting sector of the partition - ExtendedPartitionRelativeOffset += ExtendedPartitionTableEntry.SectorCountBeforePartition; - + ExtendedPartitionTableEntry.SectorCountBeforePartition += ExtendedPartitionOffset; + if (ExtendedPartitionOffset == 0) + { + // Set the start of the parrent extended partition + ExtendedPartitionOffset = ExtendedPartitionTableEntry.SectorCountBeforePartition; + } // Read the partition boot record - if (!DiskReadBootRecord(DriveNumber, ExtendedPartitionRelativeOffset, &MasterBootRecord)) + if (!DiskReadBootRecord(DriveNumber, ExtendedPartitionTableEntry.SectorCountBeforePartition, &MasterBootRecord)) { return FALSE; } @@ -139,7 +143,7 @@ BOOL DiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABL } // Now correct the start sector of the partition - PartitionTableEntry->SectorCountBeforePartition += ExtendedPartitionRelativeOffset; + PartitionTableEntry->SectorCountBeforePartition += ExtendedPartitionTableEntry.SectorCountBeforePartition; } // When we get here we should have the correct entry