Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results
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: https://www.osr.com/osr-learning-library/
So own file-system, and there is a bug in my code that I wish to fix. I mostly
test against Win10 and Win11.
The easiest example of the problem is if you download a file (for example with chrome),
the file is handed off to MsMpEng.exe for checking/scanning and does a bunch of operations
with my file system, but never reports back to chrome. Making the download appear stuck.
I'm going to assume I am doing something wrong, but it's a pretty big haystack.
I have compared FileSpy.exe traces with normal NTFS downloads, and my own file system.
I have exercised FileTest.exe to see if the operations it uses in the trace logs return different values.
Successful runs has MsMpEng.exe create ":Zone.Identifier" stream, but never tries for me, it it is
somewhere around here.
Ordinarily, I would just debug MsMpEng and see where it bails out, but it is protected. I get why, but
obviously it is frustrating. Not that I want to debug MsMpEng at all, I would rather have it tell me
what is wrong. I am guessing it does not have any verbose logs?
Are there other ways to get closer to MsMpEng, perhaps by issuing queries directly somehow, skipping the whole
chome aspect of my debugging (chrome has a lot of source lines and took quite a while to compile and to step through).
Anyone else wrestled with MsMpEng? Any tips?
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 | 16-20 October 2023 | Live, Online |
Developing Minifilters | 13-17 November 2023 | Live, Online |
Internals & Software Drivers | 4-8 Dec 2023 | Live, Online |
Writing WDF Drivers | 10-14 July 2023 | Live, Online |
Comments
Break in with the debugger during the hang. Then run:
!process 0 1f msmpeng.exe
And see what the threads are doing.
-scott
OSR
Too long to paste in here it seems:
https://pastebin.com/eF79Zps5
To my untrained eye, I liked my odds on thread
ffff800db3dd9080
I took another crack at it, dumping the stacks before, and after, and it seems this is the most likely stack:
and googling around for things I can look at, I found out the following
this "could" be HANDLE 1054 being passed into WaitForSingleObjectEx:
Assuming I held the debugger in the right direction, it would seem it is waiting for a PUSH_LOCK. I wonder then if the problem is
perhaps related to
IRP_MJ_LOCK_CONTROL
. That is the most obvious locking with filesystems?But could just be an internal lock released by something else too.
No, I don't think you're in the right direction...That thread is waiting on a Dispatcher Object (e.g. event, mutex, timer, semaphore, etc.) and the Lock field is just a lock protecting the object itself. If you look at the !thread output it will tell you which type of object the thread is waiting on. For example:
IRP_MJ_LOCK_CONTROL, otoh, is used for Byte Range Locking, which is something else entirely and isn't generally involved in deadlocks (conflicting operations fail immediately with STATUS_FILE_LOCK_CONFLICT instead of waiting).
-scott
OSR
Yeah, it never calls IRP_MJ_LOCK_CONTROL so I could rule that out pretty quickly.
I redid my IRP_MJ_READ, IRP_MJ_WRITE and IRP_MJ_CLEANUP completely, with focus on CcMgr
interaction, since there are so many special-case paths.
The good news I can now download files with browsers fine and MsMpEng.exe does not stop responding.
I am not entirely sure which part fixes it, but either way, I feel the interaction with CcMgr is more
correct, AND, it made the problem go away.