ReactOS  0.4.14-dev-49-gfb4591c
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  {
196  &FilterData.Filter);
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 
247 cleanup:
248  if (!NT_SUCCESS(Status))
249  {
251  {
252  FltCloseCommunicationPort(FilterData.ServerPort);
253  }
254  if (FilterData.Filter)
255  {
257  }
258  }
259 
260  return Status;
261 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define FLT_PORT_ALL_ACCESS
Definition: fltkernel.h:836
#define FILE_ALL_ACCESS
Definition: nt_native.h:651
PFLT_PORT ServerPort
NTSTATUS NTAPI FltStartFiltering(_In_ PFLT_FILTER Filter)
Definition: Filter.c:377
NTSTATUS FLTAPI FltBuildDefaultSecurityDescriptor(_Outptr_ PSECURITY_DESCRIPTOR *SecurityDescriptor, _In_ ACCESS_MASK DesiredAccess)
Definition: Misc.c:27
_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:182
LONG NTSTATUS
Definition: precomp.h:26
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1062
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1435
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define KMTEST_DEVICE_DRIVER_PATH
Definition: kmt_public.h:34
WCHAR DeviceName[]
Definition: adapter.cpp:21
#define PRCB_BUILD_DEBUG
Definition: ketypes.h:242
int32_t INT
Definition: typedefs.h:56
PFLT_FILTER Filter
#define PAGED_CODE()
Definition: video.h:57
static void TestEntry(const ENTRY *pEntry)
BOOLEAN KmtIsCheckedBuild
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
static PFLT_DISCONNECT_NOTIFY FilterDisconnect
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
BOOLEAN KmtIsMultiProcessorBuild
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS NTAPI ObReferenceObjectByPointer(IN PVOID Object, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode)
Definition: obref.c:383
static LONG MaxConnections
VOID FLTAPI FltUnregisterFilter(_In_ PFLT_FILTER Filter)
Definition: Filter.c:319
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
* PFILE_OBJECT
Definition: iotypes.h:1955
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static PFLT_CONNECT_NOTIFY FilterConnect
static PDRIVER_OBJECT TestDriverObject
static const WCHAR L[]
Definition: oid.c:1250
UCHAR BuildType
Definition: ketypes.h:599
static PDEVICE_OBJECT KmtestDeviceObject
Status
Definition: gdiplustypes.h:24
static PFLT_MESSAGE_NOTIFY FilterMessage
FLT_REGISTRATION FilterRegistration
#define PRCB_BUILD_UNIPROCESSOR
Definition: ketypes.h:243
static FILTER_DATA FilterData
#define DPRINT1
Definition: precomp.h:8
VOID FLTAPI FltFreeSecurityDescriptor(_In_ PSECURITY_DESCRIPTOR SecurityDescriptor)
Definition: Misc.c:39
static OBJECT_ATTRIBUTES KmtestFileObject
NTSTATUS NTAPI FltRegisterFilter(_In_ PDRIVER_OBJECT DriverObject, _In_ const FLT_REGISTRATION *Registration, _Out_ PFLT_FILTER *RetFilter)
Definition: Filter.c:112
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
char * cleanup(char *str)
Definition: wpickclick.c:99
return STATUS_SUCCESS
Definition: btrfs.c:2966
PKMT_RESULTBUFFER ResultBuffer
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231

◆ 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),
358  &LengthReturned);
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,
382  SectorSize,
383  ReportedSectorSize,
384  &VolumeName);
385 
386  Status = TestInstanceSetup(FltObjects,
387  Flags,
388  VolumeDeviceType,
389  VolumeFilesystemType,
390  &VolumeName,
391  SectorSize,
392  ReportedSectorSize);
393 
394  /* The buffer was allocated by the IoMgr */
396  }
397  }
398  }
399 
400  return Status;
401 }
#define max(a, b)
Definition: svc.c:63
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE()
Definition: video.h:57
NTSTATUS NTAPI IoVolumeDeviceToDosName(IN PVOID VolumeDeviceObject, OUT PUNICODE_STRING DosName)
Definition: volume.c:1284
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
struct _FLT_VOLUME_PROPERTIES * PFLT_VOLUME_PROPERTIES
smooth NULL
Definition: ftsmooth.c:416
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ FILE_INFORMATION_CLASS _Out_opt_ PULONG LengthReturned
Definition: fltkernel.h:1306
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
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
unsigned char UCHAR
Definition: xmlstorage.h:181
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _Inout_opt_ PUNICODE_STRING VolumeName
Definition: fltkernel.h:1117
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS FLTAPI FltGetDiskDeviceObject(_In_ PFLT_VOLUME Volume, _Outptr_ PDEVICE_OBJECT *DiskDeviceObject)
Definition: Misc.c:48
_In_ ULONG SectorSize
Definition: halfuncs.h:291
return STATUS_SUCCESS
Definition: btrfs.c:2966
struct _FLT_VOLUME_PROPERTIES FLT_VOLUME_PROPERTIES
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define FLT_ASSERT(_e)
Definition: fltkernel.h:49
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)

