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.

217 lines
6.3 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation
  3. Module Name:
  4. sxsinstall.h
  5. Abstract:
  6. Activation context section contributor for the DLL Redirection section.
  7. Author:
  8. Jay Krell (a-JayK, JayKrell) April 2000
  9. Revision History:
  10. --*/
  11. #if (_MSC_VER > 1020)
  12. #pragma once
  13. #endif
  14. #include "util.h"
  15. #include "cassemblyrecoveryinfo.h"
  16. #include "actctxgenctx.h"
  17. /*-----------------------------------------------------------------------------
  18. Side By(x) Side Install
  19. most of the work is actually done in dllredir.cpp
  20. -----------------------------------------------------------------------------*/
  21. class CAssemblyInstallReferenceInformation
  22. {
  23. GUID m_SchemeGuid;
  24. CStringBuffer m_buffIdentifier;
  25. CStringBuffer m_buffNonCanonicalData;
  26. CStringBuffer m_buffGeneratedIdentifier;
  27. BOOL m_fIdentityStuffReady;
  28. DWORD m_dwFlags;
  29. CAssemblyReference m_IdentityReference;
  30. PRIVATIZE_COPY_CONSTRUCTORS(CAssemblyInstallReferenceInformation);
  31. public:
  32. CAssemblyInstallReferenceInformation();
  33. BOOL Initialize( PCSXS_INSTALL_REFERENCEW RefData );
  34. const GUID &GetSchemeGuid() const { return m_SchemeGuid; }
  35. const CBaseStringBuffer &GetIdentifier() const { return m_buffIdentifier; }
  36. const CBaseStringBuffer &GetGeneratedIdentifier() const { return m_buffGeneratedIdentifier; }
  37. const CBaseStringBuffer &GetCanonicalData() const { return m_buffNonCanonicalData; }
  38. DWORD GetFlags() const { return m_dwFlags; }
  39. BOOL SetIdentity(PCASSEMBLY_IDENTITY pAsmIdent) { return m_IdentityReference.Initialize(pAsmIdent); }
  40. BOOL ForceReferenceData(PCWSTR pcwszPrecalcedData) {
  41. FN_PROLOG_WIN32
  42. IFW32FALSE_EXIT(
  43. m_buffGeneratedIdentifier.Win32Assign(
  44. pcwszPrecalcedData,
  45. pcwszPrecalcedData != NULL ? ::wcslen(pcwszPrecalcedData) : 0));
  46. m_fIdentityStuffReady = TRUE;
  47. FN_EPILOG
  48. }
  49. BOOL GenerateFileReference(
  50. IN const CBaseStringBuffer &buffKeyfileName,
  51. OUT CBaseStringBuffer &buffDrivePath,
  52. OUT CBaseStringBuffer &buffFilePart,
  53. OUT DWORD &dwDriveSerial
  54. );
  55. const CAssemblyReference &GetIdentity() const { return m_IdentityReference; }
  56. BOOL GenerateIdentifierValue(
  57. CBaseStringBuffer *pbuffTarget = NULL
  58. );
  59. BOOL GetIdentifierValue(CBaseStringBuffer &pBuffTarget) const
  60. {
  61. return pBuffTarget.Win32Assign(m_buffGeneratedIdentifier);
  62. }
  63. BOOL WriteIntoRegistry(const CFusionRegKey &rhkTargetKey) const;
  64. BOOL IsReferencePresentIn(const CFusionRegKey &rhkQueryKey, BOOL &rfPresent, BOOL *rfNonCanonicalMatches = NULL) const;
  65. BOOL DeleteReferenceFrom(const CFusionRegKey &rhkQueryKey, BOOL &rfWasDeleted) const;
  66. BOOL AcquireContents(const CAssemblyInstallReferenceInformation &);
  67. };
  68. MAKE_CFUSIONARRAY_READY(CAssemblyInstallReferenceInformation, AcquireContents);
  69. #define CINSTALLITEM_VALID_REFERENCE (0x0000001)
  70. #define CINSTALLITEM_VALID_RECOVERY (0x0000002)
  71. #define CINSTALLITEM_VALID_IDENTITY (0x0000004)
  72. #define CINSTALLITEM_VALID_LOGFILE (0x0000008)
  73. class CInstalledItemEntry
  74. {
  75. PRIVATIZE_COPY_CONSTRUCTORS(CInstalledItemEntry);
  76. public:
  77. CAssemblyInstallReferenceInformation m_InstallReference;
  78. CSmartPtrWithNamedDestructor<ASSEMBLY_IDENTITY, &::SxsDestroyAssemblyIdentity> m_AssemblyIdentity;
  79. CAssemblyRecoveryInfo m_RecoveryInfo;
  80. CSmallStringBuffer m_buffLogFileName;
  81. CCodebaseInformation m_CodebaseInfo;
  82. DWORD m_dwValidItems;
  83. CInstalledItemEntry() : m_dwValidItems(0) { }
  84. ~CInstalledItemEntry() { }
  85. BOOL AcquireContents( const CInstalledItemEntry &other );
  86. };
  87. MAKE_CFUSIONARRAY_READY(CInstalledItemEntry, AcquireContents);
  88. class CAssemblyInstall
  89. {
  90. public:
  91. CAssemblyInstall();
  92. ~CAssemblyInstall() { }
  93. BOOL
  94. BeginAssemblyInstall(
  95. DWORD flags,
  96. PSXS_INSTALLATION_FILE_COPY_CALLBACK installationCallback,
  97. PVOID installationContext,
  98. const CImpersonationData &ImpersonationData
  99. );
  100. enum EInstallStage
  101. {
  102. eBegin,
  103. ePer,
  104. eEnd
  105. };
  106. BOOL
  107. InstallAssembly(
  108. DWORD flags,
  109. PCWSTR manifestPath,
  110. PCSXS_INSTALL_SOURCE_INFO pcsisi,
  111. PCSXS_INSTALL_REFERENCEW pReference
  112. );
  113. BOOL
  114. EndAssemblyInstall(
  115. DWORD flags,
  116. PVOID pvReserved = NULL
  117. );
  118. BOOL
  119. InstallFile(
  120. const CBaseStringBuffer &ManifestPath,
  121. const CBaseStringBuffer &rbuffRelativeCodebase
  122. );
  123. CDirWalk::ECallbackResult
  124. InstallDirectoryDirWalkCallback(
  125. CDirWalk::ECallbackReason reason,
  126. CDirWalk *pdirWalk,
  127. DWORD dwFlags,
  128. DWORD dwWalkDirFlags
  129. );
  130. static CDirWalk::ECallbackResult
  131. StaticInstallDirectoryDirWalkCallback(
  132. CDirWalk::ECallbackReason reason,
  133. CDirWalk *dirWalk,
  134. DWORD dwWalkDirFlags
  135. );
  136. BOOL
  137. InstallDirectory(
  138. const CBaseStringBuffer &rPath,
  139. DWORD flags,
  140. WCHAR wchCodebasePathSeparator
  141. );
  142. ACTCTXGENCTX m_ActCtxGenCtx;
  143. CImpersonationData m_ImpersonationData;
  144. BOOL m_bSuccessfulSoFar;
  145. PSXS_INSTALL_SOURCE_INFO m_pInstallInfo;
  146. CFusionArray<CInstalledItemEntry> m_ItemsInstalled;
  147. // In parallel to the other paths we're building up, we also build a
  148. // relative path to the base of the directory walk which uses the
  149. // path separator(s) that were present in the codebase URL.
  150. WCHAR m_wchCodebasePathSeparator;
  151. CMediumStringBuffer m_buffCodebaseRelativePath;
  152. protected:
  153. BOOL WriteSingleInstallLog(
  154. const CInstalledItemEntry &item,
  155. BOOL bOverWrite = FALSE
  156. );
  157. SXS_INSTALL_SOURCE_INFO m_CurrentInstallInfoCopy;
  158. private:
  159. CAssemblyInstall(const CAssemblyInstall &);
  160. void operator =(const CAssemblyInstall &);
  161. };
  162. #define SXS_REFERENCE_CHUNK_SEPERATOR (L"_")
  163. #define SXS_REFERENCE_CHUNK_SEPERATOR_CCH (NUMBER_OF(SXS_REFERENCE_CHUNK_SEPERATOR)-1)
  164. #define WINSXS_INSTALLATION_REFERENCES_SUBKEY ( L"References")