- /* Check if the driver returned success */
- if(NT_SUCCESS(Status))
- {
- /* Build another IRP */
- Irp = IoBuildDeviceIoControlRequest(IOCTL_DISK_GET_PARTITION_INFO,
- DeviceObject,
- NULL,
- 0UL,
- &PartitionInfo,
- sizeof(PARTITION_INFORMATION),
- FALSE,
- Event,
- &IoStatusBlock);
- if (!Irp)
- {
- /* Fail, free the event */
- ExFreePoolWithTag(Event, TAG_FILE_SYSTEM);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- /* Reset event */
- KeClearEvent(Event);
-
- /* Call the driver and check if it's pending */
- Status = IoCallDriver(DeviceObject, Irp);
- if (Status == STATUS_PENDING)
- {
- /* Wait on the driver */
- KeWaitForSingleObject(Event, Executive, KernelMode, FALSE, NULL);
- Status = IoStatusBlock.Status;
- }
-
- /* Check if the driver returned success */
- if(NT_SUCCESS(Status))
- {
- /* Get the number of sectors */
- *RealSectorCount = (PartitionInfo.PartitionLength.QuadPart /
- Geometry->BytesPerSector);
- }
- }
-