ReactOS 0.4.15-dev-7942-gd23573b
kmtest_fsminifilter.c File Reference
#include <ntifs.h>
#include <ndk/ketypes.h>
#include <fltkernel.h>
#include <kmt_test.h>
#include <debug.h>
#include <kmt_public.h>
Include dependency graph for kmtest_fsminifilter.c:

Go to the source code of this file.

Classes

struct  _FILTER_DATA
 

Macros

#define KMT_DEFINE_TEST_FUNCTIONS
 
#define NDEBUG
 
#define KMTEST_FILTER_POOL_TAG   'fTMK'
 

Typedefs

typedef struct _FILTER_DATA FILTER_DATA
 
typedef struct _FILTER_DATAPFILTER_DATA
 

Functions

DriverUnload

Driver cleanup funtion.

Parameters
FlagsFlags describing the unload request
NTSTATUS FLTAPI FilterUnload (_In_ FLT_FILTER_UNLOAD_FLAGS Flags)
 
FilterInstanceSetup

Volume attach routine

Parameters
FltObjectsFilter Object Pointers Pointer to an FLT_RELATED_OBJECTS structure that contains opaque pointers for the objects related to the current operation
FlagsBitmask of flags that indicate why the instance is being attached
VolumeDeviceTypeDevice type of the file system volume
VolumeFilesystemTypeFile system type of the volume
Returns
Status. Return STATUS_SUCCESS to attach or STATUS_FLT_DO_NOT_ATTACH to ignore
NTSTATUS FLTAPI FilterInstanceSetup (_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_SETUP_FLAGS Flags, _In_ DEVICE_TYPE VolumeDeviceType, _In_ FLT_FILESYSTEM_TYPE VolumeFilesystemType)
 
FilterQueryTeardown

Volume detatch routine

Parameters
FltObjectsFilter Object Pointers Pointer to an FLT_RELATED_OBJECTS structure that contains opaque pointers for the objects related to the current operation
FlagsFlag that indicates why the minifilter driver instance is being torn down
NTSTATUS FLTAPI FilterQueryTeardown (_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_QUERY_TEARDOWN_FLAGS Flags)
 
FLT_PREOP_CALLBACK_STATUS FLTAPI FilterPreOperation (_Inout_ PFLT_CALLBACK_DATA Data, _In_ PCFLT_RELATED_OBJECTS FltObjects, _Outptr_result_maybenull_ PVOID *CompletionContext)
 
FLT_POSTOP_CALLBACK_STATUS FLTAPI FilterPostOperation (_Inout_ PFLT_CALLBACK_DATA Data, _In_ PCFLT_RELATED_OBJECTS FltObjects, _In_opt_ PVOID CompletionContext, _In_ FLT_POST_OPERATION_FLAGS Flags)
 
NTSTATUS KmtFilterRegisterCallbacks (_In_ CONST FLT_OPERATION_REGISTRATION *OperationRegistration)
 
NTSTATUS KmtFilterRegisterContexts (_In_ PFLT_CONTEXT_REGISTRATION ContextRegistration, _In_ PVOID Callback)
 
NTSTATUS KmtFilterRegisterComms (_In_ PFLT_CONNECT_NOTIFY ConnectNotifyCallback, _In_ PFLT_DISCONNECT_NOTIFY DisconnectNotifyCallback, _In_opt_ PFLT_MESSAGE_NOTIFY MessageNotifyCallback, _In_ LONG MaxClientConnections)
 
DriverEntry

Driver entry point.

Parameters
DriverObjectDriver Object
RegistryPathDriver Registry Path
Returns
Status
NTSTATUS NTAPI DriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
 

Variables

DRIVER_INITIALIZE DriverEntry
 
static PDRIVER_OBJECT TestDriverObject
 
static PDEVICE_OBJECT KmtestDeviceObject
 
static FILTER_DATA FilterData
 
static PFLT_OPERATION_REGISTRATION Callbacks = NULL
 
static ULONG CallbacksCount = 0
 
static PFLT_CONTEXT_REGISTRATION Contexts = NULL
 
static PFLT_CONNECT_NOTIFY FilterConnect = NULL
 
static PFLT_DISCONNECT_NOTIFY FilterDisconnect = NULL
 
static PFLT_MESSAGE_NOTIFY FilterMessage = NULL
 
static LONG MaxConnections = 0
 
FLT_REGISTRATION FilterRegistration
 

Macro Definition Documentation

