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.

2655 lines
88 KiB

  1. /*
  2. Copyright (c) Microsoft Corporation
  3. */
  4. #if !defined(_FUSION_DLL_WHISTLER_SXSP_H_INCLUDED_)
  5. #define _FUSION_DLL_WHISTLER_SXSP_H_INCLUDED_
  6. /*-----------------------------------------------------------------------------
  7. Side X ("by") Side Private
  8. -----------------------------------------------------------------------------*/
  9. #pragma once
  10. #include <stddef.h>
  11. #include "nt.h"
  12. #include "ntrtl.h"
  13. #include "nturtl.h"
  14. #include "setupapi.h"
  15. #include "preprocessor.h"
  16. #include "forwarddeclarations.h"
  17. #include "enumbitoperations.h"
  18. #include "sxstypes.h"
  19. #include "policystatement.h"
  20. #pragma warning(error:4244)
  21. #include "sxsapi.h"
  22. #include "fusion.h"
  23. #include "fusionhash.h"
  24. #include "fusionhandle.h"
  25. typedef CRegKey CFusionRegKey; // need to change this when using ATL in ManifestTool.exe.
  26. #include "processorarchitecture.h"
  27. #include "debmacro.h"
  28. #include "sxsid.h"
  29. #include "sxsidp.h"
  30. #include "xmlns.h"
  31. #include "sxsasmname.h"
  32. #include "sxsexceptionhandling.h"
  33. #include "filestream.h"
  34. #include <objbase.h>
  35. typedef struct _ACTCTXGENCTX ACTCTXGENCTX, *PACTCTXGENCTX;
  36. typedef const struct _ACTCTXGENCTX *PCACTCTXGENCTX;
  37. //
  38. // This definition controls whether or not we allow fallback probing to the MS published
  39. // assemblies. Defining SXS_NO_MORE_MR_NICE_GUY_ABOUT_MISSING_MS_PKTS prints a message
  40. // on an attached debugger regarding a missing (ms pubkey token), while
  41. // SXS_NO_MORE_FALLBACK_PROBING_PERIOD turns off even the warning output and probing check
  42. // (perf optimization.)
  43. //
  44. // #undef SXS_NO_MORE_MR_NICE_GUY_ABOUT_MISSING_MS_PKTS
  45. #define SXS_NO_MORE_MR_NICE_GUY_ABOUT_MISSING_MS_PKTS ( TRUE )
  46. #undef SXS_NO_MORE_FALLBACK_PROBING_PERIOD
  47. //#define SXS_NO_MORE_FALLBACK_PROBING_PERIOD ( TRUE )
  48. //
  49. // Here we define the minimal number of bits that a catalog signer must have
  50. // to allow installation. NOTE: The length of any key will be lied about by
  51. // CPublicKeyInformation.GetPublicKeyBitLength if the test root certificate is
  52. // installed. If so, then it always returns SXS_MINIMAL_SIGNING_KEY_LENGTH!
  53. //
  54. #define SXS_MINIMAL_SIGNING_KEY_LENGTH ( 2048 )
  55. extern "C"
  56. BOOL
  57. WINAPI
  58. SxsDllMain(
  59. HINSTANCE hInst,
  60. DWORD dwReason,
  61. PVOID pvReserved
  62. );
  63. // Due to dependencies, the rest of the includes are later in the file.
  64. #ifndef INITIALIZE_CRITICAL_SECTION_AND_SPIN_COUNT_ALLOCATE_NOW
  65. #define INITIALIZE_CRITICAL_SECTION_AND_SPIN_COUNT_ALLOCATE_NOW ( 0x8000000 )
  66. #endif
  67. #define SXS_DEFAULT_ASSEMBLY_NAMESPACE L""
  68. #define SXS_DEFAULT_ASSEMBLY_NAMESPACE_CCH 0
  69. typedef struct _name_length_pair_ {
  70. PCWSTR string;
  71. ULONG length;
  72. } SXS_NAME_LENGTH_PAIR;
  73. #define SXS_UNINSTALL_ASSEMBLY_FLAG_USING_TEXTUAL_STRING (0x00000001)
  74. #define SXS_UNINSTALL_ASSEMBLY_FLAG_USING_INSTALL_LOGFILE (0x00000002)
  75. //
  76. // Legend for decoding probing strings:
  77. //
  78. // First, we walk the string from beginning to end. Normally, characters are copied to the
  79. // probe string literally.
  80. //
  81. // If $ is found, the character after $ is an identifier for a replacement token.
  82. //
  83. // Replacement tokens (note that case is sensitive and $ followed by an illegal character results in an internal error reported):
  84. //
  85. // M - "%systemroot%\winsxs\manifests\"
  86. // . - Application root (including trailing slash)
  87. // L - langauge
  88. // N - full assembly text name
  89. // C - combined name (e.g. x86_foo.bar.baz_strong-name_language_version_hash)
  90. //
  91. #define SXSP_GENERATE_MANIFEST_PATH_FOR_PROBING_CANDIDATE_DESCRIPTOR_ROOT_SYSTEM_MANIFEST_STORE (1)
  92. #define SXSP_GENERATE_MANIFEST_PATH_FOR_PROBING_CANDIDATE_DESCRIPTOR_ROOT_APPLICATION_DIRECTORY (2)
  93. #define SXSP_GENERATE_MANIFEST_PATH_FOR_PROBING_CANDIDATE_DESCRIPTOR_IDENTITY_INCLUSION_NONE (0)
  94. #define SXSP_GENERATE_MANIFEST_PATH_FOR_PROBING_CANDIDATE_DESCRIPTOR_IDENTITY_INCLUSION_ASSEMBLY_TEXT_NAME (1)
  95. #define SXSP_GENERATE_MANIFEST_PATH_FOR_PROBING_CANDIDATE_DESCRIPTOR_IDENTITY_INCLUSION_ASSEMBLY_TEXT_SHORTENED_NAME (2)
  96. #define SXSP_GENERATE_MANIFEST_PATH_FOR_PROBING_CANDIDATE_DESCRIPTOR_IDENTITY_INCLUSION_ASSEMBLY_TEXT_NAME_FINAL_SEGMENT (3)
  97. #define SXSP_GENERATE_MANIFEST_PATH_FOR_PROBING_CANDIDATE_DESCRIPTOR_IDENTITY_INCLUSION_ASSEMBLY_DIRECTORY_NAME (4)
  98. #define SXSP_GENERATE_MANIFEST_PATH_FOR_PROBING_CANDIDATE_DESCRIPTOR_IDENTITY_INCLUSION_LANGUAGE (5)
  99. #define SXSP_GENERATE_MANIFEST_PATH_FOR_PROBING_CANDIDATE_DESCRIPTOR_IDENTITY_INCLUSION_VERSION (6)
  100. #define SXSP_GENERATE_MANIFEST_PATH_FOR_PROBING_CANDIDATE_DESCRIPTOR_MANIFEST_FILE_TYPE_INVALID (0)
  101. #define SXSP_GENERATE_MANIFEST_PATH_FOR_PROBING_CANDIDATE_DESCRIPTOR_MANIFEST_FILE_TYPE_FINAL_SEGMENT (1)
  102. #define SXSP_GENERATE_MANIFEST_PATH_FOR_PROBING_CANDIDATE_DESCRIPTOR_MANIFEST_FILE_TYPE_SHORTENED_NAME (2)
  103. #define SXSP_GENERATE_MANIFEST_PATH_FOR_PROBING_CANDIDATE_DESCRIPTOR_MANIFEST_FILE_TYPE_NAME (3)
  104. #define SXS_GENERATE_ACTCTX_SYSTEM_DEFAULT (0x0001)
  105. #define SXS_GENERATE_ACTCTX_APP_RUNNING_IN_SAFEMODE (0x0002)
  106. typedef struct _SXSP_GENERATE_MANIFEST_PATH_FOR_PROBING_CANDIDATE_DESCRIPTOR
  107. {
  108. ULONG Root;
  109. const WCHAR *SubDirectory;
  110. SIZE_T CchSubDirectory;
  111. ULONG FileType; // Only used for private probing to control order of .manifest vs. .dll probing
  112. const WCHAR *Extension;
  113. SIZE_T CchExtension;
  114. ULONG IdentityInclusionArray[8];
  115. } SXSP_GENERATE_MANIFEST_PATH_FOR_PROBING_CANDIDATE_DESCRIPTOR, *PSXSP_GENERATE_MANIFEST_PATH_FOR_PROBING_CANDIDATE_DESCRIPTOR;
  116. typedef const SXSP_GENERATE_MANIFEST_PATH_FOR_PROBING_CANDIDATE_DESCRIPTOR *PCSXSP_GENERATE_MANIFEST_PATH_FOR_PROBING_CANDIDATE_DESCRIPTOR;
  117. #define UNCHECKED_DOWNCAST static_cast
  118. #define ASSEMBLY_PRIVATE_MANIFEST (0x10)
  119. #define ASSEMBLY_PRIVATE_MANIFEST_MASK (0xF0)
  120. typedef enum _SXS_POLICY_SOURCE
  121. {
  122. SXS_POLICY_UNSPECIFIED,
  123. SXS_POLICY_SYSTEM_POLICY,
  124. SXS_POLICY_ROOT_POLICY,
  125. SXS_POLICY_REDMOND_POLICY
  126. } SXS_POLICY_SOURCE;
  127. typedef enum _SXS_PUBLISHER_POLICY_APPLY
  128. {
  129. SXS_PUBLISHER_POLICY_APPLY_DEFAULT,
  130. SXS_PUBLISHER_POLICY_APPLY_YES,
  131. SXS_PUBLISHER_POLICY_APPLY_NO
  132. } SXS_PUBLISHER_POLICY_APPLY;
  133. #define ACTCTXDATA_ALIGNMENT_BITS (2)
  134. #define ACTCTXDATA_ALIGNMENT (1 << ACTCTXDATA_ALIGNMENT_BITS)
  135. #define ROUND_ACTCTXDATA_SIZE(_cb) (((_cb) + ACTCTXDATA_ALIGNMENT - 1) & (~(ACTCTXDATA_ALIGNMENT - 1)))
  136. #define ALIGN_ACTCTXDATA_POINTER(_ptr, _type) ((_type) ROUND_ACTCTXDATA_SIZE(((ULONG_PTR) (_ptr))))
  137. #include "fusionheap.h"
  138. #include "util.h"
  139. #include "comclsidmap.h"
  140. #include "actctxgenctxctb.h"
  141. #include "impersonationdata.h"
  142. #include "fusionbuffer.h"
  143. #include "fileoper.h"
  144. // Due to dependencies, the rest of the includes are later in the file.
  145. /*-----------------------------------------------------------------------------
  146. This is useful like so:
  147. DbgPrint("something happened in %s", __FUNCTION__);
  148. approx:
  149. LogError(L"something happened in %1", LFUNCTION);
  150. but the string is actually in a message file and the extra parameters must
  151. be passed as const UNICODE_STRING&, so more like:
  152. LogError(MSG_SXS_SOMETHING_HAPPENED, CUnicodeString(LFUNCTION));
  153. -----------------------------------------------------------------------------*/
  154. #define LFUNCTION PASTE(L, __FUNCTION__)
  155. #define LFILE PASTE(L, __FILE__)
  156. #if DBG
  157. #define IF_DBG(x) x
  158. #else
  159. #define IF_DBG(x) /* nothing */
  160. #endif
  161. // This global is used for testing/debugging to set the assembly store root
  162. // to something other than %windir%\winsxs
  163. extern PCWSTR g_AlternateAssemblyStoreRoot;
  164. extern BOOL g_WriteRegistryAnyway;
  165. /*
  166. If they've set the alternate assembly store root, then they probably don't want
  167. us messing with the registry - unless, of course, they really want us to.
  168. if ((g_AlternateAssemblyStoreRoot == NULL) || g_WriteRegistryAnyway)
  169. continue;
  170. is the same as:
  171. if ((g_AlternateAssemblyStoreRoot != NULL) && !g_WriteRegistryAnyway)
  172. return TRUE;
  173. */
  174. inline
  175. BOOL
  176. SxspAvoidWritingRegistry()
  177. {
  178. return (g_AlternateAssemblyStoreRoot != NULL) && !g_WriteRegistryAnyway;
  179. }
  180. #define SXS_AVOID_WRITING_REGISTRY SxspAvoidWritingRegistry()
  181. /*-----------------------------------------------------------------------------
  182. copied from \\jayk1\g\vs\src\vsee\lib
  183. Usage
  184. If you say
  185. OutputDebugStringA(PREPEND_FILE_LINE("foo"))
  186. or
  187. CStringBuffer msg;
  188. msg.Format(PREPEND_FILE_LINE("foo%bar%x"), ...)
  189. OutputDebugStringA(msg)
  190. or
  191. pragma message (PREPEND_FILE_LINE("foo"))
  192. you can F4 through the output in VC's output window.
  193. Don't checkin #pragma messages though.
  194. -----------------------------------------------------------------------------*/
  195. #define PREPEND_FILE_LINE(msg) __FILE__ "(" STRINGIZE(__LINE__) ") : " msg
  196. #define PREPEND_FILE_LINE_W(msg) LFILE L"(" STRINGIZEW(__LINE__) L") : " msg
  197. /*-----------------------------------------------------------------------------
  198. Length = 0
  199. MaximumLength = 0
  200. Buffer = L""
  201. -----------------------------------------------------------------------------*/
  202. extern const UNICODE_STRING g_strEmptyUnicodeString;
  203. #if !defined(NUMBER_OF)
  204. #define NUMBER_OF(x) ((sizeof(x)) / sizeof((x)[0]))
  205. #endif
  206. #define PATCHES_PATH_IN_CAB L"patches"
  207. #define PATCHES_PATH_IN_CAB_CCH (NUMBER_OF(PATCHES_PATH_IN_CAB)-1)
  208. #define MANIFEST_ROOT_DIRECTORY_NAME L"manifests"
  209. #define POLICY_ROOT_DIRECTORY_NAME L"policies"
  210. #define SETUP_POLICY_ROOT_DIRECTORY_NAME L"setuppolicies"
  211. #define ASSEMBLY_TYPE_WIN32 L"win32"
  212. #define ASSEMBLY_TYPE_WIN32_CCH (NUMBER_OF(ASSEMBLY_TYPE_WIN32) - 1)
  213. #define ASSEMBLY_TYPE_WIN32_POLICY L"win32-policy"
  214. #define ASSEMBLY_TYPE_WIN32_POLICY_CCH (NUMBER_OF(ASSEMBLY_TYPE_WIN32_POLICY) - 1)
  215. #define REGISTRY_BACKUP_ROOT_DIRECTORY_NAME L"recovery"
  216. #define REGISTRY_BACKUP_ROOT_DIRECTORY_NAME_CCH (NUMBER_OF(REGISTRY_BACKUP_ROOT_DIRECTORY_NAME)-1)
  217. #define ASSEMBLY_MANIFEST_FILE_NAME_SUFFIX_MANIFEST L".manifest"
  218. #define ASSEMBLY_MANIFEST_FILE_NAME_SUFFIX_DLL L".dll"
  219. #define ASSEMBLY_MANIFEST_FILE_NAME_SUFFIX_MAN L".man"
  220. #define ASSEMBLY_POLICY_FILE_NAME_SUFFIX_POLICY L".policy"
  221. #define ASSEMBLY_LONGEST_MANIFEST_FILE_NAME_SUFFIX L".manifest"
  222. /* term is either L"\0" or , */
  223. #define ASSEMBLY_MANIFEST_FILE_NAME_SUFFIXES(term) L".manifest" term L".dll" term L".policy" term
  224. #define INSTALL_MANIFEST_FILE_NAME_SUFFIXES(term) L".Man" term L".manifest" term L".dll" term L".policy" term
  225. #define SXS_ASSEMBLY_IDENTITY_STD_ATTRIBUTE_PUBLICKEY_MISSING_VALUE L"no-public-key"
  226. //
  227. // This is the all-powerful public key token (in hex-string format) that is the
  228. // Microsoft Windows Whistler Win32 Fusion public key token. Don't change this
  229. // unless a) you get a new key b) you update all the manifests that contain this
  230. // string c) you really really really want a headache.
  231. //
  232. #define SXS_MS_PUBLIC_KEY_TOKEN_DEFAULT ( L"6595b64144ccf1df" )
  233. #define SXS_MS_PUBLIC_KEY_DEFAULT ( \
  234. L"002400000480000014010000060200000024000052534131" \
  235. L"0008000001000100d5938fed940a72fe45232d867d252f87" \
  236. L"0097e0039ffbf647ebd8817bbeaefbbbf68ce55e2542769e" \
  237. L"8a43e5880daa307ff50783d3b157ac9fc3d5410259bd0111" \
  238. L"56d60bcd4c10d2ace51445e825ef6b1929d187360b08c7e1" \
  239. L"bc73a2c6f78434729eb58e481bb3635ecfdfcb683119dc61" \
  240. L"f5d29226e8c9d7ac415d53992ca9714722abfcfd88efd3e3" \
  241. L"46ef02b83b4dbbf429e026b1889a6ba228fdb5709be852e1" \
  242. L"e81c011a6a18055f898863ccd4902041543c6cf10efb038b" \
  243. L"5ab34f1bfa18d3affa01d4980a979606abd3b7ccdae2e0ae" \
  244. L"a0d875c2d4df5509a234d9dd840ef7be91fe362799b18ba4" \
  245. L"dfcf2a110052b5d63cb69014448bdb2ffb0832418c054695" \
  246. )
  247. #define ASSEMBLY_REGISTRY_ROOT L"Software\\Microsoft\\Windows\\CurrentVersion\\SideBySide\\"
  248. #define WINSXS_INSTALLATION_INFO_REGKEY ( ASSEMBLY_REGISTRY_ROOT L"Installations")
  249. #define ASSEMBLY_INSTALL_TEMP_DIR_NAME ( L"InstallTemp" )
  250. interface IXMLNodeSource;
  251. typedef enum _SXS_NODE_TYPE
  252. { SXS_ELEMENT = 1,
  253. SXS_ATTRIBUTE = SXS_ELEMENT + 1,
  254. SXS_PI = SXS_ATTRIBUTE + 1,
  255. SXS_XMLDECL = SXS_PI + 1,
  256. SXS_DOCTYPE = SXS_XMLDECL + 1,
  257. SXS_DTDATTRIBUTE = SXS_DOCTYPE + 1,
  258. SXS_ENTITYDECL = SXS_DTDATTRIBUTE + 1,
  259. SXS_ELEMENTDECL = SXS_ENTITYDECL + 1,
  260. SXS_ATTLISTDECL = SXS_ELEMENTDECL + 1,
  261. SXS_NOTATION = SXS_ATTLISTDECL + 1,
  262. SXS_GROUP = SXS_NOTATION + 1,
  263. SXS_INCLUDESECT = SXS_GROUP + 1,
  264. SXS_PCDATA = SXS_INCLUDESECT + 1,
  265. SXS_CDATA = SXS_PCDATA + 1,
  266. SXS_IGNORESECT = SXS_CDATA + 1,
  267. SXS_COMMENT = SXS_IGNORESECT + 1,
  268. SXS_ENTITYREF = SXS_COMMENT + 1,
  269. SXS_WHITESPACE = SXS_ENTITYREF + 1,
  270. SXS_NAME = SXS_WHITESPACE + 1,
  271. SXS_NMTOKEN = SXS_NAME + 1,
  272. SXS_STRING = SXS_NMTOKEN + 1,
  273. SXS_PEREF = SXS_STRING + 1,
  274. SXS_MODEL = SXS_PEREF + 1,
  275. SXS_ATTDEF = SXS_MODEL + 1,
  276. SXS_ATTTYPE = SXS_ATTDEF + 1,
  277. SXS_ATTPRESENCE = SXS_ATTTYPE + 1,
  278. SXS_DTDSUBSET = SXS_ATTPRESENCE + 1,
  279. SXS_LASTNODETYPE = SXS_DTDSUBSET + 1
  280. } SXS_NODE_TYPE;
  281. typedef struct _SXS_NODE_INFO {
  282. _SXS_NODE_INFO() { }
  283. ULONG Size;
  284. ULONG Type;
  285. CSmallStringBuffer NamespaceStringBuf;
  286. const WCHAR *pszText; // this could be an attribute name or value string of an attribute
  287. SIZE_T cchText;
  288. private:
  289. _SXS_NODE_INFO(const _SXS_NODE_INFO &);
  290. void operator =(const _SXS_NODE_INFO &);
  291. } SXS_NODE_INFO, *PSXS_NODE_INFO;
  292. typedef const SXS_NODE_INFO *PCSXS_NODE_INFO;
  293. /*-----------------------------------------------------------------------------
  294. This returns a pointer to statically allocated memory. Don't free it.
  295. In free builds, it just returns an empty string.
  296. -----------------------------------------------------------------------------*/
  297. const WCHAR* SxspInstallDispositionToStringW(ULONG);
  298. typedef const struct _ATTRIBUTE_NAME_DESCRIPTOR *PCATTRIBUTE_NAME_DESCRIPTOR;
  299. typedef VOID (WINAPI * SXS_REPORT_PARSE_ERROR_MISSING_REQUIRED_ATTRIBUTE_CALLBACK)(
  300. IN PCACTCTXCTB_PARSE_CONTEXT ParseContext,
  301. IN PCATTRIBUTE_NAME_DESCRIPTOR AttributeName
  302. );
  303. typedef VOID (WINAPI * SXS_REPORT_PARSE_ERROR_ATTRIBUTE_NOT_ALLOWED)(
  304. IN PCACTCTXCTB_PARSE_CONTEXT ParseContext,
  305. IN PCATTRIBUTE_NAME_DESCRIPTOR AttributeName
  306. );
  307. typedef VOID (WINAPI * SXS_REPORT_PARSE_ERROR_INVALID_ATTRIBUTE_VALUE)(
  308. IN PCACTCTXCTB_PARSE_CONTEXT ParseContext,
  309. IN PCATTRIBUTE_NAME_DESCRIPTOR AttributeName
  310. );
  311. class ACTCTXCTB_INSTALLATION_CONTEXT
  312. {
  313. public:
  314. ACTCTXCTB_INSTALLATION_CONTEXT() : Callback(NULL), Context(NULL), InstallSource(NULL), SecurityMetaData(NULL) { }
  315. PSXS_INSTALLATION_FILE_COPY_CALLBACK Callback;
  316. PVOID Context;
  317. PVOID InstallSource;
  318. PVOID SecurityMetaData;
  319. const void * InstallReferenceData;
  320. };
  321. typedef const ACTCTXCTB_INSTALLATION_CONTEXT *PCACTCTXCTB_INSTALLATION_CONTEXT;
  322. typedef struct _ACTCTXCTB_CLSIDMAPPING_CONTEXT {
  323. CClsidMap *Map;
  324. } ACTCTXCTB_CLSIDMAPPING_CONTEXT, *PACTCTXCTB_CLSIDMAPPING_CONTEXT;
  325. typedef const ACTCTXCTB_CLSIDMAPPING_CONTEXT *PCACTCTXCTB_CLSIDMAPPING_CONTEXT;
  326. #define MANIFEST_OPERATION_INVALID (0)
  327. #define MANIFEST_OPERATION_GENERATE_ACTIVATION_CONTEXT (1)
  328. #define MANIFEST_OPERATION_VALIDATE_SYNTAX (2)
  329. #define MANIFEST_OPERATION_INSTALL (3)
  330. #define MANIFEST_OPERATION_INSTALL_FLAG_NOT_TRANSACTIONAL (0x00000001)
  331. #define MANIFEST_OPERATION_INSTALL_FLAG_NO_VERIFY (0x00000002)
  332. #define MANIFEST_OPERATION_INSTALL_FLAG_REPLACE_EXISTING (0x00000004)
  333. #define MANIFEST_OPERATION_INSTALL_FLAG_ABORT (0x00000008)
  334. #define MANIFEST_OPERATION_INSTALL_FLAG_FROM_DIRECTORY (0x00000010)
  335. #define MANIFEST_OPERATION_INSTALL_FLAG_FROM_DIRECTORY_RECURSIVE (0x00000020)
  336. #define MANIFEST_OPERATION_INSTALL_FLAG_MOVE (0x00000040)
  337. #define MANIFEST_OPERATION_INSTALL_FLAG_INCLUDE_CODEBASE (0x00000080)
  338. #define MANIFEST_OPERATION_INSTALL_FLAG_FROM_RESOURCE (0x00000800)
  339. #define MANIFEST_OPERATION_INSTALL_FLAG_COMMIT (0x00001000)
  340. #define MANIFEST_OPERATION_INSTALL_FLAG_CREATE_LOGFILE (0x00002000)
  341. #define MANIFEST_OPERATION_INSTALL_FLAG_INSTALLED_BY_DARWIN (0x00004000)
  342. #define MANIFEST_OPERATION_INSTALL_FLAG_REFERENCE_VALID (0x00008000)
  343. #define MANIFEST_OPERATION_INSTALL_FLAG_REFRESH (0x00010000)
  344. #define MANIFEST_OPERATION_INSTALL_FLAG_INSTALLED_BY_OSSETUP (0x00020000)
  345. #define MANIFEST_OPERATION_INSTALL_FLAG_INSTALLED_BY_MIGRATION (0x00040000)
  346. #define MANIFEST_OPERATION_INSTALL_FLAG_FROM_CABINET (0x00080000)
  347. #define MANIFEST_OPERATION_INSTALL_FLAG_APPLY_PATCHES (0x00100000)
  348. #define MANIFEST_OPERATION_INSTALL_FLAG_FORCE_LOOK_FOR_CATALOG (0x00200000)
  349. #define ASSEMBLY_MANIFEST_FILETYPE_AUTO_DETECT ( 0)
  350. #define ASSEMBLY_MANIFEST_FILETYPE_FILE ( 1)
  351. #define ASSEMBLY_MANIFEST_FILETYPE_RESOURCE ( 2)
  352. #define ASSEMBLY_MANIFEST_FILETYPE_STREAM ( 3)
  353. #define ASSEMBLY_MANIFEST_FILETYPE_MASK (0xF)
  354. #define ASSEMBLY_POLICY_FILETYPE_STREAM ( 3)
  355. #define ASSEMBLY_POLICY_FILETYPE_MASK (0xF)
  356. #define SXS_POLICY_KEY_NAME L"SOFTWARE\\Policies\\Microsoft\\Windows\\SideBySide\\AssemblyReplacementPolicies"
  357. #define SXS_POLICY_PUBLICATION_DATE_VALUE_NAME L"PublicationDate"
  358. #define SXS_POLICY_REDIRECTION_VALUE_NAME L"ReplacedBy"
  359. #include "assemblyreference.h"
  360. #include "probedassemblyinformation.h"
  361. #include "fusionheap.h"
  362. #include "comclsidmap.h"
  363. #include "actctxgenctxctb.h"
  364. #include "assemblyreference.h"
  365. #include "impersonationdata.h"
  366. #include "fusionbuffer.h"
  367. //
  368. // Notes on heap allocation by contributors:
  369. //
  370. // Heap allocations associated with processing an installation, parsing a
  371. // or generating an activation context should be done on the
  372. // heap passed in the Heap member of the callback header.
  373. //
  374. // This heap is destroyed when the operation is complete, and any leaks
  375. // by contributors are reported and may constitute a BVT break.
  376. //
  377. // The heap for the _INIT callback is guaranteed to stay alive until the
  378. // _UNINT callback is fired. It is absolutely not guaranteed to survive
  379. // any longer, and leaks are build breaks.
  380. //
  381. // In debug builds, contributors may be given private heaps so that leaks
  382. // can be tracked per-contributor.
  383. //
  384. typedef struct _ACTCTXCTB_CBHEADER {
  385. ULONG Reason;
  386. ULONG ManifestOperation;
  387. DWORD ManifestOperationFlags;
  388. DWORD Flags; // these are the same flags as ACTCTXGENCTX::m_Flags
  389. const GUID *ExtensionGuid;
  390. ULONG SectionId;
  391. PVOID ContributorContext;
  392. PVOID ActCtxGenContext;
  393. PVOID ManifestParseContext;
  394. PCACTCTXCTB_INSTALLATION_CONTEXT InstallationContext; // valid only if ACTCTXCTB_INSTALLING is set
  395. PCACTCTXCTB_CLSIDMAPPING_CONTEXT ClsidMappingContext; // Not valid if ACTCTXCTB_GENERATE_CONTEXT not set
  396. PACTCTXGENCTX pOriginalActCtxGenCtx;
  397. } ACTCTXCTB_CBHEADER, *PACTCTXCTB_CBHEADER;
  398. BOOL operator==(const ACTCTXCTB_CBHEADER&, const ACTCTXCTB_CBHEADER&);
  399. BOOL operator!=(const ACTCTXCTB_CBHEADER&, const ACTCTXCTB_CBHEADER&);
  400. #define ACTCTXCTB_CBREASON_INIT (1)
  401. #define ACTCTXCTB_CBREASON_ACTCTXGENBEGINNING (2)
  402. #define ACTCTXCTB_CBREASON_PARSEBEGINNING (3)
  403. #define ACTCTXCTB_CBREASON_IDENTITYDETERMINED (4)
  404. #define ACTCTXCTB_CBREASON_BEGINCHILDREN (5)
  405. #define ACTCTXCTB_CBREASON_ENDCHILDREN (6)
  406. #define ACTCTXCTB_CBREASON_ELEMENTPARSED (7)
  407. #define ACTCTXCTB_CBREASON_PCDATAPARSED (8)
  408. #define ACTCTXCTB_CBREASON_CDATAPARSED (9)
  409. #define ACTCTXCTB_CBREASON_PARSEENDING (10)
  410. #define ACTCTXCTB_CBREASON_PARSEENDED (11)
  411. #define ACTCTXCTB_CBREASON_ALLPARSINGDONE (12)
  412. #define ACTCTXCTB_CBREASON_GETSECTIONSIZE (13)
  413. #define ACTCTXCTB_CBREASON_GETSECTIONDATA (14)
  414. #define ACTCTXCTB_CBREASON_ACTCTXGENENDING (15)
  415. #define ACTCTXCTB_CBREASON_ACTCTXGENENDED (16)
  416. #define ACTCTXCTB_CBREASON_UNINIT (17)
  417. /*-----------------------------------------------------------------------------
  418. This returns a pointer to statically allocated memory. Don't free it.
  419. In free builds, it just returns an empty string.
  420. ACTCTXCTB_CBREASON_INIT => "INIT"
  421. ACTCTXCTB_CBREASON_ACTCTXGENBEGINNING => "GENBEGINNING"
  422. etc.
  423. -----------------------------------------------------------------------------*/
  424. PCSTR SxspActivationContextCallbackReasonToString(ULONG);
  425. //
  426. // Basics of the callback order:
  427. //
  428. // The ACTCTXCTB_CBREASON_INIT callback will always be issued first to allow
  429. // the contributor to set up some global state.
  430. //
  431. // The ACTCTXCTB_CBREASON_ACTCTXGENBEGINNING callback will be fired before any
  432. // parse callbacks (_BEGINCHILDREN, _ENDCHILDREN, _ELEMENTPARSED, _PARSEDONE,
  433. // _GETSECTIONDATA, _PARSEENDING) so that the contributor may set up per-parse
  434. // context.
  435. //
  436. // The ACTCTXCTB_CBREASON_PARSEENDING callback may be fired any time after the
  437. // _ACTCTXGENBEGINNING callback. The contributor should tear down any per-parse
  438. // state during this callback. After the _PARSEENDING callback is fired, only
  439. // the _ACTCTXGENBEGINNING and _UNINIT callbacks may be called.
  440. //
  441. // The ACTCTXCTB_CBREASON_ALLPARSINGDONE callback will be fired prior to the
  442. // _GETSECTIONSIZE or _GETSECTIONDATA callbacks. It's an opportunity for the
  443. // contributor to stabilize their data structures for generation; no further
  444. // _PARSEBEGINNING, _ELEMENTPARSED, _BEGINCHILDREN, _ENDCHILDREN or _PARSEENDING
  445. // callbacks are issued.
  446. //
  447. // The ACTCTXCTB_CBREASON_GETSECTIONSIZE callback will be fired prior to the
  448. // _GETSECTIONDATA callback. The section size reported by the _GETSECTIONSIZE
  449. // must be exact.
  450. //
  451. // The ACTCTXCTB_CBREASON_GETSECTIONDATA callback must fill in the data for the
  452. // activation context section. It may not write more bytes to the section than
  453. // were requested in the response to _PARSEDONE.
  454. //
  455. // The ACTCTXCTB_CBREASON_UNINIT callback should be used to tear down any global
  456. // state for the contributor. The contributor DLL may be unloaded, or another
  457. // _INIT callback may be issued after the _UNINIT.
  458. //
  459. // Used with ACTCTXCTB_CBREASON_INIT
  460. typedef struct _ACTCTXCTB_CBINIT {
  461. ACTCTXCTB_CBHEADER Header;
  462. } ACTCTXCTB_CBINIT, *PACTCTXCTB_CBINIT;
  463. BOOL operator==(const ACTCTXCTB_CBINIT&, const ACTCTXCTB_CBINIT&);
  464. // Used with ACTCTXCTB_CBREASON_ACTCTXGENBEGINNING
  465. typedef struct _ACTCTXCTB_CBACTCTXGENBEGINNING {
  466. ACTCTXCTB_CBHEADER Header;
  467. PCWSTR ApplicationDirectory;
  468. SIZE_T ApplicationDirectoryCch;
  469. ULONG ApplicationDirectoryPathType;
  470. BOOL Success;
  471. } ACTCTXCTB_CBACTCTXGENBEGINNING, *PACTCTXCTB_CBACTCTXGENBEGINNING;
  472. BOOL operator==(const ACTCTXCTB_CBACTCTXGENBEGINNING&, const ACTCTXCTB_CBACTCTXGENBEGINNING&);
  473. #define ACTCTXCTB_CBPARSEBEGINNING_FILEFLAGS_PRECOMPILED (0x00000001)
  474. #define XML_FILE_TYPE_MANIFEST (1)
  475. #define XML_FILE_TYPE_COMPONENT_CONFIGURATION (2)
  476. #define XML_FILE_TYPE_APPLICATION_CONFIGURATION (3)
  477. #define ACTCTXCTB_ASSEMBLY_CONTEXT_ASSEMBLY_POLICY_APPLIED (0x00000001)
  478. #define ACTCTXCTB_ASSEMBLY_CONTEXT_ROOT_POLICY_APPLIED (0x00000002)
  479. #define ACTCTXCTB_ASSEMBLY_CONTEXT_IS_ROOT_ASSEMBLY (0x00000004)
  480. #define ACTCTXCTB_ASSEMBLY_CONTEXT_IS_PRIVATE_ASSEMBLY (0x00000008)
  481. // in system-policy installation
  482. #define ACTCTXCTB_ASSEMBLY_CONTEXT_IS_SYSTEM_POLICY_INSTALLATION (0x00000010)
  483. /*-----------------------------------------------------------------------------
  484. This is the public ASSEMBLY that contributor callbacks see.
  485. It is generated from the private ASSEMBLY struct.
  486. -----------------------------------------------------------------------------*/
  487. typedef struct _ACTCTXCTB_ASSEMBLY_CONTEXT {
  488. ULONG Flags; // Various indicators include what kind of policy was used etc.
  489. ULONG AssemblyRosterIndex;
  490. ULONG ManifestPathType;
  491. PCWSTR ManifestPath; // not necessarily null terminated; respect ManifestPathCch!
  492. SIZE_T ManifestPathCch;
  493. ULONG PolicyPathType;
  494. PCWSTR PolicyPath; // not necessarily null terminated; respect PolicyPathCch!
  495. SIZE_T PolicyPathCch;
  496. PCASSEMBLY_IDENTITY AssemblyIdentity;
  497. PVOID TeeStreamForManifestInstall; // REVIEW hack/backdoor.. we might as well give the contributors the activation context
  498. PVOID pcmWriterStream; // same comment as TeeStreamForManifestInstall
  499. PVOID InstallationInfo; // ibid.
  500. PVOID AssemblySecurityContext;
  501. PVOID SecurityMetaData;
  502. const VOID *InstallReferenceData;
  503. PCWSTR TextuallyEncodedIdentity; // always null terminated
  504. SIZE_T TextuallyEncodedIdentityCch; // does not include trailing null character
  505. _ACTCTXCTB_ASSEMBLY_CONTEXT()
  506. : AssemblyIdentity(NULL),
  507. Flags(0),
  508. AssemblyRosterIndex(0),
  509. ManifestPathType(0),
  510. ManifestPathCch(0),
  511. ManifestPath(NULL),
  512. PolicyPathType(0),
  513. PolicyPath(NULL),
  514. PolicyPathCch(0),
  515. TeeStreamForManifestInstall(NULL),
  516. pcmWriterStream(NULL),
  517. InstallationInfo(NULL),
  518. InstallReferenceData(NULL),
  519. AssemblySecurityContext(NULL),
  520. TextuallyEncodedIdentity(NULL),
  521. TextuallyEncodedIdentityCch(0),
  522. SecurityMetaData(NULL) { }
  523. ~_ACTCTXCTB_ASSEMBLY_CONTEXT()
  524. {
  525. if (AssemblyIdentity != NULL)
  526. {
  527. CSxsPreserveLastError ple;
  528. ::SxsDestroyAssemblyIdentity(const_cast<PASSEMBLY_IDENTITY>(AssemblyIdentity));
  529. AssemblyIdentity = NULL;
  530. ple.Restore();
  531. }
  532. }
  533. } ACTCTXCTB_ASSEMBLY_CONTEXT, *PACTCTXCTB_ASSEMBLY_CONTEXT;
  534. typedef const ACTCTXCTB_ASSEMBLY_CONTEXT *PCACTCTXCTB_ASSEMBLY_CONTEXT;
  535. typedef struct _ACTCTXCTB_ERROR_CALLBACKS {
  536. SXS_REPORT_PARSE_ERROR_MISSING_REQUIRED_ATTRIBUTE_CALLBACK MissingRequiredAttribute;
  537. SXS_REPORT_PARSE_ERROR_ATTRIBUTE_NOT_ALLOWED AttributeNotAllowed;
  538. SXS_REPORT_PARSE_ERROR_INVALID_ATTRIBUTE_VALUE InvalidAttributeValue;
  539. } ACTCTXCTB_ERROR_CALLBACK, *PACTCTXCTB_ERROR_CALLBACKS;
  540. typedef const struct _ACTCTXCTB_ERROR_CALLBACKS *PCACTCTXCTB_ERROR_CALLBACKS;
  541. typedef struct _ACTCTXCTB_PARSE_CONTEXT {
  542. PCWSTR ElementPath; // passed to callback - null terminated but ElementPathCch is also valid
  543. SIZE_T ElementPathCch; // passed to callback
  544. PCWSTR ElementName;
  545. SIZE_T ElementNameCch;
  546. ULONG ElementHash; // passed to callback
  547. ULONG XMLElementDepth; // passed to callback
  548. ULONG SourceFilePathType; // passed to callback
  549. PCWSTR SourceFile; // passed to callback - null terminated
  550. SIZE_T SourceFileCch; // passed to callback
  551. FILETIME SourceFileLastWriteTime; // passed to callback
  552. ULONG LineNumber; // passed to callback
  553. PCACTCTXCTB_ASSEMBLY_CONTEXT AssemblyContext; // passed to callback
  554. ACTCTXCTB_ERROR_CALLBACK ErrorCallbacks; // passed to callback
  555. } ACTCTXCTB_PARSE_CONTEXT;
  556. // Used with ACTCTXCTB_CBREASON_PARSEBEGINNING
  557. typedef struct _ACTCTXCTB_CBPARSEBEGINNING {
  558. ACTCTXCTB_CBHEADER Header;
  559. PCACTCTXCTB_ASSEMBLY_CONTEXT AssemblyContext;
  560. ULONG ParseType; // passed to callback
  561. ULONG FileFlags; // passed to callback
  562. ULONG FilePathType;
  563. PCWSTR FilePath; // passed to callback
  564. SIZE_T FilePathCch; // passed to callback
  565. FILETIME FileLastWriteTime; // passed to callback
  566. ULONG FileFormatVersionMajor; // passed to callback
  567. ULONG FileFormatVersionMinor; // passed to callback
  568. ULONG MetadataSatelliteRosterIndex; // passed to callback
  569. BOOL NoMoreCallbacksThisFile; // returned from callback
  570. BOOL Success;
  571. } ACTCTXCTB_CBPARSEBEGINNING, *PACTCTXCTB_CBPARSEBEGINNING;
  572. BOOL operator==(const FILETIME&, const FILETIME&);
  573. BOOL operator!=(const FILETIME&, const FILETIME&);
  574. BOOL operator==(const ACTCTXCTB_CBPARSEBEGINNING&, const ACTCTXCTB_CBPARSEBEGINNING&);
  575. // Used with ACTCTXCTB_CBREASON_BEGINCHILDREN
  576. typedef struct _ACTCTXCTB_CBBEGINCHILDREN {
  577. ACTCTXCTB_CBHEADER Header;
  578. PCACTCTXCTB_ASSEMBLY_CONTEXT AssemblyContext;
  579. PCACTCTXCTB_PARSE_CONTEXT ParseContext;
  580. PCSXS_NODE_INFO NodeInfo; // passed to callback
  581. BOOL Success;
  582. } ACTCTXCTB_CBBEGINCHILDREN, *PACTCTXCTB_CBBEGINCHILDREN;
  583. BOOL operator==(const ACTCTXCTB_CBBEGINCHILDREN&, const ACTCTXCTB_CBBEGINCHILDREN&);
  584. // Used with ACTCTXCTB_CBREASON_ENDCHILDREN
  585. typedef struct _ACTCTXCTB_CBENDCHILDREN {
  586. ACTCTXCTB_CBHEADER Header;
  587. PCACTCTXCTB_ASSEMBLY_CONTEXT AssemblyContext;
  588. PCACTCTXCTB_PARSE_CONTEXT ParseContext;
  589. BOOL Empty; // passed to callback
  590. PCSXS_NODE_INFO NodeInfo; // passed to callback
  591. BOOL Success;
  592. } ACTCTXCTB_CBENDCHILDREN, *PACTCTXCTB_CBENDCHILDREN;
  593. BOOL operator==(const ACTCTXCTB_CBENDCHILDREN&, const ACTCTXCTB_CBENDCHILDREN&);
  594. // Used with ACTCTXCTB_CBREASON_IDENTITYDETERMINED
  595. typedef struct _ACTCTXCTB_CBIDENTITYDETERMINED {
  596. ACTCTXCTB_CBHEADER Header;
  597. PCACTCTXCTB_ASSEMBLY_CONTEXT AssemblyContext;
  598. PCACTCTXCTB_PARSE_CONTEXT ParseContext;
  599. PCASSEMBLY_IDENTITY AssemblyIdentity;
  600. BOOL Success;
  601. } ACTCTXCTB_CBIDENTITYDETERMINED, *PACTCTXCTB_CBIDENTITYDETERMINED;
  602. typedef const ACTCTXCTB_CBIDENTITYDETERMINED *PCACTCTXCTB_CBIDENTITYDETERMINED;
  603. BOOL operator==(const ACTCTXCTB_CBIDENTITYDETERMINED&, const ACTCTXCTB_CBIDENTITYDETERMINED&);
  604. // Used with ACTCTXCTB_CBREASON_ELEMENTPARSED
  605. typedef struct _ACTCTXCTB_CBELEMENTPARSED {
  606. ACTCTXCTB_CBHEADER Header;
  607. PCACTCTXCTB_ASSEMBLY_CONTEXT AssemblyContext;
  608. PCACTCTXCTB_PARSE_CONTEXT ParseContext;
  609. ULONG NodeCount; // passed to callback
  610. PCSXS_NODE_INFO NodeInfo; // passed to callback
  611. BOOL Success;
  612. } ACTCTXCTB_CBELEMENTPARSED, *PACTCTXCTB_CBELEMENTPARSED;
  613. typedef const ACTCTXCTB_CBELEMENTPARSED *PCACTCTXCTB_CBELEMENTPARSED;
  614. BOOL operator==(const ACTCTXCTB_CBELEMENTPARSED&, const ACTCTXCTB_CBELEMENTPARSED&);
  615. // Used with ACTCTXCTB_CBREASON_PCDATAPARSED
  616. typedef struct _ACTCTXCTB_CBPCDATAPARSED {
  617. ACTCTXCTB_CBHEADER Header;
  618. PCACTCTXCTB_ASSEMBLY_CONTEXT AssemblyContext;
  619. PCACTCTXCTB_PARSE_CONTEXT ParseContext;
  620. const WCHAR *Text;
  621. ULONG TextCch;
  622. BOOL Success;
  623. } ACTCTXCTB_CBPCDATAPARSED, *PACTCTXCTB_CBPCDATAPARSED;
  624. typedef const ACTCTXCTB_CBPCDATAPARSED *PCACTCTXCTB_CBPCDATAPARSED;
  625. BOOL operator==(const ACTCTXCTB_CBPCDATAPARSED&, const ACTCTXCTB_CBPCDATAPARSED&);
  626. // Used with ACTCTXCTB_CBREASON_CDATAPARSED
  627. typedef struct _ACTCTXCTB_CBCDATAPARSED {
  628. ACTCTXCTB_CBHEADER Header;
  629. PCACTCTXCTB_ASSEMBLY_CONTEXT AssemblyContext;
  630. PCACTCTXCTB_PARSE_CONTEXT ParseContext;
  631. const WCHAR *Text;
  632. ULONG TextCch;
  633. BOOL Success;
  634. } ACTCTXCTB_CBCDATAPARSED, *PACTCTXCTB_CBCDATAPARSED;
  635. typedef const ACTCTXCTB_CBCDATAPARSED *PCACTCTXCTB_CBCDATAPARSED;
  636. BOOL operator==(const ACTCTXCTB_CBCDATAPARSED&, const ACTCTXCTB_CBCDATAPARSED&);
  637. // Used with ACTCTXCTB_CBREASON_ALLPARSINGDONE
  638. typedef struct _ACTCTXCTB_CBALLPARSINGDONE {
  639. ACTCTXCTB_CBHEADER Header;
  640. BOOL Success;
  641. } ACTCTXCTB_CBALLPARSINGDONE, *PACTCTXCTB_CBALLPARSINGDONE;
  642. BOOL operator==(const ACTCTXCTB_CBALLPARSINGDONE&, const ACTCTXCTB_CBALLPARSINGDONE&);
  643. // Used with ACTCTXCTB_CBREASON_GETSECTIONSIZE
  644. typedef struct _ACTCTXCTB_CBGETSECTIONSIZE {
  645. ACTCTXCTB_CBHEADER Header;
  646. SIZE_T SectionSize; // filled in by callback
  647. BOOL Success;
  648. } ACTCTXCTB_CBGETSECTIONSIZE, *PACTCTXCTB_CBGETSECTIONSIZE;
  649. BOOL operator==(const ACTCTXCTB_CBGETSECTIONSIZE&, const ACTCTXCTB_CBGETSECTIONSIZE&);
  650. // Used with ACTCTXCTB_CBREASON_GETSECTIONDATA
  651. typedef struct _ACTCTXCTB_CBGETSECTIONDATA {
  652. ACTCTXCTB_CBHEADER Header;
  653. SIZE_T SectionSize; // passed to callback
  654. PVOID SectionDataStart; // passed to callback
  655. BOOL Success;
  656. } ACTCTXCTB_CBGETSECTIONDATA, *PACTCTXCTB_CBGETSECTIONDATA;
  657. BOOL operator==(const ACTCTXCTB_CBGETSECTIONDATA&, const ACTCTXCTB_CBGETSECTIONDATA&);
  658. // Used with ACTCTXCTB_CBREASON_PARSEENDING
  659. typedef struct _ACTCTXCTB_CBPARSEENDING {
  660. ACTCTXCTB_CBHEADER Header;
  661. PCACTCTXCTB_ASSEMBLY_CONTEXT AssemblyContext;
  662. BOOL Success;
  663. } ACTCTXCTB_CBPARSEENDING, *PACTCTXCTB_CBPARSEENDING;
  664. BOOL operator==(const ACTCTXCTB_CBPARSEENDING&, const ACTCTXCTB_CBPARSEENDING&);
  665. // Used with ACTCTXCTB_CBREASON_PARSEENDED
  666. typedef struct _ACTCTXCTB_CBPARSEENDED {
  667. ACTCTXCTB_CBHEADER Header;
  668. PCACTCTXCTB_ASSEMBLY_CONTEXT AssemblyContext;
  669. } ACTCTXCTB_CBPARSEENDED, *PACTCTXCTB_CBPARSEENDED;
  670. BOOL operator==(const ACTCTXCTB_CBPARSEENDED&, const ACTCTXCTB_CBPARSEENDED&);
  671. // Used with ACTCTXCTB_CBREASON_ACTCTXGENENDING
  672. typedef struct _ACTCTXCTB_CBACTCTXGENENDING {
  673. ACTCTXCTB_CBHEADER Header;
  674. BOOL Success;
  675. } ACTCTXCTB_CBACTCTXGENENDING, *PACTCTXCTB_CBACTCTXGENENDING;
  676. BOOL operator==(const ACTCTXCTB_CBACTCTXGENENDING&, const ACTCTXCTB_CBACTCTXGENENDING&);
  677. // Used with ACTCTXCTB_CBREASON_ACTCTXGENENDED
  678. typedef struct _ACTCTXCTB_CBACTCTXGENENDED {
  679. ACTCTXCTB_CBHEADER Header;
  680. BOOL Success;
  681. } ACTCTXCTB_CBACTCTXGENENDED, *PACTCTXCTB_CBACTCTXGENENDED;
  682. BOOL operator==(const ACTCTXCTB_CBACTCTXGENENDED&, const ACTCTXCTB_CBACTCTXGENENDED&);
  683. // Used with ACTCTXCTB_CBREASON_UNINIT
  684. typedef struct _ACTCTXCTB_CBUNINIT {
  685. ACTCTXCTB_CBHEADER Header;
  686. PVOID ContribContext; // passed to callback
  687. } ACTCTXCTB_CBUNINIT, *PACTCTXCTB_CBUNINIT;
  688. BOOL operator==(const ACTCTXCTB_CBUNINIT&, const ACTCTXCTB_CBUNINIT&);
  689. typedef union _ACTCTXCTB_CALLBACK_DATA {
  690. ACTCTXCTB_CBHEADER Header;
  691. ACTCTXCTB_CBINIT Init;
  692. ACTCTXCTB_CBACTCTXGENBEGINNING GenBeginning;
  693. ACTCTXCTB_CBPARSEBEGINNING ParseBeginning;
  694. ACTCTXCTB_CBBEGINCHILDREN BeginChildren;
  695. ACTCTXCTB_CBENDCHILDREN EndChildren;
  696. ACTCTXCTB_CBELEMENTPARSED ElementParsed;
  697. ACTCTXCTB_CBPCDATAPARSED PCDATAParsed;
  698. ACTCTXCTB_CBCDATAPARSED CDATAParsed;
  699. ACTCTXCTB_CBPARSEENDING ParseEnding;
  700. ACTCTXCTB_CBALLPARSINGDONE AllParsingDone;
  701. ACTCTXCTB_CBGETSECTIONSIZE GetSectionSize;
  702. ACTCTXCTB_CBGETSECTIONDATA GetSectionData;
  703. ACTCTXCTB_CBACTCTXGENENDING GenEnding;
  704. ACTCTXCTB_CBUNINIT Uninit;
  705. ACTCTXCTB_CBPARSEENDED ParseEnded;
  706. } ACTCTXCTB_CALLBACK_DATA, *PACTCTXCTB_CALLBACK_DATA;
  707. typedef const ACTCTXCTB_CALLBACK_DATA* PCACTCTXCTB_CALLBACK_DATA;
  708. typedef VOID (__fastcall * ACTCTXCTB_CALLBACK_FUNCTION)(
  709. IN OUT PACTCTXCTB_CALLBACK_DATA Data
  710. );
  711. #define ACTCTXCTB_MAX_PREFIX_LENGTH (32)
  712. typedef struct _ACTCTXCTB
  713. {
  714. friend BOOL SxspAddActCtxContributor(
  715. PCWSTR DllName,
  716. PCSTR Prefix,
  717. SIZE_T PrefixCch,
  718. const GUID *ExtensionGuid,
  719. ULONG SectionId,
  720. ULONG Format,
  721. PCWSTR ContributorName
  722. );
  723. friend BOOL SxspAddBuiltinActCtxContributor(
  724. IN ACTCTXCTB_CALLBACK_FUNCTION CallbackFunction,
  725. const GUID *ExtensionGuid,
  726. ULONG SectionId,
  727. ULONG Format,
  728. PCWSTR ContributorName
  729. );
  730. _ACTCTXCTB() :
  731. m_RefCount(0),
  732. m_Next(NULL),
  733. m_ExtensionGuid(GUID_NULL),
  734. m_SectionId(0),
  735. m_Format(ACTIVATION_CONTEXT_SECTION_FORMAT_UNKNOWN),
  736. m_ContributorContext(NULL),
  737. m_CallbackFunction(NULL),
  738. m_BuiltinContributor(false),
  739. m_IsExtendedSection(false),
  740. m_PrefixCch(0)
  741. {
  742. }
  743. const GUID *GetExtensionGuidPtr() const
  744. {
  745. if (m_IsExtendedSection)
  746. return &m_ExtensionGuid;
  747. return NULL;
  748. }
  749. void AddRef() { ::InterlockedIncrement(&m_RefCount); }
  750. void Release() { ULONG ulRefCount; ulRefCount = ::InterlockedDecrement(&m_RefCount); if (ulRefCount == 0) { FUSION_DELETE_SINGLETON(this); } }
  751. LONG m_RefCount;
  752. struct _ACTCTXCTB *m_Next;
  753. GUID m_ExtensionGuid;
  754. ULONG m_SectionId;
  755. #if SXS_EXTENSIBLE_CONTRIBUTORS
  756. CDynamicLinkLibrary m_DllHandle;
  757. #endif
  758. PVOID m_ContributorContext;
  759. ACTCTXCTB_CALLBACK_FUNCTION m_CallbackFunction;
  760. ULONG m_Format;
  761. bool m_BuiltinContributor; // For built-in contributors who aren't called through the extensibility
  762. // interface. This currently includes the cache coherency section and
  763. // the assembly metadata section.
  764. bool m_IsExtendedSection;
  765. CStringBuffer m_ContributorNameBuffer;
  766. CStringBuffer m_DllNameBuffer;
  767. SIZE_T m_PrefixCch;
  768. ~_ACTCTXCTB() { ASSERT_NTC(m_RefCount == 0); }
  769. private:
  770. _ACTCTXCTB(const _ACTCTXCTB &);
  771. void operator =(const _ACTCTXCTB &);
  772. } ACTCTXCTB, *PACTCTXCTB;
  773. /*-----------------------------------------------------------------------------
  774. This is the private ASSEMBLY struct.
  775. Contributor callbacks do not see this; they instead see
  776. ASSEMBLY_CONTEXT which is very similar, but for example CStringBuffers
  777. are replaced by .dll-boundary-crossing-politically-correct PCWSTR.
  778. -----------------------------------------------------------------------------*/
  779. typedef struct _ASSEMBLY
  780. {
  781. _ASSEMBLY() : m_AssemblyRosterIndex(0), m_MetadataSatelliteRosterIndex(0), m_nRefs(1) { }
  782. CDequeLinkage m_Linkage;
  783. CProbedAssemblyInformation m_ProbedAssemblyInformation;
  784. BOOL m_Incorporated;
  785. ULONG m_ManifestVersionMajor;
  786. ULONG m_ManifestVersionMinor;
  787. ULONG m_AssemblyRosterIndex;
  788. ULONG m_MetadataSatelliteRosterIndex;
  789. void AddRef() { ::InterlockedIncrement(&m_nRefs); }
  790. void Release() { if (::InterlockedDecrement(&m_nRefs) == 0) { CSxsPreserveLastError ple; delete this; ple.Restore(); } }
  791. PCASSEMBLY_IDENTITY GetAssemblyIdentity() const { return m_ProbedAssemblyInformation.GetAssemblyIdentity(); };
  792. BOOL GetAssemblyName(PCWSTR *AssemblyName, SIZE_T *Cch) const { return m_ProbedAssemblyInformation.GetAssemblyName(AssemblyName, Cch); }
  793. BOOL GetManifestPath(PCWSTR *ManifestPath, SIZE_T *Cch) const { return m_ProbedAssemblyInformation.GetManifestPath(ManifestPath, Cch); }
  794. ULONG GetManifestPathType() const { return m_ProbedAssemblyInformation.GetManifestPathType(); }
  795. BOOL GetPolicyPath(PCWSTR &rManifestFilePath, SIZE_T &rCch) const { return m_ProbedAssemblyInformation.GetPolicyPath(rManifestFilePath, rCch); }
  796. ULONG GetPolicyPathType() const { return m_ProbedAssemblyInformation.GetPolicyPathType(); }
  797. const FILETIME &GetPolicyLastWriteTime() const { return m_ProbedAssemblyInformation.GetPolicyLastWriteTime(); }
  798. const FILETIME &GetManifestLastWriteTime() const { return m_ProbedAssemblyInformation.GetManifestLastWriteTime(); }
  799. BOOL IsRoot() const { return m_AssemblyRosterIndex == 1; }
  800. BOOL IsPrivateAssembly() const { return m_ProbedAssemblyInformation.IsPrivateAssembly(); }
  801. private:
  802. ~_ASSEMBLY() { }
  803. LONG m_nRefs;
  804. _ASSEMBLY(const _ASSEMBLY &);
  805. void operator =(const _ASSEMBLY &);
  806. } ASSEMBLY, *PASSEMBLY;
  807. typedef const ASSEMBLY* PCASSEMBLY;
  808. class CAssemblyTableHelper : public CCaseInsensitiveUnicodeStringPtrTableHelper<ASSEMBLY>
  809. {
  810. public:
  811. static BOOL InitializeValue(ASSEMBLY *vin, ASSEMBLY *&rvstored) { rvstored = vin; if (vin != NULL) vin->AddRef(); return TRUE; }
  812. static BOOL UpdateValue(ASSEMBLY *vin, ASSEMBLY *&rvstored) { if (vin != NULL) vin->AddRef(); if (rvstored != NULL) { rvstored->Release(); } rvstored = vin; return TRUE; }
  813. static VOID FinalizeValue(ASSEMBLY *&rvstored) { if (rvstored != NULL) { rvstored->Release(); rvstored = NULL; } }
  814. };
  815. extern CCriticalSectionNoConstructor g_ActCtxCtbListCritSec;
  816. // The contributor list is a singly linked list
  817. extern PACTCTXCTB g_ActCtxCtbListHead;
  818. extern ULONG g_ActCtxCtbListCount;
  819. BOOL
  820. SxspCreateManifestFileNameFromTextualString(
  821. DWORD dwFlags,
  822. ULONG PathType,
  823. const CBaseStringBuffer &AssemblyDirectory,
  824. PCWSTR pwszTextualAssemblyIdentityString,
  825. CBaseStringBuffer &sbPathName
  826. );
  827. BOOL
  828. SxspGenerateActivationContext(
  829. PSXS_GENERATE_ACTIVATION_CONTEXT_PARAMETERS Parameters,
  830. CFileStream &SystemDefaultManifestFileStream
  831. );
  832. BOOL
  833. SxspInitActCtxContributors(
  834. );
  835. VOID
  836. SxspUninitActCtxContributors(
  837. VOID
  838. );
  839. BOOL
  840. SxspAddActCtxContributor(
  841. IN PCWSTR DllName,
  842. IN PCSTR Prefix OPTIONAL,
  843. IN SIZE_T PrefixCch OPTIONAL,
  844. IN const GUID *ExtensionGuid OPTIONAL,
  845. IN ULONG SectionId,
  846. IN ULONG Format,
  847. IN PCWSTR ContributorName
  848. );
  849. BOOL
  850. SxspAddBuiltinActCtxContributor(
  851. IN ACTCTXCTB_CALLBACK_FUNCTION CallbackFunction,
  852. const GUID *ExtensionGuid,
  853. ULONG SectionId,
  854. ULONG Format,
  855. PCWSTR ContributorName
  856. );
  857. VOID
  858. __fastcall
  859. SxspAssemblyMetadataContributorCallback(
  860. PACTCTXCTB_CALLBACK_DATA Data
  861. );
  862. VOID
  863. __fastcall
  864. SxspComProgIdRedirectionContributorCallback(
  865. PACTCTXCTB_CALLBACK_DATA Data
  866. );
  867. VOID
  868. __fastcall
  869. SxspComTypeLibRedirectionContributorCallback(
  870. PACTCTXCTB_CALLBACK_DATA Data
  871. );
  872. VOID
  873. __fastcall
  874. SxspComInterfaceRedirectionContributorCallback(
  875. PACTCTXCTB_CALLBACK_DATA Data
  876. );
  877. BOOL
  878. SxspGetXMLParser(
  879. REFIID riid,
  880. LPVOID *ppvObj
  881. );
  882. #define SXSP_INIT_ACT_CTX_GEN_CTX_OPERATION_PARSE_ONLY (1)
  883. #define SXSP_INIT_ACT_CTX_GEN_CTX_OPERATION_GENERATE_ACTIVATION_CONTEXT (2)
  884. #define SXSP_INIT_ACT_CTX_GEN_CTX_OPERATION_INSTALL (3)
  885. BOOL
  886. SxspInitActCtxGenCtx(
  887. OUT PACTCTXGENCTX pActCtxGenCtx,
  888. IN ULONG ulOperation,
  889. IN DWORD dwFlags, // from ACTCTXCTB_* set
  890. IN DWORD dwOperationSpecificFlags,
  891. IN const CImpersonationData &ImpersonationData,
  892. IN USHORT ProcessorArchitecture,
  893. IN LANGID LangId,
  894. IN ULONG ApplicationDirectoryPathType,
  895. IN SIZE_T ApplicationDirectoryCch,
  896. IN PCWSTR ApplicationDirectory
  897. );
  898. BOOL
  899. SxspFireActCtxGenEnding(
  900. IN PACTCTXGENCTX pActCtxGenCtx
  901. );
  902. BOOL
  903. SxspAddRootManifestToActCtxGenCtx(
  904. PACTCTXGENCTX pActCtxGenCtx,
  905. PCSXS_GENERATE_ACTIVATION_CONTEXT_PARAMETERS Parameters
  906. );
  907. BOOL
  908. SxspAddManifestToActCtxGenCtx(
  909. PACTCTXGENCTX pActCtxGenCtx,
  910. CProbedAssemblyInformation &ProbedInformation, // arbitrarily valueless on exit
  911. PASSEMBLY *AssemblyOut
  912. );
  913. BOOL
  914. SxspAddAssemblyToActCtxGenCtx(
  915. PACTCTXGENCTX pActCtxGenCtx,
  916. PCWSTR AssemblyName,
  917. PCASSEMBLY_VERSION Version
  918. );
  919. BOOL
  920. SxspEnqueueAssemblyReference(
  921. PACTCTXGENCTX pActCtxGenCtx,
  922. PASSEMBLY SourceAssembly,
  923. PCASSEMBLY_IDENTITY Identity,
  924. bool Optional,
  925. bool MetadataSatellite
  926. );
  927. /*-----------------------------------------------------------------------------
  928. given an assembly name and optional version, but no langid, or processor, and
  929. its referring generation context, this function looks in the "assembly store"
  930. (file system) for an assembly with that name that matches the generation
  931. context, first by exact match, then some ordered weaker forms, like language
  932. neutral, processor unknown, etc. If a match is found, some information
  933. about it is returned. The out parameters are clobbered upon errors as well.
  934. -----------------------------------------------------------------------------*/
  935. #define SXSP_RESOLVE_PARTIAL_REFERENCE_FLAG_OPTIONAL (0x00000001)
  936. #define SXSP_RESOLVE_PARTIAL_REFERENCE_FLAG_SKIP_WORLDWIDE (0x00000002)
  937. BOOL
  938. SxspResolvePartialReference(
  939. DWORD Flags,
  940. PCASSEMBLY ParsingAssemblyContext,
  941. PACTCTXGENCTX pActCtxGenCtx,
  942. const CAssemblyReference &PartialReference,
  943. CProbedAssemblyInformation &ProbedAssemblyInformation,
  944. bool &rfFound
  945. );
  946. BOOL
  947. SxspCloseManifestGraph(
  948. PACTCTXGENCTX pActCtxGenCtx
  949. );
  950. BOOL
  951. SxspBuildActCtxData(
  952. PACTCTXGENCTX pActCtxGenCtx,
  953. PHANDLE SectionHandle
  954. );
  955. BOOL
  956. SxspGetAssemblyRootDirectoryHelper(
  957. IN SIZE_T CchBuffer,
  958. OUT WCHAR Buffer[],
  959. OUT SIZE_T *CchWritten OPTIONAL
  960. );
  961. BOOL
  962. SxspGetAssemblyRootDirectory(
  963. IN OUT CBaseStringBuffer &rRootDirectory
  964. );
  965. BOOL
  966. SxspGetNDPGacRootDirectory(
  967. OUT CBaseStringBuffer &rRootDirectory
  968. );
  969. // x86, Alpha, IA64, Data, Alpha64
  970. #define MAXIMUM_PROCESSOR_ARCHITECTURE_NAME_LENGTH (sizeof("Alpha64")-1)
  971. BOOL
  972. SxspFormatGUID(
  973. IN const GUID &rGuid,
  974. IN OUT CBaseStringBuffer &rBuffer
  975. );
  976. //
  977. #define SXSP_PARSE_GUID_FLAG_FAIL_ON_INVALID (0x00000001)
  978. BOOL
  979. SxspParseGUID(
  980. IN PCWSTR pszGuid,
  981. IN SIZE_T cchGuid,
  982. OUT GUID &rGuid
  983. );
  984. BOOL
  985. SxspParseThreadingModel(
  986. IN PCWSTR String,
  987. IN SIZE_T Cch,
  988. OUT PULONG ThreadingModel
  989. );
  990. BOOL
  991. SxspFormatThreadingModel(
  992. IN ULONG ThreadingModel,
  993. IN OUT CBaseStringBuffer &Buffer
  994. );
  995. BOOL
  996. SxspParseUSHORT(
  997. IN PCWSTR String,
  998. IN SIZE_T Cch,
  999. OUT PUSHORT Value
  1000. );
  1001. ULONG
  1002. SxspSetLastNTError(
  1003. LONG Status
  1004. );
  1005. /*-----------------------------------------------------------------------------
  1006. private above
  1007. public below
  1008. -----------------------------------------------------------------------------*/
  1009. extern "C"
  1010. {
  1011. typedef struct _STRING_SECTION_GENERATION_CONTEXT_ENTRY
  1012. {
  1013. struct _STRING_SECTION_GENERATION_CONTEXT_ENTRY *Next;
  1014. PCWSTR String;
  1015. SIZE_T Cch;
  1016. ULONG PseudoKey;
  1017. PVOID DataContext;
  1018. SIZE_T DataSize;
  1019. } STRING_SECTION_GENERATION_CONTEXT_ENTRY, *PSTRING_SECTION_GENERATION_CONTEXT_ENTRY;
  1020. #define STRING_SECTION_GENERATION_CONTEXT_CALLBACK_REASON_GETDATASIZE (1)
  1021. #define STRING_SECTION_GENERATION_CONTEXT_CALLBACK_REASON_GETDATA (2)
  1022. #define STRING_SECTION_GENERATION_CONTEXT_CALLBACK_REASON_ENTRYDELETED (3)
  1023. #define STRING_SECTION_GENERATION_CONTEXT_CALLBACK_REASON_GETUSERDATASIZE (4)
  1024. #define STRING_SECTION_GENERATION_CONTEXT_CALLBACK_REASON_GETUSERDATA (5)
  1025. typedef struct _STRING_SECTION_GENERATION_CONTEXT_CBDATA_GETDATASIZE
  1026. {
  1027. PVOID DataContext; // DataContext passed in to SxsAddStringToStringSectionGenerationContext()
  1028. SIZE_T DataSize; // filled in by callback function
  1029. } STRING_SECTION_GENERATION_CONTEXT_CBDATA_GETDATASIZE, *PSTRING_SECTION_GENERATION_CONTEXT_CBDATA_GETDATASIZE;
  1030. typedef struct _STRING_SECTION_GENERATION_CONTEXT_CBDATA_GETDATA
  1031. {
  1032. PVOID SectionHeader;
  1033. PVOID DataContext; // DataContext passed in to SxsAddStringToStringSectionGenerationContext()
  1034. SIZE_T BufferSize; // callback function may read but not modify
  1035. PVOID Buffer; // Callback function may not modify this pointer but may modify BufferSize
  1036. // bytes starting at this address
  1037. SIZE_T BytesWritten; // Actual number of bytes written to buffer. May not differ from DataSize
  1038. // returned from the _GETDATASIZE callback.
  1039. } STRING_SECTION_GENERATION_CONTEXT_CBDATA_GETDATA, *PSTRING_SECTION_GENERATION_CONTEXT_CBDATA_GETDATA;
  1040. typedef struct _STRING_SECTION_GENERATION_CONTEXT_CBDATA_ENTRYDELETED
  1041. {
  1042. PVOID DataContext; // DataContext passed in to SxsAddStringToStringSectionGenerationContext()
  1043. } STRING_SECTION_GENERATION_CONTEXT_CBDATA_ENTRYDELETED, *PSTRING_SECTION_GENERATION_CONTEXT_CBDATA_ENTRYDELETED;
  1044. typedef struct _STRING_SECTION_GENERATION_CONTEXT_CBDATA_GETUSERDATASIZE
  1045. {
  1046. SIZE_T DataSize; // filled in by callback function
  1047. } STRING_SECTION_GENERATION_CONTEXT_CBDATA_GETUSERDATASIZE, *PSTRING_SECTION_GENERATION_CONTEXT_CBDATA_GETUSERDATASIZE;
  1048. typedef struct _STRING_SECTION_GENERATION_CONTEXT_CBDATA_GETUSERDATA
  1049. {
  1050. PVOID SectionHeader;
  1051. SIZE_T BufferSize; // callback function may read but not modify
  1052. PVOID Buffer; // Callback function may not modify this pointer but may modify BufferSize
  1053. // bytes starting at this address
  1054. SIZE_T BytesWritten; // Actual number of bytes written to buffer. May not differ from DataSize
  1055. // returned from the _GETUSERDATASIZE callback.
  1056. } STRING_SECTION_GENERATION_CONTEXT_CBDATA_GETUSERDATA, *PSTRING_SECTION_GENERATION_CONTEXT_CBDATA_GETUSERDATA;
  1057. typedef BOOL (WINAPI * STRING_SECTION_GENERATION_CONTEXT_CALLBACK_FUNCTION)(
  1058. PVOID Context,
  1059. ULONG Reason,
  1060. PVOID CallbackData
  1061. );
  1062. typedef struct _STRING_SECTION_GENERATION_CONTEXT *PSTRING_SECTION_GENERATION_CONTEXT;
  1063. BOOL
  1064. WINAPI
  1065. SxsQueryAssemblyInfo(
  1066. DWORD dwFlags,
  1067. PCWSTR pwzTextualAssembly,
  1068. ASSEMBLY_INFO *pAsmInfo);
  1069. BOOL
  1070. WINAPI
  1071. SxsInitStringSectionGenerationContext(
  1072. OUT PSTRING_SECTION_GENERATION_CONTEXT *SSGenContext,
  1073. IN ULONG DataFormatVersion,
  1074. IN BOOL CaseInSensitive,
  1075. IN STRING_SECTION_GENERATION_CONTEXT_CALLBACK_FUNCTION CallbackFunction,
  1076. IN LPVOID CallbackContext
  1077. );
  1078. PVOID
  1079. WINAPI
  1080. SxsGetStringSectionGenerationContextCallbackContext(
  1081. IN PSTRING_SECTION_GENERATION_CONTEXT SSGenContext
  1082. );
  1083. VOID
  1084. WINAPI
  1085. SxsDestroyStringSectionGenerationContext(
  1086. IN PSTRING_SECTION_GENERATION_CONTEXT SSGenContext
  1087. );
  1088. BOOL
  1089. WINAPI
  1090. SxsAddStringToStringSectionGenerationContext(
  1091. IN PSTRING_SECTION_GENERATION_CONTEXT SSGenContext,
  1092. IN PCWSTR String,
  1093. IN SIZE_T Cch,
  1094. IN PVOID DataContext,
  1095. IN ULONG AssemblyRosterIndex,
  1096. IN DWORD DuplicateErrorCode // GetLastError() returns this if the GUID is a duplicate
  1097. );
  1098. BOOL
  1099. WINAPI
  1100. SxsFindStringInStringSectionGenerationContext(
  1101. IN PSTRING_SECTION_GENERATION_CONTEXT SSGenContext,
  1102. IN PCWSTR String,
  1103. IN SIZE_T Cch,
  1104. OUT PVOID *DataContext,
  1105. OUT BOOL *Found
  1106. );
  1107. BOOL
  1108. WINAPI
  1109. SxsDoneModifyingStringSectionGenerationContext(
  1110. IN PSTRING_SECTION_GENERATION_CONTEXT SSGenContext
  1111. );
  1112. BOOL
  1113. WINAPI
  1114. SxsGetStringSectionGenerationContextSectionSize(
  1115. IN PSTRING_SECTION_GENERATION_CONTEXT SSGenContext,
  1116. OUT PSIZE_T DataSize
  1117. );
  1118. BOOL
  1119. WINAPI
  1120. SxsGetStringSectionGenerationContextSectionData(
  1121. IN PSTRING_SECTION_GENERATION_CONTEXT SSGenContext,
  1122. IN SIZE_T BufferSize,
  1123. IN PVOID Buffer,
  1124. OUT PSIZE_T BytesWritten OPTIONAL
  1125. );
  1126. typedef struct _GUID_SECTION_GENERATION_CONTEXT_ENTRY
  1127. {
  1128. struct _GUID_SECTION_GENERATION_CONTEXT_ENTRY *Next;
  1129. GUID Guid;
  1130. PVOID DataContext;
  1131. SIZE_T DataSize;
  1132. } GUID_SECTION_GENERATION_CONTEXT_ENTRY, *PGUID_SECTION_GENERATION_CONTEXT_ENTRY;
  1133. #define GUID_SECTION_GENERATION_CONTEXT_CALLBACK_REASON_GETDATASIZE (1)
  1134. #define GUID_SECTION_GENERATION_CONTEXT_CALLBACK_REASON_GETDATA (2)
  1135. #define GUID_SECTION_GENERATION_CONTEXT_CALLBACK_REASON_ENTRYDELETED (3)
  1136. #define GUID_SECTION_GENERATION_CONTEXT_CALLBACK_REASON_GETUSERDATASIZE (4)
  1137. #define GUID_SECTION_GENERATION_CONTEXT_CALLBACK_REASON_GETUSERDATA (5)
  1138. typedef struct _GUID_SECTION_GENERATION_CONTEXT_CBDATA_GETDATASIZE
  1139. {
  1140. PVOID DataContext; // DataContext passed in to SxsAddStringToGuidSectionGenerationContext()
  1141. SIZE_T DataSize; // filled in by callback function
  1142. } GUID_SECTION_GENERATION_CONTEXT_CBDATA_GETDATASIZE, *PGUID_SECTION_GENERATION_CONTEXT_CBDATA_GETDATASIZE;
  1143. typedef struct _GUID_SECTION_GENERATION_CONTEXT_CBDATA_GETDATA
  1144. {
  1145. PVOID SectionHeader;
  1146. PVOID DataContext; // DataContext passed in to SxsAddStringToGuidSectionGenerationContext()
  1147. SIZE_T BufferSize; // callback function may read but not modify
  1148. PVOID Buffer; // Callback function may not modify this pointer but may modify BufferSize
  1149. // bytes starting at this address
  1150. SIZE_T BytesWritten; // Actual number of bytes written to buffer. May not differ from DataSize
  1151. // returned from the _GETDATASIZE callback.
  1152. } GUID_SECTION_GENERATION_CONTEXT_CBDATA_GETDATA, *PGUID_SECTION_GENERATION_CONTEXT_CBDATA_GETDATA;
  1153. typedef struct _GUID_SECTION_GENERATION_CONTEXT_CBDATA_ENTRYDELETED
  1154. {
  1155. PVOID DataContext; // DataContext passed in to SxsAddStringToGuidSectionGenerationContext()
  1156. } GUID_SECTION_GENERATION_CONTEXT_CBDATA_ENTRYDELETED, *PGUID_SECTION_GENERATION_CONTEXT_CBDATA_ENTRYDELETED;
  1157. typedef struct _GUID_SECTION_GENERATION_CONTEXT_CBDATA_GETUSERDATASIZE
  1158. {
  1159. SIZE_T DataSize; // filled in by callback function
  1160. } GUID_SECTION_GENERATION_CONTEXT_CBDATA_GETUSERDATASIZE, *PGUID_SECTION_GENERATION_CONTEXT_CBDATA_GETUSERDATASIZE;
  1161. typedef struct _GUID_SECTION_GENERATION_CONTEXT_CBDATA_GETUSERDATA
  1162. {
  1163. PVOID SectionHeader;
  1164. SIZE_T BufferSize; // callback function may read but not modify
  1165. PVOID Buffer; // Callback function may not modify this pointer but may modify BufferSize
  1166. // bytes starting at this address
  1167. SIZE_T BytesWritten; // Actual number of bytes written to buffer. May not differ from DataSize
  1168. // returned from the _GETUSERDATASIZE callback.
  1169. } GUID_SECTION_GENERATION_CONTEXT_CBDATA_GETUSERDATA, *PGUID_SECTION_GENERATION_CONTEXT_CBDATA_GETUSERDATA;
  1170. typedef BOOL (WINAPI * GUID_SECTION_GENERATION_CONTEXT_CALLBACK_FUNCTION)(
  1171. PVOID Context,
  1172. ULONG Reason,
  1173. PVOID CallbackData
  1174. );
  1175. typedef struct _GUID_SECTION_GENERATION_CONTEXT *PGUID_SECTION_GENERATION_CONTEXT;
  1176. BOOL
  1177. WINAPI
  1178. SxsInitGuidSectionGenerationContext(
  1179. OUT PGUID_SECTION_GENERATION_CONTEXT *SSGenContext,
  1180. IN ULONG DataFormatVersion,
  1181. IN GUID_SECTION_GENERATION_CONTEXT_CALLBACK_FUNCTION CallbackFunction,
  1182. IN LPVOID CallbackContext
  1183. );
  1184. PVOID
  1185. WINAPI
  1186. SxsGetGuidSectionGenerationContextCallbackContext(
  1187. IN PGUID_SECTION_GENERATION_CONTEXT GSGenContext
  1188. );
  1189. VOID
  1190. WINAPI
  1191. SxsDestroyGuidSectionGenerationContext(
  1192. IN PGUID_SECTION_GENERATION_CONTEXT GSGenContext
  1193. );
  1194. BOOL
  1195. WINAPI
  1196. SxsAddGuidToGuidSectionGenerationContext(
  1197. IN PGUID_SECTION_GENERATION_CONTEXT GSGenContext,
  1198. IN const GUID *Guid,
  1199. IN PVOID DataContext,
  1200. IN ULONG AssemblyRosterIndex,
  1201. IN DWORD DuplicateErrorCode // GetLastError() returns this if the GUID is a duplicate
  1202. );
  1203. BOOL
  1204. WINAPI
  1205. SxsFindGuidInGuidSectionGenerationContext(
  1206. IN PGUID_SECTION_GENERATION_CONTEXT GSGenContext,
  1207. IN const GUID *Guid,
  1208. OUT PVOID *DataContext
  1209. );
  1210. BOOL
  1211. WINAPI
  1212. SxsGetGuidSectionGenerationContextSectionSize(
  1213. IN PGUID_SECTION_GENERATION_CONTEXT GSGenContext,
  1214. OUT PSIZE_T DataSize
  1215. );
  1216. BOOL
  1217. WINAPI
  1218. SxsGetGuidSectionGenerationContextSectionData(
  1219. IN PGUID_SECTION_GENERATION_CONTEXT GSGenContext,
  1220. IN SIZE_T BufferSize,
  1221. IN PVOID Buffer,
  1222. OUT PSIZE_T BytesWritten OPTIONAL
  1223. );
  1224. inline
  1225. BOOL
  1226. WINAPI
  1227. SxsDoneModifyingGuidSectionGenerationContext(
  1228. IN PGUID_SECTION_GENERATION_CONTEXT SSGenContext
  1229. ) { /* Nothing needs to be done here currently. */ return TRUE; }
  1230. #define SXS_COMMA_STRING L"&#x2c;"
  1231. #define SXS_QUOT_STRING L"&#x22;"
  1232. #define SXS_FUSION_TO_MSI_ATTRIBUTE_VALUE_CONVERSION_COMMA 0
  1233. #define SXS_FUSION_TO_MSI_ATTRIBUTE_VALUE_CONVERSION_QUOT 1
  1234. BOOL
  1235. SxspCreateAssemblyIdentityFromTextualString(
  1236. IN PCWSTR pszTextualAssemblyIdentityString,
  1237. OUT PASSEMBLY_IDENTITY *ppAssemblyIdentity
  1238. );
  1239. /*-----------------------------------------------------------------------------
  1240. side by side installation functions
  1241. -----------------------------------------------------------------------------*/
  1242. /*-----------------------------------------------------------------------------
  1243. public above
  1244. private below
  1245. -----------------------------------------------------------------------------*/
  1246. typedef
  1247. BOOL
  1248. (__stdcall*
  1249. SXSP_DEBUG_FUNCTION)(
  1250. ULONG iOperation,
  1251. DWORD dwFlags,
  1252. PCWSTR pszParameter1,
  1253. PVOID pvParameter2);
  1254. #define SXSP_DEBUG_ORDINAL (1)
  1255. BOOL
  1256. __stdcall
  1257. SxspDebug(
  1258. ULONG iOperation,
  1259. DWORD dwFlags,
  1260. PCWSTR pszParameter1,
  1261. PVOID pvParameter2);
  1262. } // extern "C"
  1263. /*-----------------------------------------------------------------------------*/
  1264. BOOL
  1265. SxspDuplicateString(
  1266. PCWSTR StringIn,
  1267. SIZE_T cch,
  1268. PWSTR *StringOut
  1269. );
  1270. BOOL
  1271. SxspHashString(
  1272. PCWSTR String,
  1273. SIZE_T Cch,
  1274. PULONG HashValue,
  1275. bool CaseInsensitive
  1276. );
  1277. ULONG
  1278. SxspGetHashAlgorithm(
  1279. VOID
  1280. );
  1281. BOOL
  1282. WINAPI
  1283. SxspAssemblyMetadataStringSectionGenerationCallback(
  1284. PVOID Context,
  1285. ULONG Reason,
  1286. PVOID CallbackData
  1287. );
  1288. VOID
  1289. __fastcall
  1290. SxspDllRedirectionContributorCallback(
  1291. PACTCTXCTB_CALLBACK_DATA Data
  1292. );
  1293. BOOL
  1294. WINAPI
  1295. SxspDllRedirectionStringSectionGenerationCallback(
  1296. PVOID Context,
  1297. ULONG Reason,
  1298. PVOID CallbackData
  1299. );
  1300. VOID
  1301. __fastcall
  1302. SxspWindowClassRedirectionContributorCallback(
  1303. PACTCTXCTB_CALLBACK_DATA Data
  1304. );
  1305. BOOL
  1306. WINAPI
  1307. SxspWindowClassRedirectionStringSectionGenerationCallback(
  1308. PVOID Context,
  1309. ULONG Reason,
  1310. PVOID CallbackData
  1311. );
  1312. VOID
  1313. __fastcall
  1314. SxspComClassRedirectionContributorCallback(
  1315. PACTCTXCTB_CALLBACK_DATA Data
  1316. );
  1317. BOOL
  1318. WINAPI
  1319. SxspComClassRedirectionGuidSectionGenerationCallback(
  1320. PVOID Context,
  1321. ULONG Reason,
  1322. PVOID CallbackData
  1323. );
  1324. VOID
  1325. __fastcall
  1326. SxspClrInteropContributorCallback(
  1327. PACTCTXCTB_CALLBACK_DATA Data
  1328. );
  1329. BOOL
  1330. WINAPI
  1331. SxspClrInteropGuidSectionGenerationCallback(
  1332. PVOID Context,
  1333. ULONG Reason,
  1334. PVOID CallbackData
  1335. );
  1336. BOOL
  1337. SxspVerifyPublicKeyAndStrongName(
  1338. const WCHAR *pszPublicKey,
  1339. SIZE_T CchPublicKey,
  1340. const WCHAR *pszStrongName,
  1341. SIZE_T CchStrongName,
  1342. BOOL &fValid
  1343. );
  1344. #define SXS_INSTALLATION_MOVE_FILE (0)
  1345. #define SXS_INSTALLATION_MOVE_DIRECTORY (1)
  1346. #define SXS_INSTALLATION_MOVE_DIRECTORY_IF_EXIST_MOVE_FILES_AND_SUBDIR (2)
  1347. #define SXS_GENERATE_MANIFEST_PATH_FOR_PROBING_NO_APPLICATION_ROOT_PATH_REQUIRED (0x00000001)
  1348. #define SXS_GENERATE_MANIFEST_PATH_FOR_PROBING_SKIP_LANGUAGE_SUBDIRS (0x00000002)
  1349. #define SXS_GENERATE_MANIFEST_PATH_FOR_PROBING_SKIP_PRIVATE_ASSEMBLIES (0x00000004)
  1350. #define PROBING_ATTRIBUTE_CACHE_FLAG_GOT_NAME (0x00000001)
  1351. #define PROBING_ATTRIBUTE_CACHE_FLAG_GOT_VERSION (0x00000002)
  1352. #define PROBING_ATTRIBUTE_CACHE_FLAG_GOT_PROCESSOR_ARCHITECTURE (0x00000004)
  1353. #define PROBING_ATTRIBUTE_CACHE_FLAG_GOT_PUBLIC_KEY_TOKEN (0x00000008)
  1354. #define PROBING_ATTRIBUTE_CACHE_FLAG_GOT_LANGUAGE (0x00000010)
  1355. typedef struct _PROBING_ATTRIBUTE_CACHE
  1356. {
  1357. DWORD dwFlags;
  1358. PCWSTR pszName;
  1359. SIZE_T cchName;
  1360. PCWSTR pszVersion;
  1361. SIZE_T cchVersion;
  1362. PCWSTR pszProcessorArchitecture;
  1363. SIZE_T cchProcessorArchitecture;
  1364. PCWSTR pszPublicKeyToken;
  1365. SIZE_T cchPublicKeyToken;
  1366. PCWSTR pszLanguage;
  1367. SIZE_T cchLanguage;
  1368. } PROBING_ATTRIBUTE_CACHE, *PPROBING_ATTRIBUTE_CACHE;
  1369. BOOL
  1370. SxspGenerateManifestPathForProbing(
  1371. IN DWORD dwLocationIndex,
  1372. IN DWORD dwFlags,
  1373. IN PCWSTR AssemblyRootDirectory OPTIONAL,
  1374. IN SIZE_T AssemblyRootDirectoryCchIn OPTIONAL,
  1375. IN ULONG ApplicationDirectoryPathType OPTIONAL,
  1376. IN PCWSTR ApplicationDirectory OPTIONAL,
  1377. IN SIZE_T ApplicationDirectoryCchIn OPTIONAL,
  1378. IN PCASSEMBLY_IDENTITY pAssemblyIdentity,
  1379. IN OUT PPROBING_ATTRIBUTE_CACHE pProbingAttributeCache,
  1380. IN OUT CBaseStringBuffer &PathBuffer,
  1381. BOOL *pfPrivateAssemblyFlag,
  1382. bool &rfDone
  1383. );
  1384. #define SXSP_GENERATE_SXS_PATH_PATHTYPE_INVALID (0)
  1385. #define SXSP_GENERATE_SXS_PATH_PATHTYPE_MANIFEST (1)
  1386. #define SXSP_GENERATE_SXS_PATH_PATHTYPE_ASSEMBLY (2)
  1387. #define SXSP_GENERATE_SXS_PATH_PATHTYPE_POLICY (3)
  1388. #define SXSP_GENERATE_SXS_PATH_PATHTYPE_SETUP_POLICY (4)
  1389. #define SXSP_GENERATE_SXS_PATH_FLAG_OMIT_ROOT (0x00000001)
  1390. #define SXSP_GENERATE_SXS_PATH_FLAG_PARTIAL_PATH (0x00000002)
  1391. #define SXSP_GENERATE_SXS_PATH_FLAG_OMIT_VERSION (0x00000004)
  1392. BOOL
  1393. SxspGenerateSxsPath(
  1394. IN DWORD Flags,
  1395. IN ULONG PathType,
  1396. IN PCWSTR AssemblyRootDirectory OPTIONAL,
  1397. IN SIZE_T AssemblyRootDirectoryCch OPTIONAL,
  1398. IN PCASSEMBLY_IDENTITY pAssemblyIdentity,
  1399. IN OUT PPROBING_ATTRIBUTE_CACHE ppac,
  1400. OUT CBaseStringBuffer &PathBuffer
  1401. );
  1402. //
  1403. // I tried to roll this into SxspGenerateSxsPath but the logic was
  1404. // way too convoluted. -mgrier 11/29/2001
  1405. //
  1406. BOOL
  1407. SxspGenerateNdpGACPath(
  1408. IN DWORD dwFlags,
  1409. IN PCASSEMBLY_IDENTITY pAssemblyIdentity,
  1410. IN OUT PPROBING_ATTRIBUTE_CACHE ppac,
  1411. OUT CBaseStringBuffer &rPathBuffer
  1412. );
  1413. BOOL
  1414. SxspGenerateSxsPath_FullPathToManifestOrPolicyFile(
  1415. IN const CBaseStringBuffer &AssemblyRootDirectory,
  1416. IN PCASSEMBLY_IDENTITY pAssemblyIdentity,
  1417. IN OUT PPROBING_ATTRIBUTE_CACHE ppac,
  1418. IN OUT CBaseStringBuffer &PathBuffer
  1419. );
  1420. BOOL
  1421. SxspGenerateSxsPath_RelativePathToManifestOrPolicyFile(
  1422. IN const CBaseStringBuffer &AssemblyRootDirectory,
  1423. IN PCASSEMBLY_IDENTITY pAssemblyIdentity,
  1424. IN OUT PPROBING_ATTRIBUTE_CACHE ppac,
  1425. IN OUT CBaseStringBuffer &PathBuffer
  1426. );
  1427. BOOL
  1428. SxspGenerateSxsPath_FullPathToCatalogFile(
  1429. IN const CBaseStringBuffer &AssemblyRootDirectory,
  1430. IN PCASSEMBLY_IDENTITY pAssemblyIdentity,
  1431. IN OUT PPROBING_ATTRIBUTE_CACHE ppac,
  1432. IN OUT CBaseStringBuffer &PathBuffer
  1433. );
  1434. BOOL
  1435. SxspGenerateSxsPath_RelativePathToCatalogFile(
  1436. IN const CBaseStringBuffer &AssemblyRootDirectory,
  1437. IN PCASSEMBLY_IDENTITY pAssemblyIdentity,
  1438. IN OUT PPROBING_ATTRIBUTE_CACHE ppac,
  1439. IN OUT CBaseStringBuffer &PathBuffer
  1440. );
  1441. BOOL
  1442. SxspGenerateSxsPath_FullPathToPayloadOrPolicyDirectory(
  1443. IN const CBaseStringBuffer &AssemblyRootDirectory,
  1444. IN PCASSEMBLY_IDENTITY pAssemblyIdentity,
  1445. IN OUT PPROBING_ATTRIBUTE_CACHE ppac,
  1446. IN OUT CBaseStringBuffer &PathBuffer
  1447. );
  1448. BOOL
  1449. SxspGenerateSxsPath_RelativePathToPayloadOrPolicyDirectory(
  1450. IN const CBaseStringBuffer &AssemblyRootDirectory,
  1451. IN PCASSEMBLY_IDENTITY pAssemblyIdentity,
  1452. IN OUT PPROBING_ATTRIBUTE_CACHE ppac,
  1453. IN OUT CBaseStringBuffer &PathBuffer
  1454. );
  1455. //
  1456. // Note that SxspGetAttributeValue() does not fail if the
  1457. // attribute is not found; *Found is set to TRUE/FALSE based on whether
  1458. // the attribute is found.
  1459. //
  1460. typedef struct _ATTRIBUTE_NAME_DESCRIPTOR
  1461. {
  1462. PCWSTR Namespace;
  1463. SIZE_T NamespaceCch;
  1464. PCWSTR Name;
  1465. SIZE_T NameCch;
  1466. } ATTRIBUTE_NAME_DESCRIPTOR, *PATTRIBUTE_NAME_DESCRIPTOR;
  1467. #define DECLARE_ATTRIBUTE_NAME_DESCRIPTOR(_AttributeNamespace, _AttributeName) \
  1468. static const WCHAR __AttributeName_ ## _AttributeName [] = L ## #_AttributeName; \
  1469. static const ATTRIBUTE_NAME_DESCRIPTOR s_AttributeName_ ## _AttributeName = { \
  1470. _AttributeNamespace, sizeof(_AttributeNamespace) / sizeof(_AttributeNamespace[0]) - 1, __AttributeName_ ## _AttributeName, sizeof(#_AttributeName) / sizeof(#_AttributeName [0]) - 1 }
  1471. #define DECLARE_STD_ATTRIBUTE_NAME_DESCRIPTOR(_AttributeName) \
  1472. static const WCHAR __AttributeName_ ## _AttributeName [] = L ## #_AttributeName; \
  1473. static const ATTRIBUTE_NAME_DESCRIPTOR s_AttributeName_ ## _AttributeName = { NULL, 0, __AttributeName_ ## _AttributeName, sizeof(#_AttributeName) / sizeof(#_AttributeName [0]) - 1 }
  1474. //
  1475. // For those writing validation routines:
  1476. //
  1477. // Only if the validation routine fails because of environmental conditions
  1478. // (e.g. it is not able to validate it rather than the validation fails)
  1479. // should it return false.
  1480. //
  1481. // If the validation fails, you should return a Win32 error code in the
  1482. // *pdwValidationStatus value. If you're at a loss for the error code
  1483. // to use, when in doubt use ERROR_SXS_MANIFEST_PARSE_ERROR. Any other
  1484. // code is reported in log files and the error log but is translated
  1485. // into ERROR_SXS_MANIFEST_PARSE_ERROR in higher layers anyways.
  1486. //
  1487. typedef BOOL (*SXSP_GET_ATTRIBUTE_VALUE_VALIDATION_ROUTINE)(
  1488. IN DWORD ValidationFlags,
  1489. IN const CBaseStringBuffer &rBuffer,
  1490. OUT bool &rfValid,
  1491. IN SIZE_T OutputBufferSize,
  1492. PVOID OutputBuffer,
  1493. OUT SIZE_T &OutputBytesWritten
  1494. );
  1495. //
  1496. // If the ValidationRoutine is omitted, no validation is done on the string
  1497. // and OutputBufferSize must be sizeof(CStringBuffer) and OutputBuffer must
  1498. // point to a constructed CStringBuffer instance.
  1499. //
  1500. #define SXSP_GET_ATTRIBUTE_VALUE_FLAG_REQUIRED_ATTRIBUTE (0x00000001)
  1501. BOOL
  1502. SxspGetAttributeValue(
  1503. IN DWORD dwFlags,
  1504. IN PCATTRIBUTE_NAME_DESCRIPTOR AttributeName,
  1505. IN PCSXS_NODE_INFO NodeInfo,
  1506. IN SIZE_T NodeCount,
  1507. IN PCACTCTXCTB_PARSE_CONTEXT ParseContext,
  1508. OUT bool &rfFound,
  1509. IN SIZE_T OutputBufferSize,
  1510. OUT PVOID OutputBuffer,
  1511. OUT SIZE_T &OutputBytesWritten,
  1512. IN SXSP_GET_ATTRIBUTE_VALUE_VALIDATION_ROUTINE ValidationRoutine OPTIONAL,
  1513. IN DWORD ValidationRoutineFlags OPTIONAL
  1514. );
  1515. BOOL
  1516. SxspGetAttributeValue(
  1517. IN DWORD dwFlags,
  1518. IN PCATTRIBUTE_NAME_DESCRIPTOR AttributeName,
  1519. IN PCACTCTXCTB_CBELEMENTPARSED ElementParsed,
  1520. OUT bool &rfFound,
  1521. IN SIZE_T OutputBufferSize,
  1522. OUT PVOID OutputBuffer,
  1523. OUT SIZE_T &OutputBytesWritten,
  1524. IN SXSP_GET_ATTRIBUTE_VALUE_VALIDATION_ROUTINE ValidationRoutine OPTIONAL,
  1525. IN DWORD ValidationRoutineFlags OPTIONAL
  1526. );
  1527. BOOL
  1528. SxspValidateBoolAttribute(
  1529. DWORD Flags,
  1530. const CBaseStringBuffer &rbuff,
  1531. bool &rfValid,
  1532. SIZE_T OutputBufferSize,
  1533. PVOID OutputBuffer,
  1534. SIZE_T &OutputBytesWritten
  1535. );
  1536. BOOL
  1537. SxspValidateUnsigned64Attribute(
  1538. DWORD Flags,
  1539. const CBaseStringBuffer &rbuff,
  1540. bool &rfValid,
  1541. SIZE_T OutputBufferSize,
  1542. PVOID OutputBuffer,
  1543. SIZE_T &OutputBytesWritten
  1544. );
  1545. BOOL
  1546. SxspValidateGuidAttribute(
  1547. DWORD Flags,
  1548. const CBaseStringBuffer &rbuff,
  1549. bool &rfValid,
  1550. SIZE_T OutputBufferSize,
  1551. PVOID OutputBuffer,
  1552. SIZE_T &OutputBytesWritten
  1553. );
  1554. #define SXSP_VALIDATE_PROCESSOR_ARCHITECTURE_ATTRIBUTE_FLAG_WILDCARD_ALLOWED (0x00000001)
  1555. BOOL
  1556. SxspValidateProcessorArchitectureAttribute(
  1557. DWORD Flags,
  1558. const CBaseStringBuffer &rbuff,
  1559. bool &rfValid,
  1560. SIZE_T OutputBufferSize,
  1561. PVOID OutputBuffer,
  1562. SIZE_T &OutputBytesWritten
  1563. );
  1564. #define SXSP_VALIDATE_LANGUAGE_ATTRIBUTE_FLAG_WILDCARD_ALLOWED (0x00000001)
  1565. BOOL
  1566. SxspValidateLanguageAttribute(
  1567. DWORD Flags,
  1568. const CBaseStringBuffer &rbuff,
  1569. bool &rfValid,
  1570. SIZE_T OutputBufferSize,
  1571. PVOID OutputBuffer,
  1572. SIZE_T &OutputBytesWritten
  1573. );
  1574. VOID
  1575. SxspDbgPrintActivationContextData(
  1576. ULONG Level,
  1577. PCACTIVATION_CONTEXT_DATA Data,
  1578. CBaseStringBuffer &rbuffPerLinePrefix
  1579. );
  1580. BOOL
  1581. SxspFormatFileTime(
  1582. LARGE_INTEGER ft,
  1583. CBaseStringBuffer &rBuffer
  1584. );
  1585. BOOL
  1586. SxspIsRightXMLTag(
  1587. PACTCTXCTB_CBELEMENTPARSED CBData,
  1588. ULONG ExpectedDepth,
  1589. PCWSTR ParentTagPath,
  1590. PCWSTR ChildTag
  1591. );
  1592. BOOL
  1593. SxspFindLastSegmentOfAssemblyName(
  1594. IN PCWSTR AssemblyName,
  1595. IN SIZE_T AssemblyNameCch OPTIONAL,
  1596. OUT PCWSTR *LastSegment,
  1597. OUT SIZE_T *LastSegmentCch
  1598. );
  1599. typedef struct _ELEMENT_PATH_MAP_ENTRY {
  1600. ULONG ElementDepth;
  1601. PCWSTR ElementPath;
  1602. SIZE_T ElementPathCch;
  1603. ULONG MappedValue;
  1604. } ELEMENT_PATH_MAP_ENTRY, *PELEMENT_PATH_MAP_ENTRY;
  1605. typedef const ELEMENT_PATH_MAP_ENTRY *PCELEMENT_PATH_MAP_ENTRY;
  1606. BOOL
  1607. SxspProcessElementPathMap(
  1608. PCACTCTXCTB_PARSE_CONTEXT ParseContext,
  1609. PCELEMENT_PATH_MAP_ENTRY MapEntries,
  1610. SIZE_T MapEntryCount,
  1611. ULONG &MappedValue,
  1612. bool &Found
  1613. );
  1614. HRESULT
  1615. SxspLogLastParseError(
  1616. IXMLNodeSource *pSource,
  1617. PCACTCTXCTB_PARSE_CONTEXT pParseContext
  1618. );
  1619. // Merge this with util\io.cpp\FusionpCreateDirectories.
  1620. BOOL
  1621. SxspCreateMultiLevelDirectory(
  1622. PCWSTR CurrentDirectory,
  1623. PCWSTR pwszNewDirs
  1624. );
  1625. #define SXSP_VALIDATE_IDENTITY_FLAG_VERSION_REQUIRED (0x00000001)
  1626. #define SXSP_VALIDATE_IDENTITY_FLAG_VERSION_NOT_ALLOWED (0x00000008)
  1627. #define SXSP_VALIDATE_IDENTITY_FLAG_POLICIES_NOT_ALLOWED (0x00000010)
  1628. BOOL
  1629. SxspValidateIdentity(
  1630. DWORD Flags,
  1631. ULONG Type,
  1632. PCASSEMBLY_IDENTITY AssemblyIdentity
  1633. );
  1634. typedef enum _SXS_DEBUG_OPERATION
  1635. {
  1636. SXS_DEBUG_XML_PARSER,
  1637. SXS_DEBUG_CREAT_MULTILEVEL_DIRECTORY,
  1638. SXS_DEBUG_PROBE_MANIFST,
  1639. SXS_DEBUG_CHECK_MANIFEST_SCHEMA,
  1640. SXS_DEBUG_SET_ASSEMBLY_STORE_ROOT,
  1641. SXS_DEBUG_PRECOMPILED_MANIFEST,
  1642. SXS_DEBUG_TIME_PCM,
  1643. SXS_DEBUG_FORCE_LEAK,
  1644. SXS_DEBUG_PROBE_ASSEMBLY,
  1645. SXS_DEBUG_DLL_REDIRECTION,
  1646. SXS_DEBUG_FUSION_ARRAY,
  1647. SXS_DEBUG_FOLDERNAME_FROM_ASSEMBLYIDENTITY_GENERATION,
  1648. SXS_DEBUG_ASSEMBLYNAME_CONVERSION,
  1649. SXS_DEBUG_DIRECTORY_WATCHER,
  1650. SXS_DEBUG_SFC_SCANNER,
  1651. SXS_DEBUG_GET_STRONGNAME,
  1652. SXS_DEBUG_FUSION_REPARSEPOINT,
  1653. SXS_DEBUG_ASSEMBLY_IDENTITY_HASH,
  1654. SXS_DEBUG_CATALOG_SIGNER_CHECK,
  1655. SXS_DEBUG_SYSTEM_DEFAULT_ACTCTX_GENERATION,
  1656. SXS_DEBUG_SFC_UI_TEST,
  1657. SXS_DEBUG_EXIT_PROCESS,
  1658. SXS_DEBUG_PARSE_PATCH_FILE,
  1659. SXS_DEBUG_EXPAND_CAB_FILE,
  1660. SXS_DEBUG_TERMINATE_PROCESS
  1661. } SXS_DEBUG_OPERATION;
  1662. /*-----------------------------------------------------------------------------
  1663. FALSE / GetLastError upon error
  1664. will use GetFileAttributesEx instead of FindFirstFile when available
  1665. -----------------------------------------------------------------------------*/
  1666. #define SXSP_GET_FILE_SIZE_FLAG_COMPRESSION_AWARE (0x00000001)
  1667. #define SXSP_GET_FILE_SIZE_FLAG_GET_COMPRESSED_SOURCE_SIZE (0x00000002)
  1668. BOOL
  1669. SxspGetFileSize(
  1670. DWORD dwFlags,
  1671. PCWSTR pszFileName,
  1672. ULONGLONG &rullSize
  1673. );
  1674. BOOL
  1675. SxspInitAssembly(
  1676. PASSEMBLY Asm,
  1677. CProbedAssemblyInformation &AssemblyInformation
  1678. );
  1679. /*-----------------------------------------------------------------------------
  1680. These let you avoid casting.
  1681. -----------------------------------------------------------------------------*/
  1682. LONG SxspInterlockedIncrement(LONG*);
  1683. ULONG SxspInterlockedIncrement(ULONG*);
  1684. LONG SxspInterlockedDecrement(LONG*);
  1685. ULONG SxspInterlockedDecrement(ULONG*);
  1686. LONG SxspInterlockedExchange(LONG*, LONG);
  1687. ULONG SxspInterlockedExchange(ULONG*, ULONG);
  1688. LONG SxspInterlockedCompareExchange(LONG*, LONG, LONG);
  1689. ULONG SxspInterlockedCompareExchange(ULONG*, ULONG, ULONG);
  1690. LONG SxspInterlockedExchangeAdd(LONG*, LONG, LONG);
  1691. ULONG SxspInterlockedExchangeAdd(ULONG*, ULONG, ULONG);
  1692. /*
  1693. #if defined(_WIN64)
  1694. unsigned __int64 SxspInterlockedExchange(unsigned __int64* pi, unsigned __int64 x);
  1695. unsigned __int64 SxspInterlockedCompareExchange(unsigned __int64* pi, unsigned __int64 x, unsigned __int64 y);
  1696. #endif
  1697. */
  1698. template <typename T> T* SxspInterlockedExchange(T** pp, T* p1);
  1699. template <typename T> T* SxspInterlockedCompareExchange(T** pp, T* p1, T* p2);
  1700. BOOL
  1701. SxspIncorporateAssembly(
  1702. PACTCTXGENCTX pActCtxGenCtx,
  1703. PASSEMBLY Asm
  1704. );
  1705. /*-----------------------------------------------------------------------------
  1706. impersonate in constructor, unimpersonate in destructor, but we use
  1707. explicit unimpersonation in order to progagate its error
  1708. -----------------------------------------------------------------------------*/
  1709. class CImpersonate
  1710. {
  1711. public:
  1712. CImpersonate(const CImpersonationData &ImpersonationData) : m_ImpersonationData(ImpersonationData), m_Impersonating(FALSE) { }
  1713. ~CImpersonate()
  1714. {
  1715. if (m_Impersonating)
  1716. {
  1717. CSxsPreserveLastError ple;
  1718. //
  1719. // removed SOFT_VERIFY2 because
  1720. // 1) this line has never been seen to fail
  1721. // 2) SOFT_VERIFY2 or somesuch seemed to cause problems in the past
  1722. //
  1723. m_ImpersonationData.Call(CImpersonationData::eCallTypeUnimpersonate);
  1724. ple.Restore();
  1725. }
  1726. }
  1727. BOOL Impersonate()
  1728. {
  1729. BOOL fSuccess = FALSE;
  1730. FN_TRACE_WIN32(fSuccess);
  1731. INTERNAL_ERROR_CHECK(!m_Impersonating);
  1732. IFW32FALSE_EXIT(m_ImpersonationData.Call(CImpersonationData::eCallTypeImpersonate));
  1733. m_Impersonating = TRUE;
  1734. fSuccess = TRUE;
  1735. Exit:
  1736. return fSuccess;
  1737. }
  1738. enum UnimpersonateWhenNotImpersonatingBehavior
  1739. {
  1740. eUnimpersonateFailsIfNotImpersonating,
  1741. eUnimpersonateSucceedsIfNotImpersonating
  1742. };
  1743. BOOL Unimpersonate(UnimpersonateWhenNotImpersonatingBehavior e = eUnimpersonateFailsIfNotImpersonating)
  1744. {
  1745. BOOL fSuccess = FALSE;
  1746. FN_TRACE_WIN32(fSuccess);
  1747. PARAMETER_CHECK((e == eUnimpersonateFailsIfNotImpersonating) || (e == eUnimpersonateSucceedsIfNotImpersonating));
  1748. if (e == eUnimpersonateFailsIfNotImpersonating)
  1749. INTERNAL_ERROR_CHECK(m_Impersonating);
  1750. if (m_Impersonating)
  1751. {
  1752. m_Impersonating = FALSE;
  1753. IFW32FALSE_EXIT(m_ImpersonationData.Call(CImpersonationData::eCallTypeUnimpersonate));
  1754. }
  1755. fSuccess = TRUE;
  1756. Exit:
  1757. return fSuccess;
  1758. }
  1759. private:
  1760. CImpersonationData m_ImpersonationData;
  1761. BOOL m_Impersonating;
  1762. };
  1763. /*-----------------------------------------------------------------------------
  1764. deletes recursively, including readonly files, continues after errors,
  1765. but returns if there were any
  1766. -----------------------------------------------------------------------------*/
  1767. BOOL
  1768. SxspDeleteDirectory(
  1769. const CBaseStringBuffer &rdir
  1770. );
  1771. #define SXSP_MOVE_FILE_FLAG_COMPRESSION_AWARE 1
  1772. BOOL
  1773. SxspMoveFilesUnderDir(
  1774. DWORD dwFlags,
  1775. CBaseStringBuffer & sbSourceDir,
  1776. CBaseStringBuffer & sbDestDir,
  1777. DWORD dwMoveFileFlags
  1778. );
  1779. /*-----------------------------------------------------------------------------
  1780. -----------------------------------------------------------------------------*/
  1781. typedef struct _SXSP_LOCALLY_UNIQUE_ID
  1782. {
  1783. SYSTEMTIME stTimeStamp;
  1784. ULONG ulUniquifier;
  1785. } SXSP_LOCALLY_UNIQUE_ID, *PSXSP_LOCALLY_UNIQUE_ID;
  1786. typedef const SXSP_LOCALLY_UNIQUE_ID* PCSXSP_LOCALLY_UNIQUE_ID;
  1787. BOOL
  1788. SxspCreateLocallyUniqueId(
  1789. OUT PSXSP_LOCALLY_UNIQUE_ID pUniqueId
  1790. );
  1791. BOOL
  1792. SxspFormatLocallyUniqueId(
  1793. IN const SXSP_LOCALLY_UNIQUE_ID &rluid,
  1794. OUT CBaseStringBuffer &rBuffer
  1795. );
  1796. /*-----------------------------------------------------------------------------
  1797. -----------------------------------------------------------------------------*/
  1798. VOID
  1799. SxspInitializeSListHead(
  1800. IN PSLIST_HEADER ListHead
  1801. );
  1802. PSLIST_ENTRY
  1803. SxspInterlockedPopEntrySList(
  1804. IN PSLIST_HEADER ListHead
  1805. );
  1806. PSLIST_ENTRY
  1807. SxspPopEntrySList(
  1808. IN PSLIST_HEADER ListHead
  1809. );
  1810. PSLIST_ENTRY
  1811. SxspInterlockedPushEntrySList(
  1812. IN PSLIST_HEADER ListHead,
  1813. IN PSINGLE_LIST_ENTRY ListEntry
  1814. );
  1815. /*-----------------------------------------------------------------------------
  1816. -----------------------------------------------------------------------------*/
  1817. class __declspec(align(16)) CAlignedSingleListEntry : public SLIST_ENTRY { };
  1818. class CCleanupBase : public CAlignedSingleListEntry
  1819. {
  1820. public:
  1821. CCleanupBase() : m_fInAtExitList(false) { }
  1822. virtual VOID DeleteYourself() = 0;
  1823. bool m_fInAtExitList;
  1824. protected:
  1825. virtual ~CCleanupBase() = 0 { }
  1826. };
  1827. BOOL
  1828. SxspAtExit(
  1829. CCleanupBase* pCleanup
  1830. );
  1831. BOOL
  1832. SxspTryCancelAtExit(
  1833. CCleanupBase* pCleanup
  1834. );
  1835. BOOL
  1836. SxspInstallDecompressOrCopyFileW(
  1837. PCWSTR lpSource,
  1838. PCWSTR lpDest,
  1839. BOOL bFailIfExists);
  1840. BOOL
  1841. SxspInstallMoveFileExW(
  1842. CBaseStringBuffer &moveOrigination,
  1843. CBaseStringBuffer &moveDestination,
  1844. DWORD dwFlags,
  1845. BOOL fAwareNonCompressed = FALSE
  1846. );
  1847. BOOL SxspInstallDecompressAndMoveFileExW(
  1848. LPCWSTR lpExistingFileName,
  1849. LPCWSTR lpNewFileName,
  1850. DWORD dwFlags,
  1851. BOOL fAwareNonCompressed = FALSE
  1852. );
  1853. /*-----------------------------------------------------------------------------
  1854. create a unique temp directory under %windir%\WinSxs
  1855. -----------------------------------------------------------------------------*/
  1856. BOOL
  1857. SxspCreateWinSxsTempDirectory(
  1858. OUT CBaseStringBuffer &rbuffTemp,
  1859. OUT SIZE_T * pcch OPTIONAL = NULL,
  1860. OUT CBaseStringBuffer *pBuffUniquePart OPTIONAL = NULL, // good to pass to CRunOnceDeleteDirectory::Initialize
  1861. OUT SIZE_T * pcchUniquePart OPTIONAL = NULL
  1862. );
  1863. #define SXSP_CREATE_ASSEMBLY_IDENTITY_FROM_IDENTITY_TAG_FLAG_VERIFY_PUBLIC_KEY_IF_PRESENT (0x00000001)
  1864. BOOL
  1865. SxspCreateAssemblyIdentityFromIdentityElement(
  1866. DWORD Flags,
  1867. ULONG Type,
  1868. PASSEMBLY_IDENTITY *AssemblyIdentityOut,
  1869. DWORD cNumRecs,
  1870. PCSXS_NODE_INFO prgNodeInfo
  1871. );
  1872. /*-----------------------------------------------------------------------------
  1873. this must be heap allocated
  1874. the C-api enforces that
  1875. -----------------------------------------------------------------------------*/
  1876. class CRunOnceDeleteDirectory : public CCleanupBase
  1877. {
  1878. public:
  1879. CRunOnceDeleteDirectory() { }
  1880. BOOL
  1881. Initialize(
  1882. IN const CBaseStringBuffer &rbuffDirectoryToDelete,
  1883. IN const CBaseStringBuffer *pstrUniqueKey OPTIONAL = NULL
  1884. );
  1885. BOOL Cancel();
  1886. // very unusual.. this is noncrashing, but
  1887. // leaves the stuff in the registry
  1888. BOOL Close();
  1889. VOID DeleteYourself() { FUSION_DELETE_SINGLETON(this); }
  1890. ~CRunOnceDeleteDirectory();
  1891. protected:
  1892. CFusionRegKey m_hKey;
  1893. CStringBuffer m_strValueName;
  1894. private:
  1895. CRunOnceDeleteDirectory(const CRunOnceDeleteDirectory &);
  1896. void operator =(const CRunOnceDeleteDirectory &);
  1897. };
  1898. /*-----------------------------------------------------------------------------
  1899. C-like API over the above
  1900. -----------------------------------------------------------------------------*/
  1901. BOOL
  1902. SxspCreateRunOnceDeleteDirectory(
  1903. IN const CBaseStringBuffer &rbuffDirectoryToDelete,
  1904. IN const CBaseStringBuffer *pbuffUniqueKey OPTIONAL,
  1905. OUT PVOID* cookie
  1906. );
  1907. BOOL
  1908. SxspCancelRunOnceDeleteDirectory(
  1909. PVOID cookie
  1910. );
  1911. /*-----------------------------------------------------------------------------
  1912. -----------------------------------------------------------------------------*/
  1913. USHORT
  1914. SxspGetSystemProcessorArchitecture();
  1915. /*-----------------------------------------------------------------------------*/
  1916. RTL_PATH_TYPE
  1917. SxspDetermineDosPathNameType(
  1918. PCWSTR DosFileName
  1919. );
  1920. /*-----------------------------------------------------------------------------*/
  1921. interface IAssemblyName;
  1922. typedef
  1923. HRESULT
  1924. (STDAPICALLTYPE*
  1925. PFNCreateAssemblyNameObject)(
  1926. OUT IAssemblyName** ppAssemblyName,
  1927. IN LPCOLESTR szAssemblyName,
  1928. IN DWORD dwFlags,
  1929. LPVOID pvReserved
  1930. );
  1931. typedef HRESULT (WINAPI * PFNCreateAssemblyCache)(
  1932. OUT IAssemblyCache **ppAsmCache,
  1933. IN DWORD dwReserved
  1934. );
  1935. typedef HRESULT (WINAPI * PFNCreateAssemblyCacheItem)(
  1936. OUT IAssemblyCacheItem** ppAsmItem,
  1937. IN IAssemblyName *pName,
  1938. IN PCWSTR pwzCodebase,
  1939. IN FILETIME *pftLastMod,
  1940. IN DWORD dwInstaller,
  1941. IN DWORD dwReserved
  1942. );
  1943. /*-----------------------------------------------------------------------------*/
  1944. //
  1945. // Private APIs used by OLEAUT32 to invoke isolation:
  1946. //
  1947. EXTERN_C HRESULT STDAPICALLTYPE SxsOleAut32MapReferenceClsidToConfiguredClsid(
  1948. REFCLSID rclsidIn,
  1949. CLSID *pclsidOut
  1950. );
  1951. EXTERN_C HRESULT STDAPICALLTYPE SxsOleAut32RedirectTypeLibrary(
  1952. LPCOLESTR szGuid,
  1953. WORD wMaj,
  1954. WORD wMin,
  1955. LCID lcid,
  1956. BOOL fHighest,
  1957. SIZE_T *pcchFileName,
  1958. LPOLESTR rgFileName
  1959. );
  1960. /*-----------------------------------------------------------------------------*/
  1961. BOOL
  1962. SxspDoesPathCrossReparsePointVa(
  1963. PCWSTR BasePath,
  1964. SIZE_T cchBasePath,
  1965. PCWSTR Path,
  1966. SIZE_T cchPath,
  1967. BOOL &CrossesReparsePoint,
  1968. DWORD &dwLastError,
  1969. SIZE_T cOkErrors,
  1970. va_list vaOkErrors
  1971. );
  1972. inline BOOL
  1973. SxspDoesPathCrossReparsePoint(
  1974. PCWSTR BasePath,
  1975. SIZE_T cchBasePath,
  1976. PCWSTR Path,
  1977. SIZE_T cchPath,
  1978. BOOL &CrossesReparsePoint,
  1979. DWORD &dwLastError,
  1980. SIZE_T cOkErrors,
  1981. ...
  1982. )
  1983. {
  1984. va_list va;
  1985. va_start(va, cOkErrors);
  1986. return SxspDoesPathCrossReparsePointVa(BasePath, cchBasePath, Path, cchPath, CrossesReparsePoint, dwLastError, cOkErrors, va);
  1987. }
  1988. inline BOOL
  1989. SxspDoesPathCrossReparsePoint(
  1990. PCWSTR BasePath,
  1991. SIZE_T cchBasePath,
  1992. PCWSTR Path,
  1993. SIZE_T cchPath,
  1994. BOOL &CrossesReparsePoint
  1995. )
  1996. {
  1997. DWORD dwError;
  1998. return SxspDoesPathCrossReparsePoint(BasePath, cchBasePath, Path, cchPath, CrossesReparsePoint, dwError, 0);
  1999. }
  2000. inline BOOL
  2001. SxspDoesPathCrossReparsePoint(
  2002. PCWSTR Path,
  2003. SIZE_T Start,
  2004. BOOL &CrossesReparsePoint
  2005. )
  2006. {
  2007. const SIZE_T PathLength = StringLength(Path);
  2008. return SxspDoesPathCrossReparsePoint(
  2009. Path,
  2010. PathLength,
  2011. Path + Start,
  2012. PathLength - Start,
  2013. CrossesReparsePoint);
  2014. }
  2015. /*-----------------------------------------------------------------------------
  2016. inline implementations
  2017. -----------------------------------------------------------------------------*/
  2018. #include "sxsntrtl.inl"
  2019. inline USHORT
  2020. SxspGetSystemProcessorArchitecture()
  2021. {
  2022. SYSTEM_INFO systemInfo;
  2023. systemInfo.wProcessorArchitecture = DEFAULT_ARCHITECTURE;
  2024. GetSystemInfo(&systemInfo);
  2025. return systemInfo.wProcessorArchitecture;
  2026. }
  2027. #define SXS_REALLY_PRIVATE_INTERLOCKED1(SxsFunction, Win32Function, SxsT, Win32T) \
  2028. inline SxsT Sxsp##SxsFunction(SxsT* p) { return (SxsT)Win32Function((Win32T*)p); }
  2029. #define SXS_REALLY_PRIVATE_INTERLOCKED2(SxsFunction, Win32Function, SxsT, Win32T) \
  2030. inline SxsT Sxsp##SxsFunction(SxsT* p, SxsT x) { return (SxsT)Win32Function((Win32T*)p, (Win32T)x); }
  2031. #define SXS_REALLY_PRIVATE_INTERLOCKED3(SxsFunction, Win32Function, SxsT, Win32T) \
  2032. inline SxsT Sxsp##SxsFunction(SxsT* p, SxsT x, SxsT y) { return (SxsT)Win32Function((Win32T*)p, (Win32T)x, (Win32T)y); }
  2033. SXS_REALLY_PRIVATE_INTERLOCKED1(InterlockedIncrement, InterlockedIncrement, LONG, LONG)
  2034. SXS_REALLY_PRIVATE_INTERLOCKED1(InterlockedIncrement, InterlockedIncrement, ULONG, LONG)
  2035. SXS_REALLY_PRIVATE_INTERLOCKED1(InterlockedDecrement, InterlockedDecrement, LONG, LONG)
  2036. SXS_REALLY_PRIVATE_INTERLOCKED1(InterlockedDecrement, InterlockedDecrement, ULONG, LONG)
  2037. SXS_REALLY_PRIVATE_INTERLOCKED2(InterlockedExchange, InterlockedExchange, LONG, LONG)
  2038. SXS_REALLY_PRIVATE_INTERLOCKED2(InterlockedExchange, InterlockedExchange, ULONG, LONG)
  2039. SXS_REALLY_PRIVATE_INTERLOCKED3(InterlockedCompareExchange, InterlockedCompareExchange, LONG, LONG)
  2040. SXS_REALLY_PRIVATE_INTERLOCKED3(InterlockedCompareExchange, InterlockedCompareExchange, ULONG, LONG)
  2041. SXS_REALLY_PRIVATE_INTERLOCKED2(InterlockedExchangeAdd, InterlockedExchangeAdd, LONG, LONG)
  2042. SXS_REALLY_PRIVATE_INTERLOCKED2(InterlockedExchangeAdd, InterlockedExchangeAdd, ULONG, LONG)
  2043. #if defined(_WIN64)
  2044. SXS_REALLY_PRIVATE_INTERLOCKED2(InterlockedExchange, InterlockedExchangePointer, __int64, PVOID)
  2045. SXS_REALLY_PRIVATE_INTERLOCKED2(InterlockedExchange, InterlockedExchangePointer, unsigned __int64, PVOID)
  2046. SXS_REALLY_PRIVATE_INTERLOCKED2(InterlockedExchange, InterlockedExchangePointer, PCWSTR, PVOID)
  2047. SXS_REALLY_PRIVATE_INTERLOCKED3(InterlockedCompareExchange, InterlockedCompareExchangePointer, __int64, PVOID)
  2048. SXS_REALLY_PRIVATE_INTERLOCKED3(InterlockedCompareExchange, InterlockedCompareExchangePointer, unsigned __int64, PVOID)
  2049. #endif
  2050. template <typename U> SXS_REALLY_PRIVATE_INTERLOCKED2(InterlockedExchange, InterlockedExchangePointer, U*, PVOID)
  2051. template <typename U> SXS_REALLY_PRIVATE_INTERLOCKED3(InterlockedCompareExchange, InterlockedCompareExchangePointer, U*, PVOID)
  2052. #undef SXS_REALLY_PRIVATE_INTERLOCKED1
  2053. #undef SXS_REALLY_PRIVATE_INTERLOCKED2
  2054. #undef SXS_REALLY_PRIVATE_INTERLOCKED3
  2055. inline BOOL operator==(const FILETIME& ft1, const FILETIME& ft2)
  2056. {
  2057. BOOL fResult = (
  2058. ft1.dwLowDateTime == ft2.dwLowDateTime
  2059. && ft1.dwHighDateTime == ft2.dwHighDateTime);
  2060. return fResult;
  2061. }
  2062. inline BOOL operator!=(const FILETIME& ft1, const FILETIME& ft2)
  2063. {
  2064. return !(ft1 == ft2);
  2065. }
  2066. inline BOOL operator==(const FILETIME& ft, __int64 i)
  2067. {
  2068. LARGE_INTEGER lift;
  2069. LARGE_INTEGER lii;
  2070. lii.QuadPart = i;
  2071. lift.LowPart = ft.dwLowDateTime;
  2072. lift.HighPart = ft.dwHighDateTime;
  2073. return (lii.QuadPart == lift.QuadPart);
  2074. }
  2075. inline BOOL operator!=(const FILETIME& ft, __int64 i)
  2076. {
  2077. return !(ft == i);
  2078. }
  2079. //
  2080. // Some helpful strings, centralized
  2081. //
  2082. #define FILE_EXTENSION_CATALOG ( L"cat" )
  2083. #define FILE_EXTENSION_CATALOG_CCH ( NUMBER_OF( FILE_EXTENSION_CATALOG ) - 1 )
  2084. #define FILE_EXTENSION_MANIFEST ( L"manifest" )
  2085. #define FILE_EXTENSION_MANIFEST_CCH ( NUMBER_OF( FILE_EXTENSION_MANIFEST ) - 1 )
  2086. #define FILE_EXTENSION_MAN ( L"man" )
  2087. #define FILE_EXTENSION_MAN_CCH ( NUMBER_OF( FILE_EXTENSION_MAN ) - 1 )
  2088. int SxspHexDigitToValue(WCHAR wch);
  2089. bool SxspIsHexDigit(WCHAR wch);
  2090. BOOL
  2091. SxspExpandRelativePathToFull(
  2092. IN PCWSTR wszString,
  2093. IN SIZE_T cchString,
  2094. OUT CBaseStringBuffer &rbuffDestination
  2095. );
  2096. BOOL
  2097. SxspParseComponentPolicy(
  2098. DWORD Flags,
  2099. PACTCTXGENCTX pActCtxGenCtx,
  2100. const CProbedAssemblyInformation &PolicyAssemblyInformation,
  2101. CPolicyStatement *&rpPolicyStatement
  2102. );
  2103. BOOL
  2104. SxspParseApplicationPolicy(
  2105. DWORD Flags,
  2106. PACTCTXGENCTX pActCtxGenCtx,
  2107. ULONG ulPolicyPathType,
  2108. PCWSTR pszPolicyPath,
  2109. SIZE_T cchPolicyPath,
  2110. IStream *pIStream
  2111. );
  2112. BOOL
  2113. SxspParseNdpGacComponentPolicy(
  2114. ULONG Flags,
  2115. PACTCTXGENCTX pGenContext,
  2116. const CProbedAssemblyInformation &PolicyAssemblyInformation,
  2117. CPolicyStatement *&rpPolicyStatement
  2118. );
  2119. #define POLICY_PATH_FLAG_POLICY_IDENTITY_TEXTUAL_FORMAT 0
  2120. #define POLICY_PATH_FLAG_FULL_QUALIFIED_POLICIES_DIR 1
  2121. #define POLICY_PATH_FLAG_FULL_QUALIFIED_POLICY_FILE_NAME 2
  2122. //
  2123. // Generate the shortened name version of this path string
  2124. //
  2125. BOOL
  2126. SxspGetShortPathName(
  2127. IN const CBaseStringBuffer &rcbuffLongPathName,
  2128. OUT CBaseStringBuffer &rbuffShortenedVersion
  2129. );
  2130. BOOL
  2131. SxspGetShortPathName(
  2132. IN const CBaseStringBuffer &rcbuffLongPathName,
  2133. OUT CBaseStringBuffer &rbuffShortenedVersion,
  2134. DWORD &rdwWin32Error,
  2135. SIZE_T cExceptionalWin32Errors,
  2136. ...
  2137. );
  2138. BOOL
  2139. SxspLoadString(
  2140. HINSTANCE hSource,
  2141. UINT uiStringIdent,
  2142. OUT CBaseStringBuffer &rbuffOutput
  2143. );
  2144. BOOL
  2145. SxspFormatString(
  2146. DWORD dwFlags,
  2147. LPCVOID pvSource,
  2148. DWORD dwId,
  2149. DWORD dwLangId,
  2150. OUT CBaseStringBuffer &rbuffOutput,
  2151. va_list* pvalArguments
  2152. );
  2153. BOOL
  2154. SxspSaveAssemblyRegistryData(
  2155. DWORD Flags,
  2156. IN PCASSEMBLY_IDENTITY pcAssemblyIdentity
  2157. );
  2158. #define FILE_OR_PATH_NOT_FOUND(x) (((x) == ERROR_FILE_NOT_FOUND) || ((x) == ERROR_PATH_NOT_FOUND))
  2159. #define PRIVATIZE_COPY_CONSTRUCTORS( obj ) obj( const obj& ); obj& operator=(const obj&);
  2160. BOOL
  2161. SxspGenerateAssemblyNameInRegistry(
  2162. IN PCASSEMBLY_IDENTITY pcAsmIdent,
  2163. OUT CBaseStringBuffer &rbuffRegistryName
  2164. );
  2165. BOOL
  2166. SxspGenerateAssemblyNameInRegistry(
  2167. IN const CBaseStringBuffer &rcbuffTextualString,
  2168. OUT CBaseStringBuffer &rbuffRegistryName
  2169. );
  2170. BOOL
  2171. SxspGetRemoteUniversalName(
  2172. IN PCWSTR pcszPathName,
  2173. OUT CBaseStringBuffer &rbuffUniversalName
  2174. );
  2175. #define SXS_GET_VOLUME_PATH_NAME_NO_FULLPATH (0x00000001)
  2176. BOOL
  2177. SxspGetVolumePathName(
  2178. IN DWORD dwFlags,
  2179. IN PCWSTR pcwszVolumePath,
  2180. OUT CBaseStringBuffer &buffVolumePathName
  2181. );
  2182. BOOL
  2183. SxspGetFullPathName(
  2184. IN PCWSTR pcwszPathName,
  2185. OUT CBaseStringBuffer &rbuffPathName,
  2186. OUT CBaseStringBuffer *pbuffFilePart = NULL
  2187. );
  2188. BOOL
  2189. SxspGetVolumeNameForVolumeMountPoint(
  2190. IN PCWSTR pcwsMountPoint,
  2191. OUT CBaseStringBuffer &rbuffMountPoint
  2192. );
  2193. BOOL
  2194. SxspExpandEnvironmentStrings(
  2195. IN PCWSTR pcwszSource,
  2196. OUT CBaseStringBuffer &buffTarget
  2197. );
  2198. BOOL
  2199. SxspDoesMSIStillNeedAssembly(
  2200. IN PCWSTR pcAsmName,
  2201. OUT BOOL &rfNeedsAssembly
  2202. );
  2203. BOOL
  2204. SxspIsFileNameValidForManifest(
  2205. const CBaseStringBuffer &rsbFileName,
  2206. bool &rfValid
  2207. );
  2208. typedef CSmartPtrWithNamedDestructor<ASSEMBLY_IDENTITY, &::SxsDestroyAssemblyIdentity> CSmartAssemblyIdentity;
  2209. #define SXSP_MODIFY_REGISTRY_DATA_FLAG_REPAIR_SHORT_NAMES (0x00000001)
  2210. #define SXSP_MODIFY_REGISTRY_DATA_FLAG_DELETE_SHORT_NAMES (0x00000002)
  2211. #define SXSP_MODIFY_REGISTRY_DATA_FLAG_REPAIR_OFFLINE_INSTALL_REFRESH_PROMPTS (0x00000004)
  2212. #define SXSP_MODIFY_REGISTRY_DATA_FLAG_REPAIR_ALL (0x00000008)
  2213. #define SXSP_MODIFY_REGISTRY_DATA_FLAG_REPAIR_CODEBASE_KEYS_TO_VALUES (0x00000010)
  2214. #define SXSP_MODIFY_REGISTRY_DATA_VALIDATE (0x00000020)
  2215. #define SXSP_MODIFY_REGISTRY_DATA_FLAG_VALID_FLAGS (0x0000002F)
  2216. BOOL
  2217. SxspModifyRegistryData(
  2218. DWORD Flags
  2219. );
  2220. BOOL
  2221. SxspDeleteShortNamesInRegistry(
  2222. VOID
  2223. );
  2224. STDAPI
  2225. DllInstall(
  2226. BOOL fInstall,
  2227. PCWSTR pszCmdLine
  2228. );
  2229. #define SXSP_OFFLINE_INSTALL_REFRESH_PROMPT_PLACEHOLDER L"(offline setup placeholder {b3759bd6-4503-4856-8518-109b9791855e})"
  2230. #define SXS_INSTALL_REFERENCE_SCHEME_OSINSTALL_STRING L"OS"
  2231. #endif // !defined(_FUSION_DLL_WHISTLER_SXSP_H_INCLUDED_)