NTSTATUS CUsbDkHubFilterStrategy::PNPPreProcess(PIRP Irp) { auto irpStack = IoGetCurrentIrpStackLocation(Irp); if ((irpStack->MinorFunction == IRP_MN_QUERY_DEVICE_RELATIONS) && (BusRelations == irpStack->Parameters.QueryDeviceRelations.Type)) { return PostProcessOnSuccess(Irp, [this](PIRP Irp) { CNonPagedDeviceRelations Relations; auto status = Relations.Create((PDEVICE_RELATIONS)Irp->IoStatus.Information); if (!NT_SUCCESS(status)) { TraceEvents(TRACE_LEVEL_ERROR, TRACE_FILTERDEVICE, "%!FUNC! Failed to create device relations object: %!STATUS!", status); return; } TraceEvents(TRACE_LEVEL_ERROR, TRACE_FILTERDEVICE, "%!FUNC! Starting relations array processing:"); Relations.Dump(); DropRemovedDevices(Relations); AddNewDevices(Relations); WipeHiddenDevices(Relations); TraceEvents(TRACE_LEVEL_ERROR, TRACE_FILTERDEVICE, "%!FUNC! Finished relations array processing"); }); } return CUsbDkFilterStrategy::PNPPreProcess(Irp); }
// This is called from the scan thread. Returns false if we failed to update the device list. bool USBHost::UpdateDevices(const bool always_add_hooks) { if (Core::WantsDeterminism()) return true; DeviceChangeHooks hooks; std::set<u64> plugged_devices; // If we failed to get a new, up-to-date list of devices, we cannot detect device removals. if (!AddNewDevices(plugged_devices, hooks, always_add_hooks)) return false; DetectRemovedDevices(plugged_devices, hooks); DispatchHooks(hooks); return true; }
NTSTATUS CUsbDkHubFilterStrategy::PNPPreProcess(PIRP Irp) { auto irpStack = IoGetCurrentIrpStackLocation(Irp); if ((irpStack->MinorFunction == IRP_MN_QUERY_DEVICE_RELATIONS) && (BusRelations == irpStack->Parameters.QueryDeviceRelations.Type)) { return PostProcessOnSuccess(Irp, [this](PIRP Irp) { CDeviceRelations Relations((PDEVICE_RELATIONS)Irp->IoStatus.Information); DropRemovedDevices(Relations); AddNewDevices(Relations); WipeHiddenDevices(Relations); }); } return CUsbDkFilterStrategy::PNPPreProcess(Irp); }