1 /*++ 2 3 Copyright (c) Microsoft Corporation 4 5 Module Name: 6 7 FxCallback.hpp 8 9 Abstract: 10 11 This represents a delegate object base class for 12 calling back into the driver. 13 14 Author: 15 16 17 18 19 Revision History: 20 21 --*/ 22 23 #ifndef _FXCALLBACK_H_ 24 #define _FXCALLBACK_H_ 25 26 extern "C" { 27 #if defined(EVENT_TRACING) 28 #include "FxCallback.hpp.tmh" 29 #endif 30 } 31 32 class FxCallback { 33 34 public: 35 36 FxCallback( 37 __in_opt PFX_DRIVER_GLOBALS FxDriverGlobals = NULL 38 ) 39 { 40 UNREFERENCED_PARAMETER(FxDriverGlobals); 41 } 42 43 PVOID 44 operator new( 45 __in size_t Size, 46 __in PFX_DRIVER_GLOBALS FxDriverGlobals, 47 __in POOL_TYPE PoolType = NonPagedPool 48 ) 49 { 50 return FxPoolAllocate(FxDriverGlobals, PoolType, Size); 51 } 52 53 VOID 54 operator delete( 55 __in PVOID pointer 56 ) 57 { 58 FxPoolFree(pointer); 59 } 60 61 protected: 62 void 63 __inline 64 CallbackStart( 65 VOID 66 ) 67 { 68 // intentionally does nothing, visual place marker only for now 69 DO_NOTHING(); 70 } 71 72 void 73 __inline 74 CallbackEnd( 75 VOID 76 ) 77 { 78 // intentionally does nothing, visual place marker only for now 79 DO_NOTHING(); 80 } 81 }; 82 83 class FxLockedCallback { 84 85 private: 86 FxCallbackLock* m_CallbackLock; 87 88 public: 89 FxLockedCallback( 90 VOID 91 ) 92 { 93 m_CallbackLock = NULL; 94 } 95 96 FxCallbackLock* 97 GetCallbackLockPtr( 98 VOID 99 ) 100 { 101 return m_CallbackLock; 102 } 103 104 void 105 SetCallbackLockPtr( 106 FxCallbackLock* Lock 107 ) 108 { 109 m_CallbackLock = Lock; 110 } 111 112 protected: 113 __inline 114 void 115 CallbackStart( 116 __out PKIRQL PreviousIrql 117 ) 118 { 119 if (m_CallbackLock != NULL) { 120 m_CallbackLock->Lock(PreviousIrql); 121 } 122 } 123 124 __inline 125 void 126 CallbackEnd( 127 __in KIRQL PreviousIrql 128 ) 129 { 130 if (m_CallbackLock != NULL) { 131 m_CallbackLock->Unlock(PreviousIrql); 132 } 133 } 134 }; 135 136 #endif // _FXCALLBACK_H_ 137