ReactOS  0.4.13-dev-982-g9853eab
fltmgr.h File Reference
#include <ntifs.h>
#include <ndk/obfuncs.h>
#include <ndk/exfuncs.h>
#include <fltkernel.h>
#include <pseh/pseh2.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 10 of file fltmgr.h.

◆ FLT_MAJOR_VERSION

#define FLT_MAJOR_VERSION   0x0200

Definition at line 12 of file fltmgr.h.

◆ FLT_MINOR_VERSION

#define FLT_MINOR_VERSION   0x0000

Definition at line 13 of file fltmgr.h.

◆ FM_TAG_CCB

#define FM_TAG_CCB   'bcMF'

Definition at line 21 of file fltmgr.h.

◆ FM_TAG_CONTEXT_REGISTA

#define FM_TAG_CONTEXT_REGISTA   'rcMF'

Definition at line 20 of file fltmgr.h.

◆ FM_TAG_DEV_OBJ_PTRS

#define FM_TAG_DEV_OBJ_PTRS   'ldMF'

Definition at line 17 of file fltmgr.h.

◆ FM_TAG_DISPATCH_TABLE

#define FM_TAG_DISPATCH_TABLE   'ifMF'

Definition at line 15 of file fltmgr.h.

◆ FM_TAG_FILTER

#define FM_TAG_FILTER   'lfMF'

Definition at line 19 of file fltmgr.h.

◆ FM_TAG_REGISTRY_DATA

#define FM_TAG_REGISTRY_DATA   'rtMF'

Definition at line 16 of file fltmgr.h.

◆ FM_TAG_TEMP_REGISTRY

#define FM_TAG_TEMP_REGISTRY   'rtMF'

Definition at line 22 of file fltmgr.h.

◆ FM_TAG_UNICODE_STRING

#define FM_TAG_UNICODE_STRING   'suMF'

Definition at line 18 of file fltmgr.h.

◆ MAX_DEVNAME_LENGTH

#define MAX_DEVNAME_LENGTH   64

Definition at line 24 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:130

◆ FltpExInitializeRundownProtection()

VOID FltpExInitializeRundownProtection ( _Out_ PEX_RUNDOWN_REF  RundownRef)

Definition at line 212 of file Object.c.

213 {
214  ExInitializeRundownProtection(RundownRef);
215 }
NTKERNELAPI VOID FASTCALL ExInitializeRundownProtection(_Out_ PEX_RUNDOWN_REF RunRef)

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
NTKERNELAPI VOID FASTCALL ExReleaseRundownProtection(_Inout_ PEX_RUNDOWN_REF RunRef)

◆ 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)
signed int * PLONG
Definition: retypes.h:5

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 }
static WCHAR String[]
Definition: stringtable.c:55
#define FM_TAG_UNICODE_STRING
Definition: fltmgr.h:18
smooth NULL
Definition: ftsmooth.c:416
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

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 }
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
_In_ PVOID _Out_opt_ PULONG_PTR _Outptr_opt_ PCUNICODE_STRING * ObjectName
Definition: cmfuncs.h:62
PDEVICE_OBJECT NTAPI IoGetDeviceAttachmentBaseRef(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1419
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
NTSTATUS FltpGetObjectName(_In_ PVOID Object, _Inout_ PUNICODE_STRING ObjectName)
Definition: Object.c:263

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  POBJECT_NAME_INFORMATION ObjectNameInfo = NULL;
267  OBJECT_NAME_INFORMATION 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,
282  ReturnLength,
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,
289  ReturnLength,
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)
314  {
315  ExFreePoolWithTag(ObjectNameInfo, FM_TAG_UNICODE_STRING);
316  }
317 
318  return Status;
319 }
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI ObQueryNameString(IN PVOID Object, OUT POBJECT_NAME_INFORMATION ObjectNameInfo, IN ULONG Length, OUT PULONG ReturnLength)
Definition: obname.c:1209
UNICODE_STRING Name
Definition: nt_native.h:1270
_In_ PVOID _Out_opt_ PULONG_PTR _Outptr_opt_ PCUNICODE_STRING * ObjectName
Definition: cmfuncs.h:62
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define FM_TAG_UNICODE_STRING
Definition: fltmgr.h:18
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS FltpReallocateUnicodeString(_In_ PUNICODE_STRING String, _In_ SIZE_T NewLength, _In_ BOOLEAN CopyExisting)
Definition: Lib.c:39
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static IUnknown Object
Definition: main.c:512
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Status
Definition: gdiplustypes.h:24
unsigned int ULONG
Definition: retypes.h:1
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

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 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
static WCHAR String[]
Definition: stringtable.c:55
static USHORT USHORT * NewLength
#define FM_TAG_UNICODE_STRING
Definition: fltmgr.h:18
smooth NULL
Definition: ftsmooth.c:416
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
WCHAR * PWCH
Definition: ntbasedef.h:417
UnicodeString MaximumLength
Definition: rtlfuncs.h:2982
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
return STATUS_SUCCESS
Definition: btrfs.c:2777

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 {
46  PCFLT_CONTEXT_REGISTRATION ContextPtr;
47  PALLOCATE_CONTEXT_HEADER ContextHeader, Prev;
48  PVOID Buffer;
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 */
65  BufferSize += sizeof(STREAM_LIST_CTRL);
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  {
91  ContextPtr = (PFLT_CONTEXT_REGISTRATION)Context;
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 
130 Quit:
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 }
#define FLT_VARIABLE_SIZED_CONTEXTS
Definition: fltkernel.h:513
struct _STREAM_LIST_CTRL STREAM_LIST_CTRL
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define MAX_CONTEXT_TYPES
Definition: fltmgrint.h:5
struct _FLT_CONTEXT_REGISTRATION * PFLT_CONTEXT_REGISTRATION
LONG NTSTATUS
Definition: precomp.h:26
struct _ALLOCATE_CONTEXT_HEADER * Next
Definition: fltmgrint.h:38
PALLOCATE_CONTEXT_HEADER SupportedContexts[MAX_CONTEXT_TYPES]
Definition: fltmgrint.h:112
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
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
smooth NULL
Definition: ftsmooth.c:416
FLT_CONTEXT_TYPE ContextType
Definition: fltkernel.h:516
Definition: bufpool.h:45
#define STATUS_FLT_INVALID_CONTEXT_REGISTRATION
Definition: ntstatus.h:1226
static NTSTATUS SetupContextHeader(_In_ PFLT_FILTER Filter, _In_ PCFLT_CONTEXT_REGISTRATION ContextPtr, _Out_ PALLOCATE_CONTEXT_HEADER ContextHeader)
Definition: Context.c:167
PFLT_CONTEXT_ALLOCATE_CALLBACK ContextAllocateCallback
Definition: fltkernel.h:521
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define BufferSize
Definition: classpnp.h:419
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define FM_TAG_CONTEXT_REGISTA
Definition: fltmgr.h:20
Status
Definition: gdiplustypes.h:24
unsigned short USHORT
Definition: pedump.c:61
PALLOCATE_CONTEXT_HEADER SupportedContextsListHead
Definition: fltmgrint.h:111
struct tagContext Context
Definition: acpixf.h:1012
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define FLT_CONTEXT_END
Definition: fltkernel.h:444
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
static BOOLEAN IsContextTypeValid(_In_ FLT_CONTEXT_TYPE ContextType)
Definition: Context.c:149
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define FLT_ASSERT(_e)
Definition: fltkernel.h:49

Referenced by FltRegisterFilter().