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.

159 lines
4.9 KiB

  1. /*++
  2. Copyright (c) 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. const CSecurityMetaData &GetSecurityInformation() const { return m_SecurityMetaData; }
  48. CSecurityMetaData& GetSecurityInformation() { return m_SecurityMetaData; }
  49. const CCodebaseInformationList& GetCodeBaseList() const { return m_SecurityMetaData.GetCodeBaseList(); }
  50. //protected:
  51. CCodebaseInformationList& GetCodeBaseList() { return m_SecurityMetaData.GetCodeBaseList(); }
  52. public:
  53. //
  54. // Fill out this object from a registry key
  55. //
  56. BOOL AssociateWithAssembly(CBaseStringBuffer &rcbuffLoadFromKeyName, bool &rfNoAssembly);
  57. //
  58. // Take an existing value - sort of like "initialize"
  59. //
  60. BOOL CopyValue(const CAssemblyRecoveryInfo &rsrc);
  61. //
  62. // Cheap, but effective.
  63. //
  64. const CBaseStringBuffer &GetAssemblyDirectoryName() const { return m_sbAssemblyDirectoryName; }
  65. BOOL GetHasCatalog() const { return TRUE; }
  66. BOOL GetInfoPrepared() const { return m_fLoadedAndReady; }
  67. //
  68. // Setters - useful for registration
  69. //
  70. BOOL SetAssemblyIdentity(IN const CBaseStringBuffer &rsb) { return m_SecurityMetaData.SetTextualIdentity(rsb); }
  71. BOOL SetAssemblyIdentity( IN PCASSEMBLY_IDENTITY pcidAssembly );
  72. VOID SetHasCatalog(IN BOOL fHasCatalog) { }
  73. //
  74. // Call this to try and resolve the internally listed codebase against
  75. // the system and return it into sbFinalCodebase. Returns TRUE if the
  76. // operation is successful, not based on whether the codebase is valid.
  77. //
  78. BOOL ResolveCodebase(CBaseStringBuffer &rsbFinalCodebase, SxsWFPResolveCodebase &rCodebaseType) const;
  79. //
  80. // Last bit of bookkeeping necessary before writing the assembly to disk
  81. //
  82. BOOL PrepareForWriting();
  83. BOOL WriteSecondaryAssemblyInfoIntoRegistryKey(CRegKey & rhkRegistryNode) const;
  84. #define SXSP_WRITE_PRIMARY_ASSEMBLY_INFO_TO_REGISTRY_KEY_FLAG_REFRESH (0x00000001)
  85. BOOL WritePrimaryAssemblyInfoToRegistryKey(ULONG Flags, CRegKey & rhkRegistryNode) const;
  86. BOOL ClearExistingRegistryData();
  87. VOID RestorePreviouslyExistingRegistryData();
  88. BOOL OpenInstallationSubKey(CFusionRegKey& hkSingleAssemblyInfo, DWORD OpenOrCreate, DWORD Access);
  89. private:
  90. CAssemblyRecoveryInfo(const CAssemblyRecoveryInfo &);
  91. void operator =(const CAssemblyRecoveryInfo &);
  92. };
  93. MAKE_CFUSIONARRAY_READY(CAssemblyRecoveryInfo, CopyValue);
  94. /*
  95. These are instantiated (in an unsearchable way) by the URLTAGINFO macro below.
  96. URLHEAD_WINSOURCE
  97. URLHEAD_FILE URLHEAD_CDROM
  98. URLHEAD_TAG
  99. URLHEAD_CDROM_TYPE_TAG
  100. URLHEAD_CDROM_TYPE_SERIALNUMBER
  101. URLHEAD_CDROM_TYPE_VOLUMENAME
  102. */
  103. extern const UNICODE_STRING UnicodeString_URLHEAD_WINSOURCE;
  104. #define URLTAGINFO( namevalue, str ) \
  105. __declspec(selectany) extern const WCHAR URLHEAD_ ##namevalue [] = ( str ); \
  106. static const SIZE_T URLHEAD_LENGTH_ ##namevalue = \
  107. ( sizeof( URLHEAD_ ##namevalue ) / sizeof( WCHAR ) ) - 1;
  108. //
  109. // Move these to a .cpp file.
  110. //
  111. URLTAGINFO(FILE, L"file:")
  112. URLTAGINFO(CDROM, L"cdrom:")
  113. URLTAGINFO(WINSOURCE, L"x-ms-windows-source:")
  114. //URLTAGINFO(DARWINSOURCE, L"x-ms-darwin-source:")
  115. URLTAGINFO(HTTP, L"http:")
  116. // These things are not URL heads but nonetheless still use the same macro
  117. URLTAGINFO(CDROM_TYPE_TAG, L"tagfile")
  118. URLTAGINFO(CDROM_TYPE_SERIALNUMBER, L"serialnumber")
  119. URLTAGINFO(CDROM_TYPE_VOLUMENAME, L"volumename")
  120. BOOL
  121. SxspLooksLikeAssemblyDirectoryName(
  122. const CBaseStringBuffer &rsbDoesLookLikeName,
  123. BOOL &rbLooksLikeAssemblyName
  124. );