◆ KMT_DEFINE_TEST_FUNCTIONS

#define KMT_DEFINE_TEST_FUNCTIONS

Definition at line 13 of file kmtest_fsminifilter.c.

◆ KMTEST_FILTER_POOL_TAG

#define KMTEST_FILTER_POOL_TAG   'fTMK'

Definition at line 21 of file kmtest_fsminifilter.c.

◆ NDEBUG

#define NDEBUG

Definition at line 16 of file kmtest_fsminifilter.c.

Typedef Documentation

◆ FILTER_DATA

◆ PFILTER_DATA

Function Documentation

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( IN PDRIVER_OBJECT  DriverObject,
IN PUNICODE_STRING  RegistryPath 
)

Definition at line 130 of file kmtest_fsminifilter.c.

133{
138 WCHAR DeviceNameBuffer[128] = L"\\Device\\Kmtest-";
139 UNICODE_STRING KmtestDeviceName;
141 PKMT_DEVICE_EXTENSION KmtestDeviceExtension;
142 PCWSTR DeviceNameSuffix;
143 INT Flags = 0;
144 PKPRCB Prcb;
145
146 PAGED_CODE();
147 //__debugbreak();
148 DPRINT("DriverEntry\n");
149
151
152 Prcb = KeGetCurrentPrcb();
156
157 /* get the Kmtest device, so that we get a ResultBuffer pointer */
160
161 if (!NT_SUCCESS(Status))
162 {
163 DPRINT1("Failed to get Kmtest device object pointer\n");
164 goto cleanup;
165 }
166
168
169 if (!NT_SUCCESS(Status))
170 {
171 DPRINT1("Failed to reference Kmtest device object\n");
172 goto cleanup;
173 }
174
177 KmtestDeviceExtension = KmtestDeviceObject->DeviceExtension;
178 ResultBuffer = KmtestDeviceExtension->ResultBuffer;
179 DPRINT("KmtestDeviceObject: %p\n", (PVOID)KmtestDeviceObject);
180 DPRINT("KmtestDeviceExtension: %p\n", (PVOID)KmtestDeviceExtension);
181 DPRINT("Setting ResultBuffer: %p\n", (PVOID)ResultBuffer);
182
183
184 /* call TestEntry */
185 RtlInitUnicodeString(&DeviceName, DeviceNameBuffer);
186 DeviceName.MaximumLength = sizeof DeviceNameBuffer;
187 TestEntry(DriverObject, RegistryPath, &DeviceNameSuffix, &Flags);
188
189 RtlAppendUnicodeToString(&DeviceName, DeviceNameSuffix);
190
191 /* Register with the filter manager */
192 if (!(Flags & TESTENTRY_NO_REGISTER_FILTER))
193 {
197 if (!NT_SUCCESS(Status))
198 {
199 DPRINT1("Failed to register the filter driver %wZ\n", &DeviceName);
200 goto cleanup;
201 }
202 }
203
204 if (!(Flags & TESTENTRY_NO_CREATE_COMMS_PORT))
205 {
206 /* Create a security descriptor */
209 if (!NT_SUCCESS(Status))
210 {
211 goto cleanup;
212 }
213
214 /* Initialize the security descriptor object */
216 &DeviceName,
218 NULL,
220
221
222 /* Create the usermode communication port */
223 Status = FltCreateCommunicationPort(FilterData.Filter,
226 NULL,
231
232 /* Free the security descriptor */
234
235 if (!NT_SUCCESS(Status))
236 {
237 goto cleanup;
238 }
239 }
240
241 if (!(Flags & TESTENTRY_NO_START_FILTERING))
242 {
243 /* Start filtering the requests */
245 }
246
247cleanup:
248 if (!NT_SUCCESS(Status))
249 {
251 {
252 FltCloseCommunicationPort(FilterData.ServerPort);
253 }
254 if (FilterData.Filter)
255 {
257 }
258 }
259
260 return Status;
261}
#define PAGED_CODE()
NTSTATUS NTAPI FltStartFiltering(_In_ PFLT_FILTER Filter)
Definition: Filter.c:377
VOID FLTAPI FltUnregisterFilter(_In_ PFLT_FILTER Filter)
Definition: Filter.c:319
NTSTATUS NTAPI FltRegisterFilter(_In_ PDRIVER_OBJECT DriverObject, _In_ const FLT_REGISTRATION *Registration, _Out_ PFLT_FILTER *RetFilter)
Definition: Filter.c:112
NTSTATUS FLTAPI FltBuildDefaultSecurityDescriptor(_Outptr_ PSECURITY_DESCRIPTOR *SecurityDescriptor, _In_ ACCESS_MASK DesiredAccess)
Definition: Misc.c:27
VOID FLTAPI FltFreeSecurityDescriptor(_In_ PSECURITY_DESCRIPTOR SecurityDescriptor)
Definition: Misc.c:39
static void TestEntry(const ENTRY *pEntry)
static OBJECT_ATTRIBUTES KmtestFileObject
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static void cleanup(void)
Definition: main.c:1335
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
#define FLT_PORT_ALL_ACCESS
Definition: fltkernel.h:836
Status
Definition: gdiplustypes.h:25
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define KMTEST_DEVICE_DRIVER_PATH
Definition: kmt_public.h:34
PKMT_RESULTBUFFER ResultBuffer
BOOLEAN KmtIsCheckedBuild
BOOLEAN KmtIsMultiProcessorBuild
static PDEVICE_OBJECT KmtestDeviceObject
static PFLT_DISCONNECT_NOTIFY FilterDisconnect
static PFLT_MESSAGE_NOTIFY FilterMessage
FLT_REGISTRATION FilterRegistration
static LONG MaxConnections
static PFLT_CONNECT_NOTIFY FilterConnect
static FILTER_DATA FilterData
static PDRIVER_OBJECT TestDriverObject
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define KernelMode
Definition: asm.h:34
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1161
#define PRCB_BUILD_UNIPROCESSOR
Definition: ketypes.h:324
#define PRCB_BUILD_DEBUG
Definition: ketypes.h:323
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define FILE_ALL_ACCESS
Definition: nt_native.h:651
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1435
#define L(x)
Definition: ntvdm.h:50
NTSTATUS NTAPI ObReferenceObjectByPointer(IN PVOID Object, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode)
Definition: obref.c:381
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
PVOID DeviceExtension
Definition: env_spec_w32.h:418
PFLT_PORT ServerPort
PFLT_FILTER Filter
UCHAR BuildType
Definition: ketypes.h:683
const uint16_t * PCWSTR
Definition: typedefs.h:57
int32_t INT
Definition: typedefs.h:58
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH _In_opt_ PEPROCESS _In_opt_ PETHREAD _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
Definition: wsk.h:191
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
* PFILE_OBJECT
Definition: iotypes.h:1998
#define ObDereferenceObject
Definition: obfuncs.h:203
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ FilterInstanceSetup()

NTSTATUS FLTAPI FilterInstanceSetup ( _In_ PCFLT_RELATED_OBJECTS  FltObjects,
_In_ FLT_INSTANCE_SETUP_FLAGS  Flags,
_In_ DEVICE_TYPE  VolumeDeviceType,
_In_ FLT_FILESYSTEM_TYPE  VolumeFilesystemType 
)

Definition at line 328 of file kmtest_fsminifilter.c.

333{
334#if 0
335 UCHAR VolPropBuffer[sizeof(FLT_VOLUME_PROPERTIES) + 512];
336 PFLT_VOLUME_PROPERTIES VolumeProperties = (PFLT_VOLUME_PROPERTIES)VolPropBuffer;
337#endif
340 ULONG ReportedSectorSize = 0;
341 ULONG SectorSize = 0;
343
344 PAGED_CODE();
345
346 UNREFERENCED_PARAMETER(FltObjects);
348
349 if (!(Flags & TESTENTRY_NO_INSTANCE_SETUP))
350 {
352
353#if 0 // FltGetVolumeProperties is not yet implemented
354 /* Get the properties of this volume */
356 VolumeProperties,
357 sizeof(VolPropBuffer),
359 if (NT_SUCCESS(Status))
360 {
361 FLT_ASSERT((VolumeProperties->SectorSize == 0) || (VolumeProperties->SectorSize >= MIN_SECTOR_SIZE));
362 SectorSize = max(VolumeProperties->SectorSize, MIN_SECTOR_SIZE);
363 ReportedSectorSize = VolumeProperties->SectorSize;
364 }
365 else
366 {
367 DPRINT1("Failed to get the volume properties : 0x%X", Status);
368 return Status;
369 }
370#endif
371 /* Get the storage device object we want a name for */
372 Status = FltGetDiskDeviceObject(FltObjects->Volume, &DeviceObject);
373 if (NT_SUCCESS(Status))
374 {
375 /* Get the dos device name */
377 if (NT_SUCCESS(Status))
378 {
379 DPRINT("VolumeDeviceType %lu, VolumeFilesystemType %lu, Real SectSize=0x%04x, Reported SectSize=0x%04x, Name=\"%wZ\"",
380 VolumeDeviceType,
381 VolumeFilesystemType,
383 ReportedSectorSize,
384 &VolumeName);
385
386 Status = TestInstanceSetup(FltObjects,
387 Flags,
388 VolumeDeviceType,
389 VolumeFilesystemType,
390 &VolumeName,
392 ReportedSectorSize);
393
394 /* The buffer was allocated by the IoMgr */
396 }
397 }
398 }
399
400 return Status;
401}
NTSTATUS FLTAPI FltGetDiskDeviceObject(_In_ PFLT_VOLUME Volume, _Outptr_ PDEVICE_OBJECT *DiskDeviceObject)
Definition: Misc.c:48
NTSTATUS FLTAPI FltGetVolumeProperties(_In_ PFLT_VOLUME Volume, _Out_writes_bytes_to_opt_(VolumePropertiesLength, *LengthReturned) PFLT_VOLUME_PROPERTIES VolumeProperties, _In_ ULONG VolumePropertiesLength, _Out_ PULONG LengthReturned)
Definition: Volume.c:26
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
_Must_inspect_result_ _Inout_opt_ PUNICODE_STRING VolumeName
Definition: fltkernel.h:1117
struct _FLT_VOLUME_PROPERTIES * PFLT_VOLUME_PROPERTIES
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ FILE_INFORMATION_CLASS _Out_opt_ PULONG LengthReturned
Definition: fltkernel.h:1308
#define FLT_ASSERT(_e)
Definition: fltkernel.h:49
struct _FLT_VOLUME_PROPERTIES FLT_VOLUME_PROPERTIES
NTSTATUS TestInstanceSetup(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_SETUP_FLAGS Flags, _In_ DEVICE_TYPE VolumeDeviceType, _In_ FLT_FILESYSTEM_TYPE VolumeFilesystemType, _In_ PUNICODE_STRING VolumeName, _In_ ULONG SectorSize, _In_ ULONG ReportedSectorSize)
UNICODE_STRING Volume
Definition: fltkernel.h:1172
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
NTSTATUS NTAPI IoVolumeDeviceToDosName(IN PVOID VolumeDeviceObject, OUT PUNICODE_STRING DosName)
Definition: volume.c:1279
#define max(a, b)
Definition: svc.c:63
uint32_t ULONG
Definition: typedefs.h:59
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ ULONG SectorSize
Definition: halfuncs.h:291
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ FilterPostOperation()

FLT_POSTOP_CALLBACK_STATUS FLTAPI FilterPostOperation ( _Inout_ PFLT_CALLBACK_DATA  Data,
_In_ PCFLT_RELATED_OBJECTS  FltObjects,
_In_opt_ PVOID  CompletionContext,
_In_ FLT_POST_OPERATION_FLAGS  Flags 
)

Definition at line 543 of file kmtest_fsminifilter.c.

548{
551 ULONG i;
552
554 MajorFunction = Data->Iopb->MajorFunction;
555
556 for (i = 0; i < CallbacksCount; i++)
557 {
559 {
560 // Call their post-callback
562 FltObjects,
564 Flags);
565 }
566 }
567
568 return Status;
569}
enum _FLT_POSTOP_CALLBACK_STATUS FLT_POSTOP_CALLBACK_STATUS
@ FLT_POSTOP_FINISHED_PROCESSING
Definition: fltkernel.h:588
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static PFLT_OPERATION_REGISTRATION Callbacks
static ULONG CallbacksCount
PFLT_POST_OPERATION_CALLBACK PostOperation
Definition: fltkernel.h:613
_In_ UCHAR MajorFunction
Definition: wdfdevice.h:1697
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE _In_opt_ __drv_aliasesMem WDFCONTEXT CompletionContext
Definition: wdfrequest.h:898

