Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging

The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.

Check out The OSR Learning Library at:

how to persist an information in the driver

geeklostinwoodsgeeklostinwoods Member Posts: 4
edited December 2020 in NTDEV

I have a virtual hid driver that would talk to an application. Application would send some command say on or off. My driver needs to remember this state. later, if the application asks what state are you in , with a querydevice, my driver needs to reply with the last state. My driver is a dummy driver, it has no device or anything (forget this part, why the design is in this way, because we have a non hid serial device mapping which we have all is an another software solution).

either ways, my question is how can i persist this state, driver is stateless, in this case, what is the best way to solve the problem of storing this state somewhere.

I was thinking I could have another application that can be connected to the driver as well.

Application 1 sends a ON to the driver.
driver sends an output report to the Application 2.
Application 2 could save it
if Application 1 request for the state
driver now needs to request the state from Application 2 and get another input report
then pass it back to application 1.

but this is complicated and possible deadlocks / a lot of issues in this design..

why we need this -
application may send ON
later application wants to know if device is on or off
it may do a query to know if the device is on or off now
device needs to return the status of on / off.
but the virtual hid driver is dummy, it really doesnt have a device to store on / off or act on this . we just use the on / off signal to manipulate a serial device which works with our application

what is the simplest way to store and save states in the driver, assuming i have no hardware to store the state?


  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,551
    State persistence in the driver is not tied to physical hardware. Each pnp device stack has its own parameters key where you can store state, see WdfDeviceOpenRegistryKey and open the key with PLUGPLAY_REGKEY_DEVICE
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,760

    When you say "persist", do you actually mean "persist across reboots"? Or do you just need it to survive during the current session? If you don't need to survive reboots, then just store it in a global variable.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • geeklostinwoodsgeeklostinwoods Member Posts: 4

    not accross reboot

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 8,235

    not accross reboot

    You know: We don't charge you here based on the number of words in your posts.

    You might be amazed at how much taking the time to clearly describe to us what you want to know would help us assist you.


    Peter Viscarola

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 7 Dec 2020 LIVE ONLINE
Internals & Software Drivers 25 Jan 2021 LIVE ONLINE
Developing Minifilters 8 March 2021 LIVE ONLINE