My simple attempt at a GenerateFileName seems to get involved in
run-away recursion when I call:
status = FltGetDestinationFileNameInformation(…,
FLT_FILE_NAME_REQUEST_FROM_CURRENT_PROVIDER
| FLT_FILE_NAME_NORMALIZED
| FLT_FILE_NAME_QUERY_ALWAYS_ALLOW_CACHE_LOOKUP
…
on a the destination name of a file-rename using rename.exe
The backtrace is like this:
…
fltmgr!FltpCallOpenedFileNameHandler+0x4f
fltmgr!FltpCreateFileNameInformation+0x79
fltmgr!FltpGetFileNameInformation+0x31d
fltmgr!FltGetFileNameInformationUnsafe+0x59
wepcFilter!wepcGenerateFileName+0x5c
… and on and on
and double-fault (stack overlow?) during a debug statement at:
wepcFilter!wepcGenerateFileName+0x28
The function is shown below.
I’m surprised that it is the Unsafe variant that is being followed; but
perhaps during a rename IRP it’s not surprising. I’m puzzled why it is
not missing out my minifilter when it calls FltpCallOpenedFileNameHandler
NTSTATUS wepcGenerateFileName(
IN PFLT_INSTANCE Instance,
IN PFILE_OBJECT FileObject,
IN PFLT_CALLBACK_DATA CallbackData OPTIONAL,
IN FLT_FILE_NAME_OPTIONS NameOptions,
OUT PBOOLEAN CacheFileNameInformation,
OUT PFLT_NAME_CONTROL FileName
)
{
NTSTATUS status;
PFLT_FILE_NAME_INFORMATION FileNameInformation = NULL;
/*+0x28*/ wepcDebug(“********* GenerateFileName\n”);
//FltGetFileNameFormat()
if (CallbackData) {
status = FltGetFileNameInformation(CallbackData,
NameOptions, &FileNameInformation);
} else {
/*+0x5c*/ status = FltGetFileNameInformationUnsafe(FileObject,
Instance, NameOptions, &FileNameInformation);
}
if (! NT_SUCCESS(status)) return status;
CacheFileNameInformation = FALSE;
status = FltCheckAndGrowNameControl(FileName,
FileNameInformation->Name.Length);
if (! NT_SUCCESS(status)) return status;
RtlCopyUnicodeString(&FileName->Name, &FileNameInformation->Name);
wepcDebug(“NAME: %wZ\n”, &FileNameInformation->Name);
FltReleaseFileNameInformation(FileNameInformation);
return STATUS_SUCCESS;
}
The notes on: PFLT_GENERATE_FILE_NAME
http://msdn.microsoft.com/en-us/library/ms793795.aspx
say:
When this callback routine is invoked, the minifilter driver generates
its own file name information, based on the file system’s file name
information for the file. To get the file system’s file name
information for a file, call FltGetFileNameInformation,
FltGetFileNameInformationUnsafe, or
FltGetDestinationFileNameInformation.
I can’t easily call FltGetDestinationFileNameInformation because I can’t
tell if I’m being called for a destination filename anyway.