From: Uwe Sieber on
galapogos wrote:
> On May 10, 6:27 pm, Uwe Sieber <m...(a)uwe-sieber.de> wrote:
>> galapogos wrote:
>>> Hi,
>>> I'm wondering how I can scan the system for USB devices and read off
>>> the USB descriptors such as VID/PID/serial number in C? I have an
>>> external USB HDD that I wish to access, and I'm currently able to do
>>> so with DeviceIoControl by addressing it as PhysicalDriveX, which will
>>> return me information about the device, except it only does it for the
>>> attached fixed disk, rather than the USB device.
>> Use an SetupDi enumeration for DISKs, you find your drive by
>> its DeviceNumber. The USB device is the disk's parent device.
>>
>> I've shown this in a sample:http://www.codeproject.com/system/RemoveDriveByLetter.asp
>>
>> In the demo project there are some comment lines about
>> the USB serial.
>>
>> Greetings from Germany
>>
>> Uwe
>
> Hi Uwe,
> Thanks for the link. I'll try it out tomorrow, but I've taken a brief
> look at it. It seems to support volumes and disks. For my application,
> the drive will be a fixed disk in a USB enclosure, and it will be
> uninitialized/unpartitioned/unformatted. I'm accessing it RAW using
> ReadFile() and WriteFile(), so it will be accessed with "\\.
> \PhysicalDriveX" rather than "\\.\X:". Will that change anything? Or
> will it only eliminate the volume level(child of the disk)?

This saves the step to determine the device number
of the storage volume. Obviously you know the device
number, it's the X in "\\.\PhysicalDriveX".

On fixed disks the volume is not the child device of
the disk.


Uwe

From: CBFalconer on
galapogos wrote:
>
> I'm wondering how I can scan the system for USB devices and read
> off the USB descriptors such as VID/PID/serial number in C? I
> have an external USB HDD that I wish to access, and I'm currently
> able to do so with DeviceIoControl by addressing it as
> PhysicalDriveX, which will return me information about the device,
> except it only does it for the attached fixed disk, rather than
> the USB device.

I see no reference to USB in the C standard. So this is off-topic
in c.l.c. Follow-ups set.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net



--
Posted via a free Usenet account from http://www.teranews.com

From: galapogos on
On May 11, 12:27 am, Uwe Sieber <m...(a)uwe-sieber.de> wrote:
> galapogos wrote:
> > On May 10, 6:27 pm, Uwe Sieber <m...(a)uwe-sieber.de> wrote:
> >> galapogos wrote:
> >>> Hi,
> >>> I'm wondering how I can scan the system for USB devices and read off
> >>> the USB descriptors such as VID/PID/serial number in C? I have an
> >>> external USB HDD that I wish to access, and I'm currently able to do
> >>> so with DeviceIoControl by addressing it as PhysicalDriveX, which will
> >>> return me information about the device, except it only does it for the
> >>> attached fixed disk, rather than the USB device.
> >> Use an SetupDi enumeration for DISKs, you find your drive by
> >> its DeviceNumber. The USB device is the disk's parent device.
>
> >> I've shown this in a sample:http://www.codeproject.com/system/RemoveDriveByLetter.asp
>
> >> In the demo project there are some comment lines about
> >> the USB serial.
>
> >> Greetings from Germany
>
> >> Uwe
>
> > Hi Uwe,
> > Thanks for the link. I'll try it out tomorrow, but I've taken a brief
> > look at it. It seems to support volumes and disks. For my application,
> > the drive will be a fixed disk in a USB enclosure, and it will be
> > uninitialized/unpartitioned/unformatted. I'm accessing it RAW using
> > ReadFile() and WriteFile(), so it will be accessed with "\\.
> > \PhysicalDriveX" rather than "\\.\X:". Will that change anything? Or
> > will it only eliminate the volume level(child of the disk)?
>
> This saves the step to determine the device number
> of the storage volume. Obviously you know the device
> number, it's the X in "\\.\PhysicalDriveX".
>
> On fixed disks the volume is not the child device of
> the disk.
>
> Uwe

OK. I already have code that scans all storage devices and identifies
the device number, so the X is taken care of. Now I guess I just need
to identify the parent of the device X, which is the USB-IDE bridge,
and then obtain its USB descriptors(VID/PID/SN).

I just tried loading your project in VS7, and I'm having problem
building it. PPNP_VETO_TYPE in cfgmgr32.h is not recognized. Is there
some library I need to include? This is weird since cfgmgr32.h is from
MS.

