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.

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