From 1f95a6dd13723221349a16b4518a0233d569d672 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Wed, 21 Sep 2011 09:11:42 +0000 Subject: [PATCH] [NTOSKRNL] Fix FstubFixupEfiPartition() Add helper macro SET_PARTITION_LENGTH() svn path=/trunk/; revision=53784 --- reactos/ntoskrnl/fstub/disksup.c | 11 +++++------ reactos/ntoskrnl/include/internal/hal.h | 6 ++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/reactos/ntoskrnl/fstub/disksup.c b/reactos/ntoskrnl/fstub/disksup.c index d8c284f4a79..32d6a78e8f0 100644 --- a/reactos/ntoskrnl/fstub/disksup.c +++ b/reactos/ntoskrnl/fstub/disksup.c @@ -1365,18 +1365,17 @@ NTAPI FstubFixupEfiPartition(IN PPARTITION_DESCRIPTOR PartitionDescriptor, IN ULONGLONG MaxOffset) { - ULONG PartitionLength; + ULONG PartitionMaxOffset, PartitionLength; PAGED_CODE(); /* Compute partition length (according to MBR entry) */ - PartitionLength = PartitionDescriptor->StartingSectorLsb0 + PartitionDescriptor->PartitionLengthLsb0; + PartitionMaxOffset = GET_STARTING_SECTOR(PartitionDescriptor) + GET_PARTITION_LENGTH(PartitionDescriptor); /* In case the partition length goes beyond disk size... */ - if (PartitionLength > MaxOffset) + if (PartitionMaxOffset > MaxOffset) { /* Resize partition to its maximum real length */ -#pragma message("--> FIXME: FstubFixupEfiPartition is most likeley broken!") - PartitionDescriptor->PartitionLengthLsb0 = - (UCHAR)(MaxOffset - PartitionDescriptor->StartingSectorLsb0); + PartitionLength = (ULONG)(PartitionMaxOffset - GET_STARTING_SECTOR(PartitionDescriptor)); + SET_PARTITION_LENGTH(PartitionDescriptor, PartitionLength); } } diff --git a/reactos/ntoskrnl/include/internal/hal.h b/reactos/ntoskrnl/include/internal/hal.h index 249ae64a19b..a3b6f6b0683 100644 --- a/reactos/ntoskrnl/include/internal/hal.h +++ b/reactos/ntoskrnl/include/internal/hal.h @@ -264,6 +264,12 @@ xKdUnmapVirtualAddress( (ULONG)(p->PartitionLengthMsb0 << 16) + \ (ULONG)(p->PartitionLengthMsb1 << 24)) +#define SET_PARTITION_LENGTH(p, l) \ + p->PartitionLengthLsb0 = l & 0xFF; \ + p->PartitionLengthLsb1 = (l >> 8) & 0xFF; \ + p->PartitionLengthMsb0 = (l >> 16) & 0xFF; \ + p->PartitionLengthMsb1 = (l >> 24) & 0xFF + // // Structure describing a partition //