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.

1582 lines
75 KiB

  1. // ==++==
  2. //
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. //
  5. // ==--==
  6. /*****************************************************************************
  7. ** **
  8. ** CorHdr.h - contains definitions for the Runtime structures, **
  9. ** needed to work with metadata. **
  10. ** **
  11. *****************************************************************************/
  12. #ifndef __CORHDR_H__
  13. #define __CORHDR_H__
  14. #define FRAMEWORK_REGISTRY_KEY "Software\\Microsoft\\.NETFramework"
  15. #define FRAMEWORK_REGISTRY_KEY_W L"Software\\Microsoft\\.NETFramework"
  16. #pragma warning(disable:4200) // nonstandard extension used : zero-sized array in struct/union.
  17. typedef LPVOID mdScope; // Why is this still needed?
  18. typedef ULONG32 mdToken; // Generic token
  19. // Token definitions
  20. typedef mdToken mdModule; // Module token (roughly, a scope)
  21. typedef mdToken mdTypeRef; // TypeRef reference (this or other scope)
  22. typedef mdToken mdTypeDef; // TypeDef in this scope
  23. typedef mdToken mdFieldDef; // Field in this scope
  24. typedef mdToken mdMethodDef; // Method in this scope
  25. typedef mdToken mdParamDef; // param token
  26. typedef mdToken mdInterfaceImpl; // interface implementation token
  27. typedef mdToken mdMemberRef; // MemberRef (this or other scope)
  28. typedef mdToken mdCustomAttribute; // attribute token
  29. typedef mdToken mdPermission; // DeclSecurity
  30. typedef mdToken mdSignature; // Signature object
  31. typedef mdToken mdEvent; // event token
  32. typedef mdToken mdProperty; // property token
  33. typedef mdToken mdModuleRef; // Module reference (for the imported modules)
  34. // Assembly tokens.
  35. typedef mdToken mdAssembly; // Assembly token.
  36. typedef mdToken mdAssemblyRef; // AssemblyRef token.
  37. typedef mdToken mdFile; // File token.
  38. typedef mdToken mdExportedType; // ExportedType token.
  39. typedef mdToken mdManifestResource; // ManifestResource token.
  40. typedef mdToken mdTypeSpec; // TypeSpec object
  41. // Application string.
  42. typedef mdToken mdString; // User literal string token.
  43. typedef mdToken mdCPToken; // constantpool token
  44. #ifndef MACROS_NOT_SUPPORTED
  45. typedef unsigned long RID;
  46. #else
  47. typedef unsigned RID;
  48. #endif // MACROS_NOT_SUPPORTED
  49. typedef enum ReplacesGeneralNumericDefines
  50. {
  51. // Directory entry macro for CLR data.
  52. #ifndef IMAGE_DIRECTORY_ENTRY_COMHEADER
  53. IMAGE_DIRECTORY_ENTRY_COMHEADER =14,
  54. #endif // IMAGE_DIRECTORY_ENTRY_COMHEADER
  55. _NEW_FLAGS_IMPLEMENTED =1,
  56. __NEW_FLAGS_IMPLEMENTED =1,
  57. } ReplacesGeneralNumericDefines;
  58. // @TODO: This hack is required because we pull in the COM+ 2.0 PE header
  59. // definition from winnt.h, and the flag below hasn't propogated yet.
  60. #define COMIMAGE_FLAGS_STRONGNAMESIGNED 0x00000008
  61. #ifndef __IMAGE_COR20_HEADER_DEFINED__
  62. #define __IMAGE_COR20_HEADER_DEFINED__
  63. typedef enum ReplacesCorHdrNumericDefines
  64. {
  65. // CLR Header entry point flags.
  66. COMIMAGE_FLAGS_ILONLY =0x00000001,
  67. COMIMAGE_FLAGS_32BITREQUIRED =0x00000002,
  68. COMIMAGE_FLAGS_IL_LIBRARY =0x00000004,
  69. COMIMAGE_FLAGS_TRACKDEBUGDATA =0x00010000,
  70. // Version flags for image.
  71. COR_VERSION_MAJOR_V2 =2,
  72. COR_VERSION_MAJOR =COR_VERSION_MAJOR_V2,
  73. COR_VERSION_MINOR =0,
  74. COR_DELETED_NAME_LENGTH =8,
  75. COR_VTABLEGAP_NAME_LENGTH =8,
  76. // Maximum size of a NativeType descriptor.
  77. NATIVE_TYPE_MAX_CB =1,
  78. COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE=0xFF,
  79. // #defines for the MIH FLAGS
  80. IMAGE_COR_MIH_METHODRVA =0x01,
  81. IMAGE_COR_MIH_EHRVA =0x02,
  82. IMAGE_COR_MIH_BASICBLOCK =0x08,
  83. // V-table constants
  84. COR_VTABLE_32BIT =0x01, // V-table slots are 32-bits in size.
  85. COR_VTABLE_64BIT =0x02, // V-table slots are 64-bits in size.
  86. COR_VTABLE_FROM_UNMANAGED =0x04, // If set, transition from unmanaged.
  87. COR_VTABLE_CALL_MOST_DERIVED =0x10, // Call most derived method described by
  88. // EATJ constants
  89. IMAGE_COR_EATJ_THUNK_SIZE =32, // Size of a jump thunk reserved range.
  90. // Max name lengths
  91. MAX_CLASS_NAME =1024,
  92. MAX_PACKAGE_NAME =1024,
  93. } ReplacesCorHdrNumericDefines;
  94. // CLR 2.0 header structure.
  95. typedef struct IMAGE_COR20_HEADER
  96. {
  97. // Header versioning
  98. ULONG cb;
  99. USHORT MajorRuntimeVersion;
  100. USHORT MinorRuntimeVersion;
  101. // Symbol table and startup information
  102. IMAGE_DATA_DIRECTORY MetaData;
  103. ULONG Flags;
  104. ULONG EntryPointToken;
  105. // Binding information
  106. IMAGE_DATA_DIRECTORY Resources;
  107. IMAGE_DATA_DIRECTORY StrongNameSignature;
  108. // Regular fixup and binding information
  109. IMAGE_DATA_DIRECTORY CodeManagerTable;
  110. IMAGE_DATA_DIRECTORY VTableFixups;
  111. IMAGE_DATA_DIRECTORY ExportAddressTableJumps;
  112. // Precompiled image info (internal use only - set to zero)
  113. IMAGE_DATA_DIRECTORY ManagedNativeHeader;
  114. } IMAGE_COR20_HEADER;
  115. #endif // __IMAGE_COR20_HEADER_DEFINED__
  116. // The most recent version.
  117. #define COR_CTOR_METHOD_NAME ".ctor"
  118. #define COR_CTOR_METHOD_NAME_W L".ctor"
  119. #define COR_CCTOR_METHOD_NAME ".cctor"
  120. #define COR_CCTOR_METHOD_NAME_W L".cctor"
  121. #define COR_ENUM_FIELD_NAME "value__"
  122. #define COR_ENUM_FIELD_NAME_W L"value__"
  123. // The predefined name for deleting a typeDef,MethodDef, FieldDef, Property and Event
  124. #define COR_DELETED_NAME_A "_Deleted"
  125. #define COR_DELETED_NAME_W L"_Deleted"
  126. #define COR_VTABLEGAP_NAME_A "_VtblGap"
  127. #define COR_VTABLEGAP_NAME_W L"_VtblGap"
  128. // We intentionally use strncmp so that we will ignore any suffix
  129. #define IsDeletedName(strName) (strncmp(strName, COR_DELETED_NAME_A, COR_DELETED_NAME_LENGTH) == 0)
  130. #define IsVtblGapName(strName) (strncmp(strName, COR_VTABLEGAP_NAME_A, COR_VTABLEGAP_NAME_LENGTH) == 0)
  131. // TypeDef/ExportedType attr bits, used by DefineTypeDef.
  132. typedef enum CorTypeAttr
  133. {
  134. // Use this mask to retrieve the type visibility information.
  135. tdVisibilityMask = 0x00000007,
  136. tdNotPublic = 0x00000000, // Class is not public scope.
  137. tdPublic = 0x00000001, // Class is public scope.
  138. tdNestedPublic = 0x00000002, // Class is nested with public visibility.
  139. tdNestedPrivate = 0x00000003, // Class is nested with private visibility.
  140. tdNestedFamily = 0x00000004, // Class is nested with family visibility.
  141. tdNestedAssembly = 0x00000005, // Class is nested with assembly visibility.
  142. tdNestedFamANDAssem = 0x00000006, // Class is nested with family and assembly visibility.
  143. tdNestedFamORAssem = 0x00000007, // Class is nested with family or assembly visibility.
  144. // Use this mask to retrieve class layout information
  145. tdLayoutMask = 0x00000018,
  146. tdAutoLayout = 0x00000000, // Class fields are auto-laid out
  147. tdSequentialLayout = 0x00000008, // Class fields are laid out sequentially
  148. tdExplicitLayout = 0x00000010, // Layout is supplied explicitly
  149. // end layout mask
  150. // Use this mask to retrieve class semantics information.
  151. tdClassSemanticsMask = 0x00000020,
  152. tdClass = 0x00000000, // Type is a class.
  153. tdInterface = 0x00000020, // Type is an interface.
  154. // end semantics mask
  155. // Special semantics in addition to class semantics.
  156. tdAbstract = 0x00000080, // Class is abstract
  157. tdSealed = 0x00000100, // Class is concrete and may not be extended
  158. tdSpecialName = 0x00000400, // Class name is special. Name describes how.
  159. // Implementation attributes.
  160. tdImport = 0x00001000, // Class / interface is imported
  161. tdSerializable = 0x00002000, // The class is Serializable.
  162. // Use tdStringFormatMask to retrieve string information for native interop
  163. tdStringFormatMask = 0x00030000,
  164. tdAnsiClass = 0x00000000, // LPTSTR is interpreted as ANSI in this class
  165. tdUnicodeClass = 0x00010000, // LPTSTR is interpreted as UNICODE
  166. tdAutoClass = 0x00020000, // LPTSTR is interpreted automatically
  167. // end string format mask
  168. tdBeforeFieldInit = 0x00100000, // Initialize the class any time before first static field access.
  169. // Flags reserved for runtime use.
  170. tdReservedMask = 0x00040800,
  171. tdRTSpecialName = 0x00000800, // Runtime should check name encoding.
  172. tdHasSecurity = 0x00040000, // Class has security associate with it.
  173. } CorTypeAttr;
  174. // Macros for accessing the members of the CorTypeAttr.
  175. #define IsTdNotPublic(x) (((x) & tdVisibilityMask) == tdNotPublic)
  176. #define IsTdPublic(x) (((x) & tdVisibilityMask) == tdPublic)
  177. #define IsTdNestedPublic(x) (((x) & tdVisibilityMask) == tdNestedPublic)
  178. #define IsTdNestedPrivate(x) (((x) & tdVisibilityMask) == tdNestedPrivate)
  179. #define IsTdNestedFamily(x) (((x) & tdVisibilityMask) == tdNestedFamily)
  180. #define IsTdNestedAssembly(x) (((x) & tdVisibilityMask) == tdNestedAssembly)
  181. #define IsTdNestedFamANDAssem(x) (((x) & tdVisibilityMask) == tdNestedFamANDAssem)
  182. #define IsTdNestedFamORAssem(x) (((x) & tdVisibilityMask) == tdNestedFamORAssem)
  183. #define IsTdNested(x) (((x) & tdVisibilityMask) >= tdNestedPublic)
  184. #define IsTdAutoLayout(x) (((x) & tdLayoutMask) == tdAutoLayout)
  185. #define IsTdSequentialLayout(x) (((x) & tdLayoutMask) == tdSequentialLayout)
  186. #define IsTdExplicitLayout(x) (((x) & tdLayoutMask) == tdExplicitLayout)
  187. #define IsTdClass(x) (((x) & tdClassSemanticsMask) == tdClass)
  188. #define IsTdInterface(x) (((x) & tdClassSemanticsMask) == tdInterface)
  189. #define IsTdAbstract(x) ((x) & tdAbstract)
  190. #define IsTdSealed(x) ((x) & tdSealed)
  191. #define IsTdSpecialName(x) ((x) & tdSpecialName)
  192. #define IsTdImport(x) ((x) & tdImport)
  193. #define IsTdSerializable(x) ((x) & tdSerializable)
  194. #define IsTdAnsiClass(x) (((x) & tdStringFormatMask) == tdAnsiClass)
  195. #define IsTdUnicodeClass(x) (((x) & tdStringFormatMask) == tdUnicodeClass)
  196. #define IsTdAutoClass(x) (((x) & tdStringFormatMask) == tdAutoClass)
  197. #define IsTdBeforeFieldInit(x) ((x) & tdBeforeFieldInit)
  198. #define IsTdRTSpecialName(x) ((x) & tdRTSpecialName)
  199. #define IsTdHasSecurity(x) ((x) & tdHasSecurity)
  200. // MethodDef attr bits, Used by DefineMethod.
  201. typedef enum CorMethodAttr
  202. {
  203. // member access mask - Use this mask to retrieve accessibility information.
  204. mdMemberAccessMask = 0x0007,
  205. mdPrivateScope = 0x0000, // Member not referenceable.
  206. mdPrivate = 0x0001, // Accessible only by the parent type.
  207. mdFamANDAssem = 0x0002, // Accessible by sub-types only in this Assembly.
  208. mdAssem = 0x0003, // Accessibly by anyone in the Assembly.
  209. mdFamily = 0x0004, // Accessible only by type and sub-types.
  210. mdFamORAssem = 0x0005, // Accessibly by sub-types anywhere, plus anyone in assembly.
  211. mdPublic = 0x0006, // Accessibly by anyone who has visibility to this scope.
  212. // end member access mask
  213. // method contract attributes.
  214. mdStatic = 0x0010, // Defined on type, else per instance.
  215. mdFinal = 0x0020, // Method may not be overridden.
  216. mdVirtual = 0x0040, // Method virtual.
  217. mdHideBySig = 0x0080, // Method hides by name+sig, else just by name.
  218. // vtable layout mask - Use this mask to retrieve vtable attributes.
  219. mdVtableLayoutMask = 0x0100,
  220. mdReuseSlot = 0x0000, // The default.
  221. mdNewSlot = 0x0100, // Method always gets a new slot in the vtable.
  222. // end vtable layout mask
  223. // method implementation attributes.
  224. mdAbstract = 0x0400, // Method does not provide an implementation.
  225. mdSpecialName = 0x0800, // Method is special. Name describes how.
  226. // interop attributes
  227. mdPinvokeImpl = 0x2000, // Implementation is forwarded through pinvoke.
  228. mdUnmanagedExport = 0x0008, // Managed method exported via thunk to unmanaged code.
  229. // Reserved flags for runtime use only.
  230. mdReservedMask = 0xd000,
  231. mdRTSpecialName = 0x1000, // Runtime should check name encoding.
  232. mdHasSecurity = 0x4000, // Method has security associate with it.
  233. mdRequireSecObject = 0x8000, // Method calls another method containing security code.
  234. } CorMethodAttr;
  235. // Macros for accessing the members of CorMethodAttr.
  236. #define IsMdPrivateScope(x) (((x) & mdMemberAccessMask) == mdPrivateScope)
  237. #define IsMdPrivate(x) (((x) & mdMemberAccessMask) == mdPrivate)
  238. #define IsMdFamANDAssem(x) (((x) & mdMemberAccessMask) == mdFamANDAssem)
  239. #define IsMdAssem(x) (((x) & mdMemberAccessMask) == mdAssem)
  240. #define IsMdFamily(x) (((x) & mdMemberAccessMask) == mdFamily)
  241. #define IsMdFamORAssem(x) (((x) & mdMemberAccessMask) == mdFamORAssem)
  242. #define IsMdPublic(x) (((x) & mdMemberAccessMask) == mdPublic)
  243. #define IsMdStatic(x) ((x) & mdStatic)
  244. #define IsMdFinal(x) ((x) & mdFinal)
  245. #define IsMdVirtual(x) ((x) & mdVirtual)
  246. #define IsMdHideBySig(x) ((x) & mdHideBySig)
  247. #define IsMdReuseSlot(x) (((x) & mdVtableLayoutMask) == mdReuseSlot)
  248. #define IsMdNewSlot(x) (((x) & mdVtableLayoutMask) == mdNewSlot)
  249. #define IsMdAbstract(x) ((x) & mdAbstract)
  250. #define IsMdSpecialName(x) ((x) & mdSpecialName)
  251. #define IsMdPinvokeImpl(x) ((x) & mdPinvokeImpl)
  252. #define IsMdUnmanagedExport(x) ((x) & mdUnmanagedExport)
  253. #define IsMdRTSpecialName(x) ((x) & mdRTSpecialName)
  254. #define IsMdInstanceInitializer(x, str) (((x) & mdRTSpecialName) && !strcmp((str), COR_CTOR_METHOD_NAME))
  255. #define IsMdInstanceInitializerW(x, str) (((x) & mdRTSpecialName) && !wcscmp((str), COR_CTOR_METHOD_NAME_W))
  256. #define IsMdClassConstructor(x, str) (((x) & mdRTSpecialName) && !strcmp((str), COR_CCTOR_METHOD_NAME))
  257. #define IsMdClassConstructorW(x, str) (((x) & mdRTSpecialName) && !wcscmp((str), COR_CCTOR_METHOD_NAME_W))
  258. #define IsMdHasSecurity(x) ((x) & mdHasSecurity)
  259. #define IsMdRequireSecObject(x) ((x) & mdRequireSecObject)
  260. // FieldDef attr bits, used by DefineField.
  261. typedef enum CorFieldAttr
  262. {
  263. // member access mask - Use this mask to retrieve accessibility information.
  264. fdFieldAccessMask = 0x0007,
  265. fdPrivateScope = 0x0000, // Member not referenceable.
  266. fdPrivate = 0x0001, // Accessible only by the parent type.
  267. fdFamANDAssem = 0x0002, // Accessible by sub-types only in this Assembly.
  268. fdAssembly = 0x0003, // Accessibly by anyone in the Assembly.
  269. fdFamily = 0x0004, // Accessible only by type and sub-types.
  270. fdFamORAssem = 0x0005, // Accessibly by sub-types anywhere, plus anyone in assembly.
  271. fdPublic = 0x0006, // Accessibly by anyone who has visibility to this scope.
  272. // end member access mask
  273. // field contract attributes.
  274. fdStatic = 0x0010, // Defined on type, else per instance.
  275. fdInitOnly = 0x0020, // Field may only be initialized, not written to after init.
  276. fdLiteral = 0x0040, // Value is compile time constant.
  277. fdNotSerialized = 0x0080, // Field does not have to be serialized when type is remoted.
  278. fdSpecialName = 0x0200, // field is special. Name describes how.
  279. // interop attributes
  280. fdPinvokeImpl = 0x2000, // Implementation is forwarded through pinvoke.
  281. // Reserved flags for runtime use only.
  282. fdReservedMask = 0x9500,
  283. fdRTSpecialName = 0x0400, // Runtime(metadata internal APIs) should check name encoding.
  284. fdHasFieldMarshal = 0x1000, // Field has marshalling information.
  285. fdHasDefault = 0x8000, // Field has default.
  286. fdHasFieldRVA = 0x0100, // Field has RVA.
  287. } CorFieldAttr;
  288. // Macros for accessing the members of CorFieldAttr.
  289. #define IsFdPrivateScope(x) (((x) & fdFieldAccessMask) == fdPrivateScope)
  290. #define IsFdPrivate(x) (((x) & fdFieldAccessMask) == fdPrivate)
  291. #define IsFdFamANDAssem(x) (((x) & fdFieldAccessMask) == fdFamANDAssem)
  292. #define IsFdAssembly(x) (((x) & fdFieldAccessMask) == fdAssembly)
  293. #define IsFdFamily(x) (((x) & fdFieldAccessMask) == fdFamily)
  294. #define IsFdFamORAssem(x) (((x) & fdFieldAccessMask) == fdFamORAssem)
  295. #define IsFdPublic(x) (((x) & fdFieldAccessMask) == fdPublic)
  296. #define IsFdStatic(x) ((x) & fdStatic)
  297. #define IsFdInitOnly(x) ((x) & fdInitOnly)
  298. #define IsFdLiteral(x) ((x) & fdLiteral)
  299. #define IsFdNotSerialized(x) ((x) & fdNotSerialized)
  300. #define IsFdPinvokeImpl(x) ((x) & fdPinvokeImpl)
  301. #define IsFdSpecialName(x) ((x) & fdSpecialName)
  302. #define IsFdHasFieldRVA(x) ((x) & fdHasFieldRVA)
  303. #define IsFdRTSpecialName(x) ((x) & fdRTSpecialName)
  304. #define IsFdHasFieldMarshal(x) ((x) & fdHasFieldMarshal)
  305. #define IsFdHasDefault(x) ((x) & fdHasDefault)
  306. #define IsFdHasFieldRVA(x) ((x) & fdHasFieldRVA)
  307. // Param attr bits, used by DefineParam.
  308. typedef enum CorParamAttr
  309. {
  310. pdIn = 0x0001, // Param is [In]
  311. pdOut = 0x0002, // Param is [out]
  312. pdOptional = 0x0010, // Param is optional
  313. // Reserved flags for Runtime use only.
  314. pdReservedMask = 0xf000,
  315. pdHasDefault = 0x1000, // Param has default value.
  316. pdHasFieldMarshal = 0x2000, // Param has FieldMarshal.
  317. pdUnused = 0xcfe0,
  318. } CorParamAttr;
  319. // Macros for accessing the members of CorParamAttr.
  320. #define IsPdIn(x) ((x) & pdIn)
  321. #define IsPdOut(x) ((x) & pdOut)
  322. #define IsPdOptional(x) ((x) & pdOptional)
  323. #define IsPdHasDefault(x) ((x) & pdHasDefault)
  324. #define IsPdHasFieldMarshal(x) ((x) & pdHasFieldMarshal)
  325. // Property attr bits, used by DefineProperty.
  326. typedef enum CorPropertyAttr
  327. {
  328. prSpecialName = 0x0200, // property is special. Name describes how.
  329. // Reserved flags for Runtime use only.
  330. prReservedMask = 0xf400,
  331. prRTSpecialName = 0x0400, // Runtime(metadata internal APIs) should check name encoding.
  332. prHasDefault = 0x1000, // Property has default
  333. prUnused = 0xe9ff,
  334. } CorPropertyAttr;
  335. // Macros for accessing the members of CorPropertyAttr.
  336. #define IsPrSpecialName(x) ((x) & prSpecialName)
  337. #define IsPrRTSpecialName(x) ((x) & prRTSpecialName)
  338. #define IsPrHasDefault(x) ((x) & prHasDefault)
  339. // Event attr bits, used by DefineEvent.
  340. typedef enum CorEventAttr
  341. {
  342. evSpecialName = 0x0200, // event is special. Name describes how.
  343. // Reserved flags for Runtime use only.
  344. evReservedMask = 0x0400,
  345. evRTSpecialName = 0x0400, // Runtime(metadata internal APIs) should check name encoding.
  346. } CorEventAttr;
  347. // Macros for accessing the members of CorEventAttr.
  348. #define IsEvSpecialName(x) ((x) & evSpecialName)
  349. #define IsEvRTSpecialName(x) ((x) & evRTSpecialName)
  350. // MethodSemantic attr bits, used by DefineProperty, DefineEvent.
  351. typedef enum CorMethodSemanticsAttr
  352. {
  353. msSetter = 0x0001, // Setter for property
  354. msGetter = 0x0002, // Getter for property
  355. msOther = 0x0004, // other method for property or event
  356. msAddOn = 0x0008, // AddOn method for event
  357. msRemoveOn = 0x0010, // RemoveOn method for event
  358. msFire = 0x0020, // Fire method for event
  359. } CorMethodSemanticsAttr;
  360. // Macros for accessing the members of CorMethodSemanticsAttr.
  361. #define IsMsSetter(x) ((x) & msSetter)
  362. #define IsMsGetter(x) ((x) & msGetter)
  363. #define IsMsOther(x) ((x) & msOther)
  364. #define IsMsAddOn(x) ((x) & msAddOn)
  365. #define IsMsRemoveOn(x) ((x) & msRemoveOn)
  366. #define IsMsFire(x) ((x) & msFire)
  367. // DeclSecurity attr bits, used by DefinePermissionSet.
  368. typedef enum CorDeclSecurity
  369. {
  370. dclActionMask = 0x000f, // Mask allows growth of enum.
  371. dclActionNil = 0x0000,
  372. dclRequest = 0x0001, //
  373. dclDemand = 0x0002, //
  374. dclAssert = 0x0003, //
  375. dclDeny = 0x0004, //
  376. dclPermitOnly = 0x0005, //
  377. dclLinktimeCheck = 0x0006, //
  378. dclInheritanceCheck = 0x0007, //
  379. dclRequestMinimum = 0x0008, //
  380. dclRequestOptional = 0x0009, //
  381. dclRequestRefuse = 0x000a, //
  382. dclPrejitGrant = 0x000b, // Persisted grant set at prejit time
  383. dclPrejitDenied = 0x000c, // Persisted denied set at prejit time
  384. dclNonCasDemand = 0x000d, //
  385. dclNonCasLinkDemand = 0x000e,
  386. dclNonCasInheritance= 0x000f,
  387. dclMaximumValue = 0x000f, // Maximum legal value
  388. } CorDeclSecurity;
  389. // Macros for accessing the members of CorDeclSecurity.
  390. #define IsDclActionNil(x) (((x) & dclActionMask) == dclActionNil)
  391. #define IsDclRequest(x) (((x) & dclActionMask) == dclRequest)
  392. #define IsDclDemand(x) (((x) & dclActionMask) == dclDemand)
  393. #define IsDclAssert(x) (((x) & dclActionMask) == dclAssert)
  394. #define IsDclDeny(x) (((x) & dclActionMask) == dclDeny)
  395. #define IsDclPermitOnly(x) (((x) & dclActionMask) == dclPermitOnly)
  396. #define IsDclLinktimeCheck(x) (((x) & dclActionMask) == dclLinktimeCheck)
  397. #define IsDclInheritanceCheck(x) (((x) & dclActionMask) == dclInheritanceCheck)
  398. #define IsDclMaximumValue(x) (((x) & dclActionMask) == dclMaximumValue)
  399. // MethodImpl attr bits, used by DefineMethodImpl.
  400. typedef enum CorMethodImpl
  401. {
  402. // code impl mask
  403. miCodeTypeMask = 0x0003, // Flags about code type.
  404. miIL = 0x0000, // Method impl is IL.
  405. miNative = 0x0001, // Method impl is native.
  406. miOPTIL = 0x0002, // Method impl is OPTIL
  407. miRuntime = 0x0003, // Method impl is provided by the runtime.
  408. // end code impl mask
  409. // managed mask
  410. miManagedMask = 0x0004, // Flags specifying whether the code is managed or unmanaged.
  411. miUnmanaged = 0x0004, // Method impl is unmanaged, otherwise managed.
  412. miManaged = 0x0000, // Method impl is managed.
  413. // end managed mask
  414. // implementation info and interop
  415. miForwardRef = 0x0010, // Indicates method is defined; used primarily in merge scenarios.
  416. miPreserveSig = 0x0080, // Indicates method sig is not to be mangled to do HRESULT conversion.
  417. miInternalCall = 0x1000, // Reserved for internal use.
  418. miSynchronized = 0x0020, // Method is single threaded through the body.
  419. miNoInlining = 0x0008, // Method may not be inlined.
  420. miMaxMethodImplVal = 0xffff, // Range check value
  421. } CorMethodImpl;
  422. // Macros for accesing the members of CorMethodImpl.
  423. #define IsMiIL(x) (((x) & miCodeTypeMask) == miIL)
  424. #define IsMiNative(x) (((x) & miCodeTypeMask) == miNative)
  425. #define IsMiOPTIL(x) (((x) & miCodeTypeMask) == miOPTIL)
  426. #define IsMiRuntime(x) (((x) & miCodeTypeMask) == miRuntime)
  427. #define IsMiUnmanaged(x) (((x) & miManagedMask) == miUnmanaged)
  428. #define IsMiManaged(x) (((x) & miManagedMask) == miManaged)
  429. #define IsMiForwardRef(x) ((x) & miForwardRef)
  430. #define IsMiPreserveSig(x) ((x) & miPreserveSig)
  431. #define IsMiInternalCall(x) ((x) & miInternalCall)
  432. #define IsMiSynchronized(x) ((x) & miSynchronized)
  433. #define IsMiNoInlining(x) ((x) & miNoInlining)
  434. // PinvokeMap attr bits, used by DefinePinvokeMap.
  435. typedef enum CorPinvokeMap
  436. {
  437. pmNoMangle = 0x0001, // Pinvoke is to use the member name as specified.
  438. // Use this mask to retrieve the CharSet information.
  439. pmCharSetMask = 0x0006,
  440. pmCharSetNotSpec = 0x0000,
  441. pmCharSetAnsi = 0x0002,
  442. pmCharSetUnicode = 0x0004,
  443. pmCharSetAuto = 0x0006,
  444. pmSupportsLastError = 0x0040, // Information about target function. Not relevant for fields.
  445. // None of the calling convention flags is relevant for fields.
  446. pmCallConvMask = 0x0700,
  447. pmCallConvWinapi = 0x0100, // Pinvoke will use native callconv appropriate to target windows platform.
  448. pmCallConvCdecl = 0x0200,
  449. pmCallConvStdcall = 0x0300,
  450. pmCallConvThiscall = 0x0400, // In M9, pinvoke will raise exception.
  451. pmCallConvFastcall = 0x0500,
  452. } CorPinvokeMap;
  453. // Macros for accessing the members of CorPinvokeMap
  454. #define IsPmNoMangle(x) ((x) & pmNoMangle)
  455. #define IsPmCharSetNotSpec(x) (((x) & pmCharSetMask) == pmCharSetNotSpec)
  456. #define IsPmCharSetAnsi(x) (((x) & pmCharSetMask) == pmCharSetAnsi)
  457. #define IsPmCharSetUnicode(x) (((x) & pmCharSetMask) == pmCharSetUnicode)
  458. #define IsPmCharSetAuto(x) (((x) & pmCharSetMask) == pmCharSetAuto)
  459. #define IsPmSupportsLastError(x) ((x) & pmSupportsLastError)
  460. #define IsPmCallConvWinapi(x) (((x) & pmCallConvMask) == pmCallConvWinapi)
  461. #define IsPmCallConvCdecl(x) (((x) & pmCallConvMask) == pmCallConvCdecl)
  462. #define IsPmCallConvStdcall(x) (((x) & pmCallConvMask) == pmCallConvStdcall)
  463. #define IsPmCallConvThiscall(x) (((x) & pmCallConvMask) == pmCallConvThiscall)
  464. #define IsPmCallConvFastcall(x) (((x) & pmCallConvMask) == pmCallConvFastcall)
  465. // Assembly attr bits, used by DefineAssembly.
  466. typedef enum CorAssemblyFlags
  467. {
  468. afPublicKey = 0x0001, // The assembly ref holds the full (unhashed) public key.
  469. afCompatibilityMask = 0x0070,
  470. afSideBySideCompatible = 0x0000, // The assembly is side by side compatible.
  471. afNonSideBySideAppDomain= 0x0010, // The assembly cannot execute with other versions if
  472. // they are executing in the same application domain.
  473. afNonSideBySideProcess = 0x0020, // The assembly cannot execute with other versions if
  474. // they are executing in the same process.
  475. afNonSideBySideMachine = 0x0030, // The assembly cannot execute with other versions if
  476. // they are executing on the same machine.
  477. afEnableJITcompileTracking = 0x8000, // From "DebuggableAttribute".
  478. afDisableJITcompileOptimizer= 0x4000, // From "DebuggableAttribute".
  479. } CorAssemblyFlags;
  480. // Macros for accessing the members of CorAssemblyFlags.
  481. #define IsAfSideBySideCompatible(x) (((x) & afCompatibilityMask) == afSideBySideCompatible)
  482. #define IsAfNonSideBySideAppDomain(x) (((x) & afCompatibilityMask) == afNonSideBySideAppDomain)
  483. #define IsAfNonSideBySideProcess(x) (((x) & afCompatibilityMask) == afNonSideBySideProcess)
  484. #define IsAfNonSideBySideMachine(x) (((x) & afCompatibilityMask) == afNonSideBySideMachine)
  485. #define IsAfEnableJITcompileTracking(x) ((x) & afEnableJITcompileTracking)
  486. #define IsAfDisableJITcompileOptimizer(x) ((x) & afDisableJITcompileOptimizer)
  487. // Macros for accessing the MemberRef members of CorAssemblyFlags.
  488. #define IsAfPublicKey(x) ((x) & afPublicKey)
  489. #define IsAfPublicKeyToken(x) (((x) & afPublicKey) == 0)
  490. // ManifestResource attr bits, used by DefineManifestResource.
  491. typedef enum CorManifestResourceFlags
  492. {
  493. mrVisibilityMask = 0x0007,
  494. mrPublic = 0x0001, // The Resource is exported from the Assembly.
  495. mrPrivate = 0x0002, // The Resource is private to the Assembly.
  496. } CorManifestResourceFlags;
  497. // Macros for accessing the members of CorManifestResourceFlags.
  498. #define IsMrPublic(x) (((x) & mrVisibilityMask) == mrPublic)
  499. #define IsMrPrivate(x) (((x) & mrVisibilityMask) == mrPrivate)
  500. // File attr bits, used by DefineFile.
  501. typedef enum CorFileFlags
  502. {
  503. ffContainsMetaData = 0x0000, // This is not a resource file
  504. ffContainsNoMetaData = 0x0001, // This is a resource file or other non-metadata-containing file
  505. } CorFileFlags;
  506. // Macros for accessing the members of CorFileFlags.
  507. #define IsFfContainsMetaData(x) (!((x) & ffContainsNoMetaData))
  508. #define IsFfContainsNoMetaData(x) ((x) & ffContainsNoMetaData)
  509. // structures and enums moved from COR.H
  510. typedef unsigned __int8 COR_SIGNATURE;
  511. typedef COR_SIGNATURE* PCOR_SIGNATURE; // pointer to a cor sig. Not void* so that
  512. // the bytes can be incremented easily
  513. typedef const COR_SIGNATURE* PCCOR_SIGNATURE;
  514. typedef const char * MDUTF8CSTR;
  515. typedef char * MDUTF8STR;
  516. //*****************************************************************************
  517. //
  518. // Element type for Cor signature
  519. //
  520. //*****************************************************************************
  521. typedef enum CorElementType
  522. {
  523. ELEMENT_TYPE_END = 0x0,
  524. ELEMENT_TYPE_VOID = 0x1,
  525. ELEMENT_TYPE_BOOLEAN = 0x2,
  526. ELEMENT_TYPE_CHAR = 0x3,
  527. ELEMENT_TYPE_I1 = 0x4,
  528. ELEMENT_TYPE_U1 = 0x5,
  529. ELEMENT_TYPE_I2 = 0x6,
  530. ELEMENT_TYPE_U2 = 0x7,
  531. ELEMENT_TYPE_I4 = 0x8,
  532. ELEMENT_TYPE_U4 = 0x9,
  533. ELEMENT_TYPE_I8 = 0xa,
  534. ELEMENT_TYPE_U8 = 0xb,
  535. ELEMENT_TYPE_R4 = 0xc,
  536. ELEMENT_TYPE_R8 = 0xd,
  537. ELEMENT_TYPE_STRING = 0xe,
  538. // every type above PTR will be simple type
  539. ELEMENT_TYPE_PTR = 0xf, // PTR <type>
  540. ELEMENT_TYPE_BYREF = 0x10, // BYREF <type>
  541. // Please use ELEMENT_TYPE_VALUETYPE. ELEMENT_TYPE_VALUECLASS is deprecated.
  542. ELEMENT_TYPE_VALUETYPE = 0x11, // VALUETYPE <class Token>
  543. ELEMENT_TYPE_CLASS = 0x12, // CLASS <class Token>
  544. ELEMENT_TYPE_ARRAY = 0x14, // MDARRAY <type> <rank> <bcount> <bound1> ... <lbcount> <lb1> ...
  545. ELEMENT_TYPE_TYPEDBYREF = 0x16, // This is a simple type.
  546. ELEMENT_TYPE_I = 0x18, // native integer size
  547. ELEMENT_TYPE_U = 0x19, // native unsigned integer size
  548. ELEMENT_TYPE_FNPTR = 0x1B, // FNPTR <complete sig for the function including calling convention>
  549. ELEMENT_TYPE_OBJECT = 0x1C, // Shortcut for System.Object
  550. ELEMENT_TYPE_SZARRAY = 0x1D, // Shortcut for single dimension zero lower bound array
  551. // SZARRAY <type>
  552. // This is only for binding
  553. ELEMENT_TYPE_CMOD_REQD = 0x1F, // required C modifier : E_T_CMOD_REQD <mdTypeRef/mdTypeDef>
  554. ELEMENT_TYPE_CMOD_OPT = 0x20, // optional C modifier : E_T_CMOD_OPT <mdTypeRef/mdTypeDef>
  555. // This is for signatures generated internally (which will not be persisted in any way).
  556. ELEMENT_TYPE_INTERNAL = 0x21, // INTERNAL <typehandle>
  557. // Note that this is the max of base type excluding modifiers
  558. ELEMENT_TYPE_MAX = 0x22, // first invalid element type
  559. ELEMENT_TYPE_MODIFIER = 0x40,
  560. ELEMENT_TYPE_SENTINEL = 0x01 | ELEMENT_TYPE_MODIFIER, // sentinel for varargs
  561. ELEMENT_TYPE_PINNED = 0x05 | ELEMENT_TYPE_MODIFIER,
  562. } CorElementType;
  563. //*****************************************************************************
  564. //
  565. // Serialization types for Custom attribute support
  566. //
  567. //*****************************************************************************
  568. typedef enum CorSerializationType
  569. {
  570. SERIALIZATION_TYPE_BOOLEAN = ELEMENT_TYPE_BOOLEAN,
  571. SERIALIZATION_TYPE_CHAR = ELEMENT_TYPE_CHAR,
  572. SERIALIZATION_TYPE_I1 = ELEMENT_TYPE_I1,
  573. SERIALIZATION_TYPE_U1 = ELEMENT_TYPE_U1,
  574. SERIALIZATION_TYPE_I2 = ELEMENT_TYPE_I2,
  575. SERIALIZATION_TYPE_U2 = ELEMENT_TYPE_U2,
  576. SERIALIZATION_TYPE_I4 = ELEMENT_TYPE_I4,
  577. SERIALIZATION_TYPE_U4 = ELEMENT_TYPE_U4,
  578. SERIALIZATION_TYPE_I8 = ELEMENT_TYPE_I8,
  579. SERIALIZATION_TYPE_U8 = ELEMENT_TYPE_U8,
  580. SERIALIZATION_TYPE_R4 = ELEMENT_TYPE_R4,
  581. SERIALIZATION_TYPE_R8 = ELEMENT_TYPE_R8,
  582. SERIALIZATION_TYPE_STRING = ELEMENT_TYPE_STRING,
  583. SERIALIZATION_TYPE_SZARRAY = ELEMENT_TYPE_SZARRAY, // Shortcut for single dimension zero lower bound array
  584. SERIALIZATION_TYPE_TYPE = 0x50,
  585. SERIALIZATION_TYPE_TAGGED_OBJECT= 0x51,
  586. SERIALIZATION_TYPE_FIELD = 0x53,
  587. SERIALIZATION_TYPE_PROPERTY = 0x54,
  588. SERIALIZATION_TYPE_ENUM = 0x55
  589. } CorSerializationType;
  590. //
  591. // Calling convention flags.
  592. //
  593. typedef enum CorCallingConvention
  594. {
  595. IMAGE_CEE_CS_CALLCONV_DEFAULT = 0x0,
  596. IMAGE_CEE_CS_CALLCONV_VARARG = 0x5,
  597. IMAGE_CEE_CS_CALLCONV_FIELD = 0x6,
  598. IMAGE_CEE_CS_CALLCONV_LOCAL_SIG = 0x7,
  599. IMAGE_CEE_CS_CALLCONV_PROPERTY = 0x8,
  600. IMAGE_CEE_CS_CALLCONV_UNMGD = 0x9,
  601. IMAGE_CEE_CS_CALLCONV_MAX = 0x10, // first invalid calling convention
  602. // The high bits of the calling convention convey additional info
  603. IMAGE_CEE_CS_CALLCONV_MASK = 0x0f, // Calling convention is bottom 4 bits
  604. IMAGE_CEE_CS_CALLCONV_HASTHIS = 0x20, // Top bit indicates a 'this' parameter
  605. IMAGE_CEE_CS_CALLCONV_EXPLICITTHIS = 0x40, // This parameter is explicitly in the signature
  606. } CorCallingConvention;
  607. typedef enum CorUnmanagedCallingConvention
  608. {
  609. IMAGE_CEE_UNMANAGED_CALLCONV_C = 0x1,
  610. IMAGE_CEE_UNMANAGED_CALLCONV_STDCALL = 0x2,
  611. IMAGE_CEE_UNMANAGED_CALLCONV_THISCALL = 0x3,
  612. IMAGE_CEE_UNMANAGED_CALLCONV_FASTCALL = 0x4,
  613. IMAGE_CEE_CS_CALLCONV_C = IMAGE_CEE_UNMANAGED_CALLCONV_C,
  614. IMAGE_CEE_CS_CALLCONV_STDCALL = IMAGE_CEE_UNMANAGED_CALLCONV_STDCALL,
  615. IMAGE_CEE_CS_CALLCONV_THISCALL = IMAGE_CEE_UNMANAGED_CALLCONV_THISCALL,
  616. IMAGE_CEE_CS_CALLCONV_FASTCALL = IMAGE_CEE_UNMANAGED_CALLCONV_FASTCALL,
  617. } CorUnmanagedCallingConvention;
  618. typedef enum CorArgType
  619. {
  620. IMAGE_CEE_CS_END = 0x0,
  621. IMAGE_CEE_CS_VOID = 0x1,
  622. IMAGE_CEE_CS_I4 = 0x2,
  623. IMAGE_CEE_CS_I8 = 0x3,
  624. IMAGE_CEE_CS_R4 = 0x4,
  625. IMAGE_CEE_CS_R8 = 0x5,
  626. IMAGE_CEE_CS_PTR = 0x6,
  627. IMAGE_CEE_CS_OBJECT = 0x7,
  628. IMAGE_CEE_CS_STRUCT4 = 0x8,
  629. IMAGE_CEE_CS_STRUCT32 = 0x9,
  630. IMAGE_CEE_CS_BYVALUE = 0xA,
  631. } CorArgType;
  632. //*****************************************************************************
  633. //
  634. // Native type for N-Direct
  635. //
  636. //*****************************************************************************
  637. typedef enum CorNativeType
  638. {
  639. NATIVE_TYPE_END = 0x0, //DEPRECATED
  640. NATIVE_TYPE_VOID = 0x1, //DEPRECATED
  641. NATIVE_TYPE_BOOLEAN = 0x2, // (4 byte boolean value: TRUE = non-zero, FALSE = 0)
  642. NATIVE_TYPE_I1 = 0x3,
  643. NATIVE_TYPE_U1 = 0x4,
  644. NATIVE_TYPE_I2 = 0x5,
  645. NATIVE_TYPE_U2 = 0x6,
  646. NATIVE_TYPE_I4 = 0x7,
  647. NATIVE_TYPE_U4 = 0x8,
  648. NATIVE_TYPE_I8 = 0x9,
  649. NATIVE_TYPE_U8 = 0xa,
  650. NATIVE_TYPE_R4 = 0xb,
  651. NATIVE_TYPE_R8 = 0xc,
  652. NATIVE_TYPE_SYSCHAR = 0xd, //DEPRECATED
  653. NATIVE_TYPE_VARIANT = 0xe, //DEPRECATED
  654. NATIVE_TYPE_CURRENCY = 0xf,
  655. NATIVE_TYPE_PTR = 0x10, //DEPRECATED
  656. NATIVE_TYPE_DECIMAL = 0x11, //DEPRECATED
  657. NATIVE_TYPE_DATE = 0x12, //DEPRECATED
  658. NATIVE_TYPE_BSTR = 0x13,
  659. NATIVE_TYPE_LPSTR = 0x14,
  660. NATIVE_TYPE_LPWSTR = 0x15,
  661. NATIVE_TYPE_LPTSTR = 0x16,
  662. NATIVE_TYPE_FIXEDSYSSTRING = 0x17,
  663. NATIVE_TYPE_OBJECTREF = 0x18, //DEPRECATED
  664. NATIVE_TYPE_IUNKNOWN = 0x19,
  665. NATIVE_TYPE_IDISPATCH = 0x1a,
  666. NATIVE_TYPE_STRUCT = 0x1b,
  667. NATIVE_TYPE_INTF = 0x1c,
  668. NATIVE_TYPE_SAFEARRAY = 0x1d,
  669. NATIVE_TYPE_FIXEDARRAY = 0x1e,
  670. NATIVE_TYPE_INT = 0x1f,
  671. NATIVE_TYPE_UINT = 0x20,
  672. NATIVE_TYPE_NESTEDSTRUCT = 0x21, //DEPRECATED (use NATIVE_TYPE_STRUCT)
  673. NATIVE_TYPE_BYVALSTR = 0x22,
  674. NATIVE_TYPE_ANSIBSTR = 0x23,
  675. NATIVE_TYPE_TBSTR = 0x24, // select BSTR or ANSIBSTR depending on platform
  676. NATIVE_TYPE_VARIANTBOOL = 0x25, // (2-byte boolean value: TRUE = -1, FALSE = 0)
  677. NATIVE_TYPE_FUNC = 0x26,
  678. NATIVE_TYPE_ASANY = 0x28,
  679. NATIVE_TYPE_ARRAY = 0x2a,
  680. NATIVE_TYPE_LPSTRUCT = 0x2b,
  681. NATIVE_TYPE_CUSTOMMARSHALER = 0x2c, // Custom marshaler native type. This must be followed
  682. // by a string of the following format:
  683. // "Native type name/0Custom marshaler type name/0Optional cookie/0"
  684. // Or
  685. // "{Native type GUID}/0Custom marshaler type name/0Optional cookie/0"
  686. NATIVE_TYPE_ERROR = 0x2d, // This native type coupled with ELEMENT_TYPE_I4 will map to VT_HRESULT
  687. NATIVE_TYPE_MAX = 0x50, // first invalid element type
  688. } CorNativeType;
  689. enum
  690. {
  691. DESCR_GROUP_METHODDEF = 0, // DESCR group for MethodDefs
  692. DESCR_GROUP_METHODIMPL, // DESCR group for MethodImpls
  693. };
  694. /***********************************************************************************/
  695. // a COR_ILMETHOD_SECT is a generic container for attributes that are private
  696. // to a particular method. The COR_ILMETHOD structure points to one of these
  697. // (see GetSect()). COR_ILMETHOD_SECT can decode the Kind of attribute (but not
  698. // its internal data layout, and can skip past the current attibute to find the
  699. // Next one. The overhead for COR_ILMETHOD_SECT is a minimum of 2 bytes.
  700. typedef enum CorILMethodSect // codes that identify attributes
  701. {
  702. CorILMethod_Sect_Reserved = 0,
  703. CorILMethod_Sect_EHTable = 1,
  704. CorILMethod_Sect_OptILTable = 2,
  705. CorILMethod_Sect_KindMask = 0x3F, // The mask for decoding the type code
  706. CorILMethod_Sect_FatFormat = 0x40, // fat format
  707. CorILMethod_Sect_MoreSects = 0x80, // there is another attribute after this one
  708. } CorILMethodSect;
  709. /************************************/
  710. /* NOTE this structure must be DWORD aligned!! */
  711. typedef struct IMAGE_COR_ILMETHOD_SECT_SMALL
  712. {
  713. BYTE Kind;
  714. BYTE DataSize;
  715. } IMAGE_COR_ILMETHOD_SECT_SMALL;
  716. /************************************/
  717. /* NOTE this structure must be DWORD aligned!! */
  718. typedef struct IMAGE_COR_ILMETHOD_SECT_FAT
  719. {
  720. unsigned Kind : 8;
  721. unsigned DataSize : 24;
  722. } IMAGE_COR_ILMETHOD_SECT_FAT;
  723. /***********************************************************************************/
  724. /* If COR_ILMETHOD_SECT_HEADER::Kind() = CorILMethod_Sect_EHTable then the attribute
  725. is a list of exception handling clauses. There are two formats, fat or small
  726. */
  727. typedef enum CorExceptionFlag // defintitions for the Flags field below (for both big and small)
  728. {
  729. COR_ILEXCEPTION_CLAUSE_NONE, // This is a typed handler
  730. COR_ILEXCEPTION_CLAUSE_OFFSETLEN = 0x0000, // Deprecated
  731. COR_ILEXCEPTION_CLAUSE_DEPRECATED = 0x0000, // Deprecated
  732. COR_ILEXCEPTION_CLAUSE_FILTER = 0x0001, // If this bit is on, then this EH entry is for a filter
  733. COR_ILEXCEPTION_CLAUSE_FINALLY = 0x0002, // This clause is a finally clause
  734. COR_ILEXCEPTION_CLAUSE_FAULT = 0x0004, // Fault clause (finally that is called on exception only)
  735. } CorExceptionFlag;
  736. /***********************************/
  737. // NOTE !!! NOTE
  738. // This structure should line up with EE_ILEXCEPTION_CLAUSE,
  739. // otherwise you'll have to adjust code in Excep.cpp, re: EHRangeTree
  740. // NOTE !!! NOTE
  741. typedef struct IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT
  742. {
  743. CorExceptionFlag Flags;
  744. DWORD TryOffset;
  745. DWORD TryLength; // relative to start of try block
  746. DWORD HandlerOffset;
  747. DWORD HandlerLength; // relative to start of handler
  748. union {
  749. DWORD ClassToken; // use for type-based exception handlers
  750. DWORD FilterOffset; // use for filter-based exception handlers (COR_ILEXCEPTION_FILTER is set)
  751. };
  752. } IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT;
  753. typedef struct IMAGE_COR_ILMETHOD_SECT_EH_FAT
  754. {
  755. IMAGE_COR_ILMETHOD_SECT_FAT SectFat;
  756. IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT Clauses[1]; // actually variable size
  757. } IMAGE_COR_ILMETHOD_SECT_EH_FAT;
  758. /***********************************/
  759. typedef struct IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_SMALL
  760. {
  761. #ifdef _WIN64
  762. unsigned Flags : 16;
  763. #else // !_WIN64
  764. CorExceptionFlag Flags : 16;
  765. #endif
  766. unsigned TryOffset : 16;
  767. unsigned TryLength : 8; // relative to start of try block
  768. unsigned HandlerOffset : 16;
  769. unsigned HandlerLength : 8; // relative to start of handler
  770. union {
  771. DWORD ClassToken;
  772. DWORD FilterOffset;
  773. };
  774. } IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_SMALL;
  775. /***********************************/
  776. typedef struct IMAGE_COR_ILMETHOD_SECT_EH_SMALL
  777. {
  778. IMAGE_COR_ILMETHOD_SECT_SMALL SectSmall;
  779. WORD Reserved;
  780. IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_SMALL Clauses[1]; // actually variable size
  781. } IMAGE_COR_ILMETHOD_SECT_EH_SMALL;
  782. typedef union IMAGE_COR_ILMETHOD_SECT_EH
  783. {
  784. IMAGE_COR_ILMETHOD_SECT_EH_SMALL Small;
  785. IMAGE_COR_ILMETHOD_SECT_EH_FAT Fat;
  786. } IMAGE_COR_ILMETHOD_SECT_EH;
  787. /***********************************************************************************/
  788. typedef enum CorILMethodFlags
  789. {
  790. CorILMethod_InitLocals = 0x0010, // call default constructor on all local vars
  791. CorILMethod_MoreSects = 0x0008, // there is another attribute after this one
  792. CorILMethod_CompressedIL = 0x0040, // FIX Remove this and do it on a per Module basis
  793. // Indicates the format for the COR_ILMETHOD header
  794. CorILMethod_FormatShift = 3,
  795. CorILMethod_FormatMask = ((1 << CorILMethod_FormatShift) - 1),
  796. CorILMethod_TinyFormat = 0x0002, // use this code if the code size is even
  797. CorILMethod_SmallFormat = 0x0000,
  798. CorILMethod_FatFormat = 0x0003,
  799. CorILMethod_TinyFormat1 = 0x0006, // use this code if the code size is odd
  800. } CorILMethodFlags;
  801. /***************************************************************************/
  802. /* Used when the method is tiny (< 64 bytes), and there are no local vars */
  803. typedef struct IMAGE_COR_ILMETHOD_TINY
  804. {
  805. BYTE Flags_CodeSize;
  806. } IMAGE_COR_ILMETHOD_TINY;
  807. /************************************/
  808. // This strucuture is the 'fat' layout, where no compression is attempted.
  809. // Note that this structure can be added on at the end, thus making it extensible
  810. typedef struct IMAGE_COR_ILMETHOD_FAT
  811. {
  812. unsigned Flags : 12; // Flags
  813. unsigned Size : 4; // size in DWords of this structure (currently 3)
  814. unsigned MaxStack : 16; // maximum number of items (I4, I, I8, obj ...), on the operand stack
  815. DWORD CodeSize; // size of the code
  816. mdSignature LocalVarSigTok; // token that indicates the signature of the local vars (0 means none)
  817. } IMAGE_COR_ILMETHOD_FAT;
  818. typedef union IMAGE_COR_ILMETHOD
  819. {
  820. IMAGE_COR_ILMETHOD_TINY Tiny;
  821. IMAGE_COR_ILMETHOD_FAT Fat;
  822. } IMAGE_COR_ILMETHOD;
  823. //
  824. // Native method descriptor.
  825. //
  826. typedef struct IMAGE_COR_NATIVE_DESCRIPTOR
  827. {
  828. DWORD GCInfo;
  829. DWORD EHInfo;
  830. } IMAGE_COR_NATIVE_DESCRIPTOR;
  831. typedef struct IMAGE_COR_X86_RUNTIME_FUNCTION_ENTRY
  832. {
  833. ULONG BeginAddress; // RVA of start of function
  834. ULONG EndAddress; // RVA of end of function
  835. ULONG MIH; // Associated MIH
  836. } IMAGE_COR_X86_RUNTIME_FUNCTION_ENTRY;
  837. typedef struct IMAGE_COR_MIH_ENTRY
  838. {
  839. ULONG EHRVA;
  840. ULONG MethodRVA;
  841. mdToken Token;
  842. BYTE Flags;
  843. BYTE CodeManager;
  844. BYTE MIHData[0];
  845. } IMAGE_COR_MIH_ENTRY;
  846. //*****************************************************************************
  847. // Non VOS v-table entries. Define an array of these pointed to by
  848. // IMAGE_COR20_HEADER.VTableFixups. Each entry describes a contiguous array of
  849. // v-table slots. The slots start out initialized to the meta data token value
  850. // for the method they need to call. At image load time, the CLR Loader will
  851. // turn each entry into a pointer to machine code for the CPU and can be
  852. // called directly.
  853. //*****************************************************************************
  854. typedef struct IMAGE_COR_VTABLEFIXUP
  855. {
  856. ULONG RVA; // Offset of v-table array in image.
  857. USHORT Count; // How many entries at location.
  858. USHORT Type; // COR_VTABLE_xxx type of entries.
  859. } IMAGE_COR_VTABLEFIXUP;
  860. //*****************************************************************************
  861. //*****************************************************************************
  862. //
  863. // M E T A - D A T A D E C L A R A T I O N S
  864. //
  865. //*****************************************************************************
  866. //*****************************************************************************
  867. //*****************************************************************************
  868. //
  869. // Enums for SetOption API.
  870. //
  871. //*****************************************************************************
  872. // flags for MetaDataCheckDuplicatesFor
  873. typedef enum CorCheckDuplicatesFor
  874. {
  875. MDDupAll = 0xffffffff,
  876. MDDupENC = MDDupAll,
  877. MDNoDupChecks = 0x00000000,
  878. MDDupTypeDef = 0x00000001,
  879. MDDupInterfaceImpl = 0x00000002,
  880. MDDupMethodDef = 0x00000004,
  881. MDDupTypeRef = 0x00000008,
  882. MDDupMemberRef = 0x00000010,
  883. MDDupCustomAttribute = 0x00000020,
  884. MDDupParamDef = 0x00000040,
  885. MDDupPermission = 0x00000080,
  886. MDDupProperty = 0x00000100,
  887. MDDupEvent = 0x00000200,
  888. MDDupFieldDef = 0x00000400,
  889. MDDupSignature = 0x00000800,
  890. MDDupModuleRef = 0x00001000,
  891. MDDupTypeSpec = 0x00002000,
  892. MDDupImplMap = 0x00004000,
  893. MDDupAssemblyRef = 0x00008000,
  894. MDDupFile = 0x00010000,
  895. MDDupExportedType = 0x00020000,
  896. MDDupManifestResource = 0x00040000,
  897. // gap for debug junk
  898. MDDupAssembly = 0x10000000,
  899. // This is the default behavior on metadata. It will check duplicates for TypeRef, MemberRef, Signature, and TypeSpec
  900. MDDupDefault = MDNoDupChecks | MDDupTypeRef | MDDupMemberRef | MDDupSignature | MDDupTypeSpec,
  901. } CorCheckDuplicatesFor;
  902. // flags for MetaDataRefToDefCheck
  903. typedef enum CorRefToDefCheck
  904. {
  905. // default behavior is to always perform TypeRef to TypeDef and MemberRef to MethodDef/FieldDef optimization
  906. MDRefToDefDefault = 0x00000003,
  907. MDRefToDefAll = 0xffffffff,
  908. MDRefToDefNone = 0x00000000,
  909. MDTypeRefToDef = 0x00000001,
  910. MDMemberRefToDef = 0x00000002
  911. } CorRefToDefCheck;
  912. // MetaDataNotificationForTokenMovement
  913. typedef enum CorNotificationForTokenMovement
  914. {
  915. // default behavior is to notify TypeRef, MethodDef, MemberRef, and FieldDef token remaps
  916. MDNotifyDefault = 0x0000000f,
  917. MDNotifyAll = 0xffffffff,
  918. MDNotifyNone = 0x00000000,
  919. MDNotifyMethodDef = 0x00000001,
  920. MDNotifyMemberRef = 0x00000002,
  921. MDNotifyFieldDef = 0x00000004,
  922. MDNotifyTypeRef = 0x00000008,
  923. MDNotifyTypeDef = 0x00000010,
  924. MDNotifyParamDef = 0x00000020,
  925. MDNotifyInterfaceImpl = 0x00000040,
  926. MDNotifyProperty = 0x00000080,
  927. MDNotifyEvent = 0x00000100,
  928. MDNotifySignature = 0x00000200,
  929. MDNotifyTypeSpec = 0x00000400,
  930. MDNotifyCustomAttribute = 0x00000800,
  931. MDNotifySecurityValue = 0x00001000,
  932. MDNotifyPermission = 0x00002000,
  933. MDNotifyModuleRef = 0x00004000,
  934. MDNotifyNameSpace = 0x00008000,
  935. MDNotifyAssemblyRef = 0x01000000,
  936. MDNotifyFile = 0x02000000,
  937. MDNotifyExportedType = 0x04000000,
  938. MDNotifyResource = 0x08000000,
  939. } CorNotificationForTokenMovement;
  940. typedef enum CorSetENC
  941. {
  942. MDSetENCOn = 0x00000001, // Deprecated name.
  943. MDSetENCOff = 0x00000002, // Deprecated name.
  944. MDUpdateENC = 0x00000001, // ENC mode. Tokens don't move; can be updated.
  945. MDUpdateFull = 0x00000002, // "Normal" update mode.
  946. MDUpdateExtension = 0x00000003, // Extension mode. Tokens don't move, adds only.
  947. MDUpdateIncremental = 0x00000004, // Incremental compilation
  948. MDUpdateMask = 0x00000007,
  949. MDUpdateDelta = 0x00000008, // If ENC on, save only deltas.
  950. } CorSetENC;
  951. // flags used in SetOption when pair with MetaDataErrorIfEmitOutOfOrder guid
  952. typedef enum CorErrorIfEmitOutOfOrder
  953. {
  954. MDErrorOutOfOrderDefault = 0x00000000, // default not to generate any error
  955. MDErrorOutOfOrderNone = 0x00000000, // do not generate error for out of order emit
  956. MDErrorOutOfOrderAll = 0xffffffff, // generate out of order emit for method, field, param, property, and event
  957. MDMethodOutOfOrder = 0x00000001, // generate error when methods are emitted out of order
  958. MDFieldOutOfOrder = 0x00000002, // generate error when fields are emitted out of order
  959. MDParamOutOfOrder = 0x00000004, // generate error when params are emitted out of order
  960. MDPropertyOutOfOrder = 0x00000008, // generate error when properties are emitted out of order
  961. MDEventOutOfOrder = 0x00000010, // generate error when events are emitted out of order
  962. } CorErrorIfEmitOutOfOrder;
  963. // flags used in SetOption when pair with MetaDataImportOption guid
  964. typedef enum CorImportOptions
  965. {
  966. MDImportOptionDefault = 0x00000000, // default to skip over deleted records
  967. MDImportOptionAll = 0xFFFFFFFF, // Enumerate everything
  968. MDImportOptionAllTypeDefs = 0x00000001, // all of the typedefs including the deleted typedef
  969. MDImportOptionAllMethodDefs = 0x00000002, // all of the methoddefs including the deleted ones
  970. MDImportOptionAllFieldDefs = 0x00000004, // all of the fielddefs including the deleted ones
  971. MDImportOptionAllProperties = 0x00000008, // all of the properties including the deleted ones
  972. MDImportOptionAllEvents = 0x00000010, // all of the events including the deleted ones
  973. MDImportOptionAllCustomAttributes = 0x00000020, // all of the custom attributes including the deleted ones
  974. MDImportOptionAllExportedTypes = 0x00000040, // all of the ExportedTypes including the deleted ones
  975. } CorImportOptions;
  976. // flags for MetaDataThreadSafetyOptions
  977. typedef enum CorThreadSafetyOptions
  978. {
  979. // default behavior is to have thread safety turn off. This means that MetaData APIs will not take reader/writer
  980. // lock. Clients is responsible to make sure the properly thread synchornization when using MetaData APIs.
  981. MDThreadSafetyDefault = 0x00000000,
  982. MDThreadSafetyOff = 0x00000000,
  983. MDThreadSafetyOn = 0x00000001,
  984. } CorThreadSafetyOptions;
  985. // flags for MetaDataLinkerOptions
  986. typedef enum CorLinkerOptions
  987. {
  988. // default behavior is not to keep private types
  989. MDAssembly = 0x00000000,
  990. MDNetModule = 0x00000001,
  991. } CorLinkerOptions;
  992. //
  993. // struct used to retrieve field offset
  994. // used by GetClassLayout and SetClassLayout
  995. //
  996. typedef struct COR_FIELD_OFFSET
  997. {
  998. mdFieldDef ridOfField;
  999. ULONG ulOffset;
  1000. } COR_FIELD_OFFSET;
  1001. typedef struct IMAGE_COR_FIXUPENTRY
  1002. {
  1003. ULONG ulRVA;
  1004. ULONG Count;
  1005. } IMAGE_COR_FIXUPENTRY;
  1006. //
  1007. // Token tags.
  1008. //
  1009. typedef enum CorTokenType
  1010. {
  1011. mdtModule = 0x00000000, //
  1012. mdtTypeRef = 0x01000000, //
  1013. mdtTypeDef = 0x02000000, //
  1014. mdtFieldDef = 0x04000000, //
  1015. mdtMethodDef = 0x06000000, //
  1016. mdtParamDef = 0x08000000, //
  1017. mdtInterfaceImpl = 0x09000000, //
  1018. mdtMemberRef = 0x0a000000, //
  1019. mdtCustomAttribute = 0x0c000000, //
  1020. mdtPermission = 0x0e000000, //
  1021. mdtSignature = 0x11000000, //
  1022. mdtEvent = 0x14000000, //
  1023. mdtProperty = 0x17000000, //
  1024. mdtModuleRef = 0x1a000000, //
  1025. mdtTypeSpec = 0x1b000000, //
  1026. mdtAssembly = 0x20000000, //
  1027. mdtAssemblyRef = 0x23000000, //
  1028. mdtFile = 0x26000000, //
  1029. mdtExportedType = 0x27000000, //
  1030. mdtManifestResource = 0x28000000, //
  1031. mdtString = 0x70000000, //
  1032. mdtName = 0x71000000, //
  1033. mdtBaseType = 0x72000000, // Leave this on the high end value. This does not correspond to metadata table
  1034. } CorTokenType;
  1035. //
  1036. // Build / decompose tokens.
  1037. //
  1038. #define RidToToken(rid,tktype) ((rid) |= (tktype))
  1039. #define TokenFromRid(rid,tktype) ((rid) | (tktype))
  1040. #define RidFromToken(tk) ((RID) ((tk) & 0x00ffffff))
  1041. #define TypeFromToken(tk) ((ULONG32)((tk) & 0xff000000))
  1042. #define IsNilToken(tk) ((RidFromToken(tk)) == 0)
  1043. //
  1044. // Nil tokens
  1045. //
  1046. #define mdTokenNil ((mdToken)0)
  1047. #define mdModuleNil ((mdModule)mdtModule)
  1048. #define mdTypeRefNil ((mdTypeRef)mdtTypeRef)
  1049. #define mdTypeDefNil ((mdTypeDef)mdtTypeDef)
  1050. #define mdFieldDefNil ((mdFieldDef)mdtFieldDef)
  1051. #define mdMethodDefNil ((mdMethodDef)mdtMethodDef)
  1052. #define mdParamDefNil ((mdParamDef)mdtParamDef)
  1053. #define mdInterfaceImplNil ((mdInterfaceImpl)mdtInterfaceImpl)
  1054. #define mdMemberRefNil ((mdMemberRef)mdtMemberRef)
  1055. #define mdCustomAttributeNil ((mdCustomAttribute)mdtCustomAttribute)
  1056. #define mdPermissionNil ((mdPermission)mdtPermission)
  1057. #define mdSignatureNil ((mdSignature)mdtSignature)
  1058. #define mdEventNil ((mdEvent)mdtEvent)
  1059. #define mdPropertyNil ((mdProperty)mdtProperty)
  1060. #define mdModuleRefNil ((mdModuleRef)mdtModuleRef)
  1061. #define mdTypeSpecNil ((mdTypeSpec)mdtTypeSpec)
  1062. #define mdAssemblyNil ((mdAssembly)mdtAssembly)
  1063. #define mdAssemblyRefNil ((mdAssemblyRef)mdtAssemblyRef)
  1064. #define mdFileNil ((mdFile)mdtFile)
  1065. #define mdExportedTypeNil ((mdExportedType)mdtExportedType)
  1066. #define mdManifestResourceNil ((mdManifestResource)mdtManifestResource)
  1067. #define mdStringNil ((mdString)mdtString)
  1068. //
  1069. // Open bits.
  1070. //
  1071. typedef enum CorOpenFlags
  1072. {
  1073. ofRead = 0x00000000, // Open scope for read
  1074. ofWrite = 0x00000001, // Open scope for write.
  1075. ofCopyMemory = 0x00000002, // Open scope with memory. Ask metadata to maintain its own copy of memory.
  1076. ofCacheImage = 0x00000004, // EE maps but does not do relocations or verify image
  1077. ofNoTypeLib = 0x00000080, // Don't OpenScope on a typelib.
  1078. } CorOpenFlags;
  1079. typedef enum CorBaseType // TokenFromRid(X,Y) replaced with (X | Y)
  1080. {
  1081. mdtBaseType_BOOLEAN = ( ELEMENT_TYPE_BOOLEAN | mdtBaseType ),
  1082. mdtBaseType_CHAR = ( ELEMENT_TYPE_CHAR | mdtBaseType ),
  1083. mdtBaseType_I1 = ( ELEMENT_TYPE_I1 | mdtBaseType ),
  1084. mdtBaseType_U1 = ( ELEMENT_TYPE_U1 | mdtBaseType ),
  1085. mdtBaseType_I2 = ( ELEMENT_TYPE_I2 | mdtBaseType ),
  1086. mdtBaseType_U2 = ( ELEMENT_TYPE_U2 | mdtBaseType ),
  1087. mdtBaseType_I4 = ( ELEMENT_TYPE_I4 | mdtBaseType ),
  1088. mdtBaseType_U4 = ( ELEMENT_TYPE_U4 | mdtBaseType ),
  1089. mdtBaseType_I8 = ( ELEMENT_TYPE_I8 | mdtBaseType ),
  1090. mdtBaseType_U8 = ( ELEMENT_TYPE_U8 | mdtBaseType ),
  1091. mdtBaseType_R4 = ( ELEMENT_TYPE_R4 | mdtBaseType ),
  1092. mdtBaseType_R8 = ( ELEMENT_TYPE_R8 | mdtBaseType ),
  1093. mdtBaseType_STRING = ( ELEMENT_TYPE_STRING | mdtBaseType ),
  1094. mdtBaseType_I = ( ELEMENT_TYPE_I | mdtBaseType ),
  1095. mdtBaseType_U = ( ELEMENT_TYPE_U | mdtBaseType ),
  1096. } CorBaseType;
  1097. typedef CorTypeAttr CorRegTypeAttr;
  1098. //
  1099. // Opaque type for an enumeration handle.
  1100. //
  1101. typedef void *HCORENUM;
  1102. // Note that this must be kept in sync with System.AttributeTargets.
  1103. typedef enum CorAttributeTargets
  1104. {
  1105. catAssembly = 0x0001,
  1106. catModule = 0x0002,
  1107. catClass = 0x0004,
  1108. catStruct = 0x0008,
  1109. catEnum = 0x0010,
  1110. catConstructor = 0x0020,
  1111. catMethod = 0x0040,
  1112. catProperty = 0x0080,
  1113. catField = 0x0100,
  1114. catEvent = 0x0200,
  1115. catInterface = 0x0400,
  1116. catParameter = 0x0800,
  1117. catDelegate = 0x1000,
  1118. catAll = catAssembly | catModule | catClass | catStruct | catEnum | catConstructor |
  1119. catMethod | catProperty | catField | catEvent | catInterface | catParameter | catDelegate,
  1120. catClassMembers = catClass | catStruct | catEnum | catConstructor | catMethod | catProperty | catField | catEvent | catDelegate | catInterface,
  1121. } CorAttributeTargets;
  1122. #ifndef MACROS_NOT_SUPPORTED
  1123. //
  1124. // Some well-known custom attributes
  1125. //
  1126. #ifndef IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS
  1127. #define IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS (IMAGE_CEE_CS_CALLCONV_DEFAULT | IMAGE_CEE_CS_CALLCONV_HASTHIS)
  1128. #endif
  1129. #define INTEROP_DISPID_TYPE_W L"System.Runtime.InteropServices.DispIdAttribute"
  1130. #define INTEROP_DISPID_TYPE "System.Runtime.InteropServices.DispIdAttribute"
  1131. #define INTEROP_DISPID_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I4}
  1132. #define INTEROP_INTERFACETYPE_TYPE_W L"System.Runtime.InteropServices.InterfaceTypeAttribute"
  1133. #define INTEROP_INTERFACETYPE_TYPE "System.Runtime.InteropServices.InterfaceTypeAttribute"
  1134. #define INTEROP_INTERFACETYPE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I2}
  1135. #define INTEROP_CLASSINTERFACE_TYPE_W L"System.Runtime.InteropServices.ClassInterfaceAttribute"
  1136. #define INTEROP_CLASSINTERFACE_TYPE "System.Runtime.InteropServices.ClassInterfaceAttribute"
  1137. #define INTEROP_CLASSINTERFACE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I2}
  1138. #define INTEROP_COMVISIBLE_TYPE_W L"System.Runtime.InteropServices.ComVisibleAttribute"
  1139. #define INTEROP_COMVISIBLE_TYPE "System.Runtime.InteropServices.ComVisibleAttribute"
  1140. #define INTEROP_COMVISIBLE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_BOOLEAN}
  1141. #define INTEROP_COMREGISTERFUNCTION_TYPE_W L"System.Runtime.InteropServices.ComRegisterFunctionAttribute"
  1142. #define INTEROP_COMREGISTERFUNCTION_TYPE "System.Runtime.InteropServices.ComRegisterFunctionAttribute"
  1143. #define INTEROP_COMREGISTERFUNCTION_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
  1144. #define INTEROP_COMUNREGISTERFUNCTION_TYPE_W L"System.Runtime.InteropServices.ComUnregisterFunctionAttribute"
  1145. #define INTEROP_COMUNREGISTERFUNCTION_TYPE "System.Runtime.InteropServices.ComUnregisterFunctionAttribute"
  1146. #define INTEROP_COMUNREGISTERFUNCTION_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
  1147. #define INTEROP_IMPORTEDFROMTYPELIB_TYPE_W L"System.Runtime.InteropServices.ImportedFromTypeLibAttribute"
  1148. #define INTEROP_IMPORTEDFROMTYPELIB_TYPE "System.Runtime.InteropServices.ImportedFromTypeLibAttribute"
  1149. #define INTEROP_IMPORTEDFROMTYPELIB_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_STRING}
  1150. #define INTEROP_IDISPATCHIMPL_TYPE_W L"System.Runtime.InteropServices.IDispatchImplAttribute"
  1151. #define INTEROP_IDISPATCHIMPL_TYPE "System.Runtime.InteropServices.IDispatchImplAttribute"
  1152. #define INTEROP_IDISPATCHIMPL_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I2}
  1153. #define INTEROP_COMSOURCEINTERFACES_TYPE_W L"System.Runtime.InteropServices.ComSourceInterfacesAttribute"
  1154. #define INTEROP_COMSOURCEINTERFACES_TYPE "System.Runtime.InteropServices.ComSourceInterfacesAttribute"
  1155. #define INTEROP_COMSOURCEINTERFACES_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_STRING}
  1156. #define INTEROP_COMCONVERSIONLOSS_TYPE_W L"System.Runtime.InteropServices.ComConversionLossAttribute"
  1157. #define INTEROP_COMCONVERSIONLOSS_TYPE "System.Runtime.InteropServices.ComConversionLossAttribute"
  1158. #define INTEROP_COMCONVERSIONLOSS_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
  1159. #define INTEROP_TYPELIBTYPE_TYPE_W L"System.Runtime.InteropServices.TypeLibTypeAttribute"
  1160. #define INTEROP_TYPELIBTYPE_TYPE "System.Runtime.InteropServices.TypeLibTypeAttribute"
  1161. #define INTEROP_TYPELIBTYPE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I2}
  1162. #define INTEROP_TYPELIBFUNC_TYPE_W L"System.Runtime.InteropServices.TypeLibFuncAttribute"
  1163. #define INTEROP_TYPELIBFUNC_TYPE "System.Runtime.InteropServices.TypeLibFuncAttribute"
  1164. #define INTEROP_TYPELIBFUNC_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I2}
  1165. #define INTEROP_TYPELIBVAR_TYPE_W L"System.Runtime.InteropServices.TypeLibVarAttribute"
  1166. #define INTEROP_TYPELIBVAR_TYPE "System.Runtime.InteropServices.TypeLibVarAttribute"
  1167. #define INTEROP_TYPELIBVAR_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I2}
  1168. #define INTEROP_MARSHALAS_TYPE_W L"System.Runtime.InteropServices.MarshalAsAttribute"
  1169. #define INTEROP_MARSHALAS_TYPE "System.Runtime.InteropServices.MarshalAsAttribute"
  1170. #define INTEROP_MARSHALAS_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I2}
  1171. #define INTEROP_COMIMPORT_TYPE_W L"System.Runtime.InteropServices.ComImportAttribute"
  1172. #define INTEROP_COMIMPORT_TYPE "System.Runtime.InteropServices.ComImportAttribute"
  1173. #define INTEROP_COMIMPORT_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
  1174. #define INTEROP_GUID_TYPE_W L"System.Runtime.InteropServices.GuidAttribute"
  1175. #define INTEROP_GUID_TYPE "System.Runtime.InteropServices.GuidAttribute"
  1176. #define INTEROP_GUID_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_STRING}
  1177. #define INTEROP_DEFAULTMEMBER_TYPE_W L"System.Reflection.DefaultMemberAttribute"
  1178. #define INTEROP_DEFAULTMEMBER_TYPE "System.Reflection.DefaultMemberAttribute"
  1179. #define INTEROP_DEFAULTMEMBER_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_STRING}
  1180. #define INTEROP_COMEMULATE_TYPE_W L"System.Runtime.InteropServices.ComEmulateAttribute"
  1181. #define INTEROP_COMEMULATE_TYPE "System.Runtime.InteropServices.ComEmulateAttribute"
  1182. #define INTEROP_COMEMULATE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_STRING}
  1183. #define INTEROP_PRESERVESIG_TYPE_W L"System.Runtime.InteropServices.PreserveSigAttribure"
  1184. #define INTEROP_PRESERVESIG_TYPE "System.Runtime.InteropServices.PreserveSigAttribure"
  1185. #define INTEROP_PRESERVESIG_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_BOOLEAN}
  1186. #define INTEROP_IN_TYPE_W L"System.Runtime.InteropServices.InAttribute"
  1187. #define INTEROP_IN_TYPE "System.Runtime.InteropServices.InAttribute"
  1188. #define INTEROP_IN_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
  1189. #define INTEROP_OUT_TYPE_W L"System.Runtime.InteropServices.OutAttribute"
  1190. #define INTEROP_OUT_TYPE "System.Runtime.InteropServices.OutAttribute"
  1191. #define INTEROP_OUT_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
  1192. #define INTEROP_COMALIASNAME_TYPE_W L"System.Runtime.InteropServices.ComAliasNameAttribute"
  1193. #define INTEROP_COMALIASNAME_TYPE "System.Runtime.InteropServices.ComAliasNameAttribute"
  1194. #define INTEROP_COMALIASNAME_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_STRING}
  1195. #define INTEROP_PARAMARRAY_TYPE_W L"System.ParamArrayAttribute"
  1196. #define INTEROP_PARAMARRAY_TYPE "System.ParamArrayAttribute"
  1197. #define INTEROP_PARAMARRAY_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
  1198. #define INTEROP_LCIDCONVERSION_TYPE_W L"System.Runtime.InteropServices.LCIDConversionAttribute"
  1199. #define INTEROP_LCIDCONVERSION_TYPE "System.Runtime.InteropServices.LCIDConversionAttribute"
  1200. #define INTEROP_LCIDCONVERSION_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I4}
  1201. #define INTEROP_COMSUBSTITUTABLEINTERFACE_TYPE_W L"System.Runtime.InteropServices.ComSubstitutableInterfaceAttribute"
  1202. #define INTEROP_COMSUBSTITUTABLEINTERFACE_TYPE "System.Runtime.InteropServices.ComSubstitutableInterfaceAttribute"
  1203. #define INTEROP_COMSUBSTITUTABLEINTERFACE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
  1204. #define INTEROP_DECIMALVALUE_TYPE_W L"System.Runtime.CompilerServices.DecimalConstantAttribute"
  1205. #define INTEROP_DECIMALVALUE_TYPE "System.Runtime.CompilerServices.DecimalConstantAttribute"
  1206. #define INTEROP_DECIMALVALUE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 5, ELEMENT_TYPE_VOID, ELEMENT_TYPE_U1, ELEMENT_TYPE_U1, ELEMENT_TYPE_U4, ELEMENT_TYPE_U4, ELEMENT_TYPE_U4}
  1207. #define INTEROP_DATETIMEVALUE_TYPE_W L"System.Runtime.CompilerServices.DateTimeConstantAttribute"
  1208. #define INTEROP_DATETIMEVALUE_TYPE "System.Runtime.CompilerServices.DateTimeConstantAttribute"
  1209. #define INTEROP_DATETIMEVALUE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I8}
  1210. #define INTEROP_IUNKNOWNVALUE_TYPE_W L"System.Runtime.CompilerServices.IUnknownConstantAttribute"
  1211. #define INTEROP_IUNKNOWNVALUE_TYPE "System.Runtime.CompilerServices.IUnknownConstantAttribute"
  1212. #define INTEROP_IUNKNOWNVALUE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
  1213. #define INTEROP_IDISPATCHVALUE_TYPE_W L"System.Runtime.CompilerServices.IDispatchConstantAttribute"
  1214. #define INTEROP_IDISPATCHVALUE_TYPE "System.Runtime.CompilerServices.IDispatchConstantAttribute"
  1215. #define INTEROP_IDISPATCHVALUE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
  1216. #define INTEROP_AUTOPROXY_TYPE_W L"System.Runtime.InteropServices.AutomationProxyAttribute"
  1217. #define INTEROP_AUTOPROXY_TYPE "System.Runtime.InteropServices.AutomationProxyAttribute"
  1218. #define INTEROP_AUTOPROXY_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_BOOLEAN}
  1219. #define INTEROP_COMEVENTINTERFACE_TYPE_W L"System.Runtime.InteropServices.ComEventInterfaceAttribute"
  1220. #define INTEROP_COMEVENTINTERFACE_TYPE "System.Runtime.InteropServices.ComEventInterfaceAttribute"
  1221. #define INTEROP_COCLASS_TYPE_W L"System.Runtime.InteropServices.CoClassAttribute"
  1222. #define INTEROP_COCLASS_TYPE "System.Runtime.InteropServices.CoClassAttribute"
  1223. #define DEFAULTDOMAIN_STA_TYPE_W L"System.STAThreadAttribute"
  1224. #define DEFAULTDOMAIN_STA_TYPE "System.STAThreadAttribute"
  1225. #define DEFAULTDOMAIN_STA_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
  1226. #define DEFAULTDOMAIN_MTA_TYPE_W L"System.MTAThreadAttribute"
  1227. #define DEFAULTDOMAIN_MTA_TYPE "System.MTAThreadAttribute"
  1228. #define DEFAULTDOMAIN_MTA_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
  1229. #define DEFAULTDOMAIN_LOADEROPTIMIZATION_TYPE_W L"System.LoaderOptimizationAttribute"
  1230. #define DEFAULTDOMAIN_LOADEROPTIMIZATION_TYPE "System.LoaderOptimizationAttribute"
  1231. #define DEFAULTDOMAIN_LOADEROPTIMIZATION_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I1}
  1232. #define CMOD_CALLCONV_NAMESPACE_OLD "System.Runtime.InteropServices"
  1233. #define CMOD_CALLCONV_NAMESPACE "System.Runtime.CompilerServices"
  1234. #define CMOD_CALLCONV_NAME_CDECL "CallConvCdecl"
  1235. #define CMOD_CALLCONV_NAME_STDCALL "CallConvStdcall"
  1236. #define CMOD_CALLCONV_NAME_THISCALL "CallConvThiscall"
  1237. #define CMOD_CALLCONV_NAME_FASTCALL "CallConvFastcall"
  1238. #endif // MACROS_NOT_SUPPORTED
  1239. //
  1240. // GetSaveSize accuracy
  1241. //
  1242. #ifndef _CORSAVESIZE_DEFINED_
  1243. #define _CORSAVESIZE_DEFINED_
  1244. typedef enum CorSaveSize
  1245. {
  1246. cssAccurate = 0x0000, // Find exact save size, accurate but slower.
  1247. cssQuick = 0x0001, // Estimate save size, may pad estimate, but faster.
  1248. cssDiscardTransientCAs = 0x0002, // remove all of the CAs of discardable types
  1249. } CorSaveSize;
  1250. #endif
  1251. #define COR_IS_METHOD_MANAGED_IL(flags) ((flags & 0xf) == (miIL | miManaged))
  1252. #define COR_IS_METHOD_MANAGED_OPTIL(flags) ((flags & 0xf) == (miOPTIL | miManaged))
  1253. #define COR_IS_METHOD_MANAGED_NATIVE(flags) ((flags & 0xf) == (miNative | miManaged))
  1254. #define COR_IS_METHOD_UNMANAGED_NATIVE(flags) ((flags & 0xf) == (miNative | miUnmanaged))
  1255. #define COR_IS_METHOD_IAT(flags) (flags & miIAT)
  1256. //
  1257. // Opaque types for security properties and values.
  1258. //
  1259. typedef void * PSECURITY_PROPS ;
  1260. typedef void * PSECURITY_VALUE ;
  1261. typedef void ** PPSECURITY_PROPS ;
  1262. typedef void ** PPSECURITY_VALUE ;
  1263. //-------------------------------------
  1264. //--- Security data structures
  1265. //-------------------------------------
  1266. // Descriptor for a single security custom attribute.
  1267. typedef struct COR_SECATTR {
  1268. mdMemberRef tkCtor; // Ref to constructor of security attribute.
  1269. const void *pCustomAttribute; // Blob describing ctor args and field/property values.
  1270. ULONG cbCustomAttribute; // Length of the above blob.
  1271. } COR_SECATTR;
  1272. #endif // __CORHDR_H__