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.6 KiB

  1. #pragma once
  2. #include "FusionArray.h"
  3. #include "SxsApi.h"
  4. #include "CSecurityMetaData.h"
  5. #define SXSRECOVER_MODE_MASK ( 0x0000000F )
  6. #define SXSRECOVER_NOTHING ( 0x00000000 )
  7. #define SXSRECOVER_MANIFEST ( 0x00000001 )
  8. #define SXSRECOVER_ASSEMBLYMEMBER ( 0x00000002 )
  9. #define SXSRECOVER_FULL_ASSEMBLY ( SXSRECOVER_ASSEMBLYMEMBER | SXSRECOVER_MANIFEST )
  10. enum SxsRecoveryResult
  11. {
  12. Recover_OK,
  13. Recover_ManifestMissing,
  14. Recover_CatalogInvalid,
  15. Recover_OneOrMoreFailed,
  16. Recover_SourceMissing,
  17. Recover_Unknown
  18. };
  19. #if DBG
  20. #define ENUM_TO_STRING( x ) case x: return (L#x)
  21. inline static PCWSTR SxspRecoveryResultToString( const SxsRecoveryResult r )
  22. {
  23. switch ( r )
  24. {
  25. ENUM_TO_STRING( Recover_OK );
  26. ENUM_TO_STRING( Recover_ManifestMissing );
  27. ENUM_TO_STRING( Recover_CatalogInvalid );
  28. ENUM_TO_STRING( Recover_OneOrMoreFailed );
  29. ENUM_TO_STRING( Recover_SourceMissing );
  30. ENUM_TO_STRING( Recover_Unknown );
  31. }
  32. return L"Bad SxsRecoveryResult value";
  33. }
  34. #undef ENUM_TO_STRING
  35. #endif
  36. class CAssemblyRecoveryInfo;
  37. class CRecoveryCopyQueue;
  38. BOOL
  39. SxspOpenAssemblyInstallationKey(
  40. DWORD dwFlags,
  41. DWORD dwAccess,
  42. CRegKey &rhkAssemblyInstallation
  43. );
  44. BOOL
  45. SxspRecoverAssembly(
  46. IN const CAssemblyRecoveryInfo &AsmRecoverInfo,
  47. IN CRecoveryCopyQueue *pRecoveryQueue,
  48. OUT SxsRecoveryResult &rStatus
  49. );
  50. #define SXSP_ADD_ASSEMBLY_INSTALLATION_INFO_FLAG_REFRESH (0x00000001)
  51. BOOL
  52. SxspAddAssemblyInstallationInfo(
  53. DWORD dwFlags,
  54. IN CAssemblyRecoveryInfo& rcAssemblyInfo,
  55. IN const CCodebaseInformation& rcCodebaeInfo
  56. );
  57. class CRecoveryCopyQueue
  58. {
  59. private:
  60. __declspec(align(16))
  61. SLIST_HEADER m_PostCopyList;
  62. BOOL m_bDoingOwnCopies;
  63. CStringBuffer m_sbAssemblyInstallRoot;
  64. CFusionArray<CStringBuffer> m_EligbleCopies;
  65. //
  66. // As the copy callback is triggered, we get pairs of source/destination
  67. // strings that indicate where files should be copied. These get stored
  68. // in the m_PostCopyList queue, and consumed in the queue flush. As part
  69. // of the installation callback, we validate that the file being copied to
  70. // does in fact match the hash stored in the m_pValidateTable, if it is
  71. // non-null.
  72. //
  73. class CQueueElement : public SINGLE_LIST_ENTRY
  74. {
  75. public:
  76. CStringBuffer sbSource;
  77. CStringBuffer sbDestination;
  78. private:
  79. CQueueElement(const CQueueElement &);
  80. void operator =(const CQueueElement &);
  81. };
  82. BOOL InternalCopyCallback(PSXS_INSTALLATION_FILE_COPY_CALLBACK_PARAMETERS);
  83. public:
  84. CRecoveryCopyQueue(bool bDoOwnCopies = true);
  85. ~CRecoveryCopyQueue();
  86. BOOL Initialize();
  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 CBaseStringBuffer &rsbItem);
  93. BOOL AddRecoveryItem(const CBaseStringBuffer *prgsbItems, 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. };