Referenced by KmtFilterRegisterCallbacks().

◆ FilterPreOperation()

FLT_PREOP_CALLBACK_STATUS FLTAPI FilterPreOperation ( _Inout_ PFLT_CALLBACK_DATA  Data,
_In_ PCFLT_RELATED_OBJECTS  FltObjects,
_Outptr_result_maybenull_ PVOID CompletionContext 
)

Definition at line 515 of file kmtest_fsminifilter.c.

519{
522 ULONG i;
523
525 MajorFunction = Data->Iopb->MajorFunction;
526
527 for (i = 0; i < CallbacksCount; i++)
528 {
530 {
531 // Call their pre-callback
533 FltObjects,
535 }
536 }
537
538 return Status;
539}
enum _FLT_PREOP_CALLBACK_STATUS FLT_PREOP_CALLBACK_STATUS
@ FLT_PREOP_SUCCESS_NO_CALLBACK
Definition: fltkernel.h:574
PFLT_PRE_OPERATION_CALLBACK PreOperation
Definition: fltkernel.h:612

Referenced by KmtFilterRegisterCallbacks().

◆ FilterQueryTeardown()

NTSTATUS FLTAPI FilterQueryTeardown ( _In_ PCFLT_RELATED_OBJECTS  FltObjects,
_In_ FLT_INSTANCE_QUERY_TEARDOWN_FLAGS  Flags 
)

