Given a usb mounted storage volume path, how to find usb controlle

Discussion in 'Windows Vista Drivers' started by Eric Swenson, Oct 31, 2009.

  1. Eric Swenson

    Eric Swenson Guest

    For a given usb mounted volume, specified as a path (e.g. "e:\"), how do you
    determine which USB controller or USB device it is connected to? Looking at
    some old (no-longer-working) code, it appears you used to be able to call
    SetupDiEnumDeviceInterfaces with the GUID_DEVINTERFACE_VOLUME interface GUID,
    and then walk up the device tree with CM_Get_Parent and then retrieve the
    device id with CM_Get_Device_ID. However, now, with a storage volume, the
    parent device is ROOT\VOLMGR\0000 (or similar), and its parent device is
    HTREE\ROOT\0 (the root of the device tree). So, how do you figure out which
    USB device is associated with a mounted (USB) volume, starting from the
    volume path?
    Eric Swenson, Oct 31, 2009
    1. Advertisements

  2. Resolve volume to physical disk by using IOCTL_STORAGE_GET_DEVICE_NUMBER on disks and IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS on the volume.

    The numbers must match.

    Then use the CM_xxx trick on physical disk. Immediate parent is USBSTOR's FDO, on which you can try to call USB IOCTLs.
    Maxim S. Shatskih, Oct 31, 2009
    1. Advertisements

  3. Eric Swenson

    Uwe Sieber Guest

    Walking up the tree is still working for CDROM drives
    but since NT5 it never did for FIXED drives. Here the
    volume manager is involved and since Vista this is true
    for REMOVABLE drives too.
    Here I have shown the step from the volume to its disk:

    Uwe Sieber, Oct 31, 2009
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.