1 /*++ 2 3 Copyright (c) Microsoft Corporation 4 5 Module Name: 6 7 FxFileObjectCallbacks.h 8 9 Abstract: 10 11 This module implements the I/O package queue object callbacks 12 13 Author: 14 15 16 17 18 Environment: 19 20 Both kernel and user mode 21 22 Revision History: 23 24 --*/ 25 26 #ifndef _FXFILEOBJECTCALLBACKS_H 27 #define _FXFILEOBJECTCALLBACKS_H 28 29 30 // 31 // EvtDeviceFileCreate callback delegate 32 // 33 class FxFileObjectFileCreate : public FxLockedCallback { 34 35 public: 36 PFN_WDF_DEVICE_FILE_CREATE Method; 37 38 FxFileObjectFileCreate( 39 VOID 40 ) : 41 FxLockedCallback() 42 { 43 Method = NULL; 44 } 45 46 VOID 47 Invoke( 48 __in WDFDEVICE Device, 49 __in WDFREQUEST Request, 50 __in_opt WDFFILEOBJECT FileObject 51 ) 52 { 53 54 if (Method != NULL) { 55 KIRQL irql = 0; 56 57 CallbackStart(&irql); 58 Method(Device, Request, FileObject); 59 CallbackEnd(irql); 60 } 61 } 62 }; 63 64 // 65 // EvtFileCleanup callback delegate 66 // 67 class FxFileObjectFileCleanup : public FxLockedCallback { 68 69 public: 70 PFN_WDF_FILE_CLEANUP Method; 71 72 FxFileObjectFileCleanup( 73 VOID 74 ) : 75 FxLockedCallback() 76 { 77 Method = NULL; 78 } 79 80 void 81 Invoke( 82 __in_opt WDFFILEOBJECT FileObject 83 ) 84 { 85 if (Method != NULL) { 86 KIRQL irql = 0; 87 88 CallbackStart(&irql); 89 Method(FileObject); 90 CallbackEnd(irql); 91 } 92 } 93 }; 94 95 // 96 // EvtFileClose callback delegate 97 // 98 class FxFileObjectFileClose : public FxLockedCallback { 99 100 public: 101 PFN_WDF_FILE_CLOSE Method; 102 103 FxFileObjectFileClose( 104 VOID 105 ) : 106 FxLockedCallback() 107 { 108 Method = NULL; 109 } 110 111 void 112 Invoke( 113 __in_opt WDFFILEOBJECT FileObject 114 ) 115 { 116 if (Method != NULL) { 117 KIRQL irql = 0; 118 119 CallbackStart(&irql); 120 Method(FileObject); 121 CallbackEnd(irql); 122 } 123 } 124 }; 125 126 // 127 // EvtDeviceFileCreate callback delegate 128 // 129 class FxCxFileObjectFileCreate : public FxLockedCallback { 130 131 public: 132 PFN_WDFCX_DEVICE_FILE_CREATE Method; 133 134 FxCxFileObjectFileCreate( 135 VOID 136 ) : 137 FxLockedCallback() 138 { 139 Method = NULL; 140 } 141 142 BOOLEAN 143 Invoke( 144 __in WDFDEVICE Device, 145 __in WDFREQUEST Request, 146 __in_opt WDFFILEOBJECT FileObject 147 ) 148 { 149 BOOLEAN claimed = FALSE; 150 151 if (Method != NULL) { 152 KIRQL irql = 0; 153 154 CallbackStart(&irql); 155 claimed = Method(Device, Request, FileObject); 156 CallbackEnd(irql); 157 } 158 159 return claimed; 160 } 161 }; 162 163 // 164 // Collection of file-object callbacks. 165 // 166 struct FxFileObjectInfo : public FxStump { 167 168 FxFileObjectInfo() : 169 FileObjectClass(WdfFileObjectInvalid), 170 AutoForwardCleanupClose(WdfUseDefault), 171 ClassExtension(FALSE), 172 CxDeviceInfo(NULL) 173 { 174 InitializeListHead(&ListEntry); 175 RtlZeroMemory(&Attributes, sizeof(Attributes)); 176 } 177 178 ~FxFileObjectInfo() 179 { 180 ASSERT(IsListEmpty(&ListEntry)); 181 } 182 183 LIST_ENTRY ListEntry; 184 185 FxFileObjectFileCreate EvtFileCreate; 186 FxCxFileObjectFileCreate EvtCxFileCreate; 187 FxFileObjectFileCleanup EvtFileCleanup; 188 FxFileObjectFileClose EvtFileClose; 189 190 WDF_FILEOBJECT_CLASS FileObjectClass; 191 WDF_OBJECT_ATTRIBUTES Attributes; 192 WDF_TRI_STATE AutoForwardCleanupClose; 193 194 BOOLEAN ClassExtension; 195 196 FxCxDeviceInfo* CxDeviceInfo; 197 }; 198 199 #endif // _FXFILEOBJECTCALLBACKS_H 200 201