The FltGetFileNameInformation routine returns name information for a file or directory.
NTSTATUS FltGetFileNameInformation( _In_ PFLT_CALLBACK_DATA CallbackData, _In_ FLT_FILE_NAME_OPTIONS NameOptions, _Out_ PFLT_FILE_NAME_INFORMATION *FileNameInformation );
- CallbackData [in]
A pointer to the callback data structure for the I/O operation (FLT_CALLBACK_DATA). This parameter is required and cannot be NULL.
- NameOptions [in]
FLT_FILE_NAME_OPTIONS value containing flags that specify the format of the name information to be returned, as well as the query method that the Filter Manager is to use. (Additional flags can be used by name provider minifilter drivers to specify name query options. For more information, see FLT_FILE_NAME_OPTIONS.) This parameter is required and cannot be NULL.
Following are the name format flag values. Only one of the following flags can be specified. (For an explanation of these formats, see FLT_FILE_NAME_INFORMATION.)
The FileNameInformation parameter receives the address of a structure containing the normalized name for the file.
The FileNameInformation parameter receives the address of a structure containing the name that was used when the file was opened.
The FileNameInformation parameter receives the address of a structure containing the short (8.3) name for the file. The short name consists of up to 8 characters, followed immediately by a period and up to 3 more characters. The short name for a file does not include the volume name, directory path, or stream name.
Not valid in the pre-create path.
Following are the query method flag values. Only one of the following flags can be specified.
If it is not currently safe to query the file system for the file name, FltGetFileNameInformation does nothing. Otherwise, FltGetFileNameInformation queries the Filter Manager's name cache for the file name information. If the name is not found in the cache, FltGetFileNameInformation queries the file system and caches the result.
FltGetFileNameInformation queries the Filter Manager's name cache for the file name information. FltGetFileNameInformation does not query the file system.
FltGetFileNameInformation queries the file system for the file name information. FltGetFileNameInformation does not query the Filter Manager's name cache, and does not cache the result of the file system query.
FltGetFileNameInformation queries the Filter Manager's name cache for the file name information. If the name is not found in the cache, and it is currently safe to do so, FltGetFileNameInformation queries the file system for the file name information and caches the result.
Name provider minifilters use the following flags to specify the properties of file name operations.
A name provider minifilter can use this flag to specify that a name query request should be redirected to itself (the name provider minifilter) rather than being satisfied by the name providers lower in the stack.
This flag denotes that the name retrieved from this query should not be cached. Name provider minifilters use this flag as they perform intermediate queries to generate a name.
A name provider minifilter can use this flag to specify that it is safe to query the name in the post-create path even if STATUS_REPARSE was returned. It is the caller's responsibility to ensure that the FileObject->FileName field was not changed. Do not use this flag with mount points or symbolic link reparse points.
This flag is available on Microsoft Windows Server 2003 SP1 and later. This flag is also available on Windows 2000 SP4 with Update Rollup 1 and later.
- FileNameInformation [out]
A pointer to a caller-allocated variable that receives the address of a system-allocated FLT_FILE_NAME_INFORMATION structure containing the file name information. FltGetFileNameInformation allocates this structure from paged pool. This parameter is required and cannot be NULL.
If the name information is successfully returned, FltGetFileNameInformation returns STATUS_SUCCESS. Otherwise, it returns an appropriate NTSTATUS value such as one of the following:
One of the following:
STATUS_FLT_INVALID_NAME_REQUEST is an error code.
FltGetFileNameInformation encountered a pool allocation failure. This is an error code.
One of the following:
STATUS_INVALID_PARAMETER is an error code.
The file name information is not found in the name cache and NameOptions includes FLT_FILE_NAME_QUERY_CACHE_ONLY.
The file name information is not found in the name cache when NameOptions includes FLT_FILE_NAME_QUERY_ALWAYS_ALLOW_CACHE_LOOKUP and the file name information cannot be queried from the file system.
An additional call to FltGetFileNameInformation with FLT_FILE_NAME_QUERY_FILESYSTEM_ONLY set in NameOptions may return the file name information.
If the user opened the file by file ID but does not have traverse privileges for the entire path, FltGetFileNameInformation fails with this return value.
STATUS_ACCESS_DENIED is an error code.
The file is a system file with all access denied.
FltGetFileNameInformation returns the requested name information for the file or directory that is represented by the file object that is the target of the I/O operation.
For a pre-create operation, if the CallbackData ->Iopb ->OperationFlags member contains the SL_OPEN_TARGET_DIRECTORY bitwise flag, FltGetFileNameInformation returns the name of the containing (parent) directory for the given file. This name is the actual path that the create operation opens.
To parse the contents of the FLT_FILE_NAME_INFORMATION structure returned by FltGetFileNameInformation, call FltParseFileNameInformation. (For more information about file name formats, see FLT_FILE_NAME_INFORMATION.)
After a successful call to FltGetFileNameInformation, the caller is responsible for releasing the pointer returned in the FileNameInformation parameter when the pointer is no longer needed. The caller does this by calling FltReleaseFileNameInformation.
The caller must not modify the contents of the structure returned in the FileNameInformation parameter because this structure is cached by the Filter Manager so that all minifilter drivers can use it.
If FltGetFileNameInformation is called in the preoperation callback routine for a create operation to retrieve the opened name, FltGetFileNameInformation succeeds even if the path to the file being opened does not exist on the volume. If FltGetFileNameInformation is called in the preoperation callback routine for a create operation to retrieve the normalized name, FltGetFileNameInformation succeeds even if the final component of the path to the file being opened does not exist on the volume.
In create, hard-link, and rename operations, file name tunneling can cause the final component in normalized file name information that a minifilter driver retrieves in a preoperation callback routine to be invalidated. If a minifilter driver retrieves normalized file name information in a preoperation callback (PFLT_PRE_OPERATION_CALLBACK) routine by calling a routine such as FltGetFileNameInformation, it must call FltGetTunneledName from its postoperation callback (PFLT_POST_OPERATION_CALLBACK) routine to retrieve the correct file name information for the file.
Prior to Windows 8, Filter Manager obtained the normalized name for a file or directory by collecting the name information for each component of the file path. This required multiple queries to the file system to compile the complete path. Starting with Windows 8, local file systems support the FileNormalizedNameInformation file information class and only a single query is necessary to obtain the normalized name. Remote file systems may not support the FileNormalizedNameInformation file information class. When this is the case, a query for each component of the file path is still required to assemble the normalized name. Under certain network conditions, a full name query can require a significant amount of time to complete.
For more information about normalized file name information, see FLT_FILE_NAME_INFORMATION.
Note File name tunneling affects only create, hard-link, and rename operations in this way. It does not affect other I/O operations, such as read and write.
The following paired operations can cause the file name name to be tunneled:
rename(name, newname)/rename(source, name)
For more information about file name tunneling, see Microsoft Knowledge Base Article 172190.