On Wed Mar 19 12:58:50 2025 +0000, Rémi Bernon wrote:
@vibhavp FWIW I added a FIXME in DBT_DEVICEREMOVECOMPLETE, for the CM_NOTIFY_ACTION_DEVICEREMOVECOMPLETE case because it looks like we're not doing exactly the right event sequence, and CM_NOTIFY_ACTION_DEVICEREMOVECOMPLETE is missing in the last test? I'm not sure if both CM_NOTIFY_ACTION_DEVICEINTERFACEREMOVAL and CM_NOTIFY_ACTION_DEVICEREMOVECOMPLETE should be generated from DBT_DEVICEREMOVECOMPLETE or if there's separate notifications, maybe worth investigating.
Thank you!
I'm not sure if both CM_NOTIFY_ACTION_DEVICEINTERFACEREMOVAL and CM_NOTIFY_ACTION_DEVICEREMOVECOMPLETE should be generated from DBT_DEVICEREMOVECOMPLETE or if there's separate notifications, maybe worth investigating.
`CM_NOTIFY_ACTION_DEVICEREMOVECOMPLETE` is only generated for `CM_NOTIFY_FILTER_TYPE_DEVICEHANDLE` filters, so we would have to first implement broadcasting `DBT_DEVICEREMOVECOMPLETE` events for device objects (I believe there's a TODO in the `hotplug.c` tests for this as well?).
Microsoft documents [in this example ](https://learn.microsoft.com/en-us/windows/win32/devio/processing-a-request-t... `DBT_DEVICEREMOVECOMPLETE` events are sent for `DBT_DEVTYP_HANDLE` event as well, so once we do support them, we could add a simple check to `devnotify_callback` to set the action to `CM_NOTIFY_ACTION_DEVICEREMOVECOMPLETE` if when `flags == DBT_DEVICEREMOVECOMPLETE && dbch_devicetype == DBT_DEVTYP_HANDLE`.
A quick look at the code suggests that we could possibly do this in `IoDeleteDevice`?