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.

220 lines
6.1 KiB

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