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.

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