FltDeleteContext function (fltkernel.h)

FltDeleteContext marks a specified context for deletion.

Syntax

VOID FLTAPI FltDeleteContext(
  [in] PFLT_CONTEXT Context
);

Parameters

[in] Context

A pointer to the context to delete. This parameter is required and cannot be NULL.

Return value

None.

Remarks

For more information about contexts, see About minifilter contexts.

Because contexts are reference-counted, it is not usually necessary for a minifilter driver to call a routine, such as FltDeleteContext, to explicitly delete a context.

FltDeleteContext marks a context for deletion. The context is usually freed as soon as the current reference on it is released, unless there is an outstanding reference on it (for example, because the context is still being used by another thread).

You should consider the following items when you use FltDeleteContext:

  • When a minifilter driver calls FltDeleteContext, the minifilter driver must already have a reference to the context. However, when the minifilter driver calls FltDeleteStreamHandleContext, FltDeleteStreamContext, FltDeleteInstanceContext, and so on, the minifilter driver does not require a reference to the context. After the minifilter driver calls FltDeleteContext, that reference to the context is still valid. The minifilter driver must call the FltReleaseContext routine to release the reference to the context.

  • FltDeleteContext removes the context from the internal filter manager structures. Then, further calls to functions that get contexts, such as FltGetContexts and FltGetInstanceContext, cannot locate that context. However, the context memory is not released until the reference count for the context goes to 0.

Contexts can also be deleted by calling the appropriate delete-context routine from the following table.

Context Type Delete-Context Routine
FLT_FILE_CONTEXT FltDeleteFileContext (Windows Vista and later only.)
FLT_INSTANCE_CONTEXT FltDeleteInstanceContext
FLT_SECTION_CONTEXT FltCloseSectionForDataScan (Windows 8 and later only.)
FLT_STREAM_CONTEXT FltDeleteStreamContext
FLT_STREAMHANDLE_CONTEXT FltDeleteStreamHandleContext
FLT_TRANSACTION_CONTEXT FltDeleteTransactionContext (Windows Vista and later only.)
FLT_VOLUME_CONTEXT FltDeleteVolumeContext

To allocate a new context, call FltAllocateContext.

To increment the reference count on a context, call FltReferenceContext.

To decrement the reference count on a context, call FltReleaseContext.

A section context, FLT_SECTION_CONTEXT type, must not be deleted using FltDeleteContext. Instead, use FltReleaseContext to deallocate a section context.

Requirements

Requirement Value
Target Platform Universal
Header fltkernel.h (include Fltkernel.h)
Library FltMgr.lib
DLL Fltmgr.sys
IRQL <= APC_LEVEL

See also

FltAllocateContext

FltCloseSectionForDataScan

FltDeleteFileContext

FltDeleteInstanceContext

FltDeleteStreamContext

FltDeleteStreamHandleContext

FltDeleteTransactionContext

FltDeleteVolumeContext

FltReferenceContext

FltReleaseContext