Index: class2.c =================================================================== --- drivers/storage/class/class2.c (revision 70282) +++ drivers/storage/class/class2.c (working copy) @@ -137,6 +137,7 @@ /* The following hack to assign drive letters with a non-PnP storage stack */ typedef struct _CLASS_DEVICE_INFO { + ULONG Signature; ULONG DeviceType; ULONG Partitions; ULONG DeviceNumber; @@ -346,19 +347,29 @@ IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { + PCLASS_DEVICE_INFO DeviceInfo = DeviceObject->DeviceExtension; + PDEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp); + NTSTATUS Status; if (IrpSp->MinorFunction == IRP_MN_START_DEVICE) { - IoSkipCurrentIrpStackLocation(Irp); - return STATUS_SUCCESS; + ASSERT(DeviceInfo->Signature == '2slc'); + if (!IoForwardIrpSynchronously(DeviceInfo->LowerDevice, Irp)) + { + Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; + } + Status = Irp->IoStatus.Status; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return Status; } else if (IrpSp->MinorFunction == IRP_MN_REMOVE_DEVICE) { - PCLASS_DEVICE_INFO DeviceInfo = DeviceObject->DeviceExtension; - + ASSERT(DeviceInfo->Signature == '2slc'); ScsiClassRemoveDriveLetter(DeviceInfo); + IoForwardIrpSynchronously(DeviceInfo->LowerDevice, Irp); + Irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest(Irp, IO_NO_INCREMENT); @@ -368,9 +379,11 @@ } else { - Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - return STATUS_NOT_SUPPORTED; + IoSkipCurrentIrpStackLocation(Irp); + if (DeviceInfo->Signature == '2slc') + return IoCallDriver(DeviceInfo->LowerDevice, Irp); + else + return IoCallDriver(DeviceExtension->PortDeviceObject, Irp); } } @@ -403,6 +416,7 @@ DeviceInfo = DeviceObject->DeviceExtension; RtlZeroMemory(DeviceInfo, sizeof(CLASS_DEVICE_INFO)); + DeviceInfo->Signature = '2slc'; /* Attach it to the PDO */ DeviceInfo->LowerDevice = IoAttachDeviceToDeviceStack(DeviceObject, PhysicalDeviceObject); @@ -628,7 +642,7 @@ // Invoke the device-specific routine, if one exists. Otherwise complete // with SUCCESS // - + ASSERT(*(PULONG)deviceExtension != '2slc'); if (deviceExtension->ClassCreateClose) { return deviceExtension->ClassCreateClose(DeviceObject, Irp); @@ -678,6 +692,7 @@ ULONG maximumTransferLength = deviceExtension->PortCapabilities->MaximumTransferLength; NTSTATUS status; + ASSERT(*(PULONG)deviceExtension != '2slc'); if (DeviceObject->Flags & DO_VERIFY_VOLUME && !(currentIrpStack->Flags & SL_OVERRIDE_VERIFY_VOLUME)) { @@ -1041,6 +1056,7 @@ SCSI_REQUEST_BLOCK srb; NTSTATUS status; + ASSERT(*(PULONG)deviceExtension != '2slc'); // // Allocate read capacity buffer from nonpaged pool. // @@ -1264,6 +1280,7 @@ PSCSI_REQUEST_BLOCK srb; KIRQL currentIrql; + ASSERT(*(PULONG)deviceExtension != '2slc'); // // Allocate context from nonpaged pool. // @@ -1409,6 +1426,7 @@ PCOMPLETION_CONTEXT context; PCDB cdb; + ASSERT(*(PULONG)deviceExtension != '2slc'); // // Allocate Srb from nonpaged pool. // @@ -1630,6 +1648,7 @@ ULONG i; PSCSI_REQUEST_BLOCK srb; + ASSERT(*(PULONG)deviceExtension != '2slc'); DebugPrint((2, "ScsiClassSplitRequest: Requires %d IRPs\n", irpCount)); DebugPrint((2, "ScsiClassSplitRequest: Original IRP %lx\n", Irp)); @@ -1817,6 +1836,7 @@ NTSTATUS status; BOOLEAN retry; + ASSERT(*(PULONG)deviceExtension != '2slc'); // // Check SRB status for success of completing request. // @@ -1969,6 +1989,7 @@ NTSTATUS status; BOOLEAN retry; + ASSERT(*(PULONG)deviceExtension != '2slc'); // // Check SRB status for success of completing request. // @@ -2190,6 +2211,7 @@ PAGED_CODE(); + ASSERT(*(PULONG)deviceExtension != '2slc'); dummy.QuadPart = 0; // @@ -2481,6 +2503,7 @@ ULONG i; #endif + ASSERT(*(PULONG)deviceExtension != '2slc'); // // Check that request sense buffer is valid. @@ -3161,6 +3184,7 @@ PIO_STACK_LOCATION nextIrpStack = IoGetNextIrpStackLocation(Irp); ULONG transferByteCount; + ASSERT(*(PULONG)deviceExtension != '2slc'); // // Determine the transfer count of the request. If this is a read or a // write then the transfer count is in the Irp stack. Otherwise assume @@ -3292,6 +3316,7 @@ ULONG logicalBlockAddress; USHORT transferBlocks; + ASSERT(*(PULONG)deviceExtension != '2slc'); // // Calculate relative sector address. // @@ -3511,6 +3536,7 @@ ULONG retries = 1; NTSTATUS status; + ASSERT(*(PULONG)deviceExtension != '2slc'); RtlZeroMemory(&srb, sizeof(SCSI_REQUEST_BLOCK)); // @@ -3687,6 +3713,7 @@ PAGED_CODE(); + ASSERT(*(PULONG)deviceExtension != '2slc'); // // Write length to SRB. // @@ -3860,6 +3887,7 @@ PDEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension; + ASSERT(*(PULONG)deviceExtension != '2slc'); // // Call the class specific driver DeviceControl routine. @@ -3909,6 +3937,7 @@ NTSTATUS status; ULONG modifiedIoControlCode; + ASSERT(*(PULONG)deviceExtension != '2slc'); if (irpStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_STORAGE_RESET_DEVICE) { @@ -4456,6 +4485,7 @@ { PDEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension; + ASSERT(*(PULONG)deviceExtension != '2slc'); if (deviceExtension->ClassShutdownFlush) { // @@ -4609,6 +4639,7 @@ PDEVICE_EXTENSION deviceExtension = deviceObject->DeviceExtension; + ASSERT(*(PULONG)deviceExtension != '2slc'); // // Fill in entry points // @@ -4781,7 +4812,7 @@ if (Release) { - ObDereferenceObject(PortDeviceObject); + //ObDereferenceObject(PortDeviceObject); return STATUS_SUCCESS; } @@ -4805,6 +4836,7 @@ return status; } + ObDereferenceObject(srb.DataBuffer); // // Return the new port device object pointer. @@ -4854,6 +4886,7 @@ PDEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension; PSCSI_REQUEST_BLOCK srb; + ASSERT(*(PULONG)deviceExtension != '2slc'); // // Get a pointer to the SRB. // @@ -5108,6 +5141,8 @@ deviceExtension->PhysicalDevice->DeviceExtension; PIRP originalIrp; + ASSERT(*(PULONG)deviceExtension != '2slc'); + ASSERT(*(PULONG)physicalExtension != '2slc'); originalIrp = irpStack->Parameters.Others.Argument1; //