Definition at line 419 of file kmtest_fsminifilter.c.

422{
423 PAGED_CODE();
424
425 if (!(Flags & TESTENTRY_NO_QUERY_TEARDOWN))
426 {
427 TestQueryTeardown(FltObjects, Flags);
428 }
429
430 /* We always allow a volume to detach */
431 return STATUS_SUCCESS;
432}
VOID TestQueryTeardown(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_QUERY_TEARDOWN_FLAGS Flags)
Definition: fltmgr_create.c:92

◆ FilterUnload()

NTSTATUS FLTAPI FilterUnload ( _In_ FLT_FILTER_UNLOAD_FLAGS  Flags)

Definition at line 273 of file kmtest_fsminifilter.c.

275{
276 PAGED_CODE();
278 //__debugbreak();
279
280 DPRINT("DriverUnload\n");
281
283
284 /* Close the port and unregister the filter */
286 {
287 FltCloseCommunicationPort(FilterData.ServerPort);
289 }
290 if (FilterData.Filter)
291 {
294 }
295
296 if (Callbacks)
297 {
299 Callbacks = NULL;
300 CallbacksCount = 0;
301 }
302
303 return STATUS_SUCCESS;
304}
VOID TestFilterUnload(IN ULONG Flags)
Definition: fltmgr_create.c:79
#define KMTEST_FILTER_POOL_TAG
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109

