ReactOS  0.4.14-dev-317-g96040ec
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 
20 static
21 BOOLEAN
24 );
25 
26 static
31  _Out_ PALLOCATE_CONTEXT_HEADER ContextHeader
32 );
33 
34 /* EXPORTED FUNCTIONS ******************************************************/
35 
36 
37 
38 
39 /* INTERNAL FUNCTIONS ******************************************************/
40 
41 
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 }
143 
144 
145 /* PRIVATE FUNCTIONS ******************************************************/
146 
147 static
148 BOOLEAN
150 {
151  switch (ContextType)
152  {
153  case FLT_VOLUME_CONTEXT:
155  case FLT_FILE_CONTEXT:
156  case FLT_STREAM_CONTEXT:
159  return TRUE;
160  }
161 
162  return FALSE;
163 }
164 
165 static
166 NTSTATUS
168  _In_ PCFLT_CONTEXT_REGISTRATION ContextPtr,
169  _Out_ PALLOCATE_CONTEXT_HEADER ContextHeader)
170 {
171  return 0;
172 }
#define FLT_VARIABLE_SIZED_CONTEXTS
Definition: fltkernel.h:513
struct _STREAM_LIST_CTRL STREAM_LIST_CTRL
#define TRUE
Definition: types.h:120
NTSTATUS FltpRegisterContexts(_In_ PFLT_FILTER Filter, _In_ const FLT_CONTEXT_REGISTRATION *Context)
Definition: Context.c:43
#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
USHORT FLT_CONTEXT_TYPE
Definition: fltkernel.h:436
#define FLT_TRANSACTION_CONTEXT
Definition: fltkernel.h:443
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
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define _Out_
Definition: no_sal2.h:323
FLT_CONTEXT_TYPE ContextType
Definition: fltkernel.h:516
Definition: bufpool.h:45
#define FLT_STREAM_CONTEXT
Definition: fltkernel.h:441
#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 FLT_INSTANCE_CONTEXT
Definition: fltkernel.h:439
#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
#define FLT_FILE_CONTEXT
Definition: fltkernel.h:440
Status
Definition: gdiplustypes.h:24
#define _In_
Definition: no_sal2.h:204
#define FLT_VOLUME_CONTEXT
Definition: fltkernel.h:438
unsigned short USHORT
Definition: pedump.c:61
PALLOCATE_CONTEXT_HEADER SupportedContextsListHead
Definition: fltmgrint.h:111
struct tagContext Context
Definition: acpixf.h:1024
unsigned int ULONG
Definition: retypes.h:1
#define FLT_STREAMHANDLE_CONTEXT
Definition: fltkernel.h:442
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE ContextType
Definition: fltkernel.h:1444
#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:2938
#define FLT_ASSERT(_e)
Definition: fltkernel.h:49