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.

153 lines
4.7 KiB

  1. #pragma once
  2. #define OTHERFILES 0
  3. #define MANIFEST 1
  4. #define COMPONENT 2
  5. #include "List.h"
  6. #include "fusion.h"
  7. #define ASSEMBLY_CACHE_TYPE_IMPORT 0x1
  8. #define ASSEMBLY_CACHE_TYPE_EMIT 0x2
  9. #define ASSEMBLY_CACHE_TYPE_APP 0x4
  10. #define ASSEMBLY_CACHE_TYPE_SHARED 0x8
  11. class CAssemblyCache : public IAssemblyCacheImport, public IAssemblyCacheEmit
  12. {
  13. public:
  14. enum CacheFlags
  15. {
  16. Base = 0,
  17. Temp,
  18. Manifests,
  19. Shared
  20. };
  21. typedef enum
  22. {
  23. CONFIRMED = 0,
  24. VISIBLE,
  25. CRITICAL
  26. } CacheStatus;
  27. // IUnknown methods
  28. STDMETHODIMP QueryInterface(REFIID riid,void ** ppv);
  29. STDMETHODIMP_(ULONG) AddRef();
  30. STDMETHODIMP_(ULONG) Release();
  31. // Import/Emit methods
  32. STDMETHOD(GetManifestImport)(
  33. /* out */ LPASSEMBLY_MANIFEST_IMPORT *ppManifestImport);
  34. STDMETHOD(GetAssemblyIdentity)(
  35. /* out */ LPASSEMBLY_IDENTITY *ppAssemblyId);
  36. STDMETHOD(GetManifestFilePath)(
  37. /* out */ LPOLESTR *ppwzManifestFilePath,
  38. /* in, out */ LPDWORD ccManifestFilePath);
  39. STDMETHOD(GetManifestFileDir)(
  40. /* out */ LPOLESTR *ppwzManifestFileDir,
  41. /* in, out */ LPDWORD ccManifestFileDir);
  42. STDMETHOD(GetDisplayName)(
  43. /* out */ LPOLESTR *ppwzDisplayName,
  44. /* out */ LPDWORD ccDisplayName);
  45. // Import only methods
  46. STDMETHOD(FindExistMatching)(
  47. /* in */ IManifestInfo *pAssemblyFileInfo,
  48. /* out */ LPOLESTR *ppwzPath);
  49. // Emit only methods
  50. STDMETHOD(CopyFile)(
  51. /* in */ LPOLESTR pwzSourcePath,
  52. /* in */ LPOLESTR pwzFileName,
  53. /* in */ DWORD dwFlags);
  54. STDMETHOD(Commit)(
  55. /* in */ DWORD dwFlags);
  56. // Retrieve (import).
  57. static HRESULT Retrieve(
  58. LPASSEMBLY_CACHE_IMPORT *ppAssemblyCacheImport,
  59. LPASSEMBLY_IDENTITY pAssemblyIdentity,
  60. DWORD dwFlags);
  61. // Create (emit)
  62. static HRESULT Create(
  63. LPASSEMBLY_CACHE_EMIT *ppAssemblyCacheEmit,
  64. LPASSEMBLY_CACHE_EMIT pAssemblyCacheEmit,
  65. DWORD dwFlags);
  66. // ctor, dtor
  67. CAssemblyCache();
  68. ~CAssemblyCache();
  69. // Static apis.
  70. static HRESULT GetCacheRootDir(CString &sCacheDir, CacheFlags eFlags);
  71. static HRESULT IsCached(IAssemblyIdentity *pAppId);
  72. static HRESULT IsKnownAssembly(IAssemblyIdentity *pId, DWORD dwFlags);
  73. static HRESULT IsaMissingSystemAssembly(IAssemblyIdentity *pId, DWORD dwFlags);
  74. static HRESULT CreateFusionAssemblyCache(IAssemblyCache **ppFusionAsmCache);
  75. static HRESULT GlobalCacheLookup(IAssemblyIdentity *pId, CString& sCurrentAssemblyPath);
  76. static HRESULT GlobalCacheInstall(IAssemblyCacheImport *pCacheImport, CString &sCurrentAssemblyPath,
  77. CString& sInstallerRefString);
  78. static HRESULT CreateFusionAssemblyCacheEx(
  79. IAssemblyCache **ppFusionAsmCache);
  80. static HRESULT SearchForHighestVersionInCache(
  81. LPWSTR *ppwzResultDisplayName,
  82. LPWSTR pwzSearchDisplayName,
  83. CAssemblyCache::CacheStatus eCacheStatus,
  84. CAssemblyCache* pCache);
  85. static LPCWSTR FindVersionInDisplayName(LPCWSTR pwzDisplayName);
  86. static int CompareVersion(LPCWSTR pwzVersion1, LPCWSTR pwzVersion2);
  87. static HRESULT DeleteAssemblyAndModules(LPWSTR pszManifestFilePath);
  88. static HRESULT CAssemblyCache::GetStatusStrings( CacheStatus eStatus,
  89. LPWSTR *ppValueString,
  90. LPCWSTR pwzDisplayName,
  91. CString& sRelStatusKey);
  92. // status get/set methods
  93. static BOOL IsStatus(LPWSTR pwzDisplayName, CacheStatus eStatus);
  94. static HRESULT SetStatus(LPWSTR pwzDisplayName, CacheStatus eStatus, BOOL fStatus);
  95. private:
  96. DWORD _dwSig;
  97. DWORD _cRef;
  98. DWORD _hr;
  99. DWORD _dwFlags;
  100. CString _sRootDir;
  101. CString _sManifestFileDir;
  102. CString _sManifestFilePath;
  103. CString _sDisplayName;
  104. LPASSEMBLY_MANIFEST_IMPORT _pManifestImport;
  105. LPASSEMBLY_IDENTITY _pAssemblyId;
  106. // Fusion's assembly cache interface (cached ptr).
  107. static IAssemblyCache *g_pFusionAssemblyCache;
  108. HRESULT Init(CAssemblyCache* pAssemblyCache, DWORD dwType);
  109. friend class CAssemblyCacheEnum;
  110. };
  111. inline CAssemblyCache::CacheFlags operator++(CAssemblyCache::CacheFlags &rs, int)
  112. {
  113. return rs = (CAssemblyCache::CacheFlags) (rs+1);
  114. };