Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2583 lines
82 KiB

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