Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
2.8 KiB

  1. //=================================================================
  2. //
  3. // PowerManagement.h --
  4. //
  5. // Copyright (c) 1999-2001 Microsoft Corporation, All Rights Reserved
  6. //
  7. // Revisions: 03/31/99 a-peterc Created
  8. //
  9. //=================================================================
  10. #ifndef _WBEM_POWER_EVENT_PROVIDER_H
  11. #define _WBEM_POWER_EVENT_PROVIDER_H
  12. #define IPROUTE_EVENT_CLASS L"Win32_IP4RouteTableEvent"
  13. class SmartCloseNtHandle
  14. {
  15. private:
  16. HANDLE m_h;
  17. public:
  18. SmartCloseNtHandle():m_h(INVALID_HANDLE_VALUE){}
  19. SmartCloseNtHandle(HANDLE h):m_h(h){}
  20. ~SmartCloseNtHandle(){if (m_h!=INVALID_HANDLE_VALUE) NtClose(m_h);}
  21. HANDLE operator =(HANDLE h) {if (m_h!=INVALID_HANDLE_VALUE) NtClose(m_h); m_h=h; return h;}
  22. operator HANDLE() const {return m_h;}
  23. operator HANDLE&() {return m_h;}
  24. HANDLE* operator &() {if (m_h!=INVALID_HANDLE_VALUE) NtClose(m_h); m_h = INVALID_HANDLE_VALUE; return &m_h;}
  25. };
  26. //
  27. class CIPRouteEventProviderClassFactory : public IClassFactory
  28. {
  29. private:
  30. long m_ReferenceCount ;
  31. protected:
  32. public:
  33. static LONG s_LocksInProgress ;
  34. static LONG s_ObjectsInProgress ;
  35. CIPRouteEventProviderClassFactory () ;
  36. ~CIPRouteEventProviderClassFactory () ;
  37. static BOOL DllCanUnloadNow();
  38. //IUnknown members
  39. STDMETHODIMP QueryInterface( REFIID , LPVOID FAR * ) ;
  40. STDMETHODIMP_( ULONG ) AddRef() ;
  41. STDMETHODIMP_( ULONG ) Release() ;
  42. //IClassFactory members
  43. STDMETHODIMP CreateInstance( LPUNKNOWN , REFIID , LPVOID FAR * ) ;
  44. STDMETHODIMP LockServer( BOOL ) ;
  45. };
  46. //
  47. class CIPRouteEventProvider : public IWbemEventProvider, public IWbemProviderInit
  48. {
  49. private:
  50. long m_ReferenceCount ;
  51. SmartCloseNtHandle m_TerminationEventHandle ;
  52. CRITICAL_SECTION m_csEvent ;
  53. static DWORD WINAPI dwThreadProc ( LPVOID lpParameter );
  54. void SendEvent () ;
  55. NTSTATUS OpenQuerySource (
  56. HANDLE &a_StackHandle ,
  57. HANDLE &a_CompleteEventHandle
  58. ) ;
  59. protected:
  60. IWbemObjectSink *m_pHandler ;
  61. IWbemClassObject *m_pClass ;
  62. SmartCloseHandle m_hThreadHandle ;
  63. DWORD m_dwThreadID ;
  64. public:
  65. CIPRouteEventProvider() ;
  66. ~CIPRouteEventProvider() ;
  67. void SetHandler ( IWbemObjectSink __RPC_FAR *a_pHandler ) ;
  68. void SetClass ( IWbemClassObject __RPC_FAR *a_pClass ) ;
  69. STDMETHOD ( QueryInterface ) (
  70. REFIID a_riid,
  71. void **a_ppv
  72. ) ;
  73. STDMETHOD_( ULONG, AddRef ) () ;
  74. STDMETHOD_( ULONG, Release ) () ;
  75. STDMETHOD ( ProvideEvents ) (
  76. IWbemObjectSink *a_pSink,
  77. long a_lFlags
  78. ) ;
  79. STDMETHOD ( Initialize ) (
  80. LPWSTR a_wszUser ,
  81. long a_lFlags ,
  82. LPWSTR a_wszNamespace ,
  83. LPWSTR a_wszLocale ,
  84. IWbemServices *a_pNamespace ,
  85. IWbemContext *a_pCtx ,
  86. IWbemProviderInitSink *a_pSink
  87. ) ;
  88. };
  89. #endif