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.

1555 lines
75 KiB

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