mirror of
https://github.com/reactos/reactos.git
synced 2025-05-19 17:14:32 +00:00
[USETUP]
Allocate a disk layout buffer that is large enough to keep all partitions of the disk. CORE-5818 resolve svn path=/trunk/; revision=68122
This commit is contained in:
parent
09b36e8cd5
commit
1d240a84ee
1 changed files with 32 additions and 5 deletions
|
@ -1151,12 +1151,9 @@ AddDiskToList(
|
||||||
|
|
||||||
InsertAscendingList(&List->DiskListHead, DiskEntry, DISKENTRY, ListEntry, DiskNumber);
|
InsertAscendingList(&List->DiskListHead, DiskEntry, DISKENTRY, ListEntry, DiskNumber);
|
||||||
|
|
||||||
/*
|
/* Allocate a layout buffer for 4 partition entries first */
|
||||||
* Allocate a buffer for 26 logical drives (2 entries each == 52)
|
|
||||||
* plus the main partiton table (4 entries). Total 56 entries.
|
|
||||||
*/
|
|
||||||
LayoutBufferSize = sizeof(DRIVE_LAYOUT_INFORMATION) +
|
LayoutBufferSize = sizeof(DRIVE_LAYOUT_INFORMATION) +
|
||||||
((56 - ANYSIZE_ARRAY) * sizeof(PARTITION_INFORMATION));
|
((4 - ANYSIZE_ARRAY) * sizeof(PARTITION_INFORMATION));
|
||||||
DiskEntry->LayoutBuffer = RtlAllocateHeap(ProcessHeap,
|
DiskEntry->LayoutBuffer = RtlAllocateHeap(ProcessHeap,
|
||||||
HEAP_ZERO_MEMORY,
|
HEAP_ZERO_MEMORY,
|
||||||
LayoutBufferSize);
|
LayoutBufferSize);
|
||||||
|
@ -1175,6 +1172,36 @@ AddDiskToList(
|
||||||
0,
|
0,
|
||||||
DiskEntry->LayoutBuffer,
|
DiskEntry->LayoutBuffer,
|
||||||
LayoutBufferSize);
|
LayoutBufferSize);
|
||||||
|
DPRINT("Status: 0x%08lx\n", Status);
|
||||||
|
DPRINT("PartitionCount: %lu\n", DiskEntry->LayoutBuffer->PartitionCount);
|
||||||
|
|
||||||
|
/* If we need more than 4 partition entries, reallocte the buffer and
|
||||||
|
retrieve the disk layout again */
|
||||||
|
if (!NT_SUCCESS(Status) && DiskEntry->LayoutBuffer->PartitionCount > 4)
|
||||||
|
{
|
||||||
|
LayoutBufferSize = sizeof(DRIVE_LAYOUT_INFORMATION) +
|
||||||
|
((DiskEntry->LayoutBuffer->PartitionCount - ANYSIZE_ARRAY) * sizeof(PARTITION_INFORMATION));
|
||||||
|
DiskEntry->LayoutBuffer = RtlReAllocateHeap(ProcessHeap,
|
||||||
|
HEAP_ZERO_MEMORY,
|
||||||
|
DiskEntry->LayoutBuffer,
|
||||||
|
LayoutBufferSize);
|
||||||
|
if (DiskEntry->LayoutBuffer == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = NtDeviceIoControlFile(FileHandle,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&Iosb,
|
||||||
|
IOCTL_DISK_GET_DRIVE_LAYOUT,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
DiskEntry->LayoutBuffer,
|
||||||
|
LayoutBufferSize);
|
||||||
|
}
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
#ifdef DUMP_PARTITION_TABLE
|
#ifdef DUMP_PARTITION_TABLE
|
||||||
|
|
Loading…
Reference in a new issue