WDK Mini Filter Example
change/context.h
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation. All Rights Reserved
4 
5 Module Name:
6 
7  context.h
8 
9 Abstract:
10 
11  Header file which contains context-related data
12  structures, type definitions, constants,
13  global variables and function prototypes.
14 
15 Environment:
16 
17  Kernel mode
18 
19 --*/
20 
21 #ifndef __CONTEXT_H__
22 #define __CONTEXT_H__
23 
24 #define CG_FILE_CONTEXT_TAG 'cFcG'
25 #define CG_TRANSACTION_CONTEXT_TAG 'cTcG'
26 
27 //
28 // Defines the transaction context structure
29 //
30 
31 typedef struct _CG_TRANSACTION_CONTEXT {
32 
33  //
34  // Transaction object pointer
35  //
36 
37  PKTRANSACTION Transaction;
38 
39  //
40  // A flag that tracks if it has ben enlisted in transaction
41  //
42 
43  BOOLEAN Enlisted;
44 
45  //
46  // A flag that indicates if the fc list is drained
47  //
48 
49  BOOLEAN ListDrained;
50 
51  //
52  // List head for file context list.
53  // The list is grown only when transacted writers are part of the
54  // transaction, i.e. this list contains all file contexts likely
55  // to be modified in a transaction.
56  //
57 
58  LIST_ENTRY ScListHead;
59 
60  //
61  // Lock used to protect the list.
62  //
63 
64  PFAST_MUTEX Mutex;
65 
67 
68 #define CG_TRANSACTION_CONTEXT_SIZE sizeof( CG_TRANSACTION_CONTEXT )
69 
70 //
71 // This is to deal with ReFS' 128-bit file IDs & NTFS' 64-bit FileIDs.
72 //
73 
74 typedef union _CG_FILE_REFERENCE {
75 
76  //
77  // For 64-bit fileIDs the upper 64-bits are always zeroes.
78  //
79 
80  struct {
81  ULONGLONG Value;
82  ULONGLONG UpperZeroes;
83  } FileId64;
84 
85  FILE_ID_128 FileId128;
86 
88 
89 //
90 // File context data structure
91 //
92 
93 typedef struct _CG_FILE_CONTEXT {
94 
95  //
96  // File ID, obtained from querying the file system for
97  // FileInternalInformation or FileIdInformation.
98  //
99 
101 
102  //
103  // The flag that we use to record if the file is dirty
104  // if we have seen it before.
105  //
106 
107  BOOLEAN Dirty;
108 
109  //
110  // TxDirty is to record if the file is dirty in a
111  // transaction
112  //
113 
114  BOOLEAN TxDirty;
115 
116  //
117  // A pointer to the transaction context, so we can jump to list in the transaction.
118  //
119 
120  PCG_TRANSACTION_CONTEXT TxContext;
121 
122  //
123  // This list entry is exactly the embedded entry to
124  // form a doubly linked list inside transaction context.
125  //
126 
127  LIST_ENTRY ListInTransaction;
128 
130 
131 #define CG_FILE_CONTEXT_SIZE sizeof( CG_FILE_CONTEXT )
132 
133 
134 
135 
136 NTSTATUS
138  _In_ PFLT_CALLBACK_DATA Cbd,
139  _Outptr_ PCG_FILE_CONTEXT *FileContext
140  );
141 
142 
143 NTSTATUS
145  _In_ PCFLT_RELATED_OBJECTS FltObjects,
146  _Outptr_ PCG_TRANSACTION_CONTEXT *TransactionContext
147  );
148 
149 
150 #endif
151 
union _CG_FILE_REFERENCE CG_FILE_REFERENCE
NTSTATUS CgFindOrCreateFileContext(_In_ PFLT_CALLBACK_DATA Cbd, _Outptr_ PCG_FILE_CONTEXT *FileContext)
FILE_ID_128 FileId128
CG_FILE_REFERENCE FileID
PKTRANSACTION Transaction
NTSTATUS CgFindOrCreateTransactionContext(_In_ PCFLT_RELATED_OBJECTS FltObjects, _Outptr_ PCG_TRANSACTION_CONTEXT *TransactionContext)
struct _CG_TRANSACTION_CONTEXT CG_TRANSACTION_CONTEXT
struct _CG_FILE_CONTEXT CG_FILE_CONTEXT
struct _CG_FILE_CONTEXT * PCG_FILE_CONTEXT
union _CG_FILE_REFERENCE * PCG_FILE_REFERENCE
PCG_TRANSACTION_CONTEXT TxContext
LIST_ENTRY ListInTransaction
struct _CG_TRANSACTION_CONTEXT * PCG_TRANSACTION_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