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.

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