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.

203 lines
6.8 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 CBaseStringBuffer &rAsmDirectoryName,
  25. CBaseStringBuffer &rbsManifestPath
  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. #pragma warning(disable:4327) // indirection alignment of LHS (16) is greater than RHS (8)
  46. #pragma warning(disable:4328) // indirection alignment of formal parameter 2 (16) is greater than the actual argument alignment (8)
  47. class CProtectionRequestRecord
  48. {
  49. private:
  50. CStringBuffer m_sbAssemblyDirectoryName;
  51. CStringBuffer m_sbManifestPath;
  52. CStringBuffer m_sbAssemblyStore;
  53. CStringBuffer m_sbKeyValue;
  54. DWORD m_dwAction;
  55. PSXS_PROTECT_DIRECTORY m_pvProtection;
  56. ULONG m_ulInRecoveryMode;
  57. CProtectionRequestList *m_pParent;
  58. __declspec(align(16))
  59. SLIST_HEADER m_ListHeader;
  60. BOOL m_bIsManPathResolved;
  61. BOOL m_bInitialized;
  62. CAssemblyRecoveryInfo m_RecoverInfo;
  63. public:
  64. CProtectionRequestRecord();
  65. inline CProtectionRequestList *GetParent() const { return m_pParent; }
  66. inline CAssemblyRecoveryInfo &GetRecoveryInfo() { return m_RecoverInfo; }
  67. inline const CAssemblyRecoveryInfo &GetRecoveryInfo() const { return m_RecoverInfo; }
  68. inline const CBaseStringBuffer &GetAssemblyDirectoryName() const { return m_sbAssemblyDirectoryName; }
  69. inline const CBaseStringBuffer &GetChangeBasePath() const { return m_sbKeyValue; }
  70. inline VOID SetParent(CProtectionRequestList *pParent) { m_pParent = pParent; };
  71. inline VOID MarkInRecoveryMode(BOOL inRecovery) { ::SxspInterlockedExchange( &m_ulInRecoveryMode, ( inRecovery ? 1 : 0 ) ); }
  72. inline VOID ClearList();
  73. inline BOOL GetManifestContent(CSecurityMetaData *&pSecurityData);
  74. inline BOOL SetAssemblyDirectoryName(const CBaseStringBuffer &rsbNewname) { return m_sbAssemblyDirectoryName.Win32Assign(rsbNewname); }
  75. inline BOOL GetManifestPath(CBaseStringBuffer &sbManPath);
  76. inline BOOL AddSubFile(const CBaseStringBuffer &sbThing);
  77. inline BOOL PopNextFileChange(CBaseStringBuffer &Dest);
  78. inline BOOL GetAssemblyStore(CBaseStringBuffer &Dest) { return Dest.Win32Assign(m_sbAssemblyStore); }
  79. inline BOOL Initialize(
  80. const CBaseStringBuffer &sbAssemblyName,
  81. const CBaseStringBuffer &sbKeyString,
  82. CProtectionRequestList* ParentList,
  83. PVOID pvRequestRecord,
  84. DWORD dwAction
  85. );
  86. ~CProtectionRequestRecord();
  87. private:
  88. CProtectionRequestRecord(const CProtectionRequestRecord &);
  89. void operator =(const CProtectionRequestRecord &);
  90. };
  91. class CRecoveryJobTableEntry
  92. {
  93. public:
  94. CRecoveryJobTableEntry()
  95. : m_Result(Recover_Unknown), m_dwLastError(ERROR_SUCCESS), m_fSuccessValue(TRUE),
  96. m_Subscriber(0), m_EventInstallingAssemblyComplete(INVALID_HANDLE_VALUE)
  97. { }
  98. SxsRecoveryResult m_Result;
  99. DWORD m_dwLastError;
  100. BOOL m_fSuccessValue;
  101. ULONG m_Subscriber;
  102. HANDLE m_EventInstallingAssemblyComplete;
  103. BOOL Initialize();
  104. BOOL StartInstallation();
  105. BOOL InstallationComplete( BOOL bDoneOk, SxsRecoveryResult Result, DWORD dwLastError );
  106. BOOL WaitUntilCompleted( SxsRecoveryResult &rResult, BOOL &rbSucceededValue, DWORD &rdwErrorResult );
  107. ~CRecoveryJobTableEntry();
  108. private:
  109. CRecoveryJobTableEntry(const CRecoveryJobTableEntry &);
  110. void operator =(const CRecoveryJobTableEntry &);
  111. };
  112. class CProtectionRequestList : public CCleanupBase
  113. {
  114. private:
  115. typedef CCaseInsensitiveUnicodeStringPtrTable<CProtectionRequestRecord> COurInternalTable;
  116. typedef CCaseInsensitiveUnicodeStringPtrTableIter<CProtectionRequestRecord> COurInternalTableIter;
  117. typedef CCaseInsensitiveUnicodeStringPtrTable<CRecoveryJobTableEntry> CInstallsInProgressTable;
  118. CRITICAL_SECTION m_cSection;
  119. CRITICAL_SECTION m_cInstallerCriticalSection;
  120. COurInternalTable *m_pInternalList;
  121. CInstallsInProgressTable *m_pInstallsTable;
  122. //
  123. // Manifest edits are trickier, they get their own system of being handled.
  124. //
  125. __declspec(align(16))
  126. SLIST_HEADER m_ManifestEditList;
  127. HANDLE m_hManifestEditHappened;
  128. ULONG m_ulIsAThreadServicingManifests;
  129. PVOID m_Padding; // Required for win64 win S-Lists are 16 byte aligned
  130. static DWORD ProtectionNormalThreadProc( PVOID pvParam );
  131. static DWORD ProtectionManifestThreadProc( PVOID pvParam );
  132. static BOOL ProtectionManifestThreadProcNoSEH( PVOID pvParam );
  133. inline BOOL ProtectionNormalThreadProcWrapped( CProtectionRequestRecord *pProtectionRequest );
  134. inline BOOL ProtectionManifestThreadProcWrapped();
  135. inline BOOL ProtectionManifestSingleManifestWorker( const CStringListEntry *pEntry );
  136. static PCWSTR m_arrIgnorableSubdirs[];
  137. static SIZE_T m_cIgnorableSubdirs;
  138. friend BOOL SxspConstructProtectionList();
  139. BOOL Initialize();
  140. CProtectionRequestList();
  141. BOOL PerformRecoveryOfAssembly(
  142. const CAssemblyRecoveryInfo &RecoverInfo,
  143. CRecoveryCopyQueue* pvPotentialQueue,
  144. SxsRecoveryResult &Result
  145. );
  146. ~CProtectionRequestList();
  147. public:
  148. static BOOL IsSfcIgnoredStoreSubdir( PCWSTR wsz );
  149. void DeleteYourself() { this->~CProtectionRequestList(); }
  150. VOID ClearProtectionItems(CProtectionRequestRecord *Asm) { FUSION_DELETE_SINGLETON( Asm ); }
  151. BOOL AttemptRemoveItem( CProtectionRequestRecord *AttemptRemoval );
  152. BOOL AddRequest( PSXS_PROTECT_DIRECTORY pProtect, PCWSTR pcwszDirName, SIZE_T cchName, DWORD dwAction );
  153. private:
  154. CProtectionRequestList(const CProtectionRequestList &);
  155. void operator =(const CProtectionRequestList &);
  156. };
  157. VOID
  158. SxsProtectionEnableProcessing(
  159. BOOL bActivityEnabled
  160. );