Referencing Contexts

The filter manager uses reference counting to manage the lifetime of a minifilter driver context. A reference count is a number indicating the state of a context. Whenever a context is created, the reference count of the context is initialized to one (this is called the initial reference to the context). Whenever a context is referenced by a system component, the reference count of the context is incremented by one. When a context is no longer needed, its reference count is decremented. A positive reference count means that the context is usable. When the reference count becomes zero, the context is unusable, and the filter manager eventually frees it.

The initial reference to the context is typically released when the object is torn down. However, if a minifilter driver must remove a context from an object, the minifilter driver must somehow release that initial reference to the context. To safely release that initial reference to the context, the minifilter driver calls FltDeleteContext.

A minifilter driver can add its own reference to a context by calling FltReferenceContext to increment the context's reference count. This added reference must eventually be removed by calling FltReleaseContext.

 

 

Send comments about this topic to Microsoft

Show:
© 2015 Microsoft