Hello,

I want to obtain the disk geometry and need help with an error I am
seeing.

The code snippet is as follows:

RtlInitUnicodeString ( &uName, L"\\Device\\Harddisk1\\DR2" );
dStatus = IoGetDeviceObjectPointer ( &uName,
FILE_ALL_ACCESS,
&pFileObject,
&pDeviceObject );

..........
irp = IoBuildDeviceIoControlRequest
( IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
pDeviceObject,
NULL,
0,
(PVOID)pOutputBuffer,
*pdOutputBufferSize,
FALSE,
&event,
&IoStatus );

if (!irp) {
return STATUS_INSUFFICIENT_RESOURCES;
}

status = IoCallDriver (pDeviceObject, irp);


The IoCallDriver returns NT_SUCCESS but the disk geometry
(pOutputBuffer) is all zero's.

What am I missing? I tried RtlInitUnicodeString ( &uName, L"\\\\.\
\PhysicalDrive0" ) but got the same result.

Thanks,

..Ram

Re: Disk geometry by Vladimir

Vladimir
Fri Aug 31 00:00:12 PDT 2007

May be the IoCallDriver returns STATUS_PENDING. It's also NT_SUCCESS.

--
Best regards,
Vladimir Zinin
mailto:vzinin@gmail.com

Ram wrote:
> Hello,
>
> I want to obtain the disk geometry and need help with an error I am
> seeing.
>
> The code snippet is as follows:
>
> RtlInitUnicodeString ( &uName, L"\\Device\\Harddisk1\\DR2" );
> dStatus = IoGetDeviceObjectPointer ( &uName,
> FILE_ALL_ACCESS,
> &pFileObject,
> &pDeviceObject );
>
> ...........
> irp = IoBuildDeviceIoControlRequest
> ( IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
> pDeviceObject,
> NULL,
> 0,
> (PVOID)pOutputBuffer,
> *pdOutputBufferSize,
> FALSE,
> &event,
> &IoStatus );
>
> if (!irp) {
> return STATUS_INSUFFICIENT_RESOURCES;
> }
>
> status = IoCallDriver (pDeviceObject, irp);
>
>
> The IoCallDriver returns NT_SUCCESS but the disk geometry
> (pOutputBuffer) is all zero's.
>
> What am I missing? I tried RtlInitUnicodeString ( &uName, L"\\\\.\
> \PhysicalDrive0" ) but got the same result.
>
> Thanks,
>
> ...Ram
>