Article View: borland.public.cppbuilder.nativeapi
Article #4455IOCTL_STORAGE_QUERY_PROPERTY, IDE drives and vendor/product ID
From: Kris
Date: Thu, 26 Jan 2006 15:46
Date: Thu, 26 Jan 2006 15:46
75 lines
4229 bytes
4229 bytes
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 :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/Storage_r/hh/Storage_r/structs-general_3c393126-f5c8-47d8-bfb5-6127ce656e9a.xml.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 ?
Technical Details
Message-ID:
<terht110872tqm4f8q3b8rffep2es1684r@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,bb61b58bf81d0eb8,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: Kris <x.y@xyz.xx> Newsgroups: borland.public.cppbuilder.nativeapi Subject: IOCTL_STORAGE_QUERY_PROPERTY, IDE drives and vendor/product ID Date: Thu, 26 Jan 2006 16:46:17 +0100 Message-ID: <terht110872tqm4f8q3b8rffep2es1684r@4ax.com> X-Newsreader: Forte Free Agent 3.1/32.783 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 81.11.247.137 X-Trace: newsgroups.borland.com 1138290189 81.11.247.137 (26 Jan 2006 07:43:09 -0700) Lines: 75 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail