WDK Mini Filter Example
cancelSafe.c File Reference
#include <fltKernel.h>
#include <dontuse.h>
#include <suppress.h>

Go to the source code of this file.

Data Structures

struct  _QUEUE_CONTEXT
 
struct  _INSTANCE_CONTEXT
 
struct  _CSQ_GLOBAL_DATA
 

Macros

#define CSQ_TRACE_ERROR   0x00000001
 
#define CSQ_TRACE_LOAD_UNLOAD   0x00000002
 
#define CSQ_TRACE_INSTANCE_CALLBACK   0x00000004
 
#define CSQ_TRACE_CONTEXT_CALLBACK   0x00000008
 
#define CSQ_TRACE_CBDQ_CALLBACK   0x00000010
 
#define CSQ_TRACE_PRE_READ   0x00000020
 
#define CSQ_TRACE_ALL   0xFFFFFFFF
 
#define DebugTrace(Level, Data)
 
#define INSTANCE_CONTEXT_TAG   'IqsC'
 
#define QUEUE_CONTEXT_TAG   'QqsC'
 
#define CSQ_REG_TAG   'RqsC'
 
#define CSQ_STRING_TAG   'SqsC'
 
#define CSQ_DEFAULT_TIME_DELAY   150000000
 
#define CSQ_DEFAULT_MAPPING_PATH   L"\\"
 
#define CSQ_KEY_NAME_DELAY   L"OperatingDelay"
 
#define CSQ_KEY_NAME_PATH   L"OperatingPath"
 
#define CSQ_KEY_NAME_DEBUG_LEVEL   L"DebugLevel"
 
#define CSQ_MAX_PATH_LENGTH   256
 

Typedefs

typedef struct _QUEUE_CONTEXT QUEUE_CONTEXT
 
typedef struct _QUEUE_CONTEXTPQUEUE_CONTEXT
 
typedef struct _INSTANCE_CONTEXT INSTANCE_CONTEXT
 
typedef struct _INSTANCE_CONTEXTPINSTANCE_CONTEXT
 
typedef struct _CSQ_GLOBAL_DATA CSQ_GLOBAL_DATA
 

Functions