◆ KmtFilterRegisterCallbacks()

NTSTATUS KmtFilterRegisterCallbacks ( _In_ CONST FLT_OPERATION_REGISTRATION OperationRegistration)

Definition at line 438 of file kmtest_fsminifilter.c.

440{
441 ULONG Count = 0;
442 ULONG i;
443
444 if (Callbacks)
445 {
447 }
448
449 /* Count how many IRPs being registered */
450 for (i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++)
451 {
452 if (OperationRegistration[i].MajorFunction == IRP_MJ_OPERATION_END)
453 break;
454 Count++;
455 }
456
457 /* Allocate enough pool to hold a copy of the array */
459 sizeof(FLT_OPERATION_REGISTRATION) * (Count + 1),
461 if (Callbacks == NULL)
462 {
464 }
465
466 /* Copy the array, but using our own pre/post callbacks */
467 for (i = 0; i < Count; i++)
468 {
469 Callbacks[i].MajorFunction = OperationRegistration[i].MajorFunction;
470 Callbacks[i].Flags = OperationRegistration[i].Flags;
473 }
474
475 /* Terminate the array */
477
478 /* Save the count of IRPs, not counting IRP_MJ_OPERATION_END last entry */
480
481 return STATUS_SUCCESS;
482}
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
#define IRP_MJ_OPERATION_END
Definition: fltkernel.h:79
FLT_PREOP_CALLBACK_STATUS FLTAPI FilterPreOperation(_Inout_ PFLT_CALLBACK_DATA Data, _In_ PCFLT_RELATED_OBJECTS FltObjects, _Outptr_result_maybenull_ PVOID *CompletionContext)
FLT_POSTOP_CALLBACK_STATUS FLTAPI FilterPostOperation(_Inout_ PFLT_CALLBACK_DATA Data, _In_ PCFLT_RELATED_OBJECTS FltObjects, _In_opt_ PVOID CompletionContext, _In_ FLT_POST_OPERATION_FLAGS Flags)
int Count
Definition: noreturn.cpp:7
#define STATUS_ALREADY_REGISTERED
Definition: ntstatus.h:1126
FLT_OPERATION_REGISTRATION_FLAGS Flags
Definition: fltkernel.h:611
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IRP_MJ_MAXIMUM_FUNCTION

