Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

filtrctx.c File Reference

#include "FsRtlP.h"

Go to the source code of this file.

Defines

#define MySearchList(pHdr, Ptr)   for ( Ptr = (pHdr)->Flink; Ptr != (pHdr); Ptr = Ptr->Flink )
#define Dbg   (0x80000000)

Functions

NTKERNELAPI NTSTATUS FsRtlInsertFilterContext (IN PFILE_OBJECT FileObject, IN PFSRTL_FILTER_CONTEXT Ptr)
NTKERNELAPI PFSRTL_FILTER_CONTEXT FsRtlLookupFilterContextInternal (IN PFILE_OBJECT FileObject, IN PVOID OwnerId OPTIONAL, IN PVOID InstanceId OPTIONAL)
NTKERNELAPI PFSRTL_FILTER_CONTEXT FsRtlRemoveFilterContext (IN PFILE_OBJECT FileObject, IN PVOID OwnerId OPTIONAL, IN PVOID InstanceId OPTIONAL)
NTKERNELAPI VOID FsRtlTeardownFilterContexts (IN PLIST_ENTRY FilterContexts)


Define Documentation

#define Dbg   (0x80000000)
 

Definition at line 53 of file filtrctx.c.

#define MySearchList pHdr,
Ptr   )     for ( Ptr = (pHdr)->Flink; Ptr != (pHdr); Ptr = Ptr->Flink )
 

Definition at line 46 of file filtrctx.c.

Referenced by FsRtlLookupFilterContextInternal(), and FsRtlRemoveFilterContext().


Function Documentation

NTKERNELAPI NTSTATUS FsRtlInsertFilterContext IN PFILE_OBJECT  FileObject,
IN PFSRTL_FILTER_CONTEXT  Ptr
 

Definition at line 58 of file filtrctx.c.

References ASSERT, FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS, Header, PFSRTL_FILTER_CONTEXT, and Ptr.

00064 : 00065 00066 This routine associates filter driver context with a stream. 00067 00068 Arguments: 00069 00070 FileObject - Specifies the stream of interest. 00071 00072 Ptr - Pointer to the filter-specific context structure. 00073 The common header fields OwnerId and InstanceId should 00074 be filled in by the filter driver before calling. 00075 00076 Return Value: 00077 00078 STATUS_SUCCESS - operation succeeded. 00079 00080 STATUS_INVALID_DEVICE_REQUEST - underlying filesystem does not support 00081 filter contexts. 00082 00083 --*/ 00084 00085 { 00086 PFSRTL_COMMON_FCB_HEADER Header; 00087 00088 ASSERT(FileObject); 00089 ASSERT(FileObject->FsContext); 00090 00091 Header = FileObject->FsContext; 00092 00093 if (! (Header->Flags2 & FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS) ) { 00094 return STATUS_INVALID_DEVICE_REQUEST; 00095 } 00096 00097 ExAcquireFastMutex (Header->FastMutex); 00098 00099 InsertHeadList (&Header->FilterContexts, &Ptr->Links); 00100 00101 ExReleaseFastMutex(Header->FastMutex); 00102 return STATUS_SUCCESS; 00103 }

NTKERNELAPI PFSRTL_FILTER_CONTEXT FsRtlLookupFilterContextInternal IN PFILE_OBJECT  FileObject,
IN PVOID OwnerId  OPTIONAL,
IN PVOID InstanceId  OPTIONAL
 

Definition at line 108 of file filtrctx.c.

References ASSERT, FSRTL_FILTER_CONTEXT, FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS, Header, _FSRTL_FILTER_CONTEXT::InstanceId, List, MySearchList, NULL, and _FSRTL_FILTER_CONTEXT::OwnerId.

00115 : 00116 00117 This routine lookups filter driver context associated with a stream. 00118 00119 The macro FsRtlLookupFilterContext should be used instead of calling 00120 this routine directly. The macro optimizes for the common case 00121 of an empty list. 00122 00123 Arguments: 00124 00125 FileObject - Specifies the stream of interest. 00126 00127 OwnerId - Used to identify context information belonging to a particular 00128 filter driver. 00129 00130 InstanceId - Used to search for a particular instance of a filter driver 00131 context. If not provided, any of the contexts owned by the filter 00132 driver is returned. 00133 00134 If neither the OwnerId nor the InstanceId is provided, any associated 00135 filter context will be returned. 00136 00137 Return Value: 00138 00139 A pointer to the filter context, or NULL if no match found. 00140 00141 --*/ 00142 00143 { 00144 PFSRTL_COMMON_FCB_HEADER Header; 00145 PFSRTL_FILTER_CONTEXT Ctx, RtnCtx; 00146 PLIST_ENTRY List; 00147 00148 ASSERT(FileObject); 00149 ASSERT(FileObject->FsContext); 00150 00151 Header = FileObject->FsContext; 00152 00153 ASSERT (Header->Flags2 & FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS); 00154 00155 ExAcquireFastMutex (Header->FastMutex); 00156 RtnCtx = NULL; 00157 00158 // Use different loops depending on whether we are comparing both Ids or not. 00159 if ( ARGUMENT_PRESENT(InstanceId) ) { 00160 00161 MySearchList (&Header->FilterContexts, List) { 00162 Ctx = CONTAINING_RECORD (List, FSRTL_FILTER_CONTEXT, Links); 00163 if (Ctx->OwnerId == OwnerId && Ctx->InstanceId == InstanceId) { 00164 RtnCtx = Ctx; 00165 break; 00166 } 00167 } 00168 } else if ( ARGUMENT_PRESENT(OwnerId) ) { 00169 00170 MySearchList (&Header->FilterContexts, List) { 00171 Ctx = CONTAINING_RECORD (List, FSRTL_FILTER_CONTEXT, Links); 00172 if (Ctx->OwnerId == OwnerId) { 00173 RtnCtx = Ctx; 00174 break; 00175 } 00176 } 00177 } else if (!IsListEmpty(&Header->FilterContexts)) { 00178 00179 RtnCtx = (PFSRTL_FILTER_CONTEXT) Header->FilterContexts.Flink; 00180 } 00181 00182 ExReleaseFastMutex(Header->FastMutex); 00183 return RtnCtx; 00184 }

NTKERNELAPI PFSRTL_FILTER_CONTEXT FsRtlRemoveFilterContext IN PFILE_OBJECT  FileObject,
IN PVOID OwnerId  OPTIONAL,
IN PVOID InstanceId  OPTIONAL
 

Definition at line 189 of file filtrctx.c.

References ASSERT, FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS, Header, _FSRTL_FILTER_CONTEXT::InstanceId, _FSRTL_FILTER_CONTEXT::Links, List, MySearchList, NULL, and _FSRTL_FILTER_CONTEXT::OwnerId.

00196 : 00197 00198 This routine deletes filter driver context associated with a stream. 00199 00200 Filter drivers must explicitly remove all context they associate with 00201 a stream (otherwise the underlying filesystem will BugCheck at close). 00202 00203 FsRtlRemoveFilterContext functions identically to FsRtlLookupFilterContext, 00204 except that the returned context has been removed from the list. 00205 00206 Arguments: 00207 00208 FileObject - Specifies the stream of interest. 00209 00210 OwnerId - Used to identify context information belonging to a particular 00211 filter driver. 00212 00213 InstanceId - Used to search for a particular instance of a filter driver 00214 context. If not provided, any of the contexts owned by the filter 00215 driver is removed and returned. 00216 00217 If neither the OwnerId nor the InstanceId is provided, any associated 00218 filter context will be removed and returned. 00219 00220 Return Value: 00221 00222 A pointer to the filter context, or NULL if no match found. 00223 00224 --*/ 00225 00226 { 00227 PFSRTL_COMMON_FCB_HEADER Header; 00228 PFSRTL_FILTER_CONTEXT Ctx, RtnCtx; 00229 PLIST_ENTRY List; 00230 00231 ASSERT(FileObject); 00232 00233 Header = FileObject->FsContext; 00234 00235 if ( !Header || !(Header->Flags2 & FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS) ) { 00236 return NULL; 00237 } 00238 00239 ExAcquireFastMutex (Header->FastMutex); 00240 RtnCtx = NULL; 00241 00242 // Use different loops depending on whether we are comparing both Ids or not. 00243 if ( ARGUMENT_PRESENT(InstanceId) ) { 00244 00245 MySearchList (&Header->FilterContexts, List) { 00246 Ctx = CONTAINING_RECORD (List, FSRTL_FILTER_CONTEXT, Links); 00247 if (Ctx->OwnerId == OwnerId && Ctx->InstanceId == InstanceId) { 00248 RtnCtx = Ctx; 00249 break; 00250 } 00251 } 00252 } else if ( ARGUMENT_PRESENT(OwnerId) ) { 00253 00254 MySearchList (&Header->FilterContexts, List) { 00255 Ctx = CONTAINING_RECORD (List, FSRTL_FILTER_CONTEXT, Links); 00256 if (Ctx->OwnerId == OwnerId) { 00257 RtnCtx = Ctx; 00258 break; 00259 } 00260 } 00261 } else if (!IsListEmpty(&Header->FilterContexts)) { 00262 00263 RtnCtx = (PFSRTL_FILTER_CONTEXT) Header->FilterContexts.Flink; 00264 } 00265 00266 if (RtnCtx) { 00267 RemoveEntryList(&RtnCtx->Links); // remove the matched entry 00268 } 00269 ExReleaseFastMutex(Header->FastMutex); 00270 return RtnCtx; 00271 }

NTKERNELAPI VOID FsRtlTeardownFilterContexts IN PLIST_ENTRY  FilterContexts  ) 
 

Definition at line 276 of file filtrctx.c.

References _FSRTL_FILTER_CONTEXT::FreeCallback.

00281 : 00282 00283 This routine is called by filesystems to free the filter contexts 00284 associated with an FSRTL_COMMON_FCB_HEADER by calling the FreeCallback 00285 routine for each FilterContext. 00286 00287 It is assumed that we do not need to acquire the FastMutex. 00288 00289 Arguments: 00290 00291 FilterContexts - the address of the FilterContexts field within 00292 the FSRTL_COMMON_FCB_HEADER of the structure being torn down 00293 by the filesystem. 00294 00295 Return Value: 00296 00297 None. 00298 00299 --*/ 00300 00301 { 00302 PFSRTL_FILTER_CONTEXT ctx; 00303 PLIST_ENTRY ptr; 00304 00305 ptr = FilterContexts->Flink; 00306 00307 while ( ptr != FilterContexts ) { 00308 ctx = CONTAINING_RECORD (ptr, FSRTL_FILTER_CONTEXT, Links); 00309 ptr = ptr->Flink; 00310 (*ctx->FreeCallback)(ctx); 00311 } 00312 00313 InitializeListHead( FilterContexts ); 00314 return; 00315 }


Generated on Sat May 15 19:43:40 2004 for test by doxygen 1.3.7