Board index » cppbuilder » IOCTL_STORAGE_QUERY_PROPERTY, IDE drives and vendor/product ID
Kris
![]() CBuilder Developer |
IOCTL_STORAGE_QUERY_PROPERTY, IDE drives and vendor/product ID2006-01-26 11:46:17 PM cppbuilder95 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 IOCTL_STORAGE_QUERY_PROPERTY (STORAGE_DEVICE_DESCRIPTOR, STORAGE_PROPERTY_QUERY) to get the necessary information. According to the documentation everything I need should be here : msdn.microsoft.com/library/default.asp typedef struct _STORAGE_DEVICE_DESCRIPTOR { ULONG Version; ULONG Size; UCHAR DeviceType; UCHAR DeviceTypeModifier; BOOLEAN RemovableMedia; BOOLEAN CommandQueueing; ULONG VendorIdOffset; ULONG ProductIdOffset; ULONG ProductRevisionOffset; ULONG SerialNumberOffset; STORAGE_BUS_TYPE BusType; ULONG RawPropertiesLength; UCHAR RawDeviceProperties[1]; } At first glance this works nicely. However, as it turns out there's a big problem with IDE devices : DevicePath=\\?\ide#cdromhl-dt-st_dvd-rom_gdr8163b_______________0l23____#5&3001a662&0&0.1.0#{53f56308-b6bf-11d0-94f2-00a0c91efb8b} Vendor =0=[] Product=76=[HL-DT-ST DVD-ROM GDR8163B] Rev. =102=[0L23] DevicePath=\\?\ide#cdromphilips_dvdr1640p_______________________p3.6____#5&7208d00&0&0.0.0#{53f56308-b6bf-11d0-94f2-00a0c91efb8b} Vendor =0=[] Product=76=[PHILIPS DVDR1640P] Rev. =94=[P3.6] DevicePath=\\?\usbstor#cdrom&ven_philips&prod_spd3200l1&rev_l5s3#012345600000&0#{53f56308-b6bf-11d0-94f2-00a0c91efb8b} 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 : \\?\ide#cdromphilips_dvdr1640p_______________________p3.6____#5&... \\?\usbstor#cdrom&ven_philips&prod_spd3200l1&rev_l5s3#0123456000... 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 ? |