Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

IOCTL_DISK_GET_DRIVE_LAYOUT

186 views
Skip to first unread message

Aleko Boychev

unread,
Nov 16, 2001, 5:57:27 AM11/16/01
to
Hi,
can you help me with this problem:
I'm trying to get all partitions on given physical disks.(User mode)
This can be done through the IOCTL_DISK_GET_DRIVE_LAYOUT device io control.
But when I call the iocontrol, the returned data is wrong.
For example - I have physicaldrive0 with 1 partition on it.
The iocotnrol is returning partitioncount = 4 ...
How can I get the true number of partitions on a given drive?
Here's the code wich I'm using...

DriveHandle = CreateFile(DiskName,
GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);

if (DriveHandle != INVALID_HANDLE_VALUE)
{

stDriveLayout = (DRIVE_LAYOUT_INFORMATION *)malloc(128 *
sizeof(PARTITION_INFORMATION)+4);
ZeroMemory(stDriveLayout, (128 * sizeof(PARTITION_INFORMATION)+4));
res = DeviceIoControl(DriveHandle,
IOCTL_DISK_GET_DRIVE_LAYOUT,
NULL,
0,
stDriveLayout,
(128 * sizeof(PARTITION_INFORMATION)+4),
&cbReturned,
NULL);
}

Thanks in advance


Christian Studer

unread,
Nov 16, 2001, 8:30:38 AM11/16/01
to
You can loop through the PartitionEntry array and count all entries with
PartitionNumber != 0.

Christian Studer
http://www.realtimesoft.com

Aleko Boychev

unread,
Nov 16, 2001, 8:58:33 AM11/16/01
to
Well,
for the "non-existing" partitions, the partition number is different
everytime. Sometimes it is -1, sometimes 4096, sometimes another values. I
can't see any connection between the values.
And why the PartitionCount value is greater than the count of the existing
partitions?
I need to know for sure the number of the existing partitions - formatted or
non-formated....

Thanks in advance
Aleko

"Christian Studer" <cst...@dplanet.ch> wrote in message
news:e09K0LqbBHA.1932@tkmsftngp03...

Ramu

unread,
Nov 16, 2001, 2:57:48 PM11/16/01
to
The partition table contains 4 records for storing the partition
information. All of the entries may not contain valid information. This
depends on the number of paritions in the disk. Try to get some information
about the partition table and MBR (Master Boot Record) to understand this
better.

Look at the PartitionType member of the PARTITION_INFORMATION structure to
see the type of partition. If the entry is unused, then it won't have any
valid information. Look at the ntdddisk.h for the strucure and partition
type details. You can also get some of the information from the internet.


"Aleko Boychev" <al...@crosswinds.net> wrote in message
news:O982JzobBHA.1972@tkmsftngp04...

Ramu

unread,
Nov 16, 2001, 3:33:16 PM11/16/01
to
The partition table contains 4 records for storing the partition
information. All of the entries may not contain valid information. This
depends on the number of paritions in the disk. Try to get some information
about the partition table and MBR (Master Boot Record) to understand this
better.

Look at the PartitionType member of the PARTITION_INFORMATION structure to
see the type of partition. If the entry is unused, then it won't have any
valid information. Look at the ntdddisk.h for the strucure and partition
type details. You can also get some of the information from the internet.

"Aleko Boychev" <al...@crosswinds.net> wrote in message
news:O982JzobBHA.1972@tkmsftngp04...

Aleko Boychev

unread,
Nov 19, 2001, 3:43:31 AM11/19/01
to
Thanks, but I want to see all existing partitions - recognized or not
recognized. I mean, I can't discard the partitiontype 0.....
The exact question is, how to get the existing partitions - recognizable or
not recognizable...

Thanks, Aleko
"Ramu" <ra...@uswest.net> wrote in message
news:ejtBE4tbBHA.2016@tkmsftngp07...

Aleko Boychev

unread,
Nov 19, 2001, 6:19:37 AM11/19/01
to
And how can I get the number of extended partitions on the physical
volume....
Best,
Al

"Ramu" <ra...@uswest.net> wrote in message
news:ejtBE4tbBHA.2016@tkmsftngp07...

Nathan Moinvaziri

unread,
Jan 8, 2002, 1:48:26 AM1/8/02
to
Allocate this much space when passing it to
DeviceIoControl()

DWORD nBufferSize = sizeof(DRIVE_LAYOUT_INFORMATION) +
(16 * sizeof(PARTITION_INFORMATION));

stDriveLayout = (DRIVE_LAYOUT_INFORMATION*)malloc
(nBufferSize);

Nathan

>.
>

0 new messages