Hey.
Is there any sample that deomnstrates how to attach and detach a device correctly from a plug and play callback for EventCategoryDeviceInterfaceChange?
or just generally , when should I detach a device I attach in my callback?
currently I detach it on unload, and I cant reload my driver doing so (start service failed the system cannot find the file specefied) so I suspect it's something to do with the way I detach my driver
Well, hard to say what the issue is without having a snippet of the code. When are you calling IoUnregisterPlugPlayNotification? Note the IoRegisterPlugPlayNotification call adds a reference to your driver object, and your unload will not be called until the reference count drops to 0. Therefore, you shouldn’t place it in your unload. Regarding a sample, there’s PNPMON - 9780735618039_files/Samples/Chap6/PNPMON · master · examples / Programming the Microsoft Windows Driver Model 2nd Edition · GitLab