Supporting minifilter contexts
The filter manager provides support that allows minifilter drivers to associate contexts with objects to preserve state across I/O operations. Objects that can have contexts include files, volumes, instances, streams, stream handles, and transactions. See About minifilter contexts for minifilter implementation details.
Third-party file systems must use the FSRTL_ADVANCED_FCB_HEADER structure (instead of the FSRTL_COMMON_FCB_HEADER structure) to work properly with stream and stream handle contexts.
Contexts can be allocated from paged or nonpaged pool except for volume contexts, which must be allocated from nonpaged pool.
Contexts are freed automatically when all outstanding references have been released. If the minifilter driver defines a context cleanup callback routine, the filter manager calls the routine before the context is freed.
The filter manager takes care of deleting contexts when the associated object is deleted, when an instance is detached, and when the minifilter driver is unloaded.
Contexts are not supported for paging files or during the following operations:
Preoperation processing for create requests
Postoperation processing for close requests
Processing of IRP_MJ_NETWORK_QUERY_OPEN requests
See the CTX sample for an example of a minifilter driver that uses contexts.
Filter manager support routines for context management
The filter manager provides many support context support routines for minifilters:
Creating and registering contexts:
Setting contexts:
Querying contexts:
Getting and referencing contexts:
Releasing and deleting contexts: