Get file path in minifilter driver
Asked Answered
B

2

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.

Brusa answered 22/4, 2015 at 11:31 Comment(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 letterVentriloquism
N
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);
Nason answered 6/5, 2015 at 12:30 Comment(0)
K
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/

Kalman answered 23/4, 2015 at 6:47 Comment(2)
Its for kmdf and umdf drivers I want same thing for Minifilter driver can you please help.Brusa
FltGetVolumeGuidName - function that been used is part of minifilter. Source:msdn.microsoft.com/en-us/library/windows/hardware/…Kalman
N
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);
Nason answered 6/5, 2015 at 12:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.