6

I've used the code below but it is giving me an result of file path.

status = FltGetFileNameInformation(Data,
        FLT_FILE_NAME_OPENED |
        FLT_FILE_NAME_QUERY_ALWAYS_ALLOW_CACHE_LOOKUP,
        &nameInfo);
    DbgPrint("\n Filename : %wZ",&nameInfo->Name);
\Device\HarddiskVolume1\Users\filename.ext

But I want the file path as I

c:\Users\Filename.ext

How can I get this please help.

Alex K.
  • 171,639
  • 30
  • 264
  • 288
  • 1
    Probably a better way but FltParseFileNameInformation() to get the volume path, then a lookup from a list of the results of a call to querydosdevice() for each getlogicaldrivestrings() - remembering the path may not have a corresponding physical drive letter – Alex K. Apr 22 '15 at 11:49

2 Answers2

0

Here is the best solution, but its again not using Drive letter.But using Volume GUID

more : https://www.osr.com/nt-insider/2014-issue2/drive-letter-alternatives/

samjeba
  • 136
  • 5
  • Its for kmdf and umdf drivers I want same thing for Minifilter driver can you please help. –  Apr 23 '15 at 08:52
  • FltGetVolumeGuidName - function that been used is part of minifilter. Source:https://msdn.microsoft.com/en-us/library/windows/hardware/ff543230%28v=vs.85%29.aspx – samjeba Apr 23 '15 at 13:29
0
NameLength = (USHORT)dosName.MaximumLength + Data->Iopb->TargetFileObject->FileName.MaximumLength + 2;  
NameBuffer = ExAllocatePoolWithTag(PagedPool,NameLength,NC_MAPPING_TAG);
NameString.Length = 0;
NameString.MaximumLength = NameLength;
NameString.Buffer = NameBuffer;
RtlCopyUnicodeString(&NameString, &dosName);
RtlAppendUnicodeStringToString(&NameString, &Data->Iopb->TargetFileObject->FileName);
Guillaume Pascal
  • 845
  • 1
  • 9
  • 19