Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

329 lines
12 KiB

  1. #pragma once
  2. #ifdef __cplusplus
  3. extern "C" {
  4. #endif
  5. typedef enum {
  6. eManifestState_DocumentRoot = 0,
  7. eManifestState_assembly,
  8. eManifestState_assembly_assemblyIdentity,
  9. eManifestState_assembly_description,
  10. eManifestState_assembly_dependency,
  11. eManifestState_assembly_file,
  12. eManifestState_assembly_noInherit,
  13. eManifestState_assembly_noInheritable,
  14. eManifestState_assembly_comInterfaceExternalProxyStub,
  15. eManifestState_assembly_dependency_dependentAssembly,
  16. eManifestState_assembly_dependency_dependentAssembly_assemblyIdentity,
  17. eManifestState_assembly_dependency_dependentAssembly_bindingRedirect,
  18. eManifestState_assembly_file_windowClass,
  19. eManifestState_assembly_file_comClass,
  20. eManifestState_assembly_file_typelib,
  21. eManifestState_assembly_file_comInterfaceProxyStub,
  22. eManifestState_assembly_file_comClass_progId,
  23. //
  24. // All this defines the structure of an XMLDSIG <Signature> block
  25. // for validationd
  26. //
  27. eManifestState_Signature,
  28. eManifestState_Signature_SignatureValue,
  29. eManifestState_Signature_SignedInfo,
  30. eManifestState_Signature_SignedInfo_CanonicalizationMethod,
  31. eManifestState_Signature_SignedInfo_SignatureMethod,
  32. eManifestState_Signature_SignedInfo_Reference,
  33. eManifestState_Signature_SignedInfo_Reference_Transforms,
  34. eManifestState_Signature_SignedInfo_Reference_DigestMethod,
  35. eManifestState_Signature_SignedInfo_Reference_DigestValue,
  36. eManifestState_Signature_KeyInfo,
  37. eManifestState_Signature_KeyInfo_KeyName,
  38. eManifestState_Signature_KeyInfo_KeyValue,
  39. eManifestState_Signature_KeyInfo_KeyValue_DSAKeyValue,
  40. eManifestState_Signature_KeyInfo_KeyValue_DSAKeyValue_P,
  41. eManifestState_Signature_KeyInfo_KeyValue_DSAKeyValue_Q,
  42. eManifestState_Signature_KeyInfo_KeyValue_DSAKeyValue_G,
  43. eManifestState_Signature_KeyInfo_KeyValue_DSAKeyValue_Y,
  44. eManifestState_Signature_KeyInfo_KeyValue_DSAKeyValue_J,
  45. eManifestState_Signature_KeyInfo_KeyValue_DSAKeyValue_Seed,
  46. eManifestState_Signature_KeyInfo_KeyValue_DSAKeyValue_PgenCounter,
  47. eManifestState_Signature_KeyInfo_KeyValue_RSAKeyValue,
  48. eManifestState_Signature_KeyInfo_KeyValue_RSAKeyValue_Modulus,
  49. eManifestState_Signature_KeyInfo_KeyValue_RSAKeyValue_Exponent,
  50. eManifestState_Signature_Object,
  51. eManifestState_State_Count
  52. } MANIFEST_PARSE_STATE;
  53. typedef struct _tagASSEMBLY_MEMBER_FILE_RAW {
  54. XML_EXTENT FileName;
  55. XML_EXTENT HashAlg;
  56. XML_EXTENT HashValue;
  57. XML_EXTENT LoadFrom;
  58. XML_EXTENT DigestMethod;
  59. XML_EXTENT Size;
  60. } ASSEMBLY_MEMBER_FILE_RAW, *PASSEMBLY_MEMBER_FILE_RAW;
  61. typedef struct _tagCOMINTERFACE_REDIRECTION_RAW {
  62. ULONG ulFileTag;
  63. XML_EXTENT Iid;
  64. XML_EXTENT Name;
  65. XML_EXTENT TlbId;
  66. XML_EXTENT MethodCount;
  67. XML_EXTENT ProxyStubClsid32;
  68. XML_EXTENT BaseInterface;
  69. } COMINTERFACE_REDIRECTION_RAW, *PCOMINTERFACE_REDIRECTION_RAW;
  70. typedef struct _tagCOMCLASS_REDIRECTION_RAW {
  71. ULONG ulFileTag;
  72. XML_EXTENT Description;
  73. XML_EXTENT clsid;
  74. XML_EXTENT tlbident;
  75. XML_EXTENT ThreadModel;
  76. XML_EXTENT DefaultProgid;
  77. } COMCLASS_REDIRECTION_RAW, *PCOMCLASS_REDIRECTION_RAW;
  78. typedef struct _tagCOMCLASS_PROGID_RAW {
  79. ULONG ulComClass;
  80. XML_EXTENT ProgId;
  81. } COMCLASS_PROGID_RAW, *PCOMCLASS_PROGID_RAW;
  82. typedef struct _tagWINDOWCLASS_REDIRECT_RAW {
  83. ULONG ulFileTag;
  84. XML_EXTENT WindowClass;
  85. XML_EXTENT Versioned;
  86. } WINDOWCLASS_REDIRECTION_RAW, *PWINDOWCLASS_REDIRECTION_RAW;
  87. typedef struct _tagTYPELIB_REDIRECT_RAW {
  88. ULONG ulFileTag;
  89. XML_EXTENT tlbident;
  90. XML_EXTENT Version;
  91. XML_EXTENT HelpDirectory;
  92. XML_EXTENT ResourceIdent;
  93. XML_EXTENT Flags;
  94. } TYPELIB_REDIRECT_RAW, *PTYPELIB_REDIRECT_RAW;
  95. typedef struct _tagASSEMBLY_IDENTITY_ATTRIBUTE_RAW {
  96. ULONG ulIdentityIndex;
  97. XML_EXTENT Namespace;
  98. XML_EXTENT Attribute;
  99. XML_EXTENT Value;
  100. } ASSEMBLY_IDENTITY_ATTRIBUTE_RAW, *PASSEMBLY_IDENTITY_ATTRIBUTE_RAW;
  101. #define MANIFEST_CONTENT_SELF_ALLOCATED (0x80000000)
  102. #define INVALID_ASSEMBLY_IDENTITY_INDEX ((ULONG)-1)
  103. typedef struct _tagRTL_MANIFEST_CONTENT_RAW {
  104. ULONG ulFlags;
  105. ULONG ulFileMembers;
  106. ULONG ulWindowClasses;
  107. ULONG ulComClasses;
  108. ULONG ulTypeLibraries;
  109. ULONG ulInterfaceProxyStubs;
  110. ULONG ulExternalInterfaceProxyStubs;
  111. ULONG ulDocumentSignatures;
  112. // How many assembly identity attributes did we find?
  113. ULONG ulAssemblyIdentityAttributes;
  114. // How many assembly identities is that total?
  115. ULONG ulAssemblyIdentitiesFound;
  116. // And which one is the 'root' identity element? (-1 if not present)
  117. ULONG ulRootIdentityIndex;
  118. RTL_GROWING_LIST FileMembers;
  119. RTL_GROWING_LIST AssemblyIdentityAttributes;
  120. PRTL_GROWING_LIST pWindowClasses;
  121. PRTL_GROWING_LIST pComClasses;
  122. PRTL_GROWING_LIST pTypeLibraries;
  123. PRTL_GROWING_LIST pInterfaceProxyStubs;
  124. PRTL_GROWING_LIST pExternalInterfaceProxyStubs;
  125. PRTL_GROWING_LIST pManifestSignatures;
  126. PRTL_GROWING_LIST pProgIds;
  127. } RTL_MANIFEST_CONTENT_RAW, *PRTL_MANIFEST_CONTENT_RAW;
  128. NTSTATUS
  129. RtlInspectManifestStream(
  130. ULONG ulFlags,
  131. PVOID pvManifest,
  132. SIZE_T cbManifest,
  133. PRTL_MANIFEST_CONTENT_RAW pContent,
  134. PXML_TOKENIZATION_STATE pTargetTokenState
  135. );
  136. EXTERN_C const XML_SPECIAL_STRING sc_ss_xmldecl_version_10;
  137. EXTERN_C const XML_SPECIAL_STRING sc_ss_xmldecl_yes;
  138. EXTERN_C const XML_SPECIAL_STRING sc_ss_xmlnamespace_default;
  139. NTSTATUS
  140. RtlSxsInitializeManifestRawContent(
  141. ULONG ulRequestedContent,
  142. PRTL_MANIFEST_CONTENT_RAW *pRawContentOut,
  143. PVOID pvOriginalBuffer,
  144. SIZE_T cbOriginalBuffer
  145. );
  146. NTSTATUS
  147. RtlSxsDestroyManifestContent(
  148. PRTL_MANIFEST_CONTENT_RAW pRawContent
  149. );
  150. //
  151. // This section gives definitions for how to describe an XML document to
  152. // be processed in a nicely generic way. Currently the only client of these definitions
  153. // is the manifest inspector itself, but one can imagine using these to create
  154. // recognizers for various xml document formats.
  155. //
  156. typedef NTSTATUS (*pfnRtlXmlValidateAttributeValue)(
  157. ULONG ulFlags,
  158. PXML_TOKENIZATION_STATE LogicalState,
  159. PRTL_MANIFEST_CONTENT_RAW RawContentBlob,
  160. const struct _XML_ELEMENT_DEFINITION* ParentElement,
  161. const struct _XML_VALID_ELEMENT_ATTRIBUTE* CurrentAttribDef,
  162. BOOLEAN *IsValid
  163. );
  164. #define XML_ATTRIBUTE_FLAG_REQUIRED (0x00000001)
  165. typedef struct _XML_VALID_ELEMENT_ATTRIBUTE
  166. {
  167. ULONG ulFlags;
  168. XML_ATTRIBUTE_DEFINITION Attribute;
  169. pfnRtlXmlValidateAttributeValue pfnValidator;
  170. } XML_VALID_ELEMENT_ATTRIBUTE, *PXML_VALID_ELEMENT_ATTRIBUTE;
  171. typedef const XML_VALID_ELEMENT_ATTRIBUTE *PCXML_VALID_ELEMENT_ATTRIBUTE;
  172. // This element must not contain non-whitespace PCData
  173. #define XML_ELEMENT_FLAG_NO_PCDATA (0x00000001)
  174. // This element must not contain children of any sort
  175. #define XML_ELEMENT_FLAG_NO_ELEMENTS (0x00000002)
  176. // Allow arbitrary attributes on this element, not just those defined
  177. #define XML_ELEMENT_FLAG_ALLOW_ANY_ATTRIBUTES (0x00000004)
  178. // Allow arbitrary children of this element, not just those defined
  179. // (Child elements will not be sent to the notification function)
  180. #define XML_ELEMENT_FLAG_ALLOW_ANY_CHILDREN (0x00000008)
  181. typedef enum {
  182. eElementNotify_Open,
  183. eElementNotify_Close,
  184. eElementNotify_Hyperspace
  185. } MANIFEST_ELEMENT_CALLBACK_REASON;
  186. typedef NTSTATUS (*pfnManifestElementCallback)(
  187. PXML_LOGICAL_STATE pLogicalState,
  188. PRTL_MANIFEST_CONTENT_RAW pManifestContent,
  189. PXMLDOC_THING pElement,
  190. PRTL_GROWING_LIST pAttributes,
  191. MANIFEST_ELEMENT_CALLBACK_REASON Reason,
  192. const struct _XML_ELEMENT_DEFINITION *pElementDefinition
  193. );
  194. #pragma warning(disable:4200)
  195. typedef struct _XML_ELEMENT_DEFINITION
  196. {
  197. ULONG ulFlags;
  198. ULONG StateIdentifier;
  199. const struct _XML_ELEMENT_DEFINITION *ParentElement;
  200. // The name of this element (not path, just name)
  201. PCXML_SPECIAL_STRING Namespace;
  202. const XML_SPECIAL_STRING Name;
  203. //
  204. // Who should be notified?
  205. //
  206. pfnManifestElementCallback pfnWorkerCallback;
  207. //
  208. // The children of this element, terminated with a NULL pointer.
  209. //
  210. const struct _XML_ELEMENT_DEFINITION **ChildElements;
  211. //
  212. // Potential attributes of this element
  213. //
  214. ULONG AttributeCount;
  215. const XML_VALID_ELEMENT_ATTRIBUTE AttributeList[];
  216. }
  217. XML_ELEMENT_DEFINITION, *PXML_ELEMENT_DEFINITION;
  218. typedef const XML_ELEMENT_DEFINITION *PCXML_ELEMENT_DEFINITION;
  219. #define ELEMENT_DEFINITION_NS(parentpath, thisname, ns, validator, flags) \
  220. extern PCXML_ELEMENT_DEFINITION rgs_Element_##parentpath##_##thisname##_Children[]; \
  221. XML_ELEMENT_DEFINITION rgs_Element_##parentpath##_##thisname = { \
  222. (flags), \
  223. eManifestState_##parentpath##_##thisname, \
  224. &rgs_Element_##parentpath, \
  225. &ns, \
  226. MAKE_SPECIAL_STRING(#thisname), \
  227. (validator), \
  228. rgs_Element_##parentpath##_##thisname##_Children, \
  229. eAttribs_##parentpath##_##thisname##_Count, \
  230. {
  231. #define ELEMENT_DEFINITION_DEFNS(parentpath, thisname, validator, flags) ELEMENT_DEFINITION_NS(parentpath, thisname, sc_ss_xmlnamespace_default, validator, flags)
  232. #define ELEMENT_DEFINITION_DEFNS_END() } };
  233. #define ELEMENT_DEFINITION_DEFNS_NOCB(p, t) ELEMENT_DEFINITION_DEFNS(p, t, Rtl_Default_Validator)
  234. #define ATTRIBUTE_DEFINITION_NONS_NODEFAULT(attribname) { XML_ATTRIBUTE_FLAG_REQUIRED, { NULL, MAKE_SPECIAL_STRING(#attribname) } }
  235. #define ATTRIBUTE_DEFINITION_NONS_NODEFAULT_OPTIONAL(attribname) { 0, { NULL, MAKE_SPECIAL_STRING(#attribname) } }
  236. #define NO_CHILD_ELEMENTS()
  237. #define ELEMENT_DEFINITION_CHILD_ELEMENTS(parentpath, thisname) PCXML_ELEMENT_DEFINITION rgs_Element_##parentpath##_##thisname##_Children[] = {
  238. #define ELEMENT_CHILD(path, child) (&rgs_Element_##path##_##child)
  239. #define ELEMENT_DEFINITION_CHILD_ELEMENTS_END() NULL };
  240. #define ELEMENT_NAMED(path) (&rgs_Element_##path)
  241. #define DECLARE_ELEMENT(path) \
  242. extern PCXML_ELEMENT_DEFINITION rgs_Element_##path##_Children[]; \
  243. extern XML_ELEMENT_DEFINITION rgs_Element_##path
  244. NTSTATUS
  245. RtlConvertRawToCookedContent(
  246. PRTL_MANIFEST_CONTENT_RAW pRawContent,
  247. PXML_RAWTOKENIZATION_STATE pState,
  248. PVOID pvOriginalRegion,
  249. SIZE_T cbRegionSize,
  250. PSIZE_T pcbRequired
  251. );
  252. NTSTATUS
  253. RtlValidateAttributesAndOrganize(
  254. PXML_TOKENIZATION_STATE State,
  255. PXMLDOC_ELEMENT Element,
  256. PRTL_GROWING_LIST Attributes,
  257. PCXML_ELEMENT_DEFINITION ThisElement,
  258. PXMLDOC_ATTRIBUTE *OrderedList
  259. );
  260. #ifdef __cplusplus
  261. };
  262. #endif