ReactOS 0.4.15-dev-8138-g1e75ea8
Context.c
Go to the documentation of this file.
1/*
2* PROJECT: Filesystem Filter Manager
3* LICENSE: GPL - See COPYING in the top level directory
4* FILE: drivers/filters/fltmgr/Context.c
5* PURPOSE: Contains context routines
6* PROGRAMMERS: Ged Murphy (gedmurphy@reactos.org)
7*/
8
9/* INCLUDES ******************************************************************/
10
11#include "fltmgr.h"
12#include "fltmgrint.h"
13
14#define NDEBUG
15#include <debug.h>
16
17
18/* DATA *********************************************************************/
19
20static
24);
25
26static
32);
33
34/* EXPORTED FUNCTIONS ******************************************************/
35
36
37
38
39/* INTERNAL FUNCTIONS ******************************************************/
40
41
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}
143
144
145/* PRIVATE FUNCTIONS ******************************************************/
146
147static
150{
151 switch (ContextType)
152 {
155 case FLT_FILE_CONTEXT:
159 return TRUE;
160 }
161
162 return FALSE;
163}
164
165static
169 _Out_ PALLOCATE_CONTEXT_HEADER ContextHeader)
170{
171 return 0;
172}
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
NTSTATUS FltpRegisterContexts(_In_ PFLT_FILTER Filter, _In_ const FLT_CONTEXT_REGISTRATION *Context)
Definition: Context.c:43
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
#define FLT_TRANSACTION_CONTEXT
Definition: fltkernel.h:443
struct _FLT_CONTEXT_REGISTRATION * PFLT_CONTEXT_REGISTRATION
USHORT FLT_CONTEXT_TYPE
Definition: fltkernel.h:436
#define FLT_STREAMHANDLE_CONTEXT
Definition: fltkernel.h:442
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
#define FLT_CONTEXT_END
Definition: fltkernel.h:444
#define FLT_VOLUME_CONTEXT
Definition: fltkernel.h:438
#define FLT_FILE_CONTEXT
Definition: fltkernel.h:440
#define FLT_STREAM_CONTEXT
Definition: fltkernel.h:441
#define FLT_INSTANCE_CONTEXT
Definition: fltkernel.h:439
#define FLT_VARIABLE_SIZED_CONTEXTS
Definition: fltkernel.h:513
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE ContextType
Definition: fltkernel.h:1443
#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
Status
Definition: gdiplustypes.h:25
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 ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define STATUS_FLT_INVALID_CONTEXT_REGISTRATION
Definition: ntstatus.h:1444
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_SUCCESS
Definition: shellext.h:65
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
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254