Maxim
Thu Oct 11 08:37:04 PDT 2007
OK, so I correlated IoReadPartitionTableEx/IoWritePartitionTableEx functions
with IOCTLs that they issue. Both issue IOCTL_GET_DRIVE_GEOMETRY_EX IOCTL,
which fails in my IOCTL handler because I was trying to get an output buffer
of sizeof(DISK_GEOMETRY_EX), which failed and in turn functions failed. When
requesting an output buffer of size FIELD_OFFSET(DISK_GEOMETRY_EX, Data)
(which is what CDROM sample driver does), it succeeded and in turn IO
functions succeed.
Frustrating... Why describe DISK_GEOMETRY_EX in the documentation as having
a field (+ 2 additional structures at the end) if the kernel functions that
use it do not allocate space for those structures and fail unconditinally
even when their IOCTLs return with STATUS_BUFFER_TOO_SMALL...
Thanks for both of you guys' help!
"Maxim S. Shatskih" wrote:
> > actually perform the media reads themselves, then what is the point of them
> > sending IOCTLs? If on the other hand they are nothing but wrappers for
> > IOCTLs
>
> No.
>
> IoReadPartitionTable(Ex) is the function which really reads the partition table
> sectors from the disk by handicrafted MJ_READ IRPs (and possibly some IOCTLs),
> then parses the MBR or GPT on-disk data and fills the
> DRIVE_LAYOUT_INFORMATION(_EX), which is the universal format of the partition
> table data.
>
> The reason for existence of this functions is to remove the MBR/GPT parsing
> code from Disk.sys to the kernel (actually the HAL due to some very old reasons
> of NT3 times).
>
> --
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> maxim@storagecraft.com
>
http://www.storagecraft.com
>
>