13#define KMT_DEFINE_TEST_FUNCTIONS
21#define KMTEST_FILTER_POOL_TAG 'fTMK'
62 _In_ FLT_FILESYSTEM_TYPE VolumeFilesystemType
138 WCHAR DeviceNameBuffer[128] =
L"\\Device\\Kmtest-";
141 PKMT_DEVICE_EXTENSION KmtestDeviceExtension;
163 DPRINT1(
"Failed to get Kmtest device object pointer\n");
171 DPRINT1(
"Failed to reference Kmtest device object\n");
180 DPRINT(
"KmtestDeviceExtension: %p\n", (
PVOID)KmtestDeviceExtension);
186 DeviceName.MaximumLength =
sizeof DeviceNameBuffer;
192 if (!(
Flags & TESTENTRY_NO_REGISTER_FILTER))
204 if (!(
Flags & TESTENTRY_NO_CREATE_COMMS_PORT))
241 if (!(
Flags & TESTENTRY_NO_START_FILTERING))
332 _In_ FLT_FILESYSTEM_TYPE VolumeFilesystemType)
340 ULONG ReportedSectorSize = 0;
349 if (!(
Flags & TESTENTRY_NO_INSTANCE_SETUP))
357 sizeof(VolPropBuffer),
361 FLT_ASSERT((VolumeProperties->SectorSize == 0) || (VolumeProperties->SectorSize >= MIN_SECTOR_SIZE));
362 SectorSize =
max(VolumeProperties->SectorSize, MIN_SECTOR_SIZE);
363 ReportedSectorSize = VolumeProperties->SectorSize;
367 DPRINT1(
"Failed to get the volume properties : 0x%X",
Status);
379 DPRINT(
"VolumeDeviceType %lu, VolumeFilesystemType %lu, Real SectSize=0x%04x, Reported SectSize=0x%04x, Name=\"%wZ\"",
381 VolumeFilesystemType,
389 VolumeFilesystemType,
425 if (!(
Flags & TESTENTRY_NO_QUERY_TEARDOWN))
NTSTATUS NTAPI FltStartFiltering(_In_ PFLT_FILTER Filter)
VOID FLTAPI FltUnregisterFilter(_In_ PFLT_FILTER Filter)
NTSTATUS NTAPI FltRegisterFilter(_In_ PDRIVER_OBJECT DriverObject, _In_ const FLT_REGISTRATION *Registration, _Out_ PFLT_FILTER *RetFilter)
NTSTATUS FLTAPI FltBuildDefaultSecurityDescriptor(_Outptr_ PSECURITY_DESCRIPTOR *SecurityDescriptor, _In_ ACCESS_MASK DesiredAccess)
VOID FLTAPI FltFreeSecurityDescriptor(_In_ PSECURITY_DESCRIPTOR SecurityDescriptor)
NTSTATUS FLTAPI FltGetDiskDeviceObject(_In_ PFLT_VOLUME Volume, _Outptr_ PDEVICE_OBJECT *DiskDeviceObject)
static void TestEntry(const ENTRY *pEntry)
NTSTATUS FLTAPI FltGetVolumeProperties(_In_ PFLT_VOLUME Volume, _Out_writes_bytes_to_opt_(VolumePropertiesLength, *LengthReturned) PFLT_VOLUME_PROPERTIES VolumeProperties, _In_ ULONG VolumePropertiesLength, _Out_ PULONG LengthReturned)
static OBJECT_ATTRIBUTES KmtestFileObject
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define NT_SUCCESS(StatCode)
static void cleanup(void)
#define ExAllocatePoolWithTag(hernya, size, tag)
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
_Must_inspect_result_ _Inout_opt_ PUNICODE_STRING VolumeName
struct _FLT_REGISTRATION FLT_REGISTRATION
enum _FLT_POSTOP_CALLBACK_STATUS FLT_POSTOP_CALLBACK_STATUS
struct _FLT_VOLUME_PROPERTIES * PFLT_VOLUME_PROPERTIES
ULONG FLT_INSTANCE_SETUP_FLAGS
ULONG FLT_FILTER_UNLOAD_FLAGS
VOID(FLTAPI * PFLT_DISCONNECT_NOTIFY)(_In_opt_ PVOID ConnectionCookie)
enum _FLT_PREOP_CALLBACK_STATUS FLT_PREOP_CALLBACK_STATUS
@ FLT_PREOP_SUCCESS_NO_CALLBACK
@ FLT_POSTOP_FINISHED_PROCESSING
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ FILE_INFORMATION_CLASS _Out_opt_ PULONG LengthReturned
NTSTATUS(FLTAPI * PFLT_MESSAGE_NOTIFY)(_In_opt_ PVOID PortCookie, _In_reads_bytes_opt_(InputBufferLength) PVOID InputBuffer, _In_ ULONG InputBufferLength, _Out_writes_bytes_to_opt_(OutputBufferLength, *ReturnOutputBufferLength) PVOID OutputBuffer, _In_ ULONG OutputBufferLength, _Out_ PULONG ReturnOutputBufferLength)
_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
#define FLT_PORT_ALL_ACCESS
#define FLT_REGISTRATION_VERSION
struct _FLT_PORT * PFLT_PORT
NTSTATUS(FLTAPI * PFLT_CONNECT_NOTIFY)(_In_ PFLT_PORT ClientPort, _In_opt_ PVOID ServerPortCookie, _In_reads_bytes_opt_(SizeOfContext) PVOID ConnectionContext, _In_ ULONG SizeOfContext, _Outptr_result_maybenull_ PVOID *ConnectionPortCookie)
ULONG FLT_INSTANCE_QUERY_TEARDOWN_FLAGS
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY ConnectNotifyCallback
#define IRP_MJ_OPERATION_END
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY DisconnectNotifyCallback
ULONG FLT_POST_OPERATION_FLAGS
struct _FLT_VOLUME_PROPERTIES FLT_VOLUME_PROPERTIES
VOID TestQueryTeardown(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_QUERY_TEARDOWN_FLAGS Flags)
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)
VOID TestFilterUnload(IN ULONG Flags)
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
#define OBJ_KERNEL_HANDLE
#define OBJ_CASE_INSENSITIVE
#define KMTEST_DEVICE_DRIVER_PATH
PKMT_RESULTBUFFER ResultBuffer
BOOLEAN KmtIsCheckedBuild
BOOLEAN KmtIsMultiProcessorBuild
static PFLT_CONTEXT_REGISTRATION Contexts
static PDEVICE_OBJECT KmtestDeviceObject
NTSTATUS FLTAPI FilterInstanceSetup(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_SETUP_FLAGS Flags, _In_ DEVICE_TYPE VolumeDeviceType, _In_ FLT_FILESYSTEM_TYPE VolumeFilesystemType)
static PFLT_DISCONNECT_NOTIFY FilterDisconnect
FLT_PREOP_CALLBACK_STATUS FLTAPI FilterPreOperation(_Inout_ PFLT_CALLBACK_DATA Data, _In_ PCFLT_RELATED_OBJECTS FltObjects, _Outptr_result_maybenull_ PVOID *CompletionContext)
NTSTATUS KmtFilterRegisterCallbacks(_In_ CONST FLT_OPERATION_REGISTRATION *OperationRegistration)
static PFLT_MESSAGE_NOTIFY FilterMessage
NTSTATUS KmtFilterRegisterContexts(_In_ PFLT_CONTEXT_REGISTRATION ContextRegistration, _In_ PVOID Callback)
DRIVER_INITIALIZE DriverEntry
struct _FILTER_DATA * PFILTER_DATA
FLT_REGISTRATION FilterRegistration
static LONG MaxConnections
static PFLT_OPERATION_REGISTRATION Callbacks
static PFLT_CONNECT_NOTIFY FilterConnect
struct _FILTER_DATA FILTER_DATA
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 FLTAPI FilterQueryTeardown(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_QUERY_TEARDOWN_FLAGS Flags)
static FILTER_DATA FilterData
NTSTATUS KmtFilterRegisterComms(_In_ PFLT_CONNECT_NOTIFY ConnectNotifyCallback, _In_ PFLT_DISCONNECT_NOTIFY DisconnectNotifyCallback, _In_opt_ PFLT_MESSAGE_NOTIFY MessageNotifyCallback, _In_ LONG MaxClientConnections)
#define KMTEST_FILTER_POOL_TAG
NTSTATUS FLTAPI FilterUnload(_In_ FLT_FILTER_UNLOAD_FLAGS Flags)
static PDRIVER_OBJECT TestDriverObject
static ULONG CallbacksCount
#define ExFreePoolWithTag(_P, _T)
#define InitializeObjectAttributes(p, n, a, r, s)
#define _Outptr_result_maybenull_
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
#define PRCB_BUILD_UNIPROCESSOR
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNREFERENCED_PARAMETER(P)
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
NTSTATUS NTAPI IoVolumeDeviceToDosName(IN PVOID VolumeDeviceObject, OUT PUNICODE_STRING DosName)
#define STATUS_NOT_IMPLEMENTED
#define STATUS_ALREADY_REGISTERED
NTSTATUS NTAPI ObReferenceObjectByPointer(IN PVOID Object, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode)
FLT_REGISTRATION FilterRegistration
PDRIVER_OBJECT DriverObject
PFLT_PRE_OPERATION_CALLBACK PreOperation
PFLT_POST_OPERATION_CALLBACK PostOperation
FLT_OPERATION_REGISTRATION_FLAGS Flags
#define RtlZeroMemory(Destination, Length)
#define STATUS_INSUFFICIENT_RESOURCES
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE _In_opt_ __drv_aliasesMem WDFCONTEXT CompletionContext
_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
_Must_inspect_result_ _In_ ULONG Flags
#define IRP_MJ_MAXIMUM_FUNCTION
#define ObDereferenceObject