Getting Contexts

Once a minifilter driver has set a context for an object, it can get the context by calling one of the following get routines:

Every successful get routine increments the reference count on the context, requiring that the minifilter call FltReleaseContext when it no longer needs the context pointer.

In the following code example, taken from the SwapBuffers sample minifilter, the minifilter driver calls FltGetVolumeContext to get a volume context:

status = FltGetVolumeContext(
 FltObjects->Filter,    //Filter
 FltObjects->Volume,    //Volume
                &volCtx);              //Context
...
if (volCtx != NULL) {
 FltReleaseContext(volCtx);
}

If the call to FltGetVolumeContext is successful, the Context parameter receives the address of the caller's volume context. FltGetVolumeContext increments the reference count on the Context pointer. Thus, when this pointer is no longer needed, the minifilter driver must release it by calling FltReleaseContext.