[vbox-dev] USB filtering on Windows
Ivo at UFO-Net.nl
Sun Oct 13 13:35:55 UTC 2013
While looking into the VirtualBox USB filtering code for Windows, I
noticed that, even for manually attached USB devices, the filtering code
relies only on some properties of the USB device (vendor ID, product ID,
some other IDs and descriptors) to identify the device to filter. While
this is generally "good enough", it might filter the wrong device (if
the user connects multiple similar devices to the system, which is quite
likely in my usage scenario). So I went to look for a solution...
On the kernel side, there appears to be a
which would allow the filter driver to get an unique identification of
the USB controller and the path of hub ports to the device. This should
uniquely identify the device, as long as it is not unplugged.
On the user mode side, the PCI bus, device and function numbers can be
obtained from a query (SPDRP_BUSNUMBER and SPDRP_ADDRESS) against the
USB controller device node (which is available as the root of the USB
enumeration anyway), and the path of hub ports can be constructed as the
USB tree is enumerated.
This information can be stored in a filter structure in string format
Combined with Vid and Pid, this should provide sufficient information to
uniquely identify a USB device on a port before and after "virtual
replugging". Added bonus: it could be used to forward a specific host
USB port to a VM, regardless of what is plugged into that port.
Any technical reason why this is not yet implemented? Am I missing
something? If not, I'd better start working on it.
More information about the vbox-dev