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.

235 lines
7.0 KiB

  1. #if !defined(_FUSION_SXS_PROBEDASSEMBLYINFORMATION_H_INCLUDED_)
  2. #define _FUSION_SXS_PROBEDASSEMBLYINFORMATION_H_INCLUDED_
  3. #pragma once
  4. #include "sxsp.h"
  5. #include "assemblyreference.h"
  6. #include "impersonationdata.h"
  7. #include <sxsapi.h>
  8. class CProbedAssemblyInformation : protected CAssemblyReference
  9. {
  10. typedef CAssemblyReference Base;
  11. protected:
  12. public:
  13. CProbedAssemblyInformation()
  14. :
  15. m_ManifestFlags(ASSEMBLY_MANIFEST_FILETYPE_AUTO_DETECT),
  16. m_PolicySource(SXS_POLICY_UNSPECIFIED),
  17. m_ManifestPathType(ACTIVATION_CONTEXT_PATH_TYPE_NONE),
  18. m_PolicyPathType(ACTIVATION_CONTEXT_PATH_TYPE_NONE)
  19. {
  20. m_ManifestLastWriteTime.dwLowDateTime = 0;
  21. m_ManifestLastWriteTime.dwHighDateTime = 0;
  22. m_PolicyLastWriteTime.dwLowDateTime = 0;
  23. m_PolicyLastWriteTime.dwHighDateTime = 0;
  24. }
  25. ~CProbedAssemblyInformation();
  26. BOOL Initialize();
  27. BOOL Initialize(const CAssemblyReference &r);
  28. BOOL Initialize(const CProbedAssemblyInformation &r);
  29. using CAssemblyReference::GetAssemblyIdentity;
  30. using CAssemblyReference::GetAssemblyName;
  31. using CAssemblyReference::GetPublicKeyToken;
  32. using CAssemblyReference::SetAssemblyIdentity;
  33. using CAssemblyReference::SetLanguage;
  34. using CAssemblyReference::SetProcessorArchitecture;
  35. using CAssemblyReference::SetPublicKeyToken;
  36. using CAssemblyReference::ClearLanguage;
  37. enum LanguageProbeType
  38. {
  39. eExplicitBind,
  40. eLanguageNeutral,
  41. eSpecificLanguage,
  42. eGenericLanguage,
  43. eSpecificSystemLanguage,
  44. eGenericSystemLanguage
  45. };
  46. enum ProbeAssemblyFlags
  47. {
  48. ProbeAssembly_SkipPrivateAssemblies = 0x00000001,
  49. };
  50. BOOL ProbeAssembly(DWORD dwFlags, PACTCTXGENCTX pActCtxGenCtx, LanguageProbeType lpt, bool &rfFound);
  51. BOOL Assign(const CProbedAssemblyInformation &r);
  52. BOOL SetOriginalReference(const CAssemblyReference &r, bool fCopyValidFieldsFromPartialReference = true);
  53. const CAssemblyReference &GetOriginalReference() const;
  54. BOOL SetOriginalReference(PCASSEMBLY_IDENTITY AssemblyIdentity);
  55. BOOL SetProbedIdentity(PCASSEMBLY_IDENTITY AssemblyIdentity);
  56. BOOL ResetProbedToOriginal();
  57. // manifest
  58. BOOL SetManifestPath(ULONG ulPathType, const CBaseStringBuffer &rbuff);
  59. BOOL SetManifestPath(ULONG ulPathType, PCWSTR Path, SIZE_T PathCch);
  60. BOOL GetManifestPath(PCWSTR *Path, SIZE_T *PathCch) const;
  61. const CBaseStringBuffer &GetManifestPath() const { return m_ManifestPathBuffer; }
  62. ULONG GetManifestPathType() const { return m_ManifestPathType; }
  63. ULONG GetManifestFlags() const;
  64. BOOL SetManifestFlags(ULONG Flags);
  65. BOOL SetManifestLastWriteTime(const FILETIME &LastWriteTime);
  66. const FILETIME &GetManifestLastWriteTime() const;
  67. BOOL SetManifestLastWriteTime(PACTCTXGENCTX pActCtxGenCtx, BOOL fDuringBindingAndProbingPrivateManifest = FALSE);
  68. BOOL SetManifestStream(IStream* Stream);
  69. IStream* GetManifestStream() const;
  70. BOOL ProbeManifestExistence(const CImpersonationData &ImpersonationData, bool &rfManifestExists) const;
  71. // APPLICATION policy, not component policy...
  72. ULONG GetPolicyFlags() const;
  73. BOOL SetPolicyFlags(ULONG Flags);
  74. BOOL GetPolicyPath(PCWSTR &rPath, SIZE_T &rPathCch) const;
  75. const FILETIME &GetPolicyLastWriteTime() const;
  76. BOOL SetPolicyPath(ULONG PathType, PCWSTR Path, SIZE_T PathCch);
  77. const CBaseStringBuffer &GetPolicyPath() const { return m_PolicyPathBuffer; }
  78. ULONG GetPolicyPathType() const { return m_PolicyPathType; }
  79. BOOL SetPolicyStream(IStream* Stream);
  80. IStream* GetPolicyStream() const;
  81. BOOL IsPrivateAssembly() const;
  82. SXS_POLICY_SOURCE GetPolicySource() const;
  83. void SetPolicySource(SXS_POLICY_SOURCE ps);
  84. BOOL ApplyPolicyDestination(const CAssemblyReference &r, SXS_POLICY_SOURCE s, const GUID &g);
  85. protected:
  86. BOOL LookForPolicy(PACTCTXGENCTX pActCtxGenCtx);
  87. BOOL LookForNDPWin32Policy(PACTCTXGENCTX pActCtxGenCtx);
  88. BOOL ProbeLanguageDir(CBaseStringBuffer &rbuffApplicationDirectory, const CBaseStringBuffer &rbuffLanguage, bool &rfFound);
  89. CAssemblyReference m_OriginalReference;
  90. CAssemblyReference m_CheckpointedReference;
  91. // manifest
  92. ULONG m_ManifestPathType;
  93. CStringBuffer m_ManifestPathBuffer;
  94. FILETIME m_ManifestLastWriteTime;
  95. CSmartRef<IStream> m_ManifestStream;
  96. ULONG m_ManifestFlags;
  97. // policy
  98. ULONG m_PolicyPathType;
  99. CSmallStringBuffer m_PolicyPathBuffer; // only used when policy is present
  100. FILETIME m_PolicyLastWriteTime;
  101. SXS_POLICY_SOURCE m_PolicySource;
  102. GUID m_SystemPolicyGuid;
  103. CSmartRef<IStream> m_PolicyStream;
  104. ULONG m_PolicyFlags;
  105. private: // deliberately not implemented
  106. CProbedAssemblyInformation(const CProbedAssemblyInformation&);
  107. void operator=(const CProbedAssemblyInformation&);
  108. };
  109. inline const CAssemblyReference& CProbedAssemblyInformation::GetOriginalReference() const
  110. {
  111. return m_OriginalReference;
  112. }
  113. inline BOOL CProbedAssemblyInformation::GetManifestPath(PCWSTR *Path, SIZE_T *PathCch) const
  114. {
  115. if (Path != NULL)
  116. *Path = m_ManifestPathBuffer;
  117. if (PathCch != NULL)
  118. *PathCch = m_ManifestPathBuffer.Cch();
  119. return TRUE;
  120. }
  121. inline BOOL CProbedAssemblyInformation::SetManifestLastWriteTime(const FILETIME &LastWriteTime)
  122. {
  123. m_ManifestLastWriteTime = LastWriteTime;
  124. return TRUE;
  125. }
  126. inline const FILETIME& CProbedAssemblyInformation::GetManifestLastWriteTime() const
  127. {
  128. return m_ManifestLastWriteTime;
  129. }
  130. inline BOOL
  131. CProbedAssemblyInformation::GetPolicyPath(
  132. PCWSTR &rPath,
  133. SIZE_T &rPathCch
  134. ) const
  135. {
  136. rPath = static_cast<PCWSTR>(m_PolicyPathBuffer);
  137. rPathCch = m_PolicyPathBuffer.Cch();
  138. return TRUE;
  139. }
  140. inline ULONG CProbedAssemblyInformation::GetPolicyFlags() const
  141. {
  142. return m_PolicyFlags;
  143. }
  144. inline BOOL CProbedAssemblyInformation::SetPolicyFlags(ULONG Flags)
  145. {
  146. m_PolicyFlags = Flags;
  147. return TRUE;
  148. }
  149. inline const FILETIME& CProbedAssemblyInformation::GetPolicyLastWriteTime() const
  150. {
  151. return m_PolicyLastWriteTime;
  152. }
  153. inline ULONG CProbedAssemblyInformation::GetManifestFlags() const
  154. {
  155. return m_ManifestFlags;
  156. }
  157. inline BOOL CProbedAssemblyInformation::SetManifestFlags(ULONG Flags)
  158. {
  159. m_ManifestFlags = Flags;
  160. return TRUE;
  161. }
  162. inline BOOL CProbedAssemblyInformation::SetManifestStream(IStream* Stream)
  163. {
  164. m_ManifestStream = Stream;
  165. return TRUE;
  166. }
  167. inline BOOL CProbedAssemblyInformation::SetPolicyStream(IStream* Stream)
  168. {
  169. m_PolicyStream = Stream;
  170. return TRUE;
  171. }
  172. inline IStream* CProbedAssemblyInformation::GetPolicyStream() const
  173. {
  174. return m_PolicyStream;
  175. }
  176. inline IStream* CProbedAssemblyInformation::GetManifestStream() const
  177. {
  178. return m_ManifestStream;
  179. }
  180. inline BOOL CProbedAssemblyInformation::IsPrivateAssembly() const
  181. {
  182. return ((m_ManifestFlags & ASSEMBLY_PRIVATE_MANIFEST) ? TRUE : FALSE);
  183. }
  184. inline SXS_POLICY_SOURCE CProbedAssemblyInformation::GetPolicySource() const
  185. {
  186. return m_PolicySource;
  187. }
  188. inline void CProbedAssemblyInformation::SetPolicySource(SXS_POLICY_SOURCE ps)
  189. {
  190. m_PolicySource = ps;
  191. }
  192. #endif