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.

129 lines
3.7 KiB

  1. #pragma once
  2. #include "FusionArray.h"
  3. #include "SxsApi.h"
  4. #define SXSRECOVER_MODE_MASK ( 0x0000000F )
  5. #define SXSRECOVER_NOTHING ( 0x00000000 )
  6. #define SXSRECOVER_MANIFEST ( 0x00000001 )
  7. #define SXSRECOVER_ASSEMBLYMEMBER ( 0x00000002 )
  8. #define SXSRECOVER_FULL_ASSEMBLY ( SXSRECOVER_ASSEMBLYMEMBER | SXSRECOVER_MANIFEST )
  9. enum SxsRecoveryResult
  10. {
  11. Recover_OK,
  12. Recover_ManifestMissing,
  13. Recover_CatalogInvalid,
  14. Recover_OneOrMoreFailed,
  15. Recover_SourceMissing,
  16. Recover_Unknown
  17. };
  18. #if DBG
  19. #define ENUM_TO_STRING( x ) case x: return (L#x)
  20. inline static PCWSTR SxspRecoveryResultToString( const SxsRecoveryResult r )
  21. {
  22. switch ( r )
  23. {
  24. ENUM_TO_STRING( Recover_OK );
  25. ENUM_TO_STRING( Recover_ManifestMissing );
  26. ENUM_TO_STRING( Recover_CatalogInvalid );
  27. ENUM_TO_STRING( Recover_OneOrMoreFailed );
  28. ENUM_TO_STRING( Recover_SourceMissing );
  29. ENUM_TO_STRING( Recover_Unknown );
  30. }
  31. return L"Bad SxsRecoveryResult value";
  32. }
  33. #undef ENUM_TO_STRING
  34. #endif
  35. class CManifestSecurityContent;
  36. class CAssemblyRecoveryInfo;
  37. class CRecoveryCopyQueue;
  38. BOOL
  39. SxspRecoverAssembly(
  40. IN CAssemblyRecoveryInfo &AsmRecoverInfo,
  41. IN CRecoveryCopyQueue *pRecoveryQueue,
  42. OUT SxsRecoveryResult &rStatus
  43. );
  44. BOOL
  45. SxspAddAssemblyInstallationInfo(
  46. IN PCWSTR pcwszAssemblyName,
  47. IN PCWSTR pcwszCodebase,
  48. IN PCWSTR pcwszPrompt OPTIONAL,
  49. IN BOOL bHasCatalog
  50. );
  51. BOOL
  52. SxspAddAssemblyInstallationInfo(
  53. IN const CAssemblyRecoveryInfo& AssemblyInfo
  54. );
  55. class CRecoveryCopyQueue
  56. {
  57. private:
  58. SLIST_HEADER m_PostCopyList;
  59. BOOL m_bDoingOwnCopies;
  60. CManifestSecurityContent *m_pValidateTable;
  61. CStringBuffer m_sbAssemblyInstallRoot;
  62. CFusionArray<CStringBuffer> m_EligbleCopies;
  63. //
  64. // As the copy callback is triggered, we get pairs of source/destination
  65. // strings that indicate where files should be copied. These get stored
  66. // in the m_PostCopyList queue, and consumed in the queue flush. As part
  67. // of the installation callback, we validate that the file being copied to
  68. // does in fact match the hash stored in the m_pValidateTable, if it is
  69. // non-null.
  70. //
  71. class CQueueElement : public SINGLE_LIST_ENTRY
  72. {
  73. public:
  74. CStringBuffer sbSource;
  75. CStringBuffer sbDestination;
  76. private:
  77. CQueueElement(const CQueueElement &);
  78. void operator =(const CQueueElement &);
  79. };
  80. BOOL InternalCopyCallback(PSXS_INSTALLATION_FILE_COPY_CALLBACK_PARAMETERS);
  81. public:
  82. CRecoveryCopyQueue( CManifestSecurityContent *pValidateSource = NULL, bool bDoOwnCopies = true);
  83. ~CRecoveryCopyQueue();
  84. BOOL Initialize();
  85. VOID SetManifestContentTable( CManifestSecurityContent* pSource )
  86. { m_pValidateTable = pSource; }
  87. //
  88. // This is in the setup phase - indicate that this item is to be copied
  89. // over as part of the protection copy progress. This entry is the assembly-
  90. // relative name of the file in question.
  91. //
  92. BOOL AddRecoveryItem( const CStringBuffer &sbItem );
  93. BOOL AddRecoveryItem( const CStringBuffer *sbItems, SIZE_T cItems );
  94. //
  95. // Callback used by the copy queue functionality
  96. //
  97. static BOOL WINAPI staticCopyCallback(PSXS_INSTALLATION_FILE_COPY_CALLBACK_PARAMETERS);
  98. //
  99. // After the assembly install process completes, this function is called by
  100. // SxspRecoverAssembly to do the actual copies of stuff.
  101. //
  102. BOOL FlushPending( BOOL &bFullCopyQueueRecovered );
  103. private:
  104. CRecoveryCopyQueue(const CRecoveryCopyQueue &);
  105. void operator =(const CRecoveryCopyQueue &);
  106. };