mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
xHalIoReadPartitionTable() can now handle partially corrupted partition tables
svn path=/trunk/; revision=1311
This commit is contained in:
parent
6f1d7ad00c
commit
e7dc6b7c4b
1 changed files with 41 additions and 18 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: xhaldrv.c,v 1.3 2000/08/21 00:14:04 ekohl Exp $
|
||||
/* $Id: xhaldrv.c,v 1.4 2000/08/22 14:10:59 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -236,9 +236,9 @@ xHalExamineMBR (
|
|||
|
||||
static VOID
|
||||
HalpAssignDrive (
|
||||
PUNICODE_STRING PartitionName,
|
||||
PULONG DriveMap,
|
||||
ULONG DriveNumber
|
||||
IN PUNICODE_STRING PartitionName,
|
||||
IN OUT PULONG DriveMap,
|
||||
IN ULONG DriveNumber
|
||||
)
|
||||
{
|
||||
WCHAR DriveNameBuffer[8];
|
||||
|
@ -308,7 +308,7 @@ xHalIoAssignDriveLetters (
|
|||
OUT PSTRING NtSystemPathString
|
||||
)
|
||||
{
|
||||
PDRIVE_LAYOUT_INFORMATION LayoutInfo; // ebp-4
|
||||
PDRIVE_LAYOUT_INFORMATION LayoutInfo;
|
||||
PCONFIGURATION_INFORMATION ConfigInfo;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
IO_STATUS_BLOCK StatusBlock;
|
||||
|
@ -585,7 +585,7 @@ xHalIoReadPartitionTable (
|
|||
{
|
||||
KEVENT Event;
|
||||
IO_STATUS_BLOCK StatusBlock;
|
||||
LARGE_INTEGER Offset;
|
||||
ULARGE_INTEGER Offset;
|
||||
PUCHAR SectorBuffer;
|
||||
PIRP Irp;
|
||||
NTSTATUS Status;
|
||||
|
@ -633,7 +633,7 @@ xHalIoReadPartitionTable (
|
|||
DeviceObject,
|
||||
SectorBuffer,
|
||||
SectorSize,
|
||||
&Offset,
|
||||
(PLARGE_INTEGER)&Offset,
|
||||
&Event,
|
||||
&StatusBlock);
|
||||
|
||||
|
@ -651,7 +651,7 @@ xHalIoReadPartitionTable (
|
|||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("xHalIoReadPartitonTable failed (Status = 0x%08lx)\n",
|
||||
DPRINT1("xHalIoReadPartitonTable failed (Status = 0x%08lx)\n",
|
||||
Status);
|
||||
ExFreePool (SectorBuffer);
|
||||
ExFreePool (LayoutBuffer);
|
||||
|
@ -664,10 +664,13 @@ xHalIoReadPartitionTable (
|
|||
DPRINT("Magic %x\n", PartitionTable->Magic);
|
||||
if (PartitionTable->Magic != PARTITION_MAGIC)
|
||||
{
|
||||
DPRINT("Invalid partition table magic\n");
|
||||
DPRINT1("Invalid partition table magic\n");
|
||||
ExFreePool (SectorBuffer);
|
||||
ExFreePool (LayoutBuffer);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
// ExFreePool (LayoutBuffer);
|
||||
// return STATUS_UNSUCCESSFUL;
|
||||
|
||||
*PartitionBuffer = LayoutBuffer;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
@ -702,10 +705,18 @@ xHalIoReadPartitionTable (
|
|||
Count = LayoutBuffer->PartitionCount;
|
||||
DPRINT("Logical Partition %u\n", Count);
|
||||
|
||||
if (PartitionTable->Partition[i].StartingBlock)
|
||||
{
|
||||
LayoutBuffer->PartitionEntry[Count].StartingOffset.QuadPart =
|
||||
PartitionTable->Partition[i].StartingBlock * SectorSize;
|
||||
(ULONGLONG)Offset.QuadPart +
|
||||
((ULONGLONG)PartitionTable->Partition[i].StartingBlock * (ULONGLONG)SectorSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
LayoutBuffer->PartitionEntry[Count].StartingOffset.QuadPart = 0;
|
||||
}
|
||||
LayoutBuffer->PartitionEntry[Count].PartitionLength.QuadPart =
|
||||
PartitionTable->Partition[i].SectorCount * SectorSize;
|
||||
(ULONGLONG)PartitionTable->Partition[i].SectorCount * (ULONGLONG)SectorSize;
|
||||
LayoutBuffer->PartitionEntry[Count].HiddenSectors = 0;
|
||||
|
||||
if (IsUsablePartition(PartitionTable->Partition[i].PartitionType))
|
||||
|
@ -726,13 +737,25 @@ xHalIoReadPartitionTable (
|
|||
IsRecognizedPartition (PartitionTable->Partition[i].PartitionType);
|
||||
LayoutBuffer->PartitionEntry[Count].RewritePartition = FALSE;
|
||||
|
||||
DPRINT(" Offset: 0x%I64x", Offset.QuadPart);
|
||||
|
||||
if (IsExtendedPartition(PartitionTable->Partition[i].PartitionType))
|
||||
{
|
||||
Offset.QuadPart +=
|
||||
(PartitionTable->Partition[i].StartingBlock * SectorSize);
|
||||
Offset.QuadPart = (ULONGLONG)Offset.QuadPart +
|
||||
((ULONGLONG)PartitionTable->Partition[i].StartingBlock * (ULONGLONG)SectorSize);
|
||||
ExtendedFound = TRUE;
|
||||
}
|
||||
|
||||
DPRINT(" Offset: 0x%I64x\n", Offset.QuadPart);
|
||||
|
||||
DPRINT(" %ld: nr: %d boot: %1x type: %x start: 0x%I64x count: 0x%I64x\n",
|
||||
Count,
|
||||
LayoutBuffer->PartitionEntry[Count].PartitionNumber,
|
||||
LayoutBuffer->PartitionEntry[Count].BootIndicator,
|
||||
LayoutBuffer->PartitionEntry[Count].PartitionType,
|
||||
LayoutBuffer->PartitionEntry[Count].StartingOffset.QuadPart,
|
||||
LayoutBuffer->PartitionEntry[Count].PartitionLength.QuadPart);
|
||||
|
||||
LayoutBuffer->PartitionCount++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue