I'm working on a project which requires me to operate at a low level on Windows drives, and am doing so primarily using Windows API calls. But before I can operate on the drive, I need to know the types of partitions present on it.
This is fairly simple on a disk formatted by MBR, because
DeviceIoControl(...,IOCTL_DISK_GET_DRIVE_LAYOUT_EX,...);
returns a structure in format DRIVE_LAYOUT_INFORMATION_EX
, which contains an array of PARTITION_INFORMATION_EX
. On an MBR disk, the PARTITION_INFORMATION_EX.Mbr.PartitionType
element contains a unique identifier for the partition type, e.g. for NTFS
it is 0x07
, for Extended
it is 0x05
.
However, this isn't so simple on a GPT disk. I know that I can read the identifier off of the beginning of the partition, but I'd prefer to handle this with API calls, such as DeviceIoControl
. When I run DeviceIoControl
on a GPT disk, the PARTITION_INFORMATION_EX.Mbr.PartitionType
contains completely different values than those which would be normally there.
Note that the GUID is useless to me because that only tells me the purpose of the partition, not what type of partition it is. I'm trying to figure out if the drive is NTFS, FAT, etc.