Drive Partitioning Problems

Hello all,
I am having a few problems creating an extended partition under NT/2000.

First, I am calling CreateFile() to get a handle to PhysicalDrive0. This
succeeds, but I have problems later in the code. When I then call
DeviceIoControl() with the IOCTL_DISK_GET_DRIVE_LAYOUT, the device handle is
nulled out. In other words, when I enter DeviceIoControl the handle is
valid. When I leave, the handle is now invalid. I am, however, still able
to call CloseHandle(hDevice) successfully.

After determining the size of the new partition, I again call CreateFile()
to get a new handle to PhysicalDrive0. I only do this because my previous
handle is invalid. I am then able to create the partition, but the system
crashes with a KERNEL_DATA_INPAGE_ERROR.

I think that the crash has something to do with losing the handle to the
device.

Has anyone else experienced this problem? Or, does anyone have any ideas
what could be causing me to lose the handle?

Thanks in Advance,
Mark
xxxxx@fmr.com

Hi,

First, I am calling CreateFile() to get a handle to PhysicalDrive0.
This
succeeds, but I have problems later in the code. When I then call
DeviceIoControl() with the IOCTL_DISK_GET_DRIVE_LAYOUT, the device handle
is
nulled out. In other words, when I enter DeviceIoControl the handle is
valid. When I leave, the handle is now invalid.

It seems u r not allocating enough memory to the output buffer.
Try allocating the output buffer with the following equation:

Bytes = sizeof(DRIVE_LAYOUT_INFORMATION) +
MAX_PARTITIONS * sizeof( PARTITION_INFORMATION );

thanks
Tushar B


Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com