I am creating a mini-filter driver. As a part of functionality I need to
obtain the full file name and (surprise! surprise!) use
FltGetFileNameInformation() for this.
The problem is that on WinXPsp2 platform on a post-Cleanup stage
(FILE_OBJECT already has FO_CLEANUP_COMPLETE flag set) the call returns:
STATUS_FLT_NAME_CACHE_MISS error, if the query method flag is
FLT_FILE_NAME_QUERY_ALWAYS_ALLOW_CACHE_LOOKUP and
STATUS_FLT_INVALID_NAME_REQUEST error, if the query method flag is
FLT_FILE_NAME_QUERY_FILESYSTEM_ONLY.
The method returns the file information in other cases, like on
pre-Cleanup stage.
It looks like cleanup IRP “cleans up” the file name cache and it is
considered incorrect (at this time?) to call the file system.
Does anybody else see the same behavior?
If I “manually” issue a request to FS (FltAllocateCallbackData() -> set
IRP_MJ_QUERY_INFORMATION + FileNameInformation ->
FltPerformSynchronousIo() -> FltFreeCallbackData()) then I receive the file
name without any errors even if FILE_OBJECT already has FO_CLEANUP_COMPLETE
flag set.
Is it safe to use this procedure in case FltGetFileNameInformation()
fails?
Just for information. According to Windows Driver Kit documentation
(v5256) FltGetFileNameInformation() may return
STATUS_FLT_INVALID_NAME_REQUEST in the following conditions:
- FltGetFileNameInformation cannot get file name information if the
TopLevelIrp field of the current thread is not NULL, because the resulting
file system recursion could cause deadlocks or stack overflows. - FltGetFileNameInformation cannot get file name information in the
paging I/O path. - FltGetFileNameInformation cannot get file name information in the
post-close path. - FltGetFileNameInformation cannot get the short name of a file in the
pre-create path.
That’s OK, I check for these conditions before making the call.
Any help or suggestion will be greatly appreciated.