Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Drivers > Enumerating USB device

Reply
Thread Tools Display Modes

Enumerating USB device

 
 
Odomae
Guest
Posts: n/a

 
      11-27-2009
Hi,

I have a USB device that has 2 logical units.
USBSTOR\DISK&VEN_XXXX&PROD_YYYY&REV_0100\012345678 9990&0 (Drive A

USBSTOR\DISK&VEN_XXXX&PROD_YYYY&REV_0100\012345678 9990&1 (Drive B

I used SetupDiEnumDeviceInterfaces() func and I get just
one:USBSTOR\DISK&VEN_XXXX&PROD_YYYY&REV_0100\01234 56789990

I guess this is understandable since there is only one physical device.
However, is there a function that I can use to get both the drive letters?

I used the DEVINTERFACE_VOLUME GUID for the SetupDiEnumDeviceInterfaces()
function.
 
Reply With Quote
 
 
 
 
Maxim S. Shatskih
Guest
Posts: n/a

 
      11-27-2009
> I guess this is understandable since there is only one physical device.
> However, is there a function that I can use to get both the drive letters?


Enumerate all letters, call IOCTL_STORAGE_GET_DEVICE_NUMBER on each.

Open each USBSTOR's device, and call the same IOCTL on each.

Then match the results.

--
Maxim S. Shatskih
Windows DDK MVP

http://www.storagecraft.com

 
Reply With Quote
 
Odomae
Guest
Posts: n/a

 
      11-29-2009
Maxim,

I got the device numbers for the 2 logical units along with their volume IDs
using the method you mentioned.

With this drive, at startup only the first logical drive is visible. The
second one opens up only after successful authentication.
To figure out if the second drive opened up and is available, I would need
to match the device instance IDs of the 2 drive letters. I can't use the
volume ID since it is assigned by windows?
However, like I mentioned before, I am able to get only one instance ID
using the SetupDi function.

Also if multiple USB devices are plugged in, DeviceInstanceID is the only
way I can identify multiple instances of the same device present on the
system, right?

"Maxim S. Shatskih" wrote:

> > I guess this is understandable since there is only one physical device.
> > However, is there a function that I can use to get both the drive letters?

>
> Enumerate all letters, call IOCTL_STORAGE_GET_DEVICE_NUMBER on each.
>
> Open each USBSTOR's device, and call the same IOCTL on each.
>
> Then match the results.
>
> --
> Maxim S. Shatskih
> Windows DDK MVP
>
> http://www.storagecraft.com
>
> .
>

 
Reply With Quote
 
Maxim S. Shatskih
Guest
Posts: n/a

 
      11-29-2009
> To figure out if the second drive opened up and is available, I would need
> to match the device instance IDs


No need.

Just find your parent USB device using CM_xxx and SetupDiXxx, and enumerate its children. If there are 2 of them - then the secure device is authenticated and running. If there is only 1 - then it is not such.

--
Maxim S. Shatskih
Windows DDK MVP

http://www.storagecraft.com

 
Reply With Quote
 
Odomae
Guest
Posts: n/a

 
      11-29-2009
Thank you so much, Maxim. I got the 2 IDs using the Get_Child and Get_Sibling
calls as you suggested.

Appreciate the help.


"Maxim S. Shatskih" wrote:

> > To figure out if the second drive opened up and is available, I would need
> > to match the device instance IDs

>
> No need.
>
> Just find your parent USB device using CM_xxx and SetupDiXxx, and enumerate its children. If there are 2 of them - then the secure device is authenticated and running. If there is only 1 - then it is not such.
>
> --
> Maxim S. Shatskih
> Windows DDK MVP
>
> http://www.storagecraft.com
>
> .
>

 
Reply With Quote
 
Odomae
Guest
Posts: n/a

 
      11-30-2009
I enumerated all drive letters and got the corresponding volume names.

I then used the SetupDiXXX and CM_Get_XXX to find the parent and the children.
(This helps me find the 2 logical volumes - say E: and F. The volume names
are different for the 2 logical drives and so are the device numbers(they are
3 and 1 respectively).

However, when I do a GetVolumeNameForVolumeMountPoint() on the
pDevDetail->DevicePath(which I obtained using the SetupDiXXX function) for
the particular USB device, I get only the second volume name and hence the
second drive letter(F. ALthough I have both E: and F: to the original
enumerated list, I am not sure how I can use this to get the primary drive
letter?

I think the last few letters of the volume name are the same for both E: and
F:. Can I use that reliably to do a string compare and obtain the primary
drive letter (i.e E?





I am trying to tie t

"Odomae" wrote:

> Thank you so much, Maxim. I got the 2 IDs using the Get_Child and Get_Sibling
> calls as you suggested.
>
> Appreciate the help.
>
>
> "Maxim S. Shatskih" wrote:
>
> > > To figure out if the second drive opened up and is available, I would need
> > > to match the device instance IDs

> >
> > No need.
> >
> > Just find your parent USB device using CM_xxx and SetupDiXxx, and enumerate its children. If there are 2 of them - then the secure device is authenticated and running. If there is only 1 - then it is not such.
> >
> > --
> > Maxim S. Shatskih
> > Windows DDK MVP
> >
> > http://www.storagecraft.com
> >
> > .
> >

 
Reply With Quote
 
Maxim S. Shatskih
Guest
Posts: n/a

 
      11-30-2009
> However, when I do a GetVolumeNameForVolumeMountPoint() on the
> pDevDetail->DevicePath(which I obtained using the SetupDiXXX function)


I cannot understand why are you doing this. What is the purpose?

--
Maxim S. Shatskih
Windows DDK MVP

http://www.storagecraft.com

 
Reply With Quote
 
Uwe Sieber
Guest
Posts: n/a

 
      12-01-2009

GetVolumeNameForVolumeMountPoint returns FALSE for one
volume? For which one? What does GetLastError say?

Volume names using GUIDs, string compares are good for
finding identical ones only. Finding similar ones does
not work.

Uwe



Odomae wrote:
> I enumerated all drive letters and got the corresponding volume names.
>
> I then used the SetupDiXXX and CM_Get_XXX to find the parent and the children.
> (This helps me find the 2 logical volumes - say E: and F. The volume names
> are different for the 2 logical drives and so are the device numbers(they are
> 3 and 1 respectively).
>
> However, when I do a GetVolumeNameForVolumeMountPoint() on the
> pDevDetail->DevicePath(which I obtained using the SetupDiXXX function) for
> the particular USB device, I get only the second volume name and hence the
> second drive letter(F. ALthough I have both E: and F: to the original
> enumerated list, I am not sure how I can use this to get the primary drive
> letter?
>
> I think the last few letters of the volume name are the same for both E: and
> F:. Can I use that reliably to do a string compare and obtain the primary
> drive letter (i.e E?
>
>
>
>
>
> I am trying to tie t
>
> "Odomae" wrote:
>
>> Thank you so much, Maxim. I got the 2 IDs using the Get_Child and Get_Sibling
>> calls as you suggested.
>>
>> Appreciate the help.
>>
>>
>> "Maxim S. Shatskih" wrote:
>>
>>>> To figure out if the second drive opened up and is available, I would need
>>>> to match the device instance IDs
>>> No need.
>>>
>>> Just find your parent USB device using CM_xxx and SetupDiXxx, and enumerate its children. If there are 2 of them - then the secure device is authenticated and running. If there is only 1 - then it is not such.
>>>
>>> --
>>> Maxim S. Shatskih
>>> Windows DDK MVP
>>>
>>> http://www.storagecraft.com
>>>
>>> .
>>>

 
Reply With Quote
 
Odomae
Guest
Posts: n/a

 
      12-04-2009
Maxim, I am trying to get both drive letters because I need to send some
commands to the first drive (which is read only) and others to the second
one(which is a writeable partition)

Uwe, GetVolumeNameForVolumeMountPoint() returns false for the second
writeable drive partition. It returns the volume name correctly for the first
partition. I havent checked the GetLastError() code on the fail. I will check
and let you know.

"Uwe Sieber" wrote:

>
> GetVolumeNameForVolumeMountPoint returns FALSE for one
> volume? For which one? What does GetLastError say?
>
> Volume names using GUIDs, string compares are good for
> finding identical ones only. Finding similar ones does
> not work.
>
> Uwe
>
>
>
> Odomae wrote:
> > I enumerated all drive letters and got the corresponding volume names.
> >
> > I then used the SetupDiXXX and CM_Get_XXX to find the parent and the children.
> > (This helps me find the 2 logical volumes - say E: and F. The volume names
> > are different for the 2 logical drives and so are the device numbers(they are
> > 3 and 1 respectively).
> >
> > However, when I do a GetVolumeNameForVolumeMountPoint() on the
> > pDevDetail->DevicePath(which I obtained using the SetupDiXXX function) for
> > the particular USB device, I get only the second volume name and hence the
> > second drive letter(F. ALthough I have both E: and F: to the original
> > enumerated list, I am not sure how I can use this to get the primary drive
> > letter?
> >
> > I think the last few letters of the volume name are the same for both E: and
> > F:. Can I use that reliably to do a string compare and obtain the primary
> > drive letter (i.e E?
> >
> >
> >
> >
> >
> > I am trying to tie t
> >
> > "Odomae" wrote:
> >
> >> Thank you so much, Maxim. I got the 2 IDs using the Get_Child and Get_Sibling
> >> calls as you suggested.
> >>
> >> Appreciate the help.
> >>
> >>
> >> "Maxim S. Shatskih" wrote:
> >>
> >>>> To figure out if the second drive opened up and is available, I would need
> >>>> to match the device instance IDs
> >>> No need.
> >>>
> >>> Just find your parent USB device using CM_xxx and SetupDiXxx, and enumerate its children. If there are 2 of them - then the secure device is authenticated and running. If there is only 1 - then it is not such.
> >>>
> >>> --
> >>> Maxim S. Shatskih
> >>> Windows DDK MVP
> >>>
> >>> http://www.storagecraft.com
> >>>
> >>> .
> >>>

> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
My PnP Monitor is seen as Non PnP??? Colin Windows Vista Hardware 1 11-29-2007 06:01 PM
WMDC, Ipaq PPC2K3, Vista Jan, Philippe ActiveSync 8 06-28-2007 03:54 PM
Stop Error 0x0000007b Louis LeBrun Windows Vista Installation 17 07-05-2006 10:00 AM
Trouble with driver on Windows Vista Beta 2 sujatha Windows Vista Installation 0 06-08-2006 07:44 PM
Help !!! Unable to connecte Asus 620 Nick ActiveSync 4 05-24-2005 12:56 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59