Source code of Windows XP (NT5)
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.

228 lines
7.1 KiB

  1. //=============================================================================
  2. //
  3. // Copyright (c) 1996-1999, Microsoft Corporation, All rights reserved
  4. //
  5. // ESS.H
  6. //
  7. // Implements the class that contains all the fuctionality of the ESS by
  8. // virtue of containing all the necessary components.
  9. //
  10. // Classes defined:
  11. //
  12. // CEss
  13. //
  14. // History:
  15. //
  16. // 11/27/96 a-levn Compiles.
  17. // 1/6/97 a-levn Updated to initialize TSS.
  18. //
  19. //=============================================================================
  20. #ifndef __ESS__H_
  21. #define __ESS__H_
  22. #include "pragmas.h"
  23. #include "nsrep.h"
  24. #include "equeue.h"
  25. #include "wbemtss.h"
  26. #include "essself.h"
  27. #include <evtlog.h>
  28. #include <sleeper.h>
  29. #include <wmimsg.h>
  30. #include <wstlallc.h>
  31. //*****************************************************************************
  32. //
  33. // class CEss
  34. //
  35. // This class is the central "collection point" for the ESS. It contains the
  36. // list of namespace objects and some shared components.
  37. //
  38. //*****************************************************************************
  39. class CInitActiveNamespacesRequest;
  40. class CInitNamespaceRequest;
  41. class CEss
  42. {
  43. protected:
  44. typedef std::map<WString, CEssNamespace*, WSiless,
  45. wbem_allocator<CEssNamespace*> > TNamespaceMap;
  46. typedef TNamespaceMap::iterator TNamespaceIterator;
  47. TNamespaceMap m_mapNamespaces;
  48. CWinMgmtTimerGenerator m_TimerGenerator;
  49. CEventQueue m_Queue;
  50. IWbemLocator* m_pLocator;
  51. _IWmiCoreServices* m_pCoreServices;
  52. _IWmiProvSS* m_pProvSS;
  53. _IWmiProvSSSink* m_pProvSSSink;
  54. LPWSTR m_wszServerName;
  55. IWbemDecorator* m_pDecorator;
  56. IWbemLifeControl* m_pLifeControl;
  57. long m_lObjectCount;
  58. long m_lNumActiveNamespaces;
  59. CEventLog m_EventLog;
  60. CRegistryMinMaxLimitControl m_LimitControl;
  61. IWbemTokenCache* m_pTokenCache;
  62. HANDLE m_hReadyEvent;
  63. BOOL m_bLastCallForCoreCalled;
  64. CCritSec m_cs;
  65. //
  66. // the number of namespaces that were active on startup by are still
  67. // initializating.
  68. //
  69. long m_lOutstandingActiveNamespaceInit;
  70. //
  71. // we use a background thread to perform recovery of guaranteed
  72. // event deliveries.
  73. //
  74. HANDLE m_hRecoveryThread;
  75. HRESULT InitiateRecovery();
  76. static ULONG WINAPI PerformRecovery( void* pCtx );
  77. HANDLE m_hExitBootPhaseTimer;
  78. static void CALLBACK ExitBootPhaseCallback( LPVOID, BOOLEAN );
  79. void ExecuteDeferredNSInitRequests();
  80. //
  81. // If we are in the boot phase, then we will queue up the ns init events
  82. // until we're out of the boot phase.
  83. //
  84. CPointerArray<CExecRequest> m_aDeferredNSInitRequests;
  85. BOOL m_bMSMQDisabled;
  86. public:
  87. CEss();
  88. ~CEss();
  89. void TriggerDeferredInitialization();
  90. HRESULT Initialize( LPCWSTR wszServer,
  91. long lFlags,
  92. _IWmiCoreServices* pCoreServices,
  93. IWbemDecorator* pDecorator );
  94. HRESULT Shutdown(BOOL bIsSystemShutdown);
  95. HRESULT LastCallForCore(LONG lSystemShutDown);
  96. HRESULT GetNamespaceObject( LPCWSTR wszNamespace,
  97. BOOL bEnsureActivation,
  98. RELEASE_ME CEssNamespace** ppNamespace );
  99. HRESULT GetNamespacePointer( LPCWSTR wszNamespace,
  100. BOOL bRepositoryOnly,
  101. RELEASE_ME IWbemServices** ppNamespace );
  102. HRESULT Decorate(IWbemClassObject* pObject, LPCWSTR wszNamespace);
  103. HRESULT GetProviderFactory(LPCWSTR wszNamespace, IWbemServices* pNamespace,
  104. _IWmiProviderFactory** ppFactory);
  105. HRESULT ReloadProvider( long lFlags,
  106. LPCWSTR wszNamespace,
  107. LPCWSTR wszName );
  108. HRESULT PurgeNamespace(LPCWSTR wszNamespace);
  109. HRESULT ProcessEvent(READ_ONLY CEventRepresentation& Event, long lFlags);
  110. HRESULT ProcessQueryObjectSinkEvent( READ_ONLY CEventRepresentation& Event );
  111. HRESULT VerifyInternalEvent(READ_ONLY CEventRepresentation& Event);
  112. HRESULT RegisterNotificationSink(WBEM_CWSTR wszNamespace,
  113. WBEM_CWSTR wszQueryLanguage, WBEM_CWSTR wszQuery,
  114. long lFlags, IWbemContext* pContext,
  115. IWbemObjectSink* pSink);
  116. HRESULT RemoveNotificationSink(IWbemObjectSink* pSink);
  117. CWinMgmtTimerGenerator& GetTimerGenerator() {return m_TimerGenerator;}
  118. CEventLog& GetEventLog() {return m_EventLog;}
  119. void IncrementObjectCount();
  120. void DecrementObjectCount();
  121. HRESULT SetNamespaceActive(LPCWSTR wszNamespace);
  122. HRESULT SetNamespaceInactive(LPCWSTR wszNamespace);
  123. HRESULT SaveActiveNamespaceList();
  124. HRESULT RequestStartOnBoot(BOOL bStart = TRUE);
  125. HRESULT InitializeTimerGenerator(LPCWSTR wszNamespace,
  126. IWbemServices* pNamespace);
  127. static HRESULT DecorateObject(IWbemClassObject* pObj, LPCWSTR wszNamespace);
  128. HRESULT EnqueueDeliver(CQueueingEventSink* pDest);
  129. HRESULT Enqueue(CExecRequest* pReq);
  130. HRESULT AddSleepCharge(DWORD dwSleep);
  131. HRESULT AddCache();
  132. HRESULT RemoveCache();
  133. HRESULT AddToCache(DWORD dwAdd, DWORD dwMemberTotal,
  134. DWORD* pdwSleep = NULL);
  135. HRESULT RemoveFromCache(DWORD dwRemove);
  136. HRESULT GetToken(PSID pSid, IWbemToken** ppToken);
  137. HRESULT CreatePersistentQueue( LPCWSTR wszQueueName, DWORD dwQos );
  138. HRESULT DestroyPersistentQueue( LPCWSTR wszQueueName );
  139. void DumpStatistics(FILE* f, long lFlags);
  140. //
  141. // each namespace that is active on startup notifies us when it has
  142. // finished initialization.
  143. //
  144. void NotifyActiveNamespaceInitComplete();
  145. protected:
  146. typedef CPointerArray<CInitActiveNamespacesRequest> InitActiveNsRequestList;
  147. HRESULT PrepareNamespaceInitRequest(
  148. LPCWSTR wszNamespace,
  149. CInitActiveNamespacesRequest* pRequest );
  150. HRESULT PrepareNamespaceInitRequests( IWbemServices* pRoot,
  151. BOOL bRediscover,
  152. InitActiveNsRequestList& aRequests);
  153. HRESULT RecursivePrepareNamespaceInitRequests(
  154. LPCWSTR wszNamespace,
  155. IWbemServices* pNamespace,
  156. CInitActiveNamespacesRequest* pRequest);
  157. HRESULT ScheduleNamespaceInitialize( CExecRequest* pReq );
  158. HRESULT LoadActiveNamespaces( IWbemServices* pRoot, BOOL bRediscover );
  159. HRESULT CreateNamespaceObject( LPCWSTR wszNormName,
  160. CEssNamespace** ppNamespace );
  161. HRESULT LoadNamespaceObject( LPCWSTR wszNamespace,
  162. BOOL bKnownEmpty,
  163. RELEASE_ME CEssNamespace** ppNamespace );
  164. inline HRESULT GetQueueManager( IWmiMessageQueueManager** ppQueueMgr );
  165. friend class CInObjectCount;
  166. };
  167. class CInObjectCount
  168. {
  169. protected:
  170. CEss* m_pEss;
  171. public:
  172. CInObjectCount(CEss* pEss) : m_pEss(pEss)
  173. {
  174. m_pEss->IncrementObjectCount();
  175. }
  176. ~CInObjectCount()
  177. {
  178. m_pEss->DecrementObjectCount();
  179. }
  180. };
  181. #endif