WDK Mini Filter Example
MetadataManagerStruc.h
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) 1999 - 2002 Microsoft Corporation
4 
5 Module Name:
6 
7  MetadataManagerStruct.h
8 
9 Abstract:
10 
11  This is the header file defining the data structures used by the kernel mode
12  filter driver implementing filter metadata manager.
13 
14 
15 Environment:
16 
17  Kernel mode
18 
19 
20 --*/
21 
22 //
23 // If this is 1, then the filter will validate that the metadata file is indeed open
24 // whenever a create suceeds on the volume
25 //
26 
27 #define VERIFY_METADATA_OPENED 0
28 
29 
30 //
31 // Memory Pool Tags
32 //
33 
34 #define FMM_STRING_TAG 'tSmF'
35 #define FMM_INSTANCE_CONTEXT_TAG 'cImF'
36 
37 
38 //
39 // Filter metadata management filter global data
40 //
41 
42 typedef struct _FMM_GLOBAL_DATA {
43 
44  //
45  // Handle to minifilter returned from FltRegisterFilter()
46  //
47 
48  PFLT_FILTER Filter;
49 
50 
51 #if DBG
52 
53  //
54  // Field to control nature of debug output
55  //
56 
57  ULONG DebugLevel;
58 #endif
59 
61 
63 
64 
65 
66 
67 //
68 // Instance context flags and data structure
69 //
70 
71 //
72 // Indicates that the instance context resource has been released
73 // before performing a file system operation that could potentially
74 // cause the resource to be re-acquired and deadlock the system
75 //
76 
77 #define INSTANCE_CONTEXT_F_TRANSITION 0x00000001
78 
79 
80 //
81 // Indicates if the filter has opened the metadata file and
82 // holds a reference to the metadata file object for the
83 // volume
84 //
85 
86 #define INSTANCE_CONTEXT_F_METADATA_OPENED 0x00000002
87 
88 
89 typedef struct _FMM_INSTANCE_CONTEXT {
90 
91  //
92  // Flags for this instance - defined as INSTANCE_CONTEXT_F_XXX
93  //
94 
95  ULONG Flags;
96 
97  //
98  // Instance for this context.
99  //
100 
101  PFLT_INSTANCE Instance;
102 
103  //
104  // File System Type for this instance.
105  //
106 
107  FLT_FILESYSTEM_TYPE FilesystemType;
108 
109  //
110  // Volume associated with this instance.
111  //
112 
113  PFLT_VOLUME Volume;
114 
115  //
116  // Resource for synchronizing access to the metadata file.
117  // This recource may also be overloaded to control access to in-memory
118  // structures that hang off the instance context of the volume.
119  //
120 
121  ERESOURCE MetadataResource;
122 
123  //
124  // Handle of the metadata file.
125  //
126 
128 
129  //
130  // File object of the metadata file.
131  //
132 
133  PFILE_OBJECT MetadataFileObject;
134 
135  //
136  // The file object on cleanup or cancel removal of which we need to re-open
137  // our metadata file. This is basically the file object on which we received
138  // an explicit or implicit lock or a pnp query removal that caused us to
139  // drop the references to our metadata file
140  //
141 
143 
145 
146 #define FMM_INSTANCE_CONTEXT_SIZE sizeof( FMM_INSTANCE_CONTEXT )
147 
148 
149 //
150 // Name of the metadata file for this filter.
151 // In this sample, we put the metadata file in the SystemVolumeInformation
152 // folder so as to demonstrate creation of this folder if it does not
153 // exist
154 //
155 
156 #define FMM_METADATA_FILE_NAME L"\\System Volume Information\\FilterMetadata.md"
157 #define FMM_METADATA_FILE_NAME_LENGTH (sizeof( FMM_METADATA_FILE_NAME ) - sizeof( WCHAR ))
158 
159 //
160 // Default length of the volume name.
161 //
162 
163 #define FMM_DEFAULT_VOLUME_NAME_LENGTH 64
164 
165 
166 //
167 // Debug helper functions
168 //
169 
170 #if DBG
171 
172 
173 #define DEBUG_TRACE_ERROR 0x00000001 // Errors - whenever we return a failure code
174 #define DEBUG_TRACE_LOAD_UNLOAD 0x00000002 // Loading/unloading of the filter
175 #define DEBUG_TRACE_INSTANCES 0x00000004 // Attach / detatch of instances
176 
177 #define DEBUG_TRACE_METADATA_OPERATIONS 0x00000008 // Operation to access / modify in memory metadata
178 
179 #define DEBUG_TRACE_ALL_IO 0x00000010 // All IO operations tracked by this filter
180 
181 #define DEBUG_TRACE_INFO 0x00000020 // Misc. information
182 
183 #define DEBUG_TRACE_ALL 0xFFFFFFFF // All flags
184 
185 
186 #define DebugTrace(Level, Data) \
187  if ((Level) & Globals.DebugLevel) { \
188  DbgPrint Data; \
189  }
190 
191 
192 #else
193 
194 #define DebugTrace(Level, Data) {NOTHING;}
195 
196 #endif
197 
PFILE_OBJECT MetadataOpenTriggerFileObject
struct _FMM_INSTANCE_CONTEXT FMM_INSTANCE_CONTEXT
struct _FMM_GLOBAL_DATA * PFMM_GLOBAL_DATA
struct _FMM_GLOBAL_DATA FMM_GLOBAL_DATA
FLT_FILESYSTEM_TYPE FilesystemType
FMM_GLOBAL_DATA Globals
Definition: avscan.h:152
struct _FMM_INSTANCE_CONTEXT * PFMM_INSTANCE_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