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