From: galapogos on
On May 11, 9:05 am, galapogos <gois...(a)gmail.com> wrote:
> On May 11, 12:27 am, Uwe Sieber <m...(a)uwe-sieber.de> wrote:
>
>
>
> > galapogos wrote:
> > > On May 10, 6:27 pm, Uwe Sieber <m...(a)uwe-sieber.de> wrote:
> > >> galapogos wrote:
> > >>> Hi,
> > >>> I'm wondering how I can scan the system for USB devices and read off
> > >>> the USB descriptors such as VID/PID/serial number in C? I have an
> > >>> external USB HDD that I wish to access, and I'm currently able to do
> > >>> so with DeviceIoControl by addressing it as PhysicalDriveX, which will
> > >>> return me information about the device, except it only does it for the
> > >>> attached fixed disk, rather than the USB device.
> > >> Use an SetupDi enumeration for DISKs, you find your drive by
> > >> its DeviceNumber. The USB device is the disk's parent device.
>
> > >> I've shown this in a sample:http://www.codeproject.com/system/RemoveDriveByLetter.asp
>
> > >> In the demo project there are some comment lines about
> > >> the USB serial.
>
> > >> Greetings from Germany
>
> > >> Uwe
>
> > > Hi Uwe,
> > > Thanks for the link. I'll try it out tomorrow, but I've taken a brief
> > > look at it. It seems to support volumes and disks. For my application,
> > > the drive will be a fixed disk in a USB enclosure, and it will be
> > > uninitialized/unpartitioned/unformatted. I'm accessing it RAW using
> > > ReadFile() and WriteFile(), so it will be accessed with "\\.
> > > \PhysicalDriveX" rather than "\\.\X:". Will that change anything? Or
> > > will it only eliminate the volume level(child of the disk)?
>
> > This saves the step to determine the device number
> > of the storage volume. Obviously you know the device
> > number, it's the X in "\\.\PhysicalDriveX".
>
> > On fixed disks the volume is not the child device of
> > the disk.
>
> > Uwe
>
> OK. I already have code that scans all storage devices and identifies
> the device number, so the X is taken care of. Now I guess I just need
> to identify the parent of the device X, which is the USB-IDE bridge,
> and then obtain its USB descriptors(VID/PID/SN).
>
> I just tried loading your project in VS7, and I'm having problem
> building it. PPNP_VETO_TYPE in cfgmgr32.h is not recognized. Is there
> some library I need to include? This is weird since cfgmgr32.h is from
> MS.

OK I think I might have commented out the #include <cfg.h> line in
cfgmgr32.h earlier, which is causing the syntax error. However, when I
tried uncommenting it, I get the error that cfg.h is not found. Does
anyone know where I can find it?

From: galapogos on
On May 11, 12:27 am, Uwe Sieber <m...(a)uwe-sieber.de> wrote:
> galapogos wrote:
> > On May 10, 6:27 pm, Uwe Sieber <m...(a)uwe-sieber.de> wrote:
> >> galapogos wrote:
> >>> Hi,
> >>> I'm wondering how I can scan the system for USB devices and read off
> >>> the USB descriptors such as VID/PID/serial number in C? I have an
> >>> external USB HDD that I wish to access, and I'm currently able to do
> >>> so with DeviceIoControl by addressing it as PhysicalDriveX, which will
> >>> return me information about the device, except it only does it for the
> >>> attached fixed disk, rather than the USB device.
> >> Use an SetupDi enumeration for DISKs, you find your drive by
> >> its DeviceNumber. The USB device is the disk's parent device.
>
> >> I've shown this in a sample:http://www.codeproject.com/system/RemoveDriveByLetter.asp
>
> >> In the demo project there are some comment lines about
> >> the USB serial.
>
> >> Greetings from Germany
>
> >> Uwe
>
> > Hi Uwe,
> > Thanks for the link. I'll try it out tomorrow, but I've taken a brief
> > look at it. It seems to support volumes and disks. For my application,
> > the drive will be a fixed disk in a USB enclosure, and it will be
> > uninitialized/unpartitioned/unformatted. I'm accessing it RAW using
> > ReadFile() and WriteFile(), so it will be accessed with "\\.
> > \PhysicalDriveX" rather than "\\.\X:". Will that change anything? Or
> > will it only eliminate the volume level(child of the disk)?
>
> This saves the step to determine the device number
> of the storage volume. Obviously you know the device
> number, it's the X in "\\.\PhysicalDriveX".
>
> On fixed disks the volume is not the child device of
> the disk.
>
> Uwe

Hi again,

OK so I fixed the compile error and after a bit of coding, I'm able to
get the information of the USB bridge(parent of the disk) with a
CM_Get_Device_ID() call, and this includes the USB VID, PID and SN,
exactly what I need. It however stores them as a string in the format
"USB\VID_XXXX&PID_YYYY\ZZZZ", where XXXX is the VID, YYYY is the PID
and ZZZZ is the SN. Is there any function I can call to extract the 3
fields into separate buffers, or must I write the function myself?

Thanks!