NTSTATUS DriverEntry (_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
 
VOID FreeGlobals ()
 
NTSTATUS Unload (_In_ FLT_FILTER_UNLOAD_FLAGS Flags)
 
VOID ContextCleanup (_In_ PFLT_CONTEXT Context, _In_ FLT_CONTEXT_TYPE ContextType)
 
NTSTATUS InstanceSetup (_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_SETUP_FLAGS Flags, _In_ DEVICE_TYPE VolumeDeviceType, _In_ FLT_FILESYSTEM_TYPE VolumeFilesystemType)
 
NTSTATUS InstanceQueryTeardown (_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_QUERY_TEARDOWN_FLAGS Flags)
 
VOID InstanceTeardownStart (_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_TEARDOWN_FLAGS Flags)
 
VOID InstanceTeardownComplete (_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_TEARDOWN_FLAGS Flags)
 
NTSTATUS SetConfiguration (_In_ PUNICODE_STRING RegistryPath)
 
VOID _IRQL_requires_max_ (VOID_IRQL_requires_max_(APC_LEVEL) _IRQL_requires_min_() _IRQL_raises_(PASSIVE_LEVEL) _Requires_lock_held_((CONTAINING_RECORD(DataQueue APC_LEVEL)
 
VOID _IRQL_requires_max_ (APC_LEVEL)
 
VOID _IRQL_requires_max_ (_IRQL_requires_min_() _IRQL_raises_(PASSIVE_LEVEL) _Requires_lock_held_((CONTAINING_RECORD(DataQueue APC_LEVEL)
 
NTSTATUS CsqInsertIo (_In_ PFLT_CALLBACK_DATA_QUEUE DataQueue, _In_ PFLT_CALLBACK_DATA Data, _In_opt_ PVOID Context)
 
VOID CsqRemoveIo (_In_ PFLT_CALLBACK_DATA_QUEUE DataQueue, _In_ PFLT_CALLBACK_DATA Data)
 
PFLT_CALLBACK_DATA CsqPeekNextIo (_In_ PFLT_CALLBACK_DATA_QUEUE DataQueue, _In_opt_ PFLT_CALLBACK_DATA Data, _In_opt_ PVOID PeekContext)
 
VOID CsqCompleteCanceledIo (_In_ PFLT_CALLBACK_DATA_QUEUE DataQueue, _Inout_ PFLT_CALLBACK_DATA Data)
 
FLT_PREOP_CALLBACK_STATUS PreRead (_Inout_ PFLT_CALLBACK_DATA Data, _In_ PCFLT_RELATED_OBJECTS FltObjects, _Flt_CompletionContext_Outptr_ PVOID *CompletionContext)
 
VOID PreReadWorkItemRoutine (_In_ PFLT_GENERIC_WORKITEM WorkItem, _In_ PFLT_FILTER Filter, _In_ PVOID Context)
 
NTSTATUS PreReadPendIo (_In_ PINSTANCE_CONTEXT InstanceContext)
 
NTSTATUS PreReadProcessIo (_Inout_ PFLT_CALLBACK_DATA Data)
 
VOID PreReadEmptyQueueAndComplete (_In_ PINSTANCE_CONTEXT InstanceContext)
 

Variables

CSQ_GLOBAL_DATA Globals
 
DRIVER_INITIALIZE DriverEntry
 
const FLT_CONTEXT_REGISTRATION ContextRegistration []
 
FLT_REGISTRATION FilterRegistration
 

Macro Definition Documentation

◆ CSQ_DEFAULT_MAPPING_PATH

#define CSQ_DEFAULT_MAPPING_PATH   L"\\"

Definition at line 55 of file cancelSafe.c.

◆ CSQ_DEFAULT_TIME_DELAY

#define CSQ_DEFAULT_TIME_DELAY   150000000

Definition at line 54 of file cancelSafe.c.

◆ CSQ_KEY_NAME_DEBUG_LEVEL

#define CSQ_KEY_NAME_DEBUG_LEVEL   L"DebugLevel"

Definition at line 58 of file cancelSafe.c.

◆ CSQ_KEY_NAME_DELAY

#define CSQ_KEY_NAME_DELAY   L"OperatingDelay"

Definition at line 56 of file cancelSafe.c.

◆ CSQ_KEY_NAME_PATH

#define CSQ_KEY_NAME_PATH   L"OperatingPath"

Definition at line 57 of file cancelSafe.c.

◆ CSQ_MAX_PATH_LENGTH

#define CSQ_MAX_PATH_LENGTH   256

Definition at line 59 of file cancelSafe.c.

◆ CSQ_REG_TAG

#define CSQ_REG_TAG   'RqsC'

Definition at line 47 of file cancelSafe.c.

◆ CSQ_STRING_TAG

#define CSQ_STRING_TAG   'SqsC'

Definition at line 48 of file cancelSafe.c.

◆ CSQ_TRACE_ALL

#define CSQ_TRACE_ALL   0xFFFFFFFF

Definition at line 34 of file cancelSafe.c.

◆ CSQ_TRACE_CBDQ_CALLBACK

#define CSQ_TRACE_CBDQ_CALLBACK   0x00000010

Definition at line 32 of file cancelSafe.c.

◆ CSQ_TRACE_CONTEXT_CALLBACK

#define CSQ_TRACE_CONTEXT_CALLBACK   0x00000008

Definition at line 31 of file cancelSafe.c.

◆ CSQ_TRACE_ERROR

#define CSQ_TRACE_ERROR   0x00000001

Definition at line 28 of file cancelSafe.c.

◆ CSQ_TRACE_INSTANCE_CALLBACK

#define CSQ_TRACE_INSTANCE_CALLBACK   0x00000004

Definition at line 30 of file cancelSafe.c.

◆ CSQ_TRACE_LOAD_UNLOAD

#define CSQ_TRACE_LOAD_UNLOAD   0x00000002

Definition at line 29 of file cancelSafe.c.

◆ CSQ_TRACE_PRE_READ

#define CSQ_TRACE_PRE_READ   0x00000020

Definition at line 33 of file cancelSafe.c.

◆ DebugTrace

#define DebugTrace (   Level,
  Data 
)
Value:
if ((Level) & Globals.DebugLevel) { \
DbgPrint Data; \
}
CSQ_GLOBAL_DATA Globals
Definition: cancelSafe.c:133

Definition at line 36 of file cancelSafe.c.

◆ INSTANCE_CONTEXT_TAG

#define INSTANCE_CONTEXT_TAG   'IqsC'

Definition at line 45 of file cancelSafe.c.

◆ QUEUE_CONTEXT_TAG

#define QUEUE_CONTEXT_TAG   'QqsC'

Definition at line 46 of file cancelSafe.c.

Typedef Documentation

◆ CSQ_GLOBAL_DATA

◆ INSTANCE_CONTEXT

◆ PINSTANCE_CONTEXT

◆ PQUEUE_CONTEXT

typedef struct _QUEUE_CONTEXT * PQUEUE_CONTEXT

◆ QUEUE_CONTEXT

typedef struct _QUEUE_CONTEXT QUEUE_CONTEXT

Function Documentation

◆ _IRQL_requires_max_() [1/3]

VOID _IRQL_requires_max_ ( VOID_IRQL_requires_max_(APC_LEVEL)_IRQL_requires_min_()_IRQL_raises_(PASSIVE_LEVEL)_Requires_lock_held_((CONTAINING_RECORD( DataQueue  APC_LEVEL)

Definition at line 194 of file cancelSafe.c.

◆ _IRQL_requires_max_() [2/3]

VOID _IRQL_requires_max_ ( APC_LEVEL  )

Definition at line 1049 of file cancelSafe.c.

◆ _IRQL_requires_max_() [3/3]

VOID _IRQL_requires_max_ ( _IRQL_requires_min_()_IRQL_raises_(PASSIVE_LEVEL)_Requires_lock_held_((CONTAINING_RECORD( DataQueue  APC_LEVEL)

Definition at line 1098 of file cancelSafe.c.

◆ ContextCleanup()

VOID ContextCleanup ( _In_ PFLT_CONTEXT  Context,
_In_ FLT_CONTEXT_TYPE  ContextType 
)

Definition at line 722 of file cancelSafe.c.

◆ CsqCompleteCanceledIo()

VOID CsqCompleteCanceledIo ( _In_ PFLT_CALLBACK_DATA_QUEUE  DataQueue,
_Inout_ PFLT_CALLBACK_DATA  Data 
)

Definition at line 1374 of file cancelSafe.c.

◆ CsqInsertIo()

NTSTATUS CsqInsertIo ( _In_ PFLT_CALLBACK_DATA_QUEUE  DataQueue,
_In_ PFLT_CALLBACK_DATA  Data,
_In_opt_ PVOID  Context 
)

Definition at line 1148 of file cancelSafe.c.

◆ CsqPeekNextIo()

PFLT_CALLBACK_DATA CsqPeekNextIo ( _In_ PFLT_CALLBACK_DATA_QUEUE  DataQueue,
_In_opt_ PFLT_CALLBACK_DATA  Data,
_In_opt_ PVOID  PeekContext 
)

Definition at line 1302 of file cancelSafe.c.

◆ CsqRemoveIo()

VOID CsqRemoveIo ( _In_ PFLT_CALLBACK_DATA_QUEUE  DataQueue,
_In_ PFLT_CALLBACK_DATA  Data 
)

Definition at line 1265 of file cancelSafe.c.

◆ DriverEntry()

NTSTATUS DriverEntry ( _In_ PDRIVER_OBJECT  DriverObject,
_In_ PUNICODE_STRING  RegistryPath 
)

Definition at line 335 of file cancelSafe.c.

◆ FreeGlobals()

VOID FreeGlobals ( )

Definition at line 646 of file cancelSafe.c.

◆ InstanceQueryTeardown()

NTSTATUS InstanceQueryTeardown ( _In_ PCFLT_RELATED_OBJECTS  FltObjects,
_In_ FLT_INSTANCE_QUERY_TEARDOWN_FLAGS  Flags 
)

Definition at line 899 of file cancelSafe.c.

◆ InstanceSetup()

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

Definition at line 762 of file cancelSafe.c.

◆ InstanceTeardownComplete()

VOID InstanceTeardownComplete ( _In_ PCFLT_RELATED_OBJECTS  FltObjects,
_In_ FLT_INSTANCE_TEARDOWN_FLAGS  Flags 
)

Definition at line 1011 of file cancelSafe.c.

◆ InstanceTeardownStart()

VOID InstanceTeardownStart ( _In_ PCFLT_RELATED_OBJECTS  FltObjects,
_In_ FLT_INSTANCE_TEARDOWN_FLAGS  Flags 
)

Definition at line 937 of file cancelSafe.c.

◆ PreRead()

FLT_PREOP_CALLBACK_STATUS PreRead ( _Inout_ PFLT_CALLBACK_DATA  Data,
_In_ PCFLT_RELATED_OBJECTS  FltObjects,
_Flt_CompletionContext_Outptr_ PVOID *  CompletionContext 
)

Definition at line 1427 of file cancelSafe.c.

◆ PreReadEmptyQueueAndComplete()

VOID PreReadEmptyQueueAndComplete ( _In_ PINSTANCE_CONTEXT  InstanceContext)

Definition at line 1866 of file cancelSafe.c.

◆ PreReadPendIo()

NTSTATUS PreReadPendIo ( _In_ PINSTANCE_CONTEXT  InstanceContext)

Definition at line 1800 of file cancelSafe.c.

◆ PreReadProcessIo()

NTSTATUS PreReadProcessIo ( _Inout_ PFLT_CALLBACK_DATA  Data)

Definition at line 1840 of file cancelSafe.c.

◆ PreReadWorkItemRoutine()

VOID PreReadWorkItemRoutine ( _In_ PFLT_GENERIC_WORKITEM  WorkItem,
_In_ PFLT_FILTER  Filter,
_In_ PVOID  Context 
)

Definition at line 1623 of file cancelSafe.c.

◆ SetConfiguration()

NTSTATUS SetConfiguration ( _In_ PUNICODE_STRING  RegistryPath)

Definition at line 461 of file cancelSafe.c.

◆ Unload()

NTSTATUS Unload ( _In_ FLT_FILTER_UNLOAD_FLAGS  Flags)

Definition at line 680 of file cancelSafe.c.

Variable Documentation

◆ ContextRegistration

const FLT_CONTEXT_REGISTRATION ContextRegistration[]
Initial value:
= {
{ FLT_INSTANCE_CONTEXT,
0,
sizeof( INSTANCE_CONTEXT ),
{ FLT_CONTEXT_END }
}
struct _INSTANCE_CONTEXT INSTANCE_CONTEXT
#define INSTANCE_CONTEXT_TAG
Definition: cancelSafe.c:45
VOID ContextCleanup(_In_ PFLT_CONTEXT Context, _In_ FLT_CONTEXT_TYPE ContextType)
Definition: cancelSafe.c:722

Definition at line 300 of file cancelSafe.c.

◆ DriverEntry

DRIVER_INITIALIZE DriverEntry

Definition at line 140 of file cancelSafe.c.

◆ FilterRegistration

FLT_REGISTRATION FilterRegistration
Initial value:
= {
sizeof( FLT_REGISTRATION ),
FLT_REGISTRATION_VERSION,
0,
}
VOID InstanceTeardownStart(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_TEARDOWN_FLAGS Flags)
Definition: cancelSafe.c:937
CONST FLT_OPERATION_REGISTRATION Callbacks[]
NTSTATUS Unload(_In_ FLT_FILTER_UNLOAD_FLAGS Flags)
Definition: cancelSafe.c:680
const FLT_CONTEXT_REGISTRATION ContextRegistration[]
Definition: cancelSafe.c:300
NcLoadRegistryStringRetry NULL
Definition: ncinit.c:53
VOID InstanceTeardownComplete(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_TEARDOWN_FLAGS Flags)
Definition: cancelSafe.c:1011
NTSTATUS InstanceSetup(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_SETUP_FLAGS Flags, _In_ DEVICE_TYPE VolumeDeviceType, _In_ FLT_FILESYSTEM_TYPE VolumeFilesystemType)
Definition: cancelSafe.c:762
NTSTATUS InstanceQueryTeardown(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_QUERY_TEARDOWN_FLAGS Flags)
Definition: cancelSafe.c:899

Definition at line 315 of file cancelSafe.c.

◆ Globals

CSQ_GLOBAL_DATA Globals

Definition at line 133 of file cancelSafe.c.

Social Network


Services Overview

Architect, implement and test file system filter drivers for a wide range of functionality. We can offer several levels of assistance to meet your specific.

Contact Us

You are welcome to contact us for salse or partnership.

Sales: sales@easefilter.com
Support: support@easefilter.com
Info: info@easefilter.com