// fltkernel.h
NTSTATUS FLTAPI FltSetInstanceContext(
[in] PFLT_INSTANCE Instance,
[in] FLT_SET_CONTEXT_OPERATION Operation,
[in] PFLT_CONTEXT NewContext,
[out] PFLT_CONTEXT *OldContext
);
View the official Windows Driver Kit DDI reference
No description available.
FltSetInstanceContext sets a context for a minifilter driver instance.
Instance
[in]Opaque instance pointer for the instance.
Operation
[in]Flag specifying details of the operation to be performed. This parameter must be one of the following:
Flag | Meaning |
---|---|
FLT_SET_CONTEXT_REPLACE_IF_EXISTS | If a context is already set for the instance that the Instance parameter points to, FltSetInstanceContext will replace that context with the context specified in NewContext. Otherwise, it will set NewContext as the context for Instance. |
FLT_SET_CONTEXT_KEEP_IF_EXISTS | If a context is already set for this Instance, FltSetInstanceContext returns STATUS_FLT_CONTEXT_ALREADY_DEFINED, and does not replace the existing context or increment the reference count. If a context is not already set, the routine will set NewContext as the context for Instance and increment the reference count. |
NewContext
[in]Pointer to the new context to be set for the instance. This parameter is required and cannot be NULL.
OldContext
[out]Pointer to a caller-allocated variable that receives the address of the existing instance context, if one is already set. This parameter is optional and can be NULL. For more information about this parameter, see the following Remarks section.
FltSetInstanceContext returns STATUS_SUCCESS or an appropriate NTSTATUS value such as one of the following:
Return code | Description |
---|---|
STATUS_FLT_CONTEXT_ALREADY_DEFINED | If FLT_SET_CONTEXT_KEEP_IF_EXISTS was specified for the Operation parameter, this error code indicates that a context is already attached to the instance. Only one context can be attached to an instance. |
STATUS_FLT_CONTEXT_ALREADY_LINKED | The context pointed to by the NewContext parameter is already linked to an object. In other words, this error code indicates that NewContext is already in use due to a successful prior call of a FltSetXxxContext routine. |
STATUS_FLT_DELETING_OBJECT | The instance specified in the Instance parameter is being torn down. This is an error code. |
STATUS_INVALID_PARAMETER | An invalid parameter was passed. For example, the NewContext parameter does not point to a valid file context, or an invalid value was specified for the Operation parameter. This is an error code. |
For more information about contexts, see About minifilter contexts.
A minifilter driver calls FltSetInstanceContext to attach an instance context to a caller-owned minifilter driver instance or to remove or replace an existing instance context. A minifilter driver can attach only one context to an instance.
If FltSetInstanceContext succeeds:
Else if FltSetInstanceContext fails:
Regardless of success:
For more information, see Referencing Contexts.
For more information, see Setting Contexts, and Releasing Contexts:
To allocate a new context, call FltAllocateContext.
To get an instance context, call FltGetInstanceContext.
To delete an instance context, call FltDeleteInstanceContext or FltDeleteContext.