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