Search code examples
windowskernelwdk

How to save state on service restart? Save data on DriverUnload and retrieve it in DriverEntry


In a kernel mode windows driver, how can I store data on somewhere on the OS in DriverUnload routine and retrieve the data on the DriverEntry?

What I want to do is keep some variables across service restarts (not on OS restarts but on service restarts). So I can compile & test my service quickly without configuring every time i reload it. (For development purposes only)


Solution

  • A typical approach is to store your values in the registry key specific to your driver in the Registry. When your DriverEntry runs, the registry path will be given to the function. For more information, here are some of the articles that should be useful to you: