1 /*++ 2 3 Copyright (c) Microsoft Corporation 4 5 Module Name: 6 7 FxDriverCallbacks.h 8 9 Abstract: 10 11 This module implements the FxDriver 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 _FXDRIVERCALLBACKS_H_ 27 #define _FXDRIVERCALLBACKS_H_ 28 29 // 30 // These delegates are in a seperate file 31 // 32 33 // 34 // DrvDeviceInitialize callback delegate 35 // 36 class FxDriverDeviceAdd : public FxLockedCallback { 37 38 public: 39 PFN_WDF_DRIVER_DEVICE_ADD Method; 40 FxDriverDeviceAdd(VOID)41 FxDriverDeviceAdd( 42 VOID 43 ) : 44 FxLockedCallback() 45 { 46 Method = NULL; 47 } 48 49 _Must_inspect_result_ 50 NTSTATUS Invoke(__in WDFDRIVER Driver,__in PWDFDEVICE_INIT DeviceInit)51 Invoke( 52 __in WDFDRIVER Driver, 53 __in PWDFDEVICE_INIT DeviceInit 54 ) 55 { 56 if (Method != NULL) { 57 NTSTATUS status; 58 KIRQL irql = 0; 59 60 CallbackStart(&irql); 61 status = Method(Driver, DeviceInit); 62 CallbackEnd(irql); 63 64 return status; 65 } 66 else { 67 return STATUS_UNSUCCESSFUL; 68 } 69 } 70 }; 71 72 // 73 // DrvUnload callback delegate 74 // 75 class FxDriverUnload : public FxCallback { 76 77 public: 78 79 PFN_WDF_DRIVER_UNLOAD Method; 80 FxDriverUnload(VOID)81 FxDriverUnload( 82 VOID 83 ) : 84 FxCallback() 85 { 86 Method = NULL; 87 } 88 89 void Invoke(__in WDFDRIVER Driver)90 Invoke( 91 __in WDFDRIVER Driver 92 ) 93 { 94 if (Method != NULL) { 95 96 CallbackStart(); 97 Method(Driver); 98 CallbackEnd(); 99 return; 100 } 101 else { 102 return; 103 } 104 } 105 }; 106 107 #endif // _FXDRIVERCALLBACKS_H_ 108