◆ 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 {
550  UCHAR MajorFunction;
551  ULONG i;
552 
554  MajorFunction = Data->Iopb->MajorFunction;
555 
556  for (i = 0; i < CallbacksCount; i++)
557  {
558  if (MajorFunction == Callbacks[i].MajorFunction)
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
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
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
PFLT_POST_OPERATION_CALLBACK PostOperation
Definition: fltkernel.h:613
_Unreferenced_parameter_ PVOID * CompletionContext
Definition: cdprocs.h:1130
static ULONG CallbacksCount
unsigned char UCHAR
Definition: xmlstorage.h:181
Status
Definition: gdiplustypes.h:24
static PFLT_OPERATION_REGISTRATION Callbacks
unsigned int ULONG
Definition: retypes.h:1

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 {
521  UCHAR MajorFunction;
522  ULONG i;
523 
525  MajorFunction = Data->Iopb->MajorFunction;
526 
527  for (i = 0; i < CallbacksCount; i++)
528  {
529  if (MajorFunction == Callbacks[i].MajorFunction)
530  {
531  // Call their pre-callback
533  FltObjects,
535  }
536  }
537 
538  return Status;
539 }
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
enum _FLT_PREOP_CALLBACK_STATUS FLT_PREOP_CALLBACK_STATUS
_Unreferenced_parameter_ PVOID * CompletionContext
Definition: cdprocs.h:1130
static ULONG CallbacksCount
unsigned char UCHAR
Definition: xmlstorage.h:181
Status
Definition: gdiplustypes.h:24
static PFLT_OPERATION_REGISTRATION Callbacks
unsigned int ULONG
Definition: retypes.h:1
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 }
#define PAGED_CODE()
Definition: video.h:57
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
VOID TestQueryTeardown(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_QUERY_TEARDOWN_FLAGS Flags)
Definition: fltmgr_create.c:92
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ 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 }
PFLT_PORT ServerPort
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
PFLT_FILTER Filter
#define PAGED_CODE()
Definition: video.h:57
#define KMTEST_FILTER_POOL_TAG
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
VOID FLTAPI FltUnregisterFilter(_In_ PFLT_FILTER Filter)
Definition: Filter.c:319
static ULONG CallbacksCount
VOID TestFilterUnload(IN ULONG Flags)
Definition: fltmgr_create.c:79
static PFLT_OPERATION_REGISTRATION Callbacks
static FILTER_DATA FilterData
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ 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 STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IRP_MJ_MAXIMUM_FUNCTION
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
FLT_OPERATION_REGISTRATION_FLAGS Flags
Definition: fltkernel.h:611
#define KMTEST_FILTER_POOL_TAG
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
PFLT_POST_OPERATION_CALLBACK PostOperation
Definition: fltkernel.h:613
smooth NULL
Definition: ftsmooth.c:416
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)
FLT_PREOP_CALLBACK_STATUS FLTAPI FilterPreOperation(_Inout_ PFLT_CALLBACK_DATA Data, _In_ PCFLT_RELATED_OBJECTS FltObjects, _Outptr_result_maybenull_ PVOID *CompletionContext)
static ULONG CallbacksCount
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define STATUS_ALREADY_REGISTERED
Definition: ntstatus.h:951
static PFLT_OPERATION_REGISTRATION Callbacks
unsigned int ULONG
Definition: retypes.h:1
PFLT_PRE_OPERATION_CALLBACK PreOperation
Definition: fltkernel.h:612
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define IRP_MJ_OPERATION_END
Definition: fltkernel.h:79

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 }
static PFLT_DISCONNECT_NOTIFY FilterDisconnect
static LONG MaxConnections
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY DisconnectNotifyCallback
Definition: fltkernel.h:1873
static PFLT_CONNECT_NOTIFY FilterConnect
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY ConnectNotifyCallback
Definition: fltkernel.h:1873
static PFLT_MESSAGE_NOTIFY FilterMessage
return STATUS_SUCCESS
Definition: btrfs.c:2966
_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:1873

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);
492  return STATUS_NOT_IMPLEMENTED;
493 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
static PFLT_CONTEXT_REGISTRATION Contexts
LPFNPSPCALLBACK Callback
Definition: desk.c:111

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,
}
NTSTATUS FLTAPI FilterInstanceSetup(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_SETUP_FLAGS Flags, _In_ DEVICE_TYPE VolumeDeviceType, _In_ FLT_FILESYSTEM_TYPE VolumeFilesystemType)
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS FLTAPI FilterQueryTeardown(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_QUERY_TEARDOWN_FLAGS Flags)
#define FLT_REGISTRATION_VERSION
Definition: fltkernel.h:718
NTSTATUS FLTAPI FilterUnload(_In_ FLT_FILTER_UNLOAD_FLAGS Flags)
struct _FLT_REGISTRATION FLT_REGISTRATION

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 DriverEntry(), and KmtFilterRegisterComms().

◆ TestDriverObject

PDRIVER_OBJECT TestDriverObject
static

Definition at line 38 of file kmtest_fsminifilter.c.

Referenced by DriverEntry().