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.

152 lines
4.6 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. CAssemblyRecoveryInfo.h
  5. Abstract:
  6. Author:
  7. Environment:
  8. Revision History:
  9. --*/
  10. #pragma once
  11. class CAssemblyRecoveryInfo;
  12. #include "fusionbuffer.h"
  13. #include "csecuritymetadata.h"
  14. #define WINSXS_INSTALL_SOURCE_BASEDIR (L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup")
  15. #define WINSXS_INSTALL_SVCPACK_REGKEY (L"ServicePackSourcePath")
  16. #define WINSXS_INSTALL_SOURCEPATH_REGKEY (L"SourcePath")
  17. #define WINSXS_INSTALL_SOURCE_IS_CDROM (L"CDInstall")
  18. class CAssemblyRecoveryInfo
  19. {
  20. private:
  21. CStringBuffer m_sbAssemblyDirectoryName;
  22. CSecurityMetaData m_SecurityMetaData;
  23. BOOL m_fLoadedAndReady;
  24. bool m_fHadCatalog;
  25. BOOL ResolveWinSourceMediaURL(PCWSTR wszSource, CBaseStringBuffer &rsbDestination) const;
  26. BOOL ResolveCDRomURL(PCWSTR wszSource, CBaseStringBuffer &rsbDestination) const;
  27. enum CDRomSearchType
  28. {
  29. CDRST_Tagfile,
  30. CDRST_SerialNumber,
  31. CDRST_VolumeName
  32. };
  33. public:
  34. CAssemblyRecoveryInfo()
  35. :
  36. m_fLoadedAndReady(FALSE),
  37. m_fHadCatalog(false)
  38. { }
  39. BOOL Initialize()
  40. {
  41. FN_PROLOG_WIN32
  42. m_sbAssemblyDirectoryName.Clear();
  43. m_fLoadedAndReady = FALSE;
  44. IFW32FALSE_EXIT( m_SecurityMetaData.Initialize() );
  45. FN_EPILOG
  46. }
  47. BOOL OpenInstallationSubKey(DWORD OpenOrCreate, DWORD Access);
  48. const CSecurityMetaData &GetSecurityInformation() const { return m_SecurityMetaData; }
  49. CSecurityMetaData& GetSecurityInformation() { return m_SecurityMetaData; }
  50. const CCodebaseInformationList& GetCodeBaseList() const { return m_SecurityMetaData.GetCodeBaseList(); }
  51. //protected:
  52. CCodebaseInformationList& GetCodeBaseList() { return m_SecurityMetaData.GetCodeBaseList(); }
  53. public:
  54. //
  55. // Fill out this object from a registry key
  56. //
  57. BOOL AssociateWithAssembly(CBaseStringBuffer &rcbuffLoadFromKeyName, bool &rfNoAssembly);
  58. //
  59. // Take an existing value - sort of like "initialize"
  60. //
  61. BOOL CopyValue(const CAssemblyRecoveryInfo &rsrc);
  62. //
  63. // Cheap, but effective.
  64. //
  65. const CBaseStringBuffer &GetAssemblyDirectoryName() const { return m_sbAssemblyDirectoryName; }
  66. BOOL GetHasCatalog() const { return TRUE; }
  67. BOOL GetInfoPrepared() const { return m_fLoadedAndReady; }
  68. //
  69. // Setters - useful for registration
  70. //
  71. BOOL SetAssemblyIdentity(IN const CBaseStringBuffer &rsb) { return m_SecurityMetaData.SetTextualIdentity(rsb); }
  72. BOOL SetAssemblyIdentity( IN PCASSEMBLY_IDENTITY pcidAssembly );
  73. VOID SetHasCatalog(IN BOOL fHasCatalog) { }
  74. //
  75. // Call this to try and resolve the internally listed codebase against
  76. // the system and return it into sbFinalCodebase. Returns TRUE if the
  77. // operation is successful, not based on whether the codebase is valid.
  78. //
  79. BOOL ResolveCodebase(CBaseStringBuffer &rsbFinalCodebase, SxsWFPResolveCodebase &rCodebaseType) const;
  80. //
  81. // Last bit of bookkeeping necessary before writing the assembly to disk
  82. //
  83. BOOL PrepareForWriting();
  84. BOOL WriteSecondaryAssemblyInfoIntoRegistryKey(CRegKey & rhkRegistryNode) const;
  85. #define SXSP_WRITE_PRIMARY_ASSEMBLY_INFO_TO_REGISTRY_KEY_FLAG_REFRESH (0x00000001)
  86. BOOL WritePrimaryAssemblyInfoToRegistryKey(ULONG Flags, CRegKey & rhkRegistryNode) const;
  87. BOOL ClearExistingRegistryData();
  88. VOID RestorePreviouslyExistingRegistryData();
  89. BOOL OpenInstallationSubKey(CFusionRegKey& hkSingleAssemblyInfo, DWORD OpenOrCreate, DWORD Access);
  90. SMARTTYPEDEF(CAssemblyRecoveryInfo);
  91. private:
  92. CAssemblyRecoveryInfo(const CAssemblyRecoveryInfo &);
  93. void operator =(const CAssemblyRecoveryInfo &);
  94. };
  95. MAKE_CFUSIONARRAY_READY(CAssemblyRecoveryInfo, CopyValue);
  96. #define URLTAGINFO( namevalue, str ) \
  97. __declspec(selectany) extern const WCHAR URLHEAD_ ##namevalue [] = ( str ); \
  98. static const SIZE_T URLHEAD_LENGTH_ ##namevalue = \
  99. ( sizeof( URLHEAD_ ##namevalue ) / sizeof( WCHAR ) ) - 1;
  100. //
  101. // Move these to a .cpp file.
  102. //
  103. URLTAGINFO(FILE, L"file:")
  104. URLTAGINFO(CDROM, L"cdrom:")
  105. URLTAGINFO(WINSOURCE, L"x-ms-windows-source:")
  106. //URLTAGINFO(DARWINSOURCE, L"x-ms-darwin-source:")
  107. URLTAGINFO(HTTP, L"http:")
  108. // These things are not URL heads but nonetheless still use the same macro
  109. URLTAGINFO(CDROM_TYPE_TAG, L"tagfile")
  110. URLTAGINFO(CDROM_TYPE_SERIALNUMBER, L"serialnumber")
  111. URLTAGINFO(CDROM_TYPE_VOLUMENAME, L"volumename")
  112. BOOL
  113. SxspLooksLikeAssemblyDirectoryName(
  114. const CBaseStringBuffer &rsbDoesLookLikeName,
  115. BOOL &rbLooksLikeAssemblyName
  116. );