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.

197 lines
4.6 KiB

  1. /*++
  2. Copyright (C) 2000-2001 Microsoft Corporation
  3. --*/
  4. #ifndef __CREPOSIT__H_
  5. #define __CREPOSIT__H_
  6. #include <windows.h>
  7. #include <wbemidl.h>
  8. #include <unk.h>
  9. #include <wbemcomn.h>
  10. #include <sync.h>
  11. #include <reposit.h>
  12. #include <wmiutils.h>
  13. #include <filecach.h>
  14. #include <hiecache.h>
  15. #include <corex.h>
  16. #include "a51fib.h"
  17. extern CLock g_readWriteLock;
  18. extern bool g_bShuttingDown;
  19. // extern CFileCache* g_FileCache;
  20. /* ===================================================================================
  21. * A51_REP_FS_VERSION
  22. *
  23. * 1 - Original A51 file-based repository
  24. * 2 - All Objects stored in single file (Whistler Beta 1)
  25. * 3 - BTree added
  26. * 4 - System Class optimisation - put all system classes in __SYSTEMCLASS namespace
  27. * 5 - Change to system classes in __SYSTEMCLASS namespace - need to propagate change
  28. * to all namespaces as there may be instances of these classes.
  29. * ===================================================================================
  30. */
  31. #define A51_REP_FS_VERSION_BETA1 2
  32. #define A51_REP_FS_VERSION 5
  33. #define A51_CLASSDEF_FILE_PREFIX L"CD_"
  34. #define A51_CLASSRELATION_DIR_PREFIX L"CR_"
  35. #define A51_CHILDCLASS_FILE_PREFIX L"C_"
  36. #define A51_KEYROOTINST_DIR_PREFIX L"KI_"
  37. #define A51_INSTDEF_FILE_PREFIX L"I_"
  38. #define A51_CLASSINST_DIR_PREFIX L"CI_"
  39. #define A51_INSTLINK_FILE_PREFIX L"IL_"
  40. #define A51_INSTREF_DIR_PREFIX L"IR_"
  41. #define A51_REF_FILE_PREFIX L"R_"
  42. #define A51_SCOPE_DIR_PREFIX L"SC_"
  43. #define A51_SYSTEMCLASS_NS L"__SYSTEMCLASS"
  44. class CGlobals;
  45. extern CGlobals g_Glob;
  46. class CNamespaceHandle;
  47. extern CNamespaceHandle * g_pSystemClassNamespace;
  48. /*
  49. DWORD g_dwOldRepositoryVersion = 0;
  50. DWORD g_dwCurrentRepositoryVersion = 0;
  51. DWORD g_ShutDownFlags = 0;
  52. */
  53. class CForestCache;
  54. class CGlobals
  55. {
  56. private:
  57. BOOL m_bInit;
  58. CRITICAL_SECTION m_cs;
  59. _IWmiCoreServices* m_pCoreServices;
  60. CForestCache m_ForestCache;
  61. CFileCache m_FileCache;
  62. long m_lRootDirLen;
  63. WCHAR m_wszRootDir[MAX_PATH]; // keep this last: be debugger friendly
  64. public:
  65. CGlobals():m_bInit(FALSE)
  66. {
  67. InitializeCriticalSection(&m_cs);
  68. };
  69. ~CGlobals()
  70. {
  71. DeleteCriticalSection(&m_cs);
  72. };
  73. HRESULT Initialize();
  74. HRESULT Deinitialize();
  75. _IWmiCoreServices * GetCoreSvcs();
  76. CForestCache * GetForestCache();
  77. CFileCache * GetFileCache();
  78. WCHAR * GetRootDir() {return (WCHAR *)m_wszRootDir;}
  79. long GetRootDirLen() {return m_lRootDirLen;};
  80. void SetRootDirLen(long Len) { m_lRootDirLen = Len;};
  81. BOOL IsInit(){ return m_bInit; };
  82. };
  83. HRESULT DoAutoDatabaseRestore();
  84. class CNamespaceHandle;
  85. class CRepository : public CUnkBase<IWmiDbController, &IID_IWmiDbController>
  86. {
  87. private:
  88. CFlexArray m_aSystemClasses; //Used for part of the upgrade process.
  89. protected:
  90. HRESULT Initialize();
  91. HRESULT UpgradeRepositoryFormatPhase1();
  92. HRESULT UpgradeRepositoryFormatPhase2();
  93. HRESULT UpgradeRepositoryFormatPhase3();
  94. HRESULT GetRepositoryDirectory();
  95. HRESULT InitializeGlobalVariables();
  96. HRESULT DeleteSystemClassesFromNamespaces();
  97. HRESULT InitializeRepositoryVersions();
  98. HRESULT UpgradeSystemClasses();
  99. public:
  100. HRESULT STDMETHODCALLTYPE Logon(
  101. WMIDB_LOGON_TEMPLATE *pLogonParms,
  102. DWORD dwFlags,
  103. DWORD dwRequestedHandleType,
  104. IWmiDbSession **ppSession,
  105. IWmiDbHandle **ppRootNamespace
  106. );
  107. HRESULT STDMETHODCALLTYPE GetLogonTemplate(
  108. LCID lLocale,
  109. DWORD dwFlags,
  110. WMIDB_LOGON_TEMPLATE **ppLogonTemplate
  111. );
  112. HRESULT STDMETHODCALLTYPE FreeLogonTemplate(
  113. WMIDB_LOGON_TEMPLATE **ppTemplate
  114. );
  115. HRESULT STDMETHODCALLTYPE Shutdown(
  116. DWORD dwFlags
  117. );
  118. HRESULT STDMETHODCALLTYPE SetCallTimeout(
  119. DWORD dwMaxTimeout
  120. );
  121. HRESULT STDMETHODCALLTYPE SetCacheValue(
  122. DWORD dwMaxBytes
  123. );
  124. HRESULT STDMETHODCALLTYPE FlushCache(
  125. DWORD dwFlags
  126. );
  127. HRESULT STDMETHODCALLTYPE GetStatistics(
  128. DWORD dwParameter,
  129. DWORD *pdwValue
  130. );
  131. HRESULT STDMETHODCALLTYPE Backup(
  132. LPCWSTR wszBackupFile,
  133. long lFlags
  134. );
  135. HRESULT STDMETHODCALLTYPE Restore(
  136. LPCWSTR wszBackupFile,
  137. long lFlags
  138. );
  139. HRESULT STDMETHODCALLTYPE LockRepository();
  140. HRESULT STDMETHODCALLTYPE UnlockRepository();
  141. HRESULT STDMETHODCALLTYPE GetRepositoryVersions(DWORD *pdwOldVersion, DWORD *pdwCurrentVersion);
  142. public:
  143. CRepository(CLifeControl* pControl) : TUnkBase(pControl)
  144. {
  145. }
  146. ~CRepository()
  147. {
  148. }
  149. HRESULT GetNamespaceHandle(LPCWSTR wszNamespaceName,
  150. CNamespaceHandle** ppHandle);
  151. };
  152. #endif /*__CREPOSIT__H_*/