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.

201 lines
6.5 KiB

  1. #pragma once
  2. #include "Sxsp.h"
  3. //
  4. // Turn this off to fail all manifests without catalogs during the parse!
  5. //
  6. #define SXS_LAX_MANIFEST_VALIDATION
  7. //
  8. // Warning - leaving this defined will --DISABLE-- WFP-SXS.
  9. // Define it as FALSE if you want to turn it back on.
  10. //
  11. #define YOU_ARE_HAVING_ANY_WIERDNESS_WITH_SFC_AND_SXS FALSE
  12. //
  13. // For this checkin (11/23ish/2000), we'll be leaving it turned OFF
  14. //
  15. // #define YOU_ARE_HAVING_ANY_WIERDNESS_WITH_SFC_AND_SXS TRUE
  16. //
  17. // This stuff is private!
  18. //
  19. #include "hashfile.h"
  20. #include "CAssemblyRecoveryInfo.h"
  21. #include "recover.h"
  22. BOOL
  23. SxspResolveAssemblyManifestPath(
  24. const CStringBuffer &AsmDirectoryName,
  25. CStringBuffer &bsManifestPath
  26. );
  27. BOOL
  28. SxspIsSfcIgnoredStoreSubdir(
  29. PCWSTR pwszDir
  30. );
  31. class CProtectionRequestList;
  32. class CStringListEntry;
  33. class CProtectionRequestRecord;
  34. #include "HashFile.h"
  35. #include "FusionHash.h"
  36. class CStringListEntry : public CAlignedSingleListEntry
  37. {
  38. public:
  39. CStringListEntry() { }
  40. CStringBuffer m_sbText;
  41. private:
  42. CStringListEntry(const CStringListEntry &);
  43. void operator =(const CStringListEntry &);
  44. };
  45. class CProtectionRequestRecord
  46. {
  47. private:
  48. CStringBuffer m_sbAssemblyName;
  49. CStringBuffer m_sbManifestPath;
  50. CStringBuffer m_sbAssemblyStore;
  51. CStringBuffer m_sbKeyValue;
  52. DWORD m_dwAction;
  53. PSXS_PROTECT_DIRECTORY m_pvProtection;
  54. ULONG m_ulInRecoveryMode;
  55. CProtectionRequestList *m_pParent;
  56. SLIST_HEADER m_ListHeader;
  57. CManifestSecurityContent *m_pPreParsedManifest;
  58. BOOL m_bIsManPathResolved;
  59. BOOL m_bInitialized;
  60. CAssemblyRecoveryInfo m_RecoverInfo;
  61. public:
  62. CProtectionRequestRecord();
  63. inline CProtectionRequestList *GetParent() const { return m_pParent; }
  64. inline CAssemblyRecoveryInfo &GetRecoveryInfo() const { return m_RecoverInfo; }
  65. inline const CStringBuffer &GetAssemblyDirectoryName() const { return m_sbAssemblyName; }
  66. inline const CStringBuffer &GetChangeBasePath() const { return m_sbKeyValue; }
  67. inline VOID SetParent( CProtectionRequestList *pParent ) { m_pParent = pParent; };
  68. inline VOID MarkInRecoveryMode( BOOL inRecovery ) { SxspInterlockedExchange( &m_ulInRecoveryMode, ( inRecovery ? 1 : 0 ) ); }
  69. inline VOID ClearList();
  70. inline BOOL GetManifestContent( CManifestSecurityContent *&pManifestData );
  71. inline BOOL SetAssemblyName( CStringBuffer &sbNewname ) { return m_sbAssemblyName.Win32Assign( sbNewname ); }
  72. inline BOOL GetManifestPath( CStringBuffer &sbManPath );
  73. inline BOOL AddSubFile( const CStringBuffer &sbThing );
  74. inline BOOL PopNextFileChange( CStringBuffer &Dest );
  75. inline BOOL GetAssemblyStore( CStringBuffer &Dest ) { return Dest.Win32Assign( m_sbAssemblyStore ); }
  76. inline BOOL Initialize(
  77. const CStringBuffer &sbAssemblyName,
  78. const CStringBuffer &sbKeyString,
  79. CProtectionRequestList* ParentList,
  80. PVOID pvRequestRecord,
  81. DWORD dwAction
  82. );
  83. ~CProtectionRequestRecord();
  84. private:
  85. CProtectionRequestRecord(const CProtectionRequestRecord &);
  86. void operator =(const CProtectionRequestRecord &);
  87. };
  88. class CRecoveryJobTableEntry
  89. {
  90. public:
  91. CRecoveryJobTableEntry()
  92. : m_Result(Recover_Unknown), m_dwLastError(ERROR_SUCCESS), m_bSuccessValue(TRUE),
  93. m_Subscriber(0), m_EventInstallingAssemblyComplete(INVALID_HANDLE_VALUE)
  94. { }
  95. SxsRecoveryResult m_Result;
  96. DWORD m_dwLastError;
  97. BOOL m_bSuccessValue;
  98. ULONG m_Subscriber;
  99. HANDLE m_EventInstallingAssemblyComplete;
  100. VOID Initialize();
  101. VOID StartInstallation();
  102. VOID InstallationComplete( BOOL bDoneOk, SxsRecoveryResult Result, DWORD dwLastError );
  103. VOID WaitUntilCompleted( SxsRecoveryResult &rResult, BOOL &rbSucceededValue, DWORD &rdwErrorResult );
  104. ~CRecoveryJobTableEntry();
  105. private:
  106. CRecoveryJobTableEntry(const CRecoveryJobTableEntry &);
  107. void operator =(const CRecoveryJobTableEntry &);
  108. };
  109. #pragma warning(disable:4324) // structure was padded due to __declspec(align())
  110. class CProtectionRequestList : public CCleanupBase
  111. {
  112. private:
  113. typedef CCaseInsensitiveUnicodeStringPtrTable<CProtectionRequestRecord> COurInternalTable;
  114. typedef CCaseInsensitiveUnicodeStringPtrTableIter<CProtectionRequestRecord> COurInternalTableIter;
  115. typedef CCaseInsensitiveUnicodeStringPtrTable<CRecoveryJobTableEntry> CInstallsInProgressTable;
  116. CRITICAL_SECTION m_cSection;
  117. CRITICAL_SECTION m_cInstallerCriticalSection;
  118. COurInternalTable *m_pInternalList;
  119. CInstallsInProgressTable *m_pInstallsTable;
  120. //
  121. // Manifest edits are trickier, they get their own system of being handled.
  122. //
  123. SLIST_HEADER m_ManifestEditList;
  124. HANDLE m_hManifestEditHappened;
  125. ULONG m_ulIsAThreadServicingManifests;
  126. static DWORD ProtectionNormalThreadProc( PVOID pvParam );
  127. static DWORD ProtectionManifestThreadProc( PVOID pvParam );
  128. static BOOL ProtectionManifestThreadProcNoSEH( PVOID pvParam );
  129. inline BOOL ProtectionNormalThreadProcWrapped( CProtectionRequestRecord *pProtectionRequest );
  130. inline BOOL ProtectionManifestThreadProcWrapped();
  131. inline BOOL ProtectionManifestSingleManifestWorker( const CStringListEntry *pEntry );
  132. static PCWSTR m_arrIgnorableSubdirs[];
  133. static SIZE_T m_cIgnorableSubdirs;
  134. friend BOOL SxspConstructProtectionList();
  135. BOOL Initialize();
  136. CProtectionRequestList();
  137. BOOL PerformRecoveryOfAssembly(
  138. CAssemblyRecoveryInfo &RecoverInfo,
  139. CRecoveryCopyQueue* pvPotentialQueue,
  140. SxsRecoveryResult &Result
  141. );
  142. ~CProtectionRequestList();
  143. public:
  144. static BOOL IsSfcIgnoredStoreSubdir( PCWSTR wsz );
  145. void DeleteYourself() { this->~CProtectionRequestList(); }
  146. VOID ClearProtectionItems(CProtectionRequestRecord *Asm) { FUSION_DELETE_SINGLETON( Asm ); }
  147. BOOL AttemptRemoveItem( CProtectionRequestRecord *AttemptRemoval );
  148. BOOL AddRequest( PSXS_PROTECT_DIRECTORY pProtect, PCWSTR pcwszDirName, SIZE_T cchName, DWORD dwAction );
  149. private:
  150. CProtectionRequestList(const CProtectionRequestList &);
  151. void operator =(const CProtectionRequestList &);
  152. };
  153. #pragma warning(default:4324) // structure was padded due to __declspec(align())
  154. VOID
  155. SxsProtectionEnableProcessing(
  156. BOOL bActivityEnabled
  157. );