NTSTATUS
FASTCALL
IoReadPartitionTable(
IN PDEVICE_OBJECT DeviceObject,
IN ULONG SectorSize,
IN BOOLEAN ReturnRecognizedPartitions,
OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer
);
Routine Description:
This routine walks the disk reading the partition tables and creates
an entry in the partition list buffer for each partition.
The algorithm used by this routine is two-fold:
1) Read each partition table and for each valid, recognized
partition found, to build a descriptor in a partition list.
Extended partitions are located in order to find other
partition tables, but no descriptors are built for these.
The partition list is built in nonpaged pool that is allocated
by this routine. It is the caller's responsibility to free
this pool after it has gathered the appropriate information
from the list.
2) Read each partition table and for each and every entry, build
a descriptor in the partition list. Extended partitions are
located to find each partition table on the disk, and entries
are built for these as well. The partition list is build in
nonpaged pool that is allocated by this routine. It is the
caller's responsibility to free this pool after it has copied
the information back to its caller.
The first algorithm is used when the ReturnRecognizedPartitions flag
is set. This is used to determine how many partition device objects
the device driver is to create, and where each lives on the drive.
The second algorithm is used when the ReturnRecognizedPartitions flag
is clear. This is used to find all of the partition tables and their
entries for a utility such as fdisk, that would like to revamp where
the partitions live.
Arguments:
DeviceObject - Pointer to device object for this disk.
SectorSize - Sector size on the device.
ReturnRecognizedPartitions - A flag indicated whether only recognized
partition descriptors are to be returned, or whether all partition
entries are to be returned.
PartitionBuffer - Pointer to the pointer of the buffer in which the list
of partition will be stored.
Return Value:
The functional value is STATUS_SUCCESS if at least one sector table was
read.
Notes:
It is the responsibility of the caller to deallocate the partition list
buffer allocated by this routine.