Referenced by TestEntry().

◆ KmtFilterRegisterComms()

NTSTATUS KmtFilterRegisterComms ( _In_ PFLT_CONNECT_NOTIFY  ConnectNotifyCallback,
_In_ PFLT_DISCONNECT_NOTIFY  DisconnectNotifyCallback,
_In_opt_ PFLT_MESSAGE_NOTIFY  MessageNotifyCallback,
_In_ LONG  MaxClientConnections 
)

Definition at line 496 of file kmtest_fsminifilter.c.

501{
505 MaxConnections = MaxClientConnections;
506
507 return STATUS_SUCCESS;
508}
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY _In_opt_ PFLT_MESSAGE_NOTIFY MessageNotifyCallback
Definition: fltkernel.h:1877
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY ConnectNotifyCallback
Definition: fltkernel.h:1875
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY DisconnectNotifyCallback
Definition: fltkernel.h:1876

Referenced by TestEntry().

◆ KmtFilterRegisterContexts()

NTSTATUS KmtFilterRegisterContexts ( _In_ PFLT_CONTEXT_REGISTRATION  ContextRegistration,
_In_ PVOID  Callback 
)

Definition at line 485 of file kmtest_fsminifilter.c.

488{
489 UNREFERENCED_PARAMETER(ContextRegistration);
493}
static PFLT_CONTEXT_REGISTRATION Contexts
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:458

Variable Documentation

◆ Callbacks

◆ CallbacksCount

ULONG CallbacksCount = 0
static

◆ Contexts

PFLT_CONTEXT_REGISTRATION Contexts = NULL
static

Definition at line 43 of file kmtest_fsminifilter.c.

Referenced by KmtFilterRegisterContexts().

◆ DriverEntry

DRIVER_INITIALIZE DriverEntry

Definition at line 35 of file kmtest_fsminifilter.c.

◆ FilterConnect

PFLT_CONNECT_NOTIFY FilterConnect = NULL
static

Definition at line 45 of file kmtest_fsminifilter.c.

Referenced by DriverEntry(), and KmtFilterRegisterComms().

◆ FilterData

FILTER_DATA FilterData
static

Definition at line 40 of file kmtest_fsminifilter.c.

Referenced by DriverEntry(), and FilterUnload().

◆ FilterDisconnect

PFLT_DISCONNECT_NOTIFY FilterDisconnect = NULL
static

Definition at line 46 of file kmtest_fsminifilter.c.

Referenced by DriverEntry(), and KmtFilterRegisterComms().

◆ FilterMessage

PFLT_MESSAGE_NOTIFY FilterMessage = NULL
static

Definition at line 47 of file kmtest_fsminifilter.c.

Referenced by DriverEntry(), and KmtFilterRegisterComms().

◆ FilterRegistration

FLT_REGISTRATION FilterRegistration
Initial value:
=
{
sizeof(FLT_REGISTRATION),
0,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
}
struct _FLT_REGISTRATION FLT_REGISTRATION
#define FLT_REGISTRATION_VERSION
Definition: fltkernel.h:718
NTSTATUS FLTAPI FilterInstanceSetup(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_SETUP_FLAGS Flags, _In_ DEVICE_TYPE VolumeDeviceType, _In_ FLT_FILESYSTEM_TYPE VolumeFilesystemType)
NTSTATUS FLTAPI FilterQueryTeardown(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_QUERY_TEARDOWN_FLAGS Flags)
NTSTATUS FLTAPI FilterUnload(_In_ FLT_FILTER_UNLOAD_FLAGS Flags)

Definition at line 91 of file kmtest_fsminifilter.c.

Referenced by DriverEntry().

◆ KmtestDeviceObject

PDEVICE_OBJECT KmtestDeviceObject
static

Definition at line 39 of file kmtest_fsminifilter.c.

Referenced by DriverEntry().

◆ MaxConnections

LONG MaxConnections = 0
static

Definition at line 48 of file kmtest_fsminifilter.c.

Referenced by _IRQL_requires_max_(), DriverEntry(), and KmtFilterRegisterComms().

◆ TestDriverObject

PDRIVER_OBJECT TestDriverObject
static

Definition at line 38 of file kmtest_fsminifilter.c.

Referenced by DriverEntry().