1 /*++ 2 3 Copyright (c) Microsoft Corporation 4 5 Module Name: 6 7 FxIoQueueCallbacks.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 _FXIOQUEUECALLBACKS_H_ 27 #define _FXIOQUEUECALLBACKS_H_ 28 29 // 30 // These delegates are in a seperate file since there are many 31 // 32 33 // 34 // EvtIoDefault callback delegate 35 // 36 class FxIoQueueIoDefault : public FxLockedCallback { 37 38 public: 39 PFN_WDF_IO_QUEUE_IO_DEFAULT Method; 40 41 FxIoQueueIoDefault( 42 VOID 43 ) : 44 FxLockedCallback() 45 { 46 Method = NULL; 47 } 48 49 void 50 Invoke( 51 __in WDFQUEUE Queue, 52 __in WDFREQUEST Request 53 ) 54 { 55 if (Method != NULL) { 56 KIRQL irql = 0; 57 58 CallbackStart(&irql); 59 Method(Queue, Request); 60 CallbackEnd(irql); 61 } 62 } 63 }; 64 65 66 // 67 // EvtIoStop callback delegate 68 // 69 class FxIoQueueIoStop : public FxLockedCallback { 70 71 public: 72 PFN_WDF_IO_QUEUE_IO_STOP Method; 73 74 FxIoQueueIoStop( 75 VOID 76 ) : 77 FxLockedCallback() 78 { 79 Method = NULL; 80 } 81 82 void 83 Invoke( 84 __in WDFQUEUE Queue, 85 __in WDFREQUEST Request, 86 __in ULONG ActionFlags 87 ) 88 { 89 if (Method != NULL) { 90 KIRQL irql = 0; 91 92 CallbackStart(&irql); 93 Method(Queue, Request, ActionFlags); 94 CallbackEnd(irql); 95 } 96 } 97 }; 98 99 // 100 // EvtIoResume callback delegate 101 // 102 class FxIoQueueIoResume : public FxLockedCallback { 103 104 public: 105 PFN_WDF_IO_QUEUE_IO_RESUME Method; 106 107 FxIoQueueIoResume( 108 VOID 109 ) : 110 FxLockedCallback() 111 { 112 Method = NULL; 113 } 114 115 void 116 Invoke( 117 __in WDFQUEUE Queue, 118 __in WDFREQUEST Request 119 ) 120 { 121 if (Method != NULL) { 122 KIRQL irql = 0; 123 124 CallbackStart(&irql); 125 Method(Queue, Request); 126 CallbackEnd(irql); 127 } 128 } 129 }; 130 131 // 132 // EvtIoRead callback delegate 133 // 134 class FxIoQueueIoRead : public FxLockedCallback { 135 136 public: 137 PFN_WDF_IO_QUEUE_IO_READ Method; 138 139 FxIoQueueIoRead( 140 VOID 141 ) : 142 FxLockedCallback() 143 { 144 Method = NULL; 145 } 146 147 void 148 Invoke( 149 __in WDFQUEUE Queue, 150 __in WDFREQUEST Request, 151 __in ULONG Length 152 ) 153 { 154 if (Method != NULL) { 155 KIRQL irql = 0; 156 157 CallbackStart(&irql); 158 Method(Queue, Request, Length); 159 CallbackEnd(irql); 160 } 161 } 162 }; 163 164 // 165 // EvtIoWrite callback delegate 166 // 167 class FxIoQueueIoWrite : public FxLockedCallback { 168 169 public: 170 PFN_WDF_IO_QUEUE_IO_WRITE Method; 171 172 FxIoQueueIoWrite( 173 VOID 174 ) : 175 FxLockedCallback() 176 { 177 Method = NULL; 178 } 179 180 void 181 Invoke( 182 __in WDFQUEUE Queue, 183 __in WDFREQUEST Request, 184 __in ULONG Length 185 ) 186 { 187 if (Method != NULL) { 188 KIRQL irql = 0; 189 190 CallbackStart(&irql); 191 Method(Queue, Request, Length); 192 CallbackEnd(irql); 193 } 194 } 195 }; 196 197 // 198 // EvtIoIoctl callback delegate 199 // 200 class FxIoQueueIoDeviceControl : public FxLockedCallback { 201 202 public: 203 PFN_WDF_IO_QUEUE_IO_DEVICE_CONTROL Method; 204 205 FxIoQueueIoDeviceControl( 206 VOID 207 ) : 208 FxLockedCallback() 209 { 210 Method = NULL; 211 } 212 213 void 214 Invoke( 215 __in WDFQUEUE Queue, 216 __in WDFREQUEST Request, 217 __in ULONG OutputBufferLength, 218 __in ULONG InputBufferLength, 219 __in ULONG IoControlCode 220 ) 221 { 222 if (Method != NULL) { 223 KIRQL irql = 0; 224 225 CallbackStart(&irql); 226 Method( 227 Queue, 228 Request, 229 OutputBufferLength, 230 InputBufferLength, 231 IoControlCode 232 ); 233 CallbackEnd(irql); 234 } 235 } 236 }; 237 238 // 239 // EvtIoInternalIoctl callback delegate 240 // 241 class FxIoQueueIoInternalDeviceControl : public FxLockedCallback { 242 243 public: 244 PFN_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL Method; 245 246 FxIoQueueIoInternalDeviceControl( 247 VOID 248 ) : 249 FxLockedCallback() 250 { 251 Method = NULL; 252 } 253 254 void 255 Invoke( 256 __in WDFQUEUE Queue, 257 __in WDFREQUEST Request, 258 __in ULONG OutputBufferLength, 259 __in ULONG InputBufferLength, 260 __in ULONG IoInternalControlCode 261 ) 262 { 263 if (Method != NULL) { 264 KIRQL irql = 0; 265 266 CallbackStart(&irql); 267 Method( 268 Queue, 269 Request, 270 OutputBufferLength, 271 InputBufferLength, 272 IoInternalControlCode 273 ); 274 CallbackEnd(irql); 275 } 276 } 277 }; 278 279 // 280 // EvtIoQueueStatus callback delegate 281 // 282 class FxIoQueueIoState : public FxLockedCallback { 283 284 public: 285 PFN_WDF_IO_QUEUE_STATE Method; 286 287 FxIoQueueIoState( 288 VOID 289 ) : 290 FxLockedCallback() 291 { 292 Method = NULL; 293 } 294 295 void 296 Invoke( 297 __in WDFQUEUE Queue, 298 __in WDFCONTEXT Context 299 ) 300 { 301 if (Method != NULL) { 302 KIRQL irql = 0; 303 304 CallbackStart(&irql); 305 Method(Queue, Context); 306 CallbackEnd(irql); 307 } 308 } 309 }; 310 311 class FxIoQueueIoCanceledOnQueue : public FxLockedCallback { 312 313 public: 314 PFN_WDF_IO_QUEUE_IO_CANCELED_ON_QUEUE Method; 315 316 FxIoQueueIoCanceledOnQueue( 317 VOID 318 ) : 319 FxLockedCallback() 320 { 321 Method = NULL; 322 } 323 324 void 325 Invoke( 326 __in WDFQUEUE Queue, 327 __in WDFREQUEST Request 328 ) 329 { 330 if (Method != NULL) { 331 KIRQL irql = 0; 332 333 CallbackStart(&irql); 334 Method(Queue, Request); 335 CallbackEnd(irql); 336 } 337 } 338 }; 339 340 341 class FxIoQueueForwardProgressAllocateResourcesReserved : public FxCallback { 342 343 public: 344 PFN_WDF_IO_ALLOCATE_RESOURCES_FOR_RESERVED_REQUEST Method; 345 346 FxIoQueueForwardProgressAllocateResourcesReserved( 347 VOID 348 ) : 349 FxCallback() 350 { 351 Method = NULL; 352 } 353 354 _Must_inspect_result_ 355 NTSTATUS 356 Invoke( 357 __in WDFQUEUE Queue, 358 __in WDFREQUEST Request 359 ) 360 { 361 ASSERT(Method != NULL); 362 return Method(Queue, Request); 363 } 364 }; 365 366 class FxIoQueueForwardProgressAllocateResources : public FxCallback { 367 368 public: 369 PFN_WDF_IO_ALLOCATE_REQUEST_RESOURCES Method; 370 371 FxIoQueueForwardProgressAllocateResources( 372 VOID 373 ) : 374 FxCallback() 375 { 376 Method = NULL; 377 } 378 379 _Must_inspect_result_ 380 NTSTATUS 381 Invoke( 382 __in WDFQUEUE Queue, 383 __in WDFREQUEST Request 384 ) 385 { 386 ASSERT(Method != NULL); 387 return Method(Queue, Request); 388 } 389 }; 390 391 class FxIoQueueForwardProgressExamineIrp : public FxCallback { 392 public: 393 PFN_WDF_IO_WDM_IRP_FOR_FORWARD_PROGRESS Method; 394 395 FxIoQueueForwardProgressExamineIrp( 396 VOID 397 ) : 398 FxCallback() 399 { 400 Method = NULL; 401 } 402 403 WDF_IO_FORWARD_PROGRESS_ACTION 404 Invoke( 405 __in WDFQUEUE Queue, 406 __in PIRP Irp 407 ) 408 { 409 ASSERT(Method != NULL); 410 return Method(Queue, Irp); 411 } 412 }; 413 414 415 416 #endif // _FXIOQUEUECALLBACKS_H_ 417