Skip to content

Commit db95b46

Browse files
author
Dmitry Fleytman
committed
FilterDevice: Fix recognition of HUB devices
Sometimes UsbDk cannot query device descriptors for USB hubs, in such cases it does not attach to theirs stack during parent bus relations processing. However, since UsbDk is registered as USB hub class filter, WDF will call its AddDevice callback anyway. In this case UsbDk should assume that it is dealing with a hub and assign its usual hub strategy. Signed-off-by: Dmitry Fleytman <[email protected]>
1 parent bb931ea commit db95b46

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

UsbDk/FilterDevice.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,18 @@ bool CUsbDkFilterDevice::CStrategist::SelectStrategy(PDEVICE_OBJECT DevObj)
580580
USB_DEVICE_DESCRIPTOR DevDescr;
581581
if (!m_Strategy->GetControlDevice()->GetDeviceDescriptor(ID, DevDescr))
582582
{
583-
TraceEvents(TRACE_LEVEL_ERROR, TRACE_FILTERDEVICE, "%!FUNC! Cannot query cached device descriptor");
584-
return false;
583+
// If there is no cached device descriptor then we did not
584+
// attach to this device stack during parent bus enumeration
585+
// (see CUsbDkHubFilterStrategy::RegisterNewChild).
586+
// In this case, the fact that WDF called our
587+
// EVT_WDF_DRIVER_DEVICE_ADD callback for this device means that
588+
// we are dealing with USB hub and WDF attached us to its stack
589+
// automatically because UsbDk is registered in PNP manager as
590+
// USB hubs filter
591+
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FILTERDEVICE, "%!FUNC! No cached device descriptor, assigning hub strategy");
592+
m_Strategy->Delete();
593+
m_Strategy = &m_HubStrategy;
594+
return true;
585595
}
586596

587597
// Device class is HUB -> Hub strategy

0 commit comments

Comments
 (0)