I’m not at all sure where the following problem exists - however, it appears
as if the Filter Manager function FltGetStreamContext() returns context data
that allegedly has been “freed”. I think it to be freed because my Context
Cleanup Callback has been invoked.
A quick outline of what is happening: In my PostCreate routine I call
FltGetStreamContext() to see if I am already tracking the stream. If it
fails, I allocate a new context and call FltSetStreamContext. If I get a
returned context, I increment its refcount (FltReferenceContext). In my
PostClose processing, I call FltReleaseContext(streamContext) for every
FileObject I am tracking (I am also creating StreamHandle Contexts for each
FileObject I am tracking). When my refcount on the stream goes to zero, I
see my ContextCleanupCallback invoked as expected. On the next PostCreate
call (same directory), FltGetStreamContext returns me the context I have
just reset! From the looks of it, the Filter Manager ref count is now 1 -
this should not be!
At first I saw crashes in FltGetStreamContext and I thought it was just a
simple race between CREATE and CLOSE processing of the contexts, so I added
some serialization around the FltGetStreamContext/context creation in CREATE
and the FltReleaseContext calls in CLOSE. This did stop the crashes in the
FltGetStreamContext. The only problem is the return of the “stale” context
that my driver believes has been freed!!!
Is this a known problem/deficiency in the Filter Manager or am I totally
incorrect in my attempt to track open contexts?
Need more info?
/ted