-
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
1520467
commit 9ac0357
Showing
9 changed files
with
191 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
#define PORT_NAME L"\\GilRanPort" | ||
#define PORT_BUFFER_SIZE 1024 | ||
|
||
typedef struct _PORT_REQUEST { | ||
HANDLE ProcessID; | ||
WCHAR VolumeName[PORT_BUFFER_SIZE]; | ||
WCHAR FilePath[PORT_BUFFER_SIZE]; | ||
} PORT_REQUEST, *PPORT_REQUEST; | ||
|
||
typedef struct _PORT_RESPONSE { | ||
BOOLEAN Access; | ||
} PORT_RESPONSE, *PPORT_RESPONSE; |
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,68 @@ | ||
#include <fltKernel.h> | ||
#include <dontuse.h> | ||
#include <suppress.h> | ||
|
||
#include "../Common/Common.h" | ||
#include "Port.h" | ||
|
||
PORT_INFORMATION PortInformation; | ||
|
||
NTSTATUS | ||
ClientConnect( | ||
_In_ PFLT_PORT ClientPort, | ||
_In_opt_ PVOID ServerPortCookie, | ||
_In_reads_bytes_opt_(SizeOfContext) PVOID ConnectionContext, | ||
_In_ ULONG SizeOfContext, | ||
_Outptr_result_maybenull_ PVOID *ConnectionCookie | ||
) | ||
{ | ||
UNREFERENCED_PARAMETER(ServerPortCookie); | ||
UNREFERENCED_PARAMETER(ConnectionContext); | ||
UNREFERENCED_PARAMETER(SizeOfContext); | ||
UNREFERENCED_PARAMETER(ConnectionCookie); | ||
|
||
FLT_ASSERT(PortInformation.ClientPort == NULL); | ||
FLT_ASSERT(PortInformation.UserProcess == NULL); | ||
|
||
PortInformation.UserProcess = PsGetCurrentProcess(); | ||
PortInformation.ClientPort = ClientPort; | ||
|
||
return STATUS_SUCCESS; | ||
} | ||
|
||
VOID | ||
ClientDisConnect( | ||
_In_opt_ PVOID ConnectionCookie | ||
) | ||
{ | ||
UNREFERENCED_PARAMETER(ConnectionCookie); | ||
|
||
PortInformation.UserProcess = NULL; | ||
FltCloseClientPort(PortInformation.Filter, &PortInformation.ClientPort); | ||
} | ||
|
||
NTSTATUS | ||
PortSendMessage( | ||
_In_ PPORT_REQUEST pPortRequest, | ||
_Out_ PBOOLEAN Access | ||
) | ||
{ | ||
ULONG szResponse = sizeof(FILTER_REPLY_HEADER) + sizeof(PORT_RESPONSE); | ||
PPORT_RESPONSE PortResponse = ExAllocatePoolWithTag(NonPagedPool, szResponse, 'vLIG'); | ||
|
||
if (PortResponse == NULL) return STATUS_UNSUCCESSFUL; | ||
|
||
NTSTATUS status = FltSendMessage( | ||
PortInformation.Filter, | ||
&PortInformation.ClientPort, | ||
pPortRequest, | ||
sizeof(PORT_REQUEST), | ||
&PortResponse, | ||
&szResponse, | ||
NULL | ||
); | ||
*Access = PortResponse->Access; | ||
|
||
ExFreePoolWithTag(PortResponse, '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,30 @@ | ||
#pragma once | ||
typedef struct _PORT_INFORMATION { | ||
PDRIVER_OBJECT DriverObject; | ||
PFLT_FILTER Filter; | ||
PFLT_PORT ServerPort; | ||
PEPROCESS UserProcess; | ||
PFLT_PORT ClientPort; | ||
} PORT_INFORMATION, *PPORT_INFORMATION; | ||
|
||
extern PORT_INFORMATION PortInformation; | ||
|
||
NTSTATUS | ||
ClientConnect( | ||
_In_ PFLT_PORT ClientPort, | ||
_In_opt_ PVOID ServerPortCookie, | ||
_In_reads_bytes_opt_(SizeOfContext) PVOID ConnectionContext, | ||
_In_ ULONG SizeOfContext, | ||
_Outptr_result_maybenull_ PVOID *connectionCookie | ||
); | ||
|
||
VOID | ||
ClientDisConnect( | ||
_In_opt_ PVOID ConnectionCookie | ||
); | ||
|
||
NTSTATUS | ||
PortSendMessage( | ||
_In_ PPORT_REQUEST pPortRequest, | ||
_Out_ PBOOLEAN Acces | ||
); |
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
#pragma once | ||
NTSTATUS GetFilePath( | ||
NTSTATUS | ||
GetFilePath( | ||
_In_ PFLT_CALLBACK_DATA Data, | ||
_Out_ PWCHAR pFilePath | ||
); | ||
|
||
NTSTATUS GetVolumeName( | ||
NTSTATUS | ||
GetVolumeName( | ||
_In_ PCFLT_RELATED_OBJECTS FltObjects, | ||
_Out_ PWCHAR pVolumeName | ||
); |