IOCTL_STORAGE_QUERY_PROPERTY, IDE drives and vendor/product ID

2006-01-26 11:46:17 PM
I require a device's Inquiry data (Vendor ID, Product ID, FW
revision). I accomplish this by enumerating all the devices (from the
GUID_DEVINTERFACE_CDROM class), get their devicepath and open a handle
to the device. Then I use DeviceIoControl's IOCTL_SCSI_PASS_THROUGH to
send the Inquiry CDB to the device to get all the information I need.
This all works just fine.
However, I also would like to implement an alternative method to be
used when the user does not have sufficient rights (and thus
IOCTL_SCSI_PASS_THROUGH fails) so that I can at least obtain the
Vendor/Product/Revision device information.
This is done by using CreateFile to get a READ-only handle for the
devicepath. Then I execute DeviceIoControl's
STORAGE_PROPERTY_QUERY) to get the necessary information. According to
the documentation everything I need should be here :
ULONG Version;
UCHAR DeviceType;
UCHAR DeviceTypeModifier;
BOOLEAN RemovableMedia;
BOOLEAN CommandQueueing;
ULONG VendorIdOffset;
ULONG ProductIdOffset;
ULONG ProductRevisionOffset;
ULONG SerialNumberOffset;
ULONG RawPropertiesLength;
UCHAR RawDeviceProperties[1];
At first glance this works nicely. However, as it turns out there's a
big problem with IDE devices :
Vendor =0=[]
Product=76=[HL-DT-ST DVD-ROM GDR8163B]
Rev. =102=[0L23]
Vendor =0=[]
Product=76=[PHILIPS DVDR1640P]
Rev. =94=[P3.6]
Vendor =72=[PHILIPS ]
Product=81=[SPD3200L1 ]
Rev. =98=[L5S3]
It works great for USB or SCSI devices, but when dealing with IDE
devices the VendorID becomes part of the ProductID. I've taken a look
at the raw hex dump of INQ return data and there's nothing wrong with
the actual INQ data ; it just happens with all IDE devices.
You can already predict this behaviour by looking at the DevicePath :
All devicepaths are nicely separated by &ven_, &prod_ and &rev_ but
NOT when dealing with IDE devices. And apparently this change in
devicepath notation is also carried to the output of
IOCTL_STORAGE_QUERY_PROPERTY. Furthermore, an extra space is also
added in the product field ([HL-DT-ST DVD-ROM GDR8163B] is actually
[HL-DT-ST] and [DVD-ROM GDR8163B] without an extra space).
Does anyone have any ideas on how to deal with this ? It is very
important that I know the exact content of all three fields.
Are there any other IOCTL-calls I can make to accurately obtain the
INQ information and which can also executed by a user with limited
rights ?