Search code examples
windowsdriverkmdf

Updating KMDF Driver Without Windows Restart


I recently wrote a KMDF Driver in windows using Visual Studios. I then proceeded to locally install the driver whilst in TestMode (e.g., devcon install driver.inf hwid). Cool so the driver is running, and I can see the driver Callbacks firing in Dbgview.exe.

But now I have a bug in my driver. So I write some code, build the new driver, and now I want to restart it. So I attempt to use devcon to update to my new driver. However, upon doing so devcon reminds me that I need to perform a system restart in order for the change to take effect. This is really painful for debugging a new version of the driver (Please don't suggest using a VM/Remote target machine , I'm not interested in this solution).

Is there anyway to update the driver without restarting Windows?

Note, i can see that there is a "Driver Service" running for my driver but I'm unable to stop it. I wonder if this service is preventing me from updating my driver.


Solution

  • Since you install your driver via DevCon using the INF file, the driver is a PnP one. Unlike legacy drivers, PnP drivers cannot be stopped directly. You need to disable all devices controlled by the driver, and PnP Manager will unload the driver automatically.

    To disable a device, you can use the appropriate DevCon command, or do it in Device Manager.