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

Sept/Oct 2019 Issue of The NT Insider available


Download PDF here: http://insider.osr.com/2019/ntinsider_2019_01.pdf

It’s a particularly BIG issue, too: 40 pages of technical goodness, ranging from WDF to Minifilters. Check it out.
Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

When to call FsRtlEnterFileSystem/KeEnterCriticalRegion in minifilter ?

Sergey_PisarevSergey_Pisarev Member - All Emails Posts: 152

Hello !

I am reading MS avscan sample and noticed that they call FsRtlEnterFileSystem/KeEnterCriticalRegion not before ExAcquireResource***Lite. They call FsRtlEnterFileSystem/KeEnterCriticalRegion in context of PostCreate, PreCleanup and InstanceSetupCallback. My understanding was that in general we don’t need to call FsRtlEnterFileSystem/KeEnterCriticalRegion in minifilter. In filesystem we call FsRtlEnterFileSystem before acquiring file resources for thread to not became suspended.

So when should we care about thread suspension in minifilter ?

Comments

  • Koby_KahaneKoby_Kahane Member Posts: 10

    Entering a critical region is appropriate whenever suspension of the current thread could lead to deadlocks. In particular, when the current thread obtains a resource that could prevent another thread from making progress indefinitely. In avscan, the AvScan routine enters a critical region before initiating the scan because if the scan initiating thread is suspended, any other thread that tries to access the file being scanned will end up hanging indefinitely waiting for the scan to complete - but it never will.

    Generalizing this, a minifilter should enter a critical region whenever it obtains a resource (in the broad sense, not just an ERESOURCE) that, if it is suspended while holding it, will prevent other threads accessing the object the resource is related to from making progress indefinitely. In the file systems themselves, this applies to the file's main and paging I/O resources. In a minifilter, what this applies to depends on your goals and on your specific design.

  • Sergey_PisarevSergey_Pisarev Member - All Emails Posts: 152
    Thank you very much again Koby !
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
Writing WDF Drivers 21 Oct 2019 OSR Seminar Space & ONLINE
Internals & Software Drivers 18 Nov 2019 Dulles, VA
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Developing Minifilters 27 Apr 2020 OSR Seminar Space & ONLINE