FltSetInstanceContext function

FltSetInstanceContext sets a context for a minifilter driver instance.

Syntax


NTSTATUS FltSetInstanceContext(
  _In_  PFLT_INSTANCE             Instance,
  _In_  FLT_SET_CONTEXT_OPERATION Operation,
  _In_  PFLT_CONTEXT              NewContext,
  _Out_ PFLT_CONTEXT              *OldContext
);

Parameters

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:

FLT_SET_CONTEXT_REPLACE_IF_EXISTS

If a context is already set for this Instance, replace it with NewContext. Otherwise, set NewContext as the context for Instance.

FLT_SET_CONTEXT_KEEP_IF_EXISTS

If a context is already set for this Instance, return STATUS_FLT_CONTEXT_ALREADY_DEFINED. Otherwise, set NewContext as the context for Instance.

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.)

Return value

FltSetInstanceContext returns STATUS_SUCCESS or an appropriate NTSTATUS value such as one of the following:

Return codeDescription
STATUS_FLT_CONTEXT_ALREADY_DEFINED

If FLT_SET_CONTEXT_KEEP_IF_EXISTS was specified for Operation, 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 an FltSetXxxContext routine.

STATUS_FLT_DELETING_OBJECT

The specified Instance is being torn down. This is an error code.

STATUS_INVALID_PARAMETER

One of the following:

  • The NewContext parameter does not point to a valid instance context.

  • An invalid value was specified for Operation.

 

Remarks

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.

A successful call to FltSetInstanceContext increments the reference count on NewContext. If FltSetInstanceContext fails, the reference count remains unchanged. In either case, the filter calling FltSetInstanceContext must call FltReleaseContext to decrement the NewContext object. If FltSetInstanceContext fails and if the OldContext parameter is not NULL and does not point to NULL_CONTEXT then OldContext is a referenced pointer to the context currently associated with the transaction. The filter calling FltSetInstanceContext must call FltReleaseContext for OldContext as well.

Note that the OldContext pointer returned by FltSetInstanceContext must also be released by calling FltReleaseContext when it is no longer needed. For more information, see Setting Contexts and Releasing Contexts.

To get an instance context, call FltGetInstanceContext.

To allocate a new context, call FltAllocateContext.

To delete an instance context, call FltDeleteInstanceContext or FltDeleteContext.

For more information about context reference counting, see Referencing Contexts.

Requirements

Target platform

Universal

Version

Available and supported in Microsoft Windows 2000 Update Rollup 1 for SP4, Windows XP SP2, Windows Server 2003 SP1, and later versions of the operating system. Not available nor supported on Windows 2000 SP4 and earlier operating systems.

Header

Fltkernel.h (include Fltkernel.h)

Library

FltMgr.lib

DLL

Fltmgr.sys

IRQL

<= APC_LEVEL

See also

FltAllocateContext
FltDeleteContext
FltDeleteInstanceContext
FltGetInstanceContext
FltReleaseContext

 

 

Send comments about this topic to Microsoft

Show: