1*8a978a17SVictor Perevertkin /*++ 2*8a978a17SVictor Perevertkin 3*8a978a17SVictor Perevertkin Copyright (c) Microsoft Corporation. All rights reserved. 4*8a978a17SVictor Perevertkin 5*8a978a17SVictor Perevertkin Module Name: 6*8a978a17SVictor Perevertkin 7*8a978a17SVictor Perevertkin FxIoTargetRemoteUm.hpp 8*8a978a17SVictor Perevertkin 9*8a978a17SVictor Perevertkin Abstract: 10*8a978a17SVictor Perevertkin 11*8a978a17SVictor Perevertkin User-mode specific definitions of FxIoTargetRemote 12*8a978a17SVictor Perevertkin 13*8a978a17SVictor Perevertkin Author: 14*8a978a17SVictor Perevertkin 15*8a978a17SVictor Perevertkin 16*8a978a17SVictor Perevertkin Environment: 17*8a978a17SVictor Perevertkin 18*8a978a17SVictor Perevertkin User mode only 19*8a978a17SVictor Perevertkin 20*8a978a17SVictor Perevertkin Revision History: 21*8a978a17SVictor Perevertkin 22*8a978a17SVictor Perevertkin --*/ 23*8a978a17SVictor Perevertkin 24*8a978a17SVictor Perevertkin #pragma once 25*8a978a17SVictor Perevertkin 26*8a978a17SVictor Perevertkin class FxIoTargetRemoteNotificationCallback : 27*8a978a17SVictor Perevertkin public FxGlobalsStump, 28*8a978a17SVictor Perevertkin public IWudfTargetCallbackDeviceChange 29*8a978a17SVictor Perevertkin { 30*8a978a17SVictor Perevertkin private: 31*8a978a17SVictor Perevertkin 32*8a978a17SVictor Perevertkin LONG m_cRefs; 33*8a978a17SVictor Perevertkin 34*8a978a17SVictor Perevertkin FxIoTargetRemote* m_RemoteTarget; 35*8a978a17SVictor Perevertkin 36*8a978a17SVictor Perevertkin public: 37*8a978a17SVictor Perevertkin FxIoTargetRemoteNotificationCallback(PFX_DRIVER_GLOBALS FxDriverGlobals,FxIoTargetRemote * Target)38*8a978a17SVictor Perevertkin FxIoTargetRemoteNotificationCallback( 39*8a978a17SVictor Perevertkin PFX_DRIVER_GLOBALS FxDriverGlobals, 40*8a978a17SVictor Perevertkin FxIoTargetRemote* Target 41*8a978a17SVictor Perevertkin ) : 42*8a978a17SVictor Perevertkin FxGlobalsStump(FxDriverGlobals), 43*8a978a17SVictor Perevertkin m_RemoteTarget(Target), 44*8a978a17SVictor Perevertkin m_cRefs(1) 45*8a978a17SVictor Perevertkin { 46*8a978a17SVictor Perevertkin } 47*8a978a17SVictor Perevertkin ~FxIoTargetRemoteNotificationCallback()48*8a978a17SVictor Perevertkin ~FxIoTargetRemoteNotificationCallback() {}; 49*8a978a17SVictor Perevertkin 50*8a978a17SVictor Perevertkin WUDF_TARGET_CONTEXT GetRegistrationId(VOID)51*8a978a17SVictor Perevertkin GetRegistrationId( 52*8a978a17SVictor Perevertkin VOID 53*8a978a17SVictor Perevertkin ) 54*8a978a17SVictor Perevertkin { 55*8a978a17SVictor Perevertkin return m_RemoteTarget->m_TargetNotifyHandle; 56*8a978a17SVictor Perevertkin } 57*8a978a17SVictor Perevertkin 58*8a978a17SVictor Perevertkin BOOL 59*8a978a17SVictor Perevertkin __stdcall 60*8a978a17SVictor Perevertkin OnQueryRemove( 61*8a978a17SVictor Perevertkin _In_ WUDF_TARGET_CONTEXT RegistrationID 62*8a978a17SVictor Perevertkin ); 63*8a978a17SVictor Perevertkin 64*8a978a17SVictor Perevertkin VOID 65*8a978a17SVictor Perevertkin __stdcall 66*8a978a17SVictor Perevertkin OnRemoveCanceled( 67*8a978a17SVictor Perevertkin _In_ WUDF_TARGET_CONTEXT RegistrationID 68*8a978a17SVictor Perevertkin ); 69*8a978a17SVictor Perevertkin 70*8a978a17SVictor Perevertkin VOID 71*8a978a17SVictor Perevertkin __stdcall 72*8a978a17SVictor Perevertkin OnRemoveComplete( 73*8a978a17SVictor Perevertkin _In_ WUDF_TARGET_CONTEXT RegistrationID 74*8a978a17SVictor Perevertkin ); 75*8a978a17SVictor Perevertkin 76*8a978a17SVictor Perevertkin VOID 77*8a978a17SVictor Perevertkin __stdcall 78*8a978a17SVictor Perevertkin OnCustomEvent( 79*8a978a17SVictor Perevertkin _In_ WUDF_TARGET_CONTEXT RegistrationID, 80*8a978a17SVictor Perevertkin _In_ REFGUID Event, 81*8a978a17SVictor Perevertkin _In_reads_bytes_(DataSize) BYTE * Data, 82*8a978a17SVictor Perevertkin _In_ DWORD DataSize, 83*8a978a17SVictor Perevertkin _In_ DWORD NameBufferOffset 84*8a978a17SVictor Perevertkin ); 85*8a978a17SVictor Perevertkin 86*8a978a17SVictor Perevertkin HRESULT 87*8a978a17SVictor Perevertkin __stdcall QueryInterface(__in const IID & iid,__out void ** ppv)88*8a978a17SVictor Perevertkin QueryInterface( 89*8a978a17SVictor Perevertkin __in const IID& iid, 90*8a978a17SVictor Perevertkin __out void ** ppv 91*8a978a17SVictor Perevertkin ) 92*8a978a17SVictor Perevertkin { 93*8a978a17SVictor Perevertkin if (NULL == ppv) { 94*8a978a17SVictor Perevertkin return E_INVALIDARG; 95*8a978a17SVictor Perevertkin } 96*8a978a17SVictor Perevertkin 97*8a978a17SVictor Perevertkin *ppv = NULL; 98*8a978a17SVictor Perevertkin 99*8a978a17SVictor Perevertkin if ( iid == IID_IUnknown) { 100*8a978a17SVictor Perevertkin *ppv = static_cast<IUnknown *> (this); 101*8a978a17SVictor Perevertkin } 102*8a978a17SVictor Perevertkin else if ( iid == IID_IWudfTargetCallbackDeviceChange) { 103*8a978a17SVictor Perevertkin *ppv = static_cast<IWudfTargetCallbackDeviceChange *> (this); 104*8a978a17SVictor Perevertkin } 105*8a978a17SVictor Perevertkin else { 106*8a978a17SVictor Perevertkin return E_INVALIDARG; 107*8a978a17SVictor Perevertkin } 108*8a978a17SVictor Perevertkin 109*8a978a17SVictor Perevertkin this->AddRef(); 110*8a978a17SVictor Perevertkin return S_OK; 111*8a978a17SVictor Perevertkin } 112*8a978a17SVictor Perevertkin 113*8a978a17SVictor Perevertkin ULONG 114*8a978a17SVictor Perevertkin __stdcall AddRef()115*8a978a17SVictor Perevertkin AddRef( 116*8a978a17SVictor Perevertkin ) 117*8a978a17SVictor Perevertkin { 118*8a978a17SVictor Perevertkin LONG cRefs = InterlockedIncrement( &m_cRefs ); 119*8a978a17SVictor Perevertkin return cRefs; 120*8a978a17SVictor Perevertkin } 121*8a978a17SVictor Perevertkin 122*8a978a17SVictor Perevertkin ULONG 123*8a978a17SVictor Perevertkin __stdcall Release()124*8a978a17SVictor Perevertkin Release( 125*8a978a17SVictor Perevertkin ) 126*8a978a17SVictor Perevertkin { 127*8a978a17SVictor Perevertkin LONG cRefs = InterlockedDecrement( &m_cRefs ); 128*8a978a17SVictor Perevertkin if (0 == cRefs) { 129*8a978a17SVictor Perevertkin // 130*8a978a17SVictor Perevertkin // The lifetime of this object is controlled by FxIoTargetRemote 131*8a978a17SVictor Perevertkin // object (the container object), and not by this ref count. This 132*8a978a17SVictor Perevertkin // method is implemented just to satisfy the interface implemetation 133*8a978a17SVictor Perevertkin // requirement. 134*8a978a17SVictor Perevertkin // 135*8a978a17SVictor Perevertkin DO_NOTHING(); 136*8a978a17SVictor Perevertkin } 137*8a978a17SVictor Perevertkin 138*8a978a17SVictor Perevertkin return cRefs; 139*8a978a17SVictor Perevertkin } 140*8a978a17SVictor Perevertkin }; 141*8a978a17SVictor Perevertkin 142