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.

167 lines
5.8 KiB

  1. #pragma once
  2. class CAssemblyIdentity
  3. {
  4. public:
  5. typedef CEnv::CConstantUnicodeStringPair CStringPair;
  6. CAssemblyIdentity();
  7. ~CAssemblyIdentity();
  8. CEnv::StatusCode SetAttribute(const CStringPair &Namespace, const CStringPair &Name, const CStringPair &Value, bool fReplace = true);
  9. CEnv::StatusCode SetAttribute(const CStringPair &Name, const CStringPair& Value, bool fReplace = true) { return SetAttribute(CStringPair(), Name, Value, fReplace); }
  10. CEnv::StatusCode DeleteAttribute(const CStringPair &Namespace, const CStringPair &Name);
  11. //
  12. // The const version will do a linear or a bsearch depending on the sorted state. The non-const
  13. // version will sort the internal attribute list first if necessary before looking up the value.
  14. // These two are also a little dangerous because they return pointers directly into the data structures
  15. // (const of course), which if you hold onto them might get invalidated. If you plan on caching the
  16. // data for a while, consider using the next two.
  17. //
  18. CEnv::StatusCode FindAttribute(const CStringPair &Namespace, const CStringPair &Name, CStringPair& Value) const;
  19. CEnv::StatusCode FindAttribute(const CStringPair &Namespace, const CStringPair &Name, CStringPair& Value);
  20. CEnv::StatusCode FindAttribute(const CStringPair &Namespace, const CStringPair &Name, CEnv::CStringBuffer &Target) const;
  21. CEnv::StatusCode FindAttribute(const CStringPair &Namespace, const CStringPair &Name, CEnv::CStringBuffer &Target);
  22. unsigned long IdentityHash() const;
  23. unsigned long IdentityHash();
  24. unsigned long long IdentityHashV2() const;
  25. unsigned long long IdentityHashV2();
  26. //
  27. // Maintainence stuff
  28. //
  29. CEnv::StatusCode Freeze();
  30. CEnv::StatusCode DeleteAllValues();
  31. protected:
  32. //
  33. // This is an all-in-one allocation blob
  34. //
  35. class CIdentityValue
  36. {
  37. CIdentityValue(const CIdentityValue&);
  38. void operator=(const CIdentityValue&);
  39. public:
  40. CIdentityValue() { }
  41. SIZE_T cbAllocationSize;
  42. bool HashV1Valid;
  43. unsigned long HashV1;
  44. CStringPair Namespace;
  45. CStringPair Name;
  46. CStringPair Value;
  47. CEnv::StatusCode WriteValues(const CStringPair& Namespace, const CStringPair& Name, const CStringPair& Value);
  48. CEnv::StatusCode Compare(const CIdentityValue &Other, int &iResult) const;
  49. };
  50. SIZE_T m_cIdentityValues;
  51. SIZE_T m_cAvailableIdentitySlots;
  52. CIdentityValue** m_IdentityValues;
  53. bool m_fFrozen;
  54. bool m_fSorted;
  55. bool m_fHashDirtyV1;
  56. unsigned long m_ulHashV1;
  57. bool m_fHashDirtyV2;
  58. unsigned char m_IdentityShaHash[20];
  59. CEnv::StatusCode RegenerateHash();
  60. CEnv::StatusCode SortIdentityAttributes();
  61. static int __cdecl SortingCallback(const CIdentityValue **left, const CIdentityValue **right);
  62. CEnv::StatusCode InternalFindValue(const CStringPair &Namespace, const CStringPair &Name, SIZE_T &cIndex) const;
  63. CEnv::StatusCode InternalFindValue(const CStringPair &Namespace, const CStringPair &Name, SIZE_T &cIndex);
  64. CEnv::StatusCode InternalCreateValue(const CStringPair &Namespace, const CStringPair &Name, const CStringPair &Value);
  65. CEnv::StatusCode InternalAllocateValue(const CStringPair &Namespace, const CStringPair &Name, const CStringPair &Value, CIdentityValue* &Allocated);
  66. CEnv::StatusCode InternalInsertValue(CIdentityValue* NewValue);
  67. CEnv::StatusCode InternalDestroyValue(CIdentityValue* Victim);
  68. };
  69. static CEnv::StatusCode
  70. CreateIdentityFromCookedData(
  71. CAssemblyIdentity& Target,
  72. PMANIFEST_COOKED_IDENTITY IdentityData
  73. );
  74. class COSAssemblyCache
  75. {
  76. public:
  77. enum UninstallResult {
  78. UResult_NotPresent,
  79. UResult_RemovedPayload,
  80. UResult_RemovedManifest,
  81. UResult_RemovedReference,
  82. };
  83. virtual ~COSAssemblyCache() { }
  84. virtual CEnv::StatusCode Initialize() = 0;
  85. virtual CEnv::StatusCode InstallAssembly(
  86. ULONG Flags,
  87. PMANIFEST_COOKED_DATA ManifestData,
  88. const CEnv::CConstantUnicodeStringPair &FilePath
  89. ) = 0;
  90. virtual CEnv::StatusCode UninstallAssembly(
  91. ULONG Flags,
  92. PMANIFEST_COOKED_DATA ManifestData,
  93. UninstallResult &Result
  94. ) = 0;
  95. };
  96. class CDotNetSxsAssemblyCache : public COSAssemblyCache
  97. {
  98. CDotNetSxsAssemblyCache(ULONG ulFlags);
  99. CDotNetSxsAssemblyCache(const CDotNetSxsAssemblyCache&);
  100. void operator=(const CDotNetSxsAssemblyCache&);
  101. static const CEnv::CConstantUnicodeStringPair s_PoliciesPath;
  102. static const CEnv::CConstantUnicodeStringPair s_ManifestsPath;
  103. static const CEnv::CConstantUnicodeStringPair s_InstallTemp;
  104. static const CEnv::CConstantUnicodeStringPair s_BaseDirectory;
  105. CEnv::StatusCode EnsurePathsAvailable();
  106. CEnv::CConstantUnicodeStringPair m_WindowsDirectory;
  107. CEnv::StatusCode IdentityToTargetPath(const CAssemblyIdentity& Ident, CEnv::CStringBuffer &PathSegment);
  108. public:
  109. virtual ~CDotNetSxsAssemblyCache();
  110. virtual CEnv::StatusCode Initialize();
  111. virtual CEnv::StatusCode InstallAssembly(
  112. ULONG Flags,
  113. PMANIFEST_COOKED_DATA ManifestData,
  114. const CEnv::CConstantUnicodeStringPair &FilePath
  115. );
  116. virtual CEnv::StatusCode UninstallAssembly(
  117. ULONG Flags,
  118. PMANIFEST_COOKED_DATA ManifestData,
  119. UninstallResult &Result
  120. );
  121. const static GUID CacheIdentifier;
  122. static COSAssemblyCache *CreateSelf(ULONG, const GUID *);
  123. };
  124. typedef struct {
  125. const GUID *CacheIdent;
  126. COSAssemblyCache* (*pfnCreator)(ULONG ulFlags, const GUID *Ident);
  127. } ASSEMBLY_CACHE_LISTING;
  128. EXTERN_C ASSEMBLY_CACHE_LISTING s_AssemblyCaches[];