-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
GIL
committed
Sep 16, 2018
1 parent
49b9f7e
commit 1520467
Showing
6 changed files
with
87 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include <fltKernel.h> | ||
#include <dontuse.h> | ||
#include <suppress.h> | ||
#include <ntstrsafe.h> | ||
#include "Utils.h" | ||
|
||
NTSTATUS GetFilePath( | ||
_In_ PFLT_CALLBACK_DATA Data, | ||
_Out_ PWCHAR pFilePath | ||
) | ||
{ | ||
PFLT_FILE_NAME_INFORMATION pFileNameInformation; | ||
NTSTATUS status = FltGetFileNameInformation(Data, FLT_FILE_NAME_NORMALIZED | FLT_FILE_NAME_QUERY_DEFAULT, &pFileNameInformation); | ||
if (!NT_SUCCESS(status)) return status; | ||
|
||
status = FltParseFileNameInformation(pFileNameInformation); | ||
if (!NT_SUCCESS(status)) return status; | ||
|
||
wcscpy_s(pFilePath, pFileNameInformation->ParentDir.Length, pFileNameInformation->ParentDir.Buffer); | ||
|
||
FltReleaseFileNameInformation(pFileNameInformation); | ||
|
||
return STATUS_SUCCESS; | ||
} | ||
|
||
NTSTATUS GetVolumeName( | ||
_In_ PCFLT_RELATED_OBJECTS FltObjects, | ||
_Out_ PWCHAR pVolumeName | ||
) | ||
{ | ||
NTSTATUS status; | ||
|
||
UNICODE_STRING VolumeName; | ||
VolumeName.Length = 0; | ||
VolumeName.MaximumLength = FltObjects->FileObject->FileName.MaximumLength + 2; | ||
|
||
ULONG szBufferNeeded; | ||
status = FltGetVolumeName(FltObjects->Volume, NULL, &szBufferNeeded); | ||
|
||
if (status == STATUS_BUFFER_TOO_SMALL) { | ||
VolumeName.MaximumLength += (USHORT)szBufferNeeded; | ||
} | ||
|
||
VolumeName.Buffer = ExAllocatePoolWithTag(NonPagedPool, VolumeName.MaximumLength, 'vLIG'); | ||
if (VolumeName.Buffer == NULL) return STATUS_UNSUCCESSFUL; | ||
|
||
status = FltGetVolumeName(FltObjects->Volume, &VolumeName, &szBufferNeeded); | ||
if (NT_SUCCESS(status)) { | ||
wcscpy_s(pVolumeName, VolumeName.Length, VolumeName.Buffer); | ||
} | ||
|
||
ExFreePoolWithTag(VolumeName.Buffer, 'vLIG'); | ||
return status; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
NTSTATUS GetFilePath( | ||
_In_ PFLT_CALLBACK_DATA Data, | ||
_Out_ PWCHAR pFilePath | ||
); | ||
|
||
NTSTATUS GetVolumeName( | ||
_In_ PCFLT_RELATED_OBJECTS FltObjects, | ||
_Out_ PWCHAR pVolumeName | ||
); |