Home | Info | Community | Development | myReactOS | Contact Us
Definition at line 7012 of file cdrom.c.
Referenced by CdRomStartIo().
{ PIO_STACK_LOCATION currentIrpStack = IoGetCurrentIrpStackLocation(Irp); ULONG ioctl = currentIrpStack->Parameters.DeviceIoControl.IoControlCode; PVOID systemBuffer = Irp->AssociatedIrp.SystemBuffer; ASSERT(systemBuffer); if ((ioctl != IOCTL_DISK_GET_DRIVE_LAYOUT) && (ioctl != IOCTL_DISK_GET_DRIVE_LAYOUT_EX) && (ioctl != IOCTL_DISK_GET_PARTITION_INFO) && (ioctl != IOCTL_DISK_GET_PARTITION_INFO_EX)) { TraceLog((CdromDebugError, "CdromFakePartitionInfo: unhandled ioctl %x\n", ioctl)); Irp->IoStatus.Status = STATUS_INTERNAL_ERROR; Irp->IoStatus.Information = 0; CdRomCompleteIrpAndStartNextPacketSafely(CommonExtension->DeviceObject, Irp); return; } // // nothing to fail from this point on, so set the size appropriately // and set irp's status to success. // TraceLog((CdromDebugWarning, "CdromFakePartitionInfo: incoming ioctl %x\n", ioctl)); Irp->IoStatus.Status = STATUS_SUCCESS; switch (ioctl) { case IOCTL_DISK_GET_DRIVE_LAYOUT: Irp->IoStatus.Information = FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION, PartitionEntry[1]); RtlZeroMemory(systemBuffer, FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION, PartitionEntry[1])); break; case IOCTL_DISK_GET_DRIVE_LAYOUT_EX: Irp->IoStatus.Information = FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION_EX, PartitionEntry[1]); RtlZeroMemory(systemBuffer, FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION_EX, PartitionEntry[1])); break; case IOCTL_DISK_GET_PARTITION_INFO: Irp->IoStatus.Information = sizeof(PARTITION_INFORMATION); RtlZeroMemory(systemBuffer, sizeof(PARTITION_INFORMATION)); break; case IOCTL_DISK_GET_PARTITION_INFO_EX: Irp->IoStatus.Information = sizeof(PARTITION_INFORMATION_EX); RtlZeroMemory(systemBuffer, sizeof(PARTITION_INFORMATION_EX)); break; default: ASSERT(!"Invalid ioctl should not have reached this point\n"); break; } // // if we are getting the drive layout, then we need to start by // adding some of the non-partition stuff that says we have // exactly one partition available. // if (ioctl == IOCTL_DISK_GET_DRIVE_LAYOUT) { PDRIVE_LAYOUT_INFORMATION layout; layout = (PDRIVE_LAYOUT_INFORMATION)systemBuffer; layout->PartitionCount = 1; layout->Signature = 1; systemBuffer = (PVOID)(layout->PartitionEntry); ioctl = IOCTL_DISK_GET_PARTITION_INFO; } else if (ioctl == IOCTL_DISK_GET_DRIVE_LAYOUT_EX) { PDRIVE_LAYOUT_INFORMATION_EX layoutEx; layoutEx = (PDRIVE_LAYOUT_INFORMATION_EX)systemBuffer; layoutEx->PartitionStyle = PARTITION_STYLE_MBR; layoutEx->PartitionCount = 1; layoutEx->Mbr.Signature = 1; systemBuffer = (PVOID)(layoutEx->PartitionEntry); ioctl = IOCTL_DISK_GET_PARTITION_INFO_EX; } // // NOTE: the local var 'ioctl' is now modified to either EX or // non-EX version. the local var 'systemBuffer' is now pointing // to the partition information structure. // if (ioctl == IOCTL_DISK_GET_PARTITION_INFO) { PPARTITION_INFORMATION partitionInfo; partitionInfo = (PPARTITION_INFORMATION)systemBuffer; partitionInfo->RewritePartition = FALSE; partitionInfo->RecognizedPartition = TRUE; partitionInfo->PartitionType = PARTITION_FAT32; partitionInfo->BootIndicator = FALSE; partitionInfo->HiddenSectors = 0; partitionInfo->StartingOffset.QuadPart = 0; partitionInfo->PartitionLength = CommonExtension->PartitionLength; partitionInfo->PartitionNumber = 0; } else { PPARTITION_INFORMATION_EX partitionInfo; partitionInfo = (PPARTITION_INFORMATION_EX)systemBuffer; partitionInfo->PartitionStyle = PARTITION_STYLE_MBR; partitionInfo->RewritePartition = FALSE; partitionInfo->Mbr.RecognizedPartition = TRUE; partitionInfo->Mbr.PartitionType = PARTITION_FAT32; partitionInfo->Mbr.BootIndicator = FALSE; partitionInfo->Mbr.HiddenSectors = 0; partitionInfo->StartingOffset.QuadPart = 0; partitionInfo->PartitionLength = CommonExtension->PartitionLength; partitionInfo->PartitionNumber = 0; } TraceLog((CdromDebugWarning, "CdromFakePartitionInfo: finishing ioctl %x\n", currentIrpStack->Parameters.DeviceIoControl.IoControlCode)); // // complete the irp // CdRomCompleteIrpAndStartNextPacketSafely(CommonExtension->DeviceObject, Irp); return; }