On Thu Aug 29 23:38:23 2024 +0000, Vibhav Pant wrote:
@zfigura Testing it is tricky. My plan was to utilize it in the bluetooth driver by directly calling `plugplay_send_event` from the driver code itself, and I'm not sure what the equivalent of that would be in Windows. @rbernon I'm okay with using reserved as an offset to pass the device path, but we'd still have to pass it for every message for filtering. I didn't want to utilize `reserved` mostly out of caution, if it ever turned out to be that the field did have some undocumented semantics after all.
After doing a bit of research, I believe the Windows interface is IoReportTargetDeviceChange(). See [1], which mentions using that function to report the device notification, and that user mode should register for it with RegisterDeviceNotification().
That function is probably only used for DBT_DEVTYP_HANDLE. I suspect there is no public interface for DBT_DEVTYP_DEVICEINTERFACE. The corresponding kernel-mode identifier for that one is EventCategoryDeviceInterfaceChange, but I suspect that IoReportTargetDeviceChange() only deals with EventCategoryTargetDeviceChange. This would make sense since device interface notifications should only be generated by the kernel anyway.
[I have no idea about the other DBT_DEVTYPE_* values. Are they even ever sent in NT?]
[1] https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/using-pnp-...