WDK Mini Filter Example
CtxStruc.h
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) 1999 - 2002 Microsoft Corporation
4 
5 Module Name:
6 
7  CtxStruct.h
8 
9 Abstract:
10 
11  This is the header file defining the data structures used by the kernel mode
12  filter driver implementing the context sample.
13 
14 
15 Environment:
16 
17  Kernel mode
18 
19 
20 --*/
21 
22 //
23 // Memory Pool Tags
24 //
25 
26 #define CTX_STRING_TAG 'tSxC'
27 #define CTX_RESOURCE_TAG 'cRxC'
28 #define CTX_INSTANCE_CONTEXT_TAG 'cIxC'
29 #define CTX_FILE_CONTEXT_TAG 'cFxC'
30 #define CTX_STREAM_CONTEXT_TAG 'cSxC'
31 #define CTX_STREAMHANDLE_CONTEXT_TAG 'cHxC'
32 
33 
34 //
35 // Context sample filter global data
36 //
37 
38 typedef struct _CTX_GLOBAL_DATA {
39 
40  //
41  // Handle to minifilter returned from FltRegisterFilter()
42  //
43 
44  PFLT_FILTER Filter;
45 
46 #if DBG
47 
48  //
49  // Field to control nature of debug output
50  //
51 
52  ULONG DebugLevel;
53 #endif
54 
56 
58 
59 
60 
61 
62 //
63 // Instance context data structure
64 //
65 
66 typedef struct _CTX_INSTANCE_CONTEXT {
67 
68  //
69  // Instance for this context.
70  //
71 
72  PFLT_INSTANCE Instance;
73 
74  //
75  // Volume associated with this instance.
76  //
77 
78  PFLT_VOLUME Volume;
79 
80  //
81  // Name of the volume associated with this instance.
82  //
83 
84  UNICODE_STRING VolumeName;
85 
87 
88 #define CTX_INSTANCE_CONTEXT_SIZE sizeof( CTX_INSTANCE_CONTEXT )
89 
90 
91 //
92 // File context data structure
93 //
94 
95 typedef struct _CTX_FILE_CONTEXT {
96 
97  //
98  // Name of the file associated with this context.
99  //
100 
101  UNICODE_STRING FileName;
102 
103  //
104  // There is no resource to protect the context since the
105  // filename in the context is never modified. The filename
106  // is put in when the context is created and then freed
107  // with context is cleaned-up
108  //
109 
111 
112 #define CTX_FILE_CONTEXT_SIZE sizeof( CTX_FILE_CONTEXT )
113 
114 
115 
116 //
117 // Stream context data structure
118 //
119 
120 typedef struct _CTX_STREAM_CONTEXT {
121 
122  //
123  // Name of the file associated with this context.
124  //
125 
126  UNICODE_STRING FileName;
127 
128  //
129  // Number of times we saw a create on this stream
130  //
131 
132  ULONG CreateCount;
133 
134  //
135  // Number of times we saw a cleanup on this stream
136  //
137 
139 
140  //
141  // Number of times we saw a close on this stream
142  //
143 
144  ULONG CloseCount;
145 
146  //
147  // Lock used to protect this context.
148  //
149 
150  PERESOURCE Resource;
151 
153 
154 #define CTX_STREAM_CONTEXT_SIZE sizeof( CTX_STREAM_CONTEXT )
155 
156 
157 
158 //
159 // Stream handle context data structure
160 //
161 
163 
164  //
165  // Name of the file associated with this context.
166  //
167 
168  UNICODE_STRING FileName;
169 
170  //
171  // Lock used to protect this context.
172  //
173 
174  PERESOURCE Resource;
175 
177 
178 #define CTX_STREAMHANDLE_CONTEXT_SIZE sizeof( CTX_STREAMHANDLE_CONTEXT )
179 
180 
181 //
182 // Debug helper functions
183 //
184 
185 #if DBG
186 
187 
188 #define DEBUG_TRACE_ERROR 0x00000001 // Errors - whenever we return a failure code
189 #define DEBUG_TRACE_LOAD_UNLOAD 0x00000002 // Loading/unloading of the filter
190 #define DEBUG_TRACE_INSTANCES 0x00000004 // Attach / detatch of instances
191 
192 #define DEBUG_TRACE_INSTANCE_CONTEXT_OPERATIONS 0x00000008 // Operation on instance context
193 #define DEBUG_TRACE_FILE_CONTEXT_OPERATIONS 0x00000010 // Operation on file context
194 #define DEBUG_TRACE_STREAM_CONTEXT_OPERATIONS 0x00000020 // Operation on stream context
195 #define DEBUG_TRACE_STREAMHANDLE_CONTEXT_OPERATIONS 0x00000040 // Operation on stream handle context
196 
197 #define DEBUG_TRACE_ALL_IO 0x00000080 // All IO operations tracked by this filter
198 
199 #define DEBUG_TRACE_ALL 0xFFFFFFFF // All flags
200 
201 
202 #define DebugTrace(Level, Data) \
203  if ((Level) & Globals.DebugLevel) { \
204  DbgPrint Data; \
205  }
206 
207 
208 #else
209 
210 #define DebugTrace(Level, Data) {NOTHING;}
211 
212 #endif
213 
struct _CTX_GLOBAL_DATA CTX_GLOBAL_DATA
UNICODE_STRING FileName
Definition: CtxStruc.h:168
struct _CTX_STREAMHANDLE_CONTEXT * PCTX_STREAMHANDLE_CONTEXT
struct _CTX_STREAMHANDLE_CONTEXT CTX_STREAMHANDLE_CONTEXT
CTX_GLOBAL_DATA Globals
Definition: avscan.h:152
struct _CTX_STREAM_CONTEXT * PCTX_STREAM_CONTEXT
struct _CTX_GLOBAL_DATA * PCTX_GLOBAL_DATA
struct _CTX_STREAM_CONTEXT CTX_STREAM_CONTEXT
PFLT_VOLUME Volume
Definition: CtxStruc.h:78
struct _CTX_FILE_CONTEXT CTX_FILE_CONTEXT
PERESOURCE Resource
Definition: CtxStruc.h:150
UNICODE_STRING FileName
Definition: CtxStruc.h:101
UNICODE_STRING VolumeName
Definition: CtxStruc.h:84
PFLT_FILTER Filter
Definition: CtxStruc.h:44
struct _CTX_INSTANCE_CONTEXT * PCTX_INSTANCE_CONTEXT
PFLT_INSTANCE Instance
Definition: CtxStruc.h:72
UNICODE_STRING FileName
Definition: CtxStruc.h:126
struct _CTX_INSTANCE_CONTEXT CTX_INSTANCE_CONTEXT
struct _CTX_FILE_CONTEXT * PCTX_FILE_CONTEXT

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