VirtualBox

Changeset 80978 in vbox for trunk/src


Ignore:
Timestamp:
Sep 24, 2019 2:24:18 PM (5 years ago)
Author:
vboxsync
Message:

USB/win: Make USB device class/subclass/protocol matching optional since VBoxUSBMon may not be able to read them and reconstruct the values (see bugref:9479).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.cpp

    r80941 r80978  
    9595    /* true iff device is filtered with a one-shot filter */
    9696    bool fIsFilterOneShot;
     97    /* true if descriptors could not be read and only inferred from PnP Manager data */
     98    bool fInferredDesc;
    9799    /* The device state. If the non-owner session is requesting the state while the device is grabbed,
    98100     * the USBDEVICESTATE_USED_BY_HOST is returned. */
     
    341343    USBFilterSetNumExact(&DevFlt, USBFILTERIDX_PRODUCT_ID, pDevice->idProduct, true);
    342344    USBFilterSetNumExact(&DevFlt, USBFILTERIDX_DEVICE_REV, pDevice->bcdDevice, true);
    343     USBFilterSetNumExact(&DevFlt, USBFILTERIDX_DEVICE_CLASS, pDevice->bClass, true);
    344     USBFilterSetNumExact(&DevFlt, USBFILTERIDX_DEVICE_SUB_CLASS, pDevice->bSubClass, true);
    345     USBFilterSetNumExact(&DevFlt, USBFILTERIDX_DEVICE_PROTOCOL, pDevice->bProtocol, true);
    346345    USBFilterSetStringExact(&DevFlt, USBFILTERIDX_MANUFACTURER_STR, pDevice->szMfgName, true /*fMustBePresent*/, true /*fPurge*/);
    347346    USBFilterSetStringExact(&DevFlt, USBFILTERIDX_PRODUCT_STR, pDevice->szProduct, true /*fMustBePresent*/, true /*fPurge*/);
    348347    USBFilterSetStringExact(&DevFlt, USBFILTERIDX_SERIAL_NUMBER_STR, pDevice->szSerial, true /*fMustBePresent*/, true /*fPurge*/);
     348
     349    /* If device descriptor had to be inferred from PnP Manager data, the class/subclass/protocol may be wrong.
     350     * When Windows reports CompatibleIDs 'USB\Class_03&SubClass_00&Prot_00', the device descriptor might be
     351     * reporting class 3 (HID), *or* the device descriptor might be reporting class 0 (specified by interface)
     352     * and the device's interface reporting class 3. Ignore the class/subclass/protocol in such case, since
     353     * we are more or less guaranteed to rely on VID/PID anyway.
     354     * See @bugref{9479}.
     355     */
     356    if (pDevice->fInferredDesc)
     357    {
     358        LOG(("Device descriptor was not read, only inferred; ignoring class/subclass/protocol!"));
     359    }
     360    else
     361    {
     362        USBFilterSetNumExact(&DevFlt, USBFILTERIDX_DEVICE_CLASS, pDevice->bClass, true);
     363        USBFilterSetNumExact(&DevFlt, USBFILTERIDX_DEVICE_SUB_CLASS, pDevice->bSubClass, true);
     364        USBFilterSetNumExact(&DevFlt, USBFILTERIDX_DEVICE_PROTOCOL, pDevice->bProtocol, true);
     365    }
    349366
    350367    /* Run filters on the thing. */
     
    515532    do
    516533    {
     534        pDevice->fInferredDesc = false;
    517535        Status = VBoxUsbToolGetDescriptor(pDo, pDevDr, sizeof(*pDevDr), USB_DEVICE_DESCRIPTOR_TYPE, 0, 0, VBOXUSBMON_POPULATE_REQUEST_TIMEOUT_MS);
    518536        if (!NT_SUCCESS(Status))
     
    569587            pDevDr->bDeviceSubClass = sub;
    570588            pDevDr->bDeviceProtocol = prt;
     589
     590            /* The USB device class/subclass/protocol may not be accurate. We have to be careful when comparing
     591             * and not take mismatches too seriously.
     592             */
     593            pDevice->fInferredDesc = true;
    571594        }
    572595
     
    11051128    USBFilterSetMustBePresent(pFilter, USBFILTERIDX_PORT, false);
    11061129
     1130    /* We may not be able to reconstruct the class/subclass/protocol if we aren't able to
     1131     * read the device descriptor. Don't require these to be present. See also the fInferredDesc flag.
     1132     */
     1133    USBFilterSetMustBePresent(pFilter, USBFILTERIDX_DEVICE_CLASS, false);
     1134    USBFilterSetMustBePresent(pFilter, USBFILTERIDX_DEVICE_SUB_CLASS, false);
     1135    USBFilterSetMustBePresent(pFilter, USBFILTERIDX_DEVICE_PROTOCOL, false);
     1136
    11071137    uintptr_t uId = 0;
    11081138    VBOXUSBFLT_LOCK_ACQUIRE();
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette