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:

Issues detected related to IO_RemoveLock for IRP when Static Driver Verifier is run

mahendrashravanmahendrashravan Member Posts: 16

I am working on migrating the USB driver(written using WDM) from Windows 7 to Windows 10/11 operating systems.
In this process, while running Static Driver Verifier tool, it detected issues around RemoveLock for IRP's.
I am confused by the usage of RemoveLocks usage with PnPDispatch, DispatchIOCTL functions and with respect to PausedIOQueues.

Can someone provide some pointer in this regard.

When analyzed the defects, I figured that IoReleaseRemoveLock is releasing the lock irrespective of the tag provided when acquired. Is there any way to restrict of check the status of lock before releasing the lock?

Below are the list of SDV rules that are failed:


  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,828

    remove locks are used to synchronize I/O (and anything else) processing with the pnp remove request. It provides simple run down semantics so that all acquires are fully released before the remove request can be processed and completed. Acquire and release calls must be paired (obviously), a missing release or release without acquire results in a state where rundown will hang (waiting for the missing release) or occur too early (the missing acquire meant the remove was processed while there was pending activity). To aid in debugging both, you can pair an acquire and release with the same tag and when you release the tag without acquiring it first, it is an error. You can choose to use the same tag everywhere (NULL) and essentially forgo this check or use a locally unique tag to aid in creating a paper trail. !remlock will provide the list of acquires with their tag and a history of tags to also help you debug.

    PauseIOQueues is internal to your driver, there is no way for anyone to answer the question how remove locks are used in that context.

  • mahendrashravanmahendrashravan Member Posts: 16

    Thanks @Doron_Holan for your reply.

    As I mentioned in my query, irrespective of the lock acquired for a specific tag, IoReleaseRemoveLock with any tag is releasing it.
    May I know, the importance of tag here?

    Is there any equivalent synchronizing calls?

  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,828

    As I already told you the tag helps you debug. IIRC in a release build, mismatched tags for acquire and release are not checked. if you have mismatched tags with verifier turned on, it will assert when you release a tag that was not acquired.

    Is there any equivalent synchronizing calls?

    I have no idea what you are asking about.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

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!
Kernel Debugging 13-17 May 2024 Live, Online
Developing Minifilters 1-5 Apr 2024 Live, Online
Internals & Software Drivers 11-15 Mar 2024 Live, Online
Writing WDF Drivers 20-24 May 2024 Live, Online