Lower filter, CDs being identified as ACPI

I’m seeing some very strange behavior in my lower filter driver in the storage stack. On some systems, optical drives are showing up as FILE_DEVICE_ACPI. Hard drives are fine, as are USB drives that I plug in. My filter sits directly beneath the disk class driver, and I’m not seeing any other filter drivers on the CD that would be changing anything.

Here is the relevant code, cleaned up a bit for readability:

NTSTATUS NtioAddDevice( IN PDRIVER_OBJECT driverObject, IN PDEVICE_OBJECT physDeviceObject )
{
NTSTATUS status;
IO_STATUS_BLOCK ioStatus;
PDEVICE_OBJECT hookDevice;
HookExtensionEntry *hookExtension;
KIRQL irql;

/* Create a filter device object for this device (partition). */
status = IoCreateDevice( driverObject,
(ULONG)sizeof(HookExtensionEntry),
(PUNICODE_STRING)NULL,
physDeviceObject->DeviceType,
0,
FALSE,
&hookDevice );

hookDevice->Flags |= physDeviceObject->Flags & ( DO_DIRECT_IO | DO_BUFFERED_IO );
hookExtension = (HookExtensionEntry *) hookDevice->DeviceExtension;
RtlZeroMemory( hookExtension, sizeof(HookExtensionEntry) );
hookExtension->targetDevice = IoAttachDeviceToDeviceStack( hookDevice, physDeviceObject );


}

At this point, targetDevice->DeviceType is 0x32 for optical drives. It is always 0x7 for disk drives, and when I build my filter as an upper filter, I always see optical drives as 0x2, as they should be.

Does anyone have any idea what the class driver may be doing to change the PDO? I’d think I needed to look at a different part of the PDO, except that it works perfectly for hard drives. Google has been no help at all, for a change.

Thanks for any insight,
Dennis

xxxxx@intel.com wrote:

I’m seeing some very strange behavior in my lower filter driver in the storage stack. On some systems, optical drives are showing up as FILE_DEVICE_ACPI. Hard drives are fine, as are USB drives that I plug in. My filter sits directly beneath the disk class driver, and I’m not seeing any other filter drivers on the CD that would be changing anything.

At this point, targetDevice->DeviceType is 0x32 for optical drives. It is always 0x7 for disk drives, and when I build my filter as an upper filter, I always see optical drives as 0x2, as they should be.

Does anyone have any idea what the class driver may be doing to change the PDO? I’d think I needed to look at a different part of the PDO, except that it works perfectly for hard drives. Google has been no help at all, for a change.

Well, isn’t this really just a case of “that’s the way it is?” There’s
certainly no rocket science to change the DeviceType in the PDO. All it
has to do is change the field.

It is amusing to note that 0x32 is the hex value of the ASCII ‘2’.
Perhaps this is a long-standing but innocent bug that the disk class
driver fixes.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.