ReactOS 0.4.15-dev-7961-gdcf9eb0
fltmgr.h File Reference
#include <ntifs.h>
#include <ndk/obfuncs.h>
#include <ndk/exfuncs.h>
#include <fltkernel.h>
#include <pseh/pseh2.h>
#include <section_attribs.h>
Include dependency graph for fltmgr.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _DRIVER_DATA
 
struct  _FLTMGR_DEVICE_EXTENSION
 

Macros

#define DRIVER_NAME   L"FltMgr"
 
#define FLT_MAJOR_VERSION   0x0200
 
#define FLT_MINOR_VERSION   0x0000
 
#define FM_TAG_DISPATCH_TABLE   'ifMF'
 
#define FM_TAG_REGISTRY_DATA   'rtMF'
 
#define FM_TAG_DEV_OBJ_PTRS   'ldMF'
 
#define FM_TAG_UNICODE_STRING   'suMF'
 
#define FM_TAG_FILTER   'lfMF'
 
#define FM_TAG_CONTEXT_REGISTA   'rcMF'
 
#define FM_TAG_CCB   'bcMF'
 
#define FM_TAG_TEMP_REGISTRY   'rtMF'
 
#define MAX_DEVNAME_LENGTH   64
 

Typedefs

typedef struct _DRIVER_DATA DRIVER_DATA
 
typedef struct _DRIVER_DATAPDRIVER_DATA
 
typedef struct _FLTMGR_DEVICE_EXTENSION FLTMGR_DEVICE_EXTENSION
 
typedef struct _FLTMGR_DEVICE_EXTENSIONPFLTMGR_DEVICE_EXTENSION
 

Functions

NTSTATUS FltpRegisterContexts (_In_ PFLT_FILTER Filter, _In_ const FLT_CONTEXT_REGISTRATION *Context)
 
VOID FltpExInitializeRundownProtection (_Out_ PEX_RUNDOWN_REF RundownRef)
 
BOOLEAN FltpExAcquireRundownProtection (_Inout_ PEX_RUNDOWN_REF RundownRef)
 
BOOLEAN FltpExReleaseRundownProtection (_Inout_ PEX_RUNDOWN_REF RundownRef)
 
NTSTATUS NTAPI FltpObjectRundownWait (_Inout_ PEX_RUNDOWN_REF RundownRef)
 
BOOLEAN FltpExRundownCompleted (_Inout_ PEX_RUNDOWN_REF RundownRef)
 
NTSTATUS FltpGetBaseDeviceObjectName (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PUNICODE_STRING ObjectName)
 
NTSTATUS FltpGetObjectName (_In_ PVOID Object, _Inout_ PUNICODE_STRING ObjectName)
 
NTSTATUS FltpReallocateUnicodeString (_In_ PUNICODE_STRING String, _In_ SIZE_T NewLength, _In_ BOOLEAN CopyExisting)
 
VOID FltpFreeUnicodeString (_In_ PUNICODE_STRING String)
 

Macro Definition Documentation

◆ DRIVER_NAME

#define DRIVER_NAME   L"FltMgr"

Definition at line 12 of file fltmgr.h.

◆ FLT_MAJOR_VERSION

#define FLT_MAJOR_VERSION   0x0200

Definition at line 14 of file fltmgr.h.

◆ FLT_MINOR_VERSION

#define FLT_MINOR_VERSION   0x0000

Definition at line 15 of file fltmgr.h.

◆ FM_TAG_CCB

#define FM_TAG_CCB   'bcMF'

Definition at line 23 of file fltmgr.h.

◆ FM_TAG_CONTEXT_REGISTA

#define FM_TAG_CONTEXT_REGISTA   'rcMF'

Definition at line 22 of file fltmgr.h.

◆ FM_TAG_DEV_OBJ_PTRS

#define FM_TAG_DEV_OBJ_PTRS   'ldMF'

Definition at line 19 of file fltmgr.h.

◆ FM_TAG_DISPATCH_TABLE

#define FM_TAG_DISPATCH_TABLE   'ifMF'

Definition at line 17 of file fltmgr.h.

◆ FM_TAG_FILTER

#define FM_TAG_FILTER   'lfMF'

Definition at line 21 of file fltmgr.h.

◆ FM_TAG_REGISTRY_DATA

#define FM_TAG_REGISTRY_DATA   'rtMF'

Definition at line 18 of file fltmgr.h.

◆ FM_TAG_TEMP_REGISTRY

#define FM_TAG_TEMP_REGISTRY   'rtMF'

Definition at line 24 of file fltmgr.h.

◆ FM_TAG_UNICODE_STRING

#define FM_TAG_UNICODE_STRING   'suMF'

Definition at line 20 of file fltmgr.h.

◆ MAX_DEVNAME_LENGTH

#define MAX_DEVNAME_LENGTH   64

Definition at line 26 of file fltmgr.h.

Typedef Documentation

◆ DRIVER_DATA

◆ FLTMGR_DEVICE_EXTENSION

◆ PDRIVER_DATA

◆ PFLTMGR_DEVICE_EXTENSION

Function Documentation

◆ FltpExAcquireRundownProtection()

BOOLEAN FltpExAcquireRundownProtection ( _Inout_ PEX_RUNDOWN_REF  RundownRef)

Definition at line 218 of file Object.c.

219{
220 return ExAcquireRundownProtection(RundownRef);
221}
#define ExAcquireRundownProtection
Definition: ex.h:135

◆ FltpExInitializeRundownProtection()

VOID FltpExInitializeRundownProtection ( _Out_ PEX_RUNDOWN_REF  RundownRef)

Definition at line 212 of file Object.c.

213{
215}
#define ExInitializeRundownProtection
Definition: ex.h:137

Referenced by FltRegisterFilter().

◆ FltpExReleaseRundownProtection()

BOOLEAN FltpExReleaseRundownProtection ( _Inout_ PEX_RUNDOWN_REF  RundownRef)

Definition at line 224 of file Object.c.

225{
226 ExReleaseRundownProtection(RundownRef);
227 return TRUE;
228}
#define TRUE
Definition: types.h:120
#define ExReleaseRundownProtection
Definition: ex.h:136

◆ FltpExRundownCompleted()

BOOLEAN FltpExRundownCompleted ( _Inout_ PEX_RUNDOWN_REF  RundownRef)

Definition at line 231 of file Object.c.

232{
233 return _InterlockedExchange((PLONG)RundownRef, 1);
234}
long __cdecl _InterlockedExchange(_Interlocked_operand_ long volatile *_Target, long _Value)
int32_t * PLONG
Definition: typedefs.h:58

Referenced by FltUnregisterFilter().

◆ FltpFreeUnicodeString()

VOID FltpFreeUnicodeString ( _In_ PUNICODE_STRING  String)

Definition at line 24 of file Lib.c.

25{
26 /* Free up any existing buffer */
27 if (String->Buffer)
28 {
30 }
31
32 /* Empty the string */
33 String->Buffer = NULL;
34 String->Length = 0;
35 String->MaximumLength = 0;
36}
#define NULL
Definition: types.h:112
#define FM_TAG_UNICODE_STRING
Definition: fltmgr.h:20
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433

Referenced by FltpEnumerateFileSystemVolumes(), and FltpFsNotification().

◆ FltpGetBaseDeviceObjectName()

NTSTATUS FltpGetBaseDeviceObjectName ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PUNICODE_STRING  ObjectName 
)

Definition at line 245 of file Object.c.

247{
248 PDEVICE_OBJECT BaseDeviceObject;
250
251 /*
252 * Get the lowest device object on the stack, which may be the
253 * object we were passed, and lookup the name for that object
254 */
255 BaseDeviceObject = IoGetDeviceAttachmentBaseRef(DeviceObject);
256 Status = FltpGetObjectName(BaseDeviceObject, ObjectName);
257 ObDereferenceObject(BaseDeviceObject);
258
259 return Status;
260}
NTSTATUS FltpGetObjectName(_In_ PVOID Object, _Inout_ PUNICODE_STRING ObjectName)
Definition: Object.c:263
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:25
PDEVICE_OBJECT NTAPI IoGetDeviceAttachmentBaseRef(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1419
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PVOID _Out_opt_ PULONG_PTR _Outptr_opt_ PCUNICODE_STRING * ObjectName
Definition: cmfuncs.h:64
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by FltpEnumerateFileSystemVolumes(), and FltpFsNotification().

◆ FltpGetObjectName()

NTSTATUS FltpGetObjectName ( _In_ PVOID  Object,
_Inout_ PUNICODE_STRING  ObjectName 
)

Definition at line 263 of file Object.c.

265{
266 OBJECT_NAME_INFORMATION LocalNameInfo;
267 POBJECT_NAME_INFORMATION ObjectNameInfo = &LocalNameInfo;
270
271 if (ObjectName == NULL)
273
274 /* Get the size of the buffer required to hold the nameinfo */
276 &LocalNameInfo,
277 sizeof(LocalNameInfo),
278 &ReturnLength);
280 {
281 ObjectNameInfo = ExAllocatePoolWithTag(PagedPool,
284 if (ObjectNameInfo == NULL) return STATUS_INSUFFICIENT_RESOURCES;
285
286 /* Get the actual name info now we have the buffer to hold it */
288 ObjectNameInfo,
290 &ReturnLength);
291 }
292
293
294 if (NT_SUCCESS(Status))
295 {
296 /* Make sure the buffer we were passed is large enough to hold the string */
297 if (ObjectName->MaximumLength < ObjectNameInfo->Name.Length)
298 {
299 /* It wasn't, let's enlarge the buffer */
301 ObjectNameInfo->Name.Length,
302 FALSE);
303
304 }
305
306 if (NT_SUCCESS(Status))
307 {
308 /* Copy the object name into the callers buffer */
309 RtlCopyUnicodeString(ObjectName, &ObjectNameInfo->Name);
310 }
311 }
312
313 if (ObjectNameInfo != &LocalNameInfo)
314 {
316 }
317
318 return Status;
319}
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:43
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
NTSTATUS FltpReallocateUnicodeString(_In_ PUNICODE_STRING String, _In_ SIZE_T NewLength, _In_ BOOLEAN CopyExisting)
Definition: Lib.c:39
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
NTSTATUS NTAPI ObQueryNameString(IN PVOID Object, OUT POBJECT_NAME_INFORMATION ObjectNameInfo, IN ULONG Length, OUT PULONG ReturnLength)
Definition: obname.c:1207
UNICODE_STRING Name
Definition: nt_native.h:1270
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object

Referenced by FltpAttachToFileSystemDevice(), and FltpEnumerateFileSystemVolumes().

◆ FltpObjectRundownWait()

NTSTATUS NTAPI FltpObjectRundownWait ( _Inout_ PEX_RUNDOWN_REF  RundownRef)

Definition at line 238 of file Object.c.

239{
240 //return FltpExWaitForRundownProtectionRelease(RundownRef);
241 return 0;
242}

Referenced by FltUnregisterFilter().

◆ FltpReallocateUnicodeString()

NTSTATUS FltpReallocateUnicodeString ( _In_ PUNICODE_STRING  String,
_In_ SIZE_T  NewLength,
_In_ BOOLEAN  CopyExisting 
)

Definition at line 39 of file Lib.c.

42{
43 PWCH NewBuffer;
44
45 /* Don't bother reallocating if the buffer is smaller */
46 if (NewLength <= String->MaximumLength)
47 {
48 String->Length = 0;
49 return STATUS_SUCCESS;
50 }
51
52 /* Allocate a new buffer at the size requested */
54 if (NewBuffer == NULL) return STATUS_INSUFFICIENT_RESOURCES;
55
56 if (CopyExisting)
57 {
58 /* Copy the old data across */
59 RtlCopyMemory(NewBuffer, String->Buffer, String->Length);
60 }
61 else
62 {
63 /* Reset the length */
64 String->Length = 0;
65 }
66
67 /* Free any old buffer */
68 if (String->Buffer)
70
71 /* Update the lengths */
72 String->Buffer = NewBuffer;
73 String->MaximumLength = NewLength;
74
75 return STATUS_SUCCESS;
76}
static USHORT USHORT * NewLength
WCHAR * PWCH
Definition: ntbasedef.h:410
#define STATUS_SUCCESS
Definition: shellext.h:65
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
_In_ WDFDMATRANSACTION _In_ size_t MaximumLength

Referenced by FltpGetObjectName().

◆ FltpRegisterContexts()

NTSTATUS FltpRegisterContexts ( _In_ PFLT_FILTER  Filter,
_In_ const FLT_CONTEXT_REGISTRATION Context 
)

Definition at line 43 of file Context.c.

45{
47 PALLOCATE_CONTEXT_HEADER ContextHeader, Prev;
49 ULONG BufferSize = 0;
50 USHORT i;
52
53 /* Loop through all entries in the context registration array */
54 ContextPtr = Context;
55 while (ContextPtr)
56 {
57 /* Bail if we found the terminator */
58 if (ContextPtr->ContextType == FLT_CONTEXT_END)
59 break;
60
61 /* Make sure we have a valid context */
62 if (IsContextTypeValid(ContextPtr->ContextType))
63 {
64 /* Each context is backed by a crtl struct. Reserve space for it */
66 }
67
68 /* Move to the next entry */
69 ContextPtr++;
70 }
71
72 /* Bail if we found no valid registration requests */
73 if (BufferSize == 0)
74 {
75 return STATUS_SUCCESS;
76 }
77
78 /* Allocate the pool that'll hold the context crtl structs */
81
83
84 /* Setup our loop data */
85 ContextHeader = Buffer;
86 Prev = NULL;
88
89 for (i = 0; i < MAX_CONTEXT_TYPES; i++)
90 {
92 while (ContextPtr)
93 {
94 /* We don't support variable sized contents yet */
96
97 /* Bail if we found the terminator */
98 if (ContextPtr->ContextType == FLT_CONTEXT_END)
99 break;
100
101 /* Size and pooltag are only checked when ContextAllocateCallback is null */
102 if (ContextPtr->ContextAllocateCallback == FALSE && ContextPtr->PoolTag == FALSE)
103 {
105 goto Quit;
106 }
107
108 /* Make sure we have a valid context */
109 if (IsContextTypeValid(ContextPtr->ContextType))
110 {
111 Status = SetupContextHeader(Filter, ContextPtr, ContextHeader);
112 if (NT_SUCCESS(Status))
113 {
114 if (Prev)
115 {
116 Prev->Next = ContextHeader;
117 }
118
119 Filter->SupportedContexts[i] = ContextHeader;
120 }
121 }
122
123 Prev = ContextHeader;
124
125 /* Move to the next entry */
126 ContextPtr++;
127 }
128 }
129
130Quit:
131 if (NT_SUCCESS(Status))
132 {
134 }
135 else
136 {
138 //FIXME: Cleanup anything that SetupContextHeader may have allocated
139 }
140
141 return Status;
142}
static NTSTATUS SetupContextHeader(_In_ PFLT_FILTER Filter, _In_ PCFLT_CONTEXT_REGISTRATION ContextPtr, _Out_ PALLOCATE_CONTEXT_HEADER ContextHeader)
Definition: Context.c:167
static BOOLEAN IsContextTypeValid(_In_ FLT_CONTEXT_TYPE ContextType)
Definition: Context.c:149
Definition: bufpool.h:45
#define NonPagedPool
Definition: env_spec_w32.h:307
struct _FLT_CONTEXT_REGISTRATION * PFLT_CONTEXT_REGISTRATION
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
#define FLT_CONTEXT_END
Definition: fltkernel.h:444
#define FLT_VARIABLE_SIZED_CONTEXTS
Definition: fltkernel.h:513
#define FLT_ASSERT(_e)
Definition: fltkernel.h:49
#define FM_TAG_CONTEXT_REGISTA
Definition: fltmgr.h:22
#define MAX_CONTEXT_TYPES
Definition: fltmgrint.h:5
struct _STREAM_LIST_CTRL STREAM_LIST_CTRL
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
#define STATUS_FLT_INVALID_CONTEXT_REGISTRATION
Definition: ntstatus.h:1444
unsigned short USHORT
Definition: pedump.c:61
struct _ALLOCATE_CONTEXT_HEADER * Next
Definition: fltmgrint.h:38
PFLT_CONTEXT_ALLOCATE_CALLBACK ContextAllocateCallback
Definition: fltkernel.h:521
FLT_CONTEXT_TYPE ContextType
Definition: fltkernel.h:516
PALLOCATE_CONTEXT_HEADER SupportedContexts[MAX_CONTEXT_TYPES]
Definition: fltmgrint.h:112
PALLOCATE_CONTEXT_HEADER SupportedContextsListHead
Definition: fltmgrint.h:111
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by FltRegisterFilter().