FsRtlInsertPerFileContext function (ntifs.h)

The FsRtlInsertPerFileContext routine associates a FSRTL_PER_FILE_CONTEXT object with a driver-specified context object for a file.

Syntax

NTSTATUS FsRtlInsertPerFileContext(
  [in] PVOID                   *PerFileContextPointer,
  [in] PFSRTL_PER_FILE_CONTEXT Ptr
);

Parameters

[in] PerFileContextPointer

A pointer to an opaque pointer used by the file system runtime library (FSRTL) package to track file contexts. To retrieve this pointer from a file object, use the FsRtlGetPerFileContextPointer macro.

[in] Ptr

A pointer to the driver-specific context structure.

Return value

The FsRtlInsertPerFileContext routine returns STATUS_SUCCESS, or an appropriate error code, such as:

Return code Description
STATUS_INVALID_DEVICE_REQUEST
The underlying file system does not support filter file contexts. You can use the FsRtlSupportsPerFileContexts macro to check whether a file system supports per file context objects.
STATUS_INSUFFICIENT_RESOURCES
The system could not allocate resources (typically memory).

Remarks

The FsRtlGetPerFileContextPointer macro returns a FileContextSupportPointer for an open file.

Parameters

FileObject

FILE_OBJECT

A pointer to a file object.

Return value

PVOID

The FsRtlGetPerFileContextPointer macro returns an opaque pointer used by the file system runtime library (FSRTL) package to track file contexts. The macro returns NULL if the file system does not support the use of per-file context objects with files.

The FsRtlGetPerFileContextPointer macro returns the pointer to be passed to routines such as FsRtlInsertPerFileContext, FsRtlLookupPerFileContext, and FsRtlRemovePerFileContext.

For more information about how to use and create context objects, see Tracking Per-File Context in a Legacy File System Filter Driver.

Requirements

Requirement Value
Minimum supported client Windows Vista
Target Platform Universal
Header ntifs.h (include FltKernel.h, Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL <=APC_LEVEL

See also

FSRTL_PER_FILE_CONTEXT

FsRtlLookupPerFileContext

FsRtlRemovePerFileContext

Tracking Per-File Context in a Legacy File System Filter Driver