1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5/*****************************************************************************
6 ** **
7 ** CorHdr.h - contains definitions for the Runtime structures, **
8**
9
10 ** needed to work with metadata. **
11 ** **
12 *****************************************************************************/
13//
14// The top most managed code structure in a EXE or DLL is the IMAGE_COR20_HEADER
15// see code:#ManagedHeader for more
16
17#ifndef __CORHDR_H__
18#define __CORHDR_H__
19
20#define FRAMEWORK_REGISTRY_KEY "Software\\Microsoft\\.NETFramework"
21#define FRAMEWORK_REGISTRY_KEY_W L"Software\\Microsoft\\.NETFramework"
22
23// keys for HKCU
24#ifdef _WIN64
25#define USER_FRAMEWORK_REGISTRY_KEY "Software\\Microsoft\\.NETFramework64"
26#define USER_FRAMEWORK_REGISTRY_KEY_W L"Software\\Microsoft\\.NETFramework64"
27#else
28#define USER_FRAMEWORK_REGISTRY_KEY "Software\\Microsoft\\.NETFramework"
29#define USER_FRAMEWORK_REGISTRY_KEY_W L"Software\\Microsoft\\.NETFramework"
30#endif
31
32
33#ifdef _MSC_VER
34#pragma warning(disable:4200) // nonstandard extension used : zero-sized array in struct/union.
35#endif
36typedef LPVOID mdScope; // Obsolete; not used in the runtime.
37typedef ULONG32 mdToken; // Generic token
38
39
40// Token definitions
41
42
43typedef mdToken mdModule; // Module token (roughly, a scope)
44typedef mdToken mdTypeRef; // TypeRef reference (this or other scope)
45typedef mdToken mdTypeDef; // TypeDef in this scope
46typedef mdToken mdFieldDef; // Field in this scope
47typedef mdToken mdMethodDef; // Method in this scope
48typedef mdToken mdParamDef; // param token
49typedef mdToken mdInterfaceImpl; // interface implementation token
50
51typedef mdToken mdMemberRef; // MemberRef (this or other scope)
52typedef mdToken mdCustomAttribute; // attribute token
53typedef mdToken mdPermission; // DeclSecurity
54
55typedef mdToken mdSignature; // Signature object
56typedef mdToken mdEvent; // event token
57typedef mdToken mdProperty; // property token
58
59typedef mdToken mdModuleRef; // Module reference (for the imported modules)
60
61// Assembly tokens.
62typedef mdToken mdAssembly; // Assembly token.
63typedef mdToken mdAssemblyRef; // AssemblyRef token.
64typedef mdToken mdFile; // File token.
65typedef mdToken mdExportedType; // ExportedType token.
66typedef mdToken mdManifestResource; // ManifestResource token.
67
68typedef mdToken mdTypeSpec; // TypeSpec object
69
70typedef mdToken mdGenericParam; // formal parameter to generic type or method
71typedef mdToken mdMethodSpec; // instantiation of a generic method
72typedef mdToken mdGenericParamConstraint; // constraint on a formal generic parameter
73
74// Application string.
75typedef mdToken mdString; // User literal string token.
76
77typedef mdToken mdCPToken; // constantpool token
78
79#ifndef MACROS_NOT_SUPPORTED
80typedef ULONG RID;
81#else
82typedef unsigned RID;
83#endif // MACROS_NOT_SUPPORTED
84
85typedef enum ReplacesGeneralNumericDefines
86{
87// Directory entry macro for CLR data.
88#ifndef IMAGE_DIRECTORY_ENTRY_COMHEADER
89 IMAGE_DIRECTORY_ENTRY_COMHEADER =14,
90#endif // IMAGE_DIRECTORY_ENTRY_COMHEADER
91} ReplacesGeneralNumericDefines;
92
93
94// The COMIMAGE_FLAGS_32BITREQUIRED and COMIMAGE_FLAGS_32BITPREFERRED flags defined below interact as a pair
95// in order to get the performance profile we desire for platform neutral assemblies while retaining backwards
96// compatibility with pre-4.5 runtimes/OSs, which don't know about COMIMAGE_FLAGS_32BITPREFERRED.
97//
98// COMIMAGE_FLAGS_32BITREQUIRED originally meant "this assembly is x86-only" (required to distinguish platform
99// neutral assemblies which also mark their PE MachineType as IMAGE_FILE_MACHINE_I386).
100//
101// COMIMAGE_FLAGS_32BITPREFERRED has been added so we can create a sub-class of platform neutral assembly that
102// prefers to be loaded into 32-bit environment for perf reasons, but is still compatible with 64-bit
103// environments.
104//
105// In order to retain maximum backwards compatibility you cannot simply read or write one of these flags
106// however. You must treat them as a pair, a two-bit field with the following meanings:
107//
108// 32BITREQUIRED 32BITPREFERRED
109// 0 0 : no special meaning, MachineType and ILONLY flag determine image requirements
110// 0 1 : illegal, reserved for future use
111// 1 0 : image is x86-specific
112// 1 1 : image is platform neutral and prefers to be loaded 32-bit when possible
113//
114// To simplify manipulation of these flags the following macros are provided below.
115
116#define COR_IS_32BIT_REQUIRED(_flags) \
117 (((_flags) & (COMIMAGE_FLAGS_32BITREQUIRED|COMIMAGE_FLAGS_32BITPREFERRED)) == (COMIMAGE_FLAGS_32BITREQUIRED))
118
119#define COR_IS_32BIT_PREFERRED(_flags) \
120 (((_flags) & (COMIMAGE_FLAGS_32BITREQUIRED|COMIMAGE_FLAGS_32BITPREFERRED)) == (COMIMAGE_FLAGS_32BITREQUIRED|COMIMAGE_FLAGS_32BITPREFERRED))
121
122#define COR_SET_32BIT_REQUIRED(_flagsfield) \
123 do { _flagsfield = (_flagsfield & ~COMIMAGE_FLAGS_32BITPREFERRED) | COMIMAGE_FLAGS_32BITREQUIRED; } while (false)
124
125#define COR_SET_32BIT_PREFERRED(_flagsfield) \
126 do { _flagsfield |= COMIMAGE_FLAGS_32BITPREFERRED|COMIMAGE_FLAGS_32BITREQUIRED; } while (false)
127
128#define COR_CLEAR_32BIT_REQUIRED(_flagsfield) \
129 do { _flagsfield &= ~(COMIMAGE_FLAGS_32BITREQUIRED|COMIMAGE_FLAGS_32BITPREFERRED); } while (false)
130
131#define COR_CLEAR_32BIT_PREFERRED(_flagsfield) \
132 do { _flagsfield &= ~(COMIMAGE_FLAGS_32BITREQUIRED|COMIMAGE_FLAGS_32BITPREFERRED); } while (false)
133
134
135#ifndef __IMAGE_COR20_HEADER_DEFINED__
136#define __IMAGE_COR20_HEADER_DEFINED__
137
138typedef enum ReplacesCorHdrNumericDefines
139{
140// COM+ Header entry point flags.
141 COMIMAGE_FLAGS_ILONLY =0x00000001,
142 COMIMAGE_FLAGS_32BITREQUIRED =0x00000002, // *** Do not manipulate this bit directly (see notes above)
143 COMIMAGE_FLAGS_IL_LIBRARY =0x00000004,
144 COMIMAGE_FLAGS_STRONGNAMESIGNED =0x00000008,
145 COMIMAGE_FLAGS_NATIVE_ENTRYPOINT =0x00000010,
146 COMIMAGE_FLAGS_TRACKDEBUGDATA =0x00010000,
147 COMIMAGE_FLAGS_32BITPREFERRED =0x00020000, // *** Do not manipulate this bit directly (see notes above)
148
149
150// Version flags for image.
151 COR_VERSION_MAJOR_V2 =2,
152 COR_VERSION_MAJOR =COR_VERSION_MAJOR_V2,
153 COR_VERSION_MINOR =5,
154 COR_DELETED_NAME_LENGTH =8,
155 COR_VTABLEGAP_NAME_LENGTH =8,
156
157// Maximum size of a NativeType descriptor.
158 NATIVE_TYPE_MAX_CB =1,
159 COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE=0xFF,
160
161// V-table constants
162 COR_VTABLE_32BIT =0x01, // V-table slots are 32-bits in size.
163 COR_VTABLE_64BIT =0x02, // V-table slots are 64-bits in size.
164 COR_VTABLE_FROM_UNMANAGED =0x04, // If set, transition from unmanaged.
165 COR_VTABLE_FROM_UNMANAGED_RETAIN_APPDOMAIN=0x08, // NEW
166 COR_VTABLE_CALL_MOST_DERIVED =0x10, // Call most derived method described by
167
168// EATJ constants
169 IMAGE_COR_EATJ_THUNK_SIZE = 32, // Size of a jump thunk reserved range.
170
171// Max name lengths
172 //@todo: Change to unlimited name lengths.
173 MAX_CLASS_NAME =1024,
174 MAX_PACKAGE_NAME =1024,
175} ReplacesCorHdrNumericDefines;
176
177// #ManagedHeader
178//
179// A managed code EXE or DLL uses the same basic format that unmanaged executables use call the Portable
180// Executable (PE) format. See http://en.wikipedia.org/wiki/Portable_Executable or
181// http://msdn.microsoft.com/msdnmag/issues/02/02/PE/default.aspx for more on this format and RVAs.
182//
183// PE files define fixed table of well known entry pointers call Directory entries. Each entry holds the
184// relative virtual address (RVA) and length of a blob of data within the PE file. You can see these using
185// the command
186//
187// link /dump /headers <EXENAME>
188//
189//
190// Managed code has defined one of these entries (the 14th see code:IMAGE_DIRECTORY_ENTRY_COMHEADER) and the RVA points
191// that the IMAGE_COR20_HEADER. This header shows up in the previous dump as the following line
192//
193// // Managed code is identified by is following line
194//
195// 2008 [ 48] RVA [size] of COM Descriptor Directory
196//
197// The IMAGE_COR20_HEADER is mostly just RVA:Length pairs (pointers) to other interesting data structures.
198// The most important of these is the MetaData tables. The easiest way of looking at meta-data is using
199// the IlDasm.exe tool.
200//
201// MetaData holds most of the information in the IL image. The exceptions are resource blobs and the IL
202// instructions streams for individual methods. Instead the Meta-data for a method holds an RVA to a
203// code:IMAGE_COR_ILMETHOD which holds all the IL stream (and exception handling information).
204//
205// Precompiled (NGEN) images use the same IMAGE_COR20_HEADER but also use the ManagedNativeHeader field to
206// point at structures that only exist in precompiled images.
207//
208typedef struct IMAGE_COR20_HEADER
209{
210 // Header versioning
211 DWORD cb;
212 WORD MajorRuntimeVersion;
213 WORD MinorRuntimeVersion;
214
215 // Symbol table and startup information
216 IMAGE_DATA_DIRECTORY MetaData;
217 DWORD Flags;
218
219 // The main program if it is an EXE (not used if a DLL?)
220 // If COMIMAGE_FLAGS_NATIVE_ENTRYPOINT is not set, EntryPointToken represents a managed entrypoint.
221 // If COMIMAGE_FLAGS_NATIVE_ENTRYPOINT is set, EntryPointRVA represents an RVA to a native entrypoint
222 // (depricated for DLLs, use modules constructors intead).
223 union {
224 DWORD EntryPointToken;
225 DWORD EntryPointRVA;
226 };
227
228 // This is the blob of managed resources. Fetched using code:AssemblyNative.GetResource and
229 // code:PEFile.GetResource and accessible from managed code from
230 // System.Assembly.GetManifestResourceStream. The meta data has a table that maps names to offsets into
231 // this blob, so logically the blob is a set of resources.
232 IMAGE_DATA_DIRECTORY Resources;
233 // IL assemblies can be signed with a public-private key to validate who created it. The signature goes
234 // here if this feature is used.
235 IMAGE_DATA_DIRECTORY StrongNameSignature;
236
237 IMAGE_DATA_DIRECTORY CodeManagerTable; // Depricated, not used
238 // Used for manged codee that has unmaanaged code inside it (or exports methods as unmanaged entry points)
239 IMAGE_DATA_DIRECTORY VTableFixups;
240 IMAGE_DATA_DIRECTORY ExportAddressTableJumps;
241
242 // null for ordinary IL images. NGEN images it points at a code:CORCOMPILE_HEADER structure
243 IMAGE_DATA_DIRECTORY ManagedNativeHeader;
244
245} IMAGE_COR20_HEADER, *PIMAGE_COR20_HEADER;
246
247#else // !__IMAGE_COR20_HEADER_DEFINED__
248
249// <TODO>@TODO: This is required because we pull in the COM+ 2.0 PE header
250// definition from WinNT.h, and these constants have not yet propogated to there.</TODO>
251//
252#define COR_VTABLE_FROM_UNMANAGED_RETAIN_APPDOMAIN 0x08
253#define COMIMAGE_FLAGS_32BITPREFERRED 0x00020000
254
255#endif // __IMAGE_COR20_HEADER_DEFINED__
256
257
258// The most recent version.
259
260#define COR_CTOR_METHOD_NAME ".ctor"
261#define COR_CTOR_METHOD_NAME_W L".ctor"
262#define COR_CCTOR_METHOD_NAME ".cctor"
263#define COR_CCTOR_METHOD_NAME_W L".cctor"
264
265#define COR_ENUM_FIELD_NAME "value__"
266#define COR_ENUM_FIELD_NAME_W L"value__"
267
268// The predefined name for deleting a typeDef,MethodDef, FieldDef, Property and Event
269#define COR_DELETED_NAME_A "_Deleted"
270#define COR_DELETED_NAME_W L"_Deleted"
271#define COR_VTABLEGAP_NAME_A "_VtblGap"
272#define COR_VTABLEGAP_NAME_W L"_VtblGap"
273
274// We intentionally use strncmp so that we will ignore any suffix
275#define IsDeletedName(strName) (strncmp(strName, COR_DELETED_NAME_A, COR_DELETED_NAME_LENGTH) == 0)
276#define IsVtblGapName(strName) (strncmp(strName, COR_VTABLEGAP_NAME_A, COR_VTABLEGAP_NAME_LENGTH) == 0)
277
278// TypeDef/ExportedType attr bits, used by DefineTypeDef.
279typedef enum CorTypeAttr
280{
281 // Use this mask to retrieve the type visibility information.
282 tdVisibilityMask = 0x00000007,
283 tdNotPublic = 0x00000000, // Class is not public scope.
284 tdPublic = 0x00000001, // Class is public scope.
285 tdNestedPublic = 0x00000002, // Class is nested with public visibility.
286 tdNestedPrivate = 0x00000003, // Class is nested with private visibility.
287 tdNestedFamily = 0x00000004, // Class is nested with family visibility.
288 tdNestedAssembly = 0x00000005, // Class is nested with assembly visibility.
289 tdNestedFamANDAssem = 0x00000006, // Class is nested with family and assembly visibility.
290 tdNestedFamORAssem = 0x00000007, // Class is nested with family or assembly visibility.
291
292 // Use this mask to retrieve class layout information
293 tdLayoutMask = 0x00000018,
294 tdAutoLayout = 0x00000000, // Class fields are auto-laid out
295 tdSequentialLayout = 0x00000008, // Class fields are laid out sequentially
296 tdExplicitLayout = 0x00000010, // Layout is supplied explicitly
297 // end layout mask
298
299 // Use this mask to retrieve class semantics information.
300 tdClassSemanticsMask = 0x00000020,
301 tdClass = 0x00000000, // Type is a class.
302 tdInterface = 0x00000020, // Type is an interface.
303 // end semantics mask
304
305 // Special semantics in addition to class semantics.
306 tdAbstract = 0x00000080, // Class is abstract
307 tdSealed = 0x00000100, // Class is concrete and may not be extended
308 tdSpecialName = 0x00000400, // Class name is special. Name describes how.
309
310 // Implementation attributes.
311 tdImport = 0x00001000, // Class / interface is imported
312 tdSerializable = 0x00002000, // The class is Serializable.
313 tdWindowsRuntime = 0x00004000, // The type is a Windows Runtime type
314
315 // Use tdStringFormatMask to retrieve string information for native interop
316 tdStringFormatMask = 0x00030000,
317 tdAnsiClass = 0x00000000, // LPTSTR is interpreted as ANSI in this class
318 tdUnicodeClass = 0x00010000, // LPTSTR is interpreted as UNICODE
319 tdAutoClass = 0x00020000, // LPTSTR is interpreted automatically
320 tdCustomFormatClass = 0x00030000, // A non-standard encoding specified by CustomFormatMask
321 tdCustomFormatMask = 0x00C00000, // Use this mask to retrieve non-standard encoding information for native interop. The meaning of the values of these 2 bits is unspecified.
322
323 // end string format mask
324
325 tdBeforeFieldInit = 0x00100000, // Initialize the class any time before first static field access.
326 tdForwarder = 0x00200000, // This ExportedType is a type forwarder.
327
328 // Flags reserved for runtime use.
329 tdReservedMask = 0x00040800,
330 tdRTSpecialName = 0x00000800, // Runtime should check name encoding.
331 tdHasSecurity = 0x00040000, // Class has security associate with it.
332} CorTypeAttr;
333
334
335// Macros for accessing the members of the CorTypeAttr.
336#define IsTdNotPublic(x) (((x) & tdVisibilityMask) == tdNotPublic)
337#define IsTdPublic(x) (((x) & tdVisibilityMask) == tdPublic)
338#define IsTdNestedPublic(x) (((x) & tdVisibilityMask) == tdNestedPublic)
339#define IsTdNestedPrivate(x) (((x) & tdVisibilityMask) == tdNestedPrivate)
340#define IsTdNestedFamily(x) (((x) & tdVisibilityMask) == tdNestedFamily)
341#define IsTdNestedAssembly(x) (((x) & tdVisibilityMask) == tdNestedAssembly)
342#define IsTdNestedFamANDAssem(x) (((x) & tdVisibilityMask) == tdNestedFamANDAssem)
343#define IsTdNestedFamORAssem(x) (((x) & tdVisibilityMask) == tdNestedFamORAssem)
344#define IsTdNested(x) (((x) & tdVisibilityMask) >= tdNestedPublic)
345
346#define IsTdAutoLayout(x) (((x) & tdLayoutMask) == tdAutoLayout)
347#define IsTdSequentialLayout(x) (((x) & tdLayoutMask) == tdSequentialLayout)
348#define IsTdExplicitLayout(x) (((x) & tdLayoutMask) == tdExplicitLayout)
349
350#define IsTdClass(x) (((x) & tdClassSemanticsMask) == tdClass)
351#define IsTdInterface(x) (((x) & tdClassSemanticsMask) == tdInterface)
352
353#define IsTdAbstract(x) ((x) & tdAbstract)
354#define IsTdSealed(x) ((x) & tdSealed)
355#define IsTdSpecialName(x) ((x) & tdSpecialName)
356
357#define IsTdImport(x) ((x) & tdImport)
358#define IsTdSerializable(x) ((x) & tdSerializable)
359#define IsTdWindowsRuntime(x) ((x) & tdWindowsRuntime)
360
361#define IsTdAnsiClass(x) (((x) & tdStringFormatMask) == tdAnsiClass)
362#define IsTdUnicodeClass(x) (((x) & tdStringFormatMask) == tdUnicodeClass)
363#define IsTdAutoClass(x) (((x) & tdStringFormatMask) == tdAutoClass)
364#define IsTdCustomFormatClass(x) (((x) & tdStringFormatMask) == tdCustomFormatClass)
365#define IsTdBeforeFieldInit(x) ((x) & tdBeforeFieldInit)
366#define IsTdForwarder(x) ((x) & tdForwarder)
367
368#define IsTdRTSpecialName(x) ((x) & tdRTSpecialName)
369#define IsTdHasSecurity(x) ((x) & tdHasSecurity)
370
371// MethodDef attr bits, Used by DefineMethod.
372typedef enum CorMethodAttr
373{
374 // member access mask - Use this mask to retrieve accessibility information.
375 mdMemberAccessMask = 0x0007,
376 mdPrivateScope = 0x0000, // Member not referenceable.
377 mdPrivate = 0x0001, // Accessible only by the parent type.
378 mdFamANDAssem = 0x0002, // Accessible by sub-types only in this Assembly.
379 mdAssem = 0x0003, // Accessibly by anyone in the Assembly.
380 mdFamily = 0x0004, // Accessible only by type and sub-types.
381 mdFamORAssem = 0x0005, // Accessibly by sub-types anywhere, plus anyone in assembly.
382 mdPublic = 0x0006, // Accessibly by anyone who has visibility to this scope.
383 // end member access mask
384
385 // method contract attributes.
386 mdStatic = 0x0010, // Defined on type, else per instance.
387 mdFinal = 0x0020, // Method may not be overridden.
388 mdVirtual = 0x0040, // Method virtual.
389 mdHideBySig = 0x0080, // Method hides by name+sig, else just by name.
390
391 // vtable layout mask - Use this mask to retrieve vtable attributes.
392 mdVtableLayoutMask = 0x0100,
393 mdReuseSlot = 0x0000, // The default.
394 mdNewSlot = 0x0100, // Method always gets a new slot in the vtable.
395 // end vtable layout mask
396
397 // method implementation attributes.
398 mdCheckAccessOnOverride = 0x0200, // Overridability is the same as the visibility.
399 mdAbstract = 0x0400, // Method does not provide an implementation.
400 mdSpecialName = 0x0800, // Method is special. Name describes how.
401
402 // interop attributes
403 mdPinvokeImpl = 0x2000, // Implementation is forwarded through pinvoke.
404 mdUnmanagedExport = 0x0008, // Managed method exported via thunk to unmanaged code.
405
406 // Reserved flags for runtime use only.
407 mdReservedMask = 0xd000,
408 mdRTSpecialName = 0x1000, // Runtime should check name encoding.
409 mdHasSecurity = 0x4000, // Method has security associate with it.
410 mdRequireSecObject = 0x8000, // Method calls another method containing security code.
411
412} CorMethodAttr;
413
414// Macros for accessing the members of CorMethodAttr.
415#define IsMdPrivateScope(x) (((x) & mdMemberAccessMask) == mdPrivateScope)
416#define IsMdPrivate(x) (((x) & mdMemberAccessMask) == mdPrivate)
417#define IsMdFamANDAssem(x) (((x) & mdMemberAccessMask) == mdFamANDAssem)
418#define IsMdAssem(x) (((x) & mdMemberAccessMask) == mdAssem)
419#define IsMdFamily(x) (((x) & mdMemberAccessMask) == mdFamily)
420#define IsMdFamORAssem(x) (((x) & mdMemberAccessMask) == mdFamORAssem)
421#define IsMdPublic(x) (((x) & mdMemberAccessMask) == mdPublic)
422
423#define IsMdStatic(x) ((x) & mdStatic)
424#define IsMdFinal(x) ((x) & mdFinal)
425#define IsMdVirtual(x) ((x) & mdVirtual)
426#define IsMdHideBySig(x) ((x) & mdHideBySig)
427
428#define IsMdReuseSlot(x) (((x) & mdVtableLayoutMask) == mdReuseSlot)
429#define IsMdNewSlot(x) (((x) & mdVtableLayoutMask) == mdNewSlot)
430
431#define IsMdCheckAccessOnOverride(x) ((x) & mdCheckAccessOnOverride)
432#define IsMdAbstract(x) ((x) & mdAbstract)
433#define IsMdSpecialName(x) ((x) & mdSpecialName)
434
435#define IsMdPinvokeImpl(x) ((x) & mdPinvokeImpl)
436#define IsMdUnmanagedExport(x) ((x) & mdUnmanagedExport)
437
438#define IsMdRTSpecialName(x) ((x) & mdRTSpecialName)
439#define IsMdInstanceInitializer(x, str) (((x) & mdRTSpecialName) && !strcmp((str), COR_CTOR_METHOD_NAME))
440#define IsMdInstanceInitializerW(x, str) (((x) & mdRTSpecialName) && !wcscmp((str), COR_CTOR_METHOD_NAME_W))
441#define IsMdClassConstructor(x, str) (((x) & mdRTSpecialName) && !strcmp((str), COR_CCTOR_METHOD_NAME))
442#define IsMdClassConstructorW(x, str) (((x) & mdRTSpecialName) && !wcscmp((str), COR_CCTOR_METHOD_NAME_W))
443#define IsMdHasSecurity(x) ((x) & mdHasSecurity)
444#define IsMdRequireSecObject(x) ((x) & mdRequireSecObject)
445
446// FieldDef attr bits, used by DefineField.
447typedef enum CorFieldAttr
448{
449 // member access mask - Use this mask to retrieve accessibility information.
450 fdFieldAccessMask = 0x0007,
451 fdPrivateScope = 0x0000, // Member not referenceable.
452 fdPrivate = 0x0001, // Accessible only by the parent type.
453 fdFamANDAssem = 0x0002, // Accessible by sub-types only in this Assembly.
454 fdAssembly = 0x0003, // Accessibly by anyone in the Assembly.
455 fdFamily = 0x0004, // Accessible only by type and sub-types.
456 fdFamORAssem = 0x0005, // Accessibly by sub-types anywhere, plus anyone in assembly.
457 fdPublic = 0x0006, // Accessibly by anyone who has visibility to this scope.
458 // end member access mask
459
460 // field contract attributes.
461 fdStatic = 0x0010, // Defined on type, else per instance.
462 fdInitOnly = 0x0020, // Field may only be initialized, not written to after init.
463 fdLiteral = 0x0040, // Value is compile time constant.
464 fdNotSerialized = 0x0080, // Field does not have to be serialized when type is remoted.
465
466 fdSpecialName = 0x0200, // field is special. Name describes how.
467
468 // interop attributes
469 fdPinvokeImpl = 0x2000, // Implementation is forwarded through pinvoke.
470
471 // Reserved flags for runtime use only.
472 fdReservedMask = 0x9500,
473 fdRTSpecialName = 0x0400, // Runtime(metadata internal APIs) should check name encoding.
474 fdHasFieldMarshal = 0x1000, // Field has marshalling information.
475 fdHasDefault = 0x8000, // Field has default.
476 fdHasFieldRVA = 0x0100, // Field has RVA.
477} CorFieldAttr;
478
479// Macros for accessing the members of CorFieldAttr.
480#define IsFdPrivateScope(x) (((x) & fdFieldAccessMask) == fdPrivateScope)
481#define IsFdPrivate(x) (((x) & fdFieldAccessMask) == fdPrivate)
482#define IsFdFamANDAssem(x) (((x) & fdFieldAccessMask) == fdFamANDAssem)
483#define IsFdAssembly(x) (((x) & fdFieldAccessMask) == fdAssembly)
484#define IsFdFamily(x) (((x) & fdFieldAccessMask) == fdFamily)
485#define IsFdFamORAssem(x) (((x) & fdFieldAccessMask) == fdFamORAssem)
486#define IsFdPublic(x) (((x) & fdFieldAccessMask) == fdPublic)
487
488#define IsFdStatic(x) ((x) & fdStatic)
489#define IsFdInitOnly(x) ((x) & fdInitOnly)
490#define IsFdLiteral(x) ((x) & fdLiteral)
491#define IsFdNotSerialized(x) ((x) & fdNotSerialized)
492
493#define IsFdPinvokeImpl(x) ((x) & fdPinvokeImpl)
494#define IsFdSpecialName(x) ((x) & fdSpecialName)
495#define IsFdHasFieldRVA(x) ((x) & fdHasFieldRVA)
496
497#define IsFdRTSpecialName(x) ((x) & fdRTSpecialName)
498#define IsFdHasFieldMarshal(x) ((x) & fdHasFieldMarshal)
499#define IsFdHasDefault(x) ((x) & fdHasDefault)
500
501// Param attr bits, used by DefineParam.
502typedef enum CorParamAttr
503{
504 pdIn = 0x0001, // Param is [In]
505 pdOut = 0x0002, // Param is [out]
506 pdOptional = 0x0010, // Param is optional
507
508 // Reserved flags for Runtime use only.
509 pdReservedMask = 0xf000,
510 pdHasDefault = 0x1000, // Param has default value.
511 pdHasFieldMarshal = 0x2000, // Param has FieldMarshal.
512
513 pdUnused = 0xcfe0,
514} CorParamAttr;
515
516// Macros for accessing the members of CorParamAttr.
517#define IsPdIn(x) ((x) & pdIn)
518#define IsPdOut(x) ((x) & pdOut)
519#define IsPdOptional(x) ((x) & pdOptional)
520
521#define IsPdHasDefault(x) ((x) & pdHasDefault)
522#define IsPdHasFieldMarshal(x) ((x) & pdHasFieldMarshal)
523
524
525// Property attr bits, used by DefineProperty.
526typedef enum CorPropertyAttr
527{
528 prSpecialName = 0x0200, // property is special. Name describes how.
529
530 // Reserved flags for Runtime use only.
531 prReservedMask = 0xf400,
532 prRTSpecialName = 0x0400, // Runtime(metadata internal APIs) should check name encoding.
533 prHasDefault = 0x1000, // Property has default
534
535 prUnused = 0xe9ff,
536} CorPropertyAttr;
537
538// Macros for accessing the members of CorPropertyAttr.
539#define IsPrSpecialName(x) ((x) & prSpecialName)
540
541#define IsPrRTSpecialName(x) ((x) & prRTSpecialName)
542#define IsPrHasDefault(x) ((x) & prHasDefault)
543
544// Event attr bits, used by DefineEvent.
545typedef enum CorEventAttr
546{
547 evSpecialName = 0x0200, // event is special. Name describes how.
548
549 // Reserved flags for Runtime use only.
550 evReservedMask = 0x0400,
551 evRTSpecialName = 0x0400, // Runtime(metadata internal APIs) should check name encoding.
552} CorEventAttr;
553
554// Macros for accessing the members of CorEventAttr.
555#define IsEvSpecialName(x) ((x) & evSpecialName)
556
557#define IsEvRTSpecialName(x) ((x) & evRTSpecialName)
558
559
560// MethodSemantic attr bits, used by DefineProperty, DefineEvent.
561typedef enum CorMethodSemanticsAttr
562{
563 msSetter = 0x0001, // Setter for property
564 msGetter = 0x0002, // Getter for property
565 msOther = 0x0004, // other method for property or event
566 msAddOn = 0x0008, // AddOn method for event
567 msRemoveOn = 0x0010, // RemoveOn method for event
568 msFire = 0x0020, // Fire method for event
569} CorMethodSemanticsAttr;
570
571// Macros for accessing the members of CorMethodSemanticsAttr.
572#define IsMsSetter(x) ((x) & msSetter)
573#define IsMsGetter(x) ((x) & msGetter)
574#define IsMsOther(x) ((x) & msOther)
575#define IsMsAddOn(x) ((x) & msAddOn)
576#define IsMsRemoveOn(x) ((x) & msRemoveOn)
577#define IsMsFire(x) ((x) & msFire)
578
579
580// DeclSecurity attr bits, used by DefinePermissionSet.
581typedef enum CorDeclSecurity
582{
583 dclActionMask = 0x001f, // Mask allows growth of enum.
584 dclActionNil = 0x0000, //
585 dclRequest = 0x0001, //
586 dclDemand = 0x0002, //
587 dclAssert = 0x0003, //
588 dclDeny = 0x0004, //
589 dclPermitOnly = 0x0005, //
590 dclLinktimeCheck = 0x0006, //
591 dclInheritanceCheck = 0x0007, //
592 dclRequestMinimum = 0x0008, //
593 dclRequestOptional = 0x0009, //
594 dclRequestRefuse = 0x000a, //
595 dclPrejitGrant = 0x000b, // Persisted grant set at prejit time
596 dclPrejitDenied = 0x000c, // Persisted denied set at prejit time
597 dclNonCasDemand = 0x000d, //
598 dclNonCasLinkDemand = 0x000e, //
599 dclNonCasInheritance = 0x000f, //
600 dclMaximumValue = 0x000f, // Maximum legal value
601} CorDeclSecurity;
602
603// Macros for accessing the members of CorDeclSecurity.
604#define IsDclActionNil(x) (((x) & dclActionMask) == dclActionNil)
605
606// Is this a demand that can trigger a stackwalk?
607#define IsDclActionAnyStackModifier(x) ((((x) & dclActionMask) == dclAssert) || \
608 (((x) & dclActionMask) == dclDeny) || \
609 (((x) & dclActionMask) == dclPermitOnly))
610
611// Is this an assembly level attribute (i.e. not applicable on Type/Member)?
612#define IsAssemblyDclAction(x) (((x) >= dclRequestMinimum) && \
613 ((x) <= dclRequestRefuse))
614
615// Is this an NGen only attribute?
616#define IsNGenOnlyDclAction(x) (((x) == dclPrejitGrant) || \
617 ((x) == dclPrejitDenied))
618
619
620// MethodImpl attr bits, used by DefineMethodImpl.
621typedef enum CorMethodImpl
622{
623 // code impl mask
624 miCodeTypeMask = 0x0003, // Flags about code type.
625 miIL = 0x0000, // Method impl is IL.
626 miNative = 0x0001, // Method impl is native.
627 miOPTIL = 0x0002, // Method impl is OPTIL
628 miRuntime = 0x0003, // Method impl is provided by the runtime.
629 // end code impl mask
630
631 // managed mask
632 miManagedMask = 0x0004, // Flags specifying whether the code is managed or unmanaged.
633 miUnmanaged = 0x0004, // Method impl is unmanaged, otherwise managed.
634 miManaged = 0x0000, // Method impl is managed.
635 // end managed mask
636
637 // implementation info and interop
638 miForwardRef = 0x0010, // Indicates method is defined; used primarily in merge scenarios.
639 miPreserveSig = 0x0080, // Indicates method sig is not to be mangled to do HRESULT conversion.
640
641 miInternalCall = 0x1000, // Reserved for internal use.
642
643 miSynchronized = 0x0020, // Method is single threaded through the body.
644 miNoInlining = 0x0008, // Method may not be inlined.
645 miAggressiveInlining = 0x0100, // Method should be inlined if possible.
646 miNoOptimization = 0x0040, // Method may not be optimized.
647 miAggressiveOptimization = 0x0200, // Method may contain hot code and should be aggressively optimized.
648
649 // These are the flags that are allowed in MethodImplAttribute's Value
650 // property. This should include everything above except the code impl
651 // flags (which are used for MethodImplAttribute's MethodCodeType field).
652 miUserMask = miManagedMask | miForwardRef | miPreserveSig |
653 miInternalCall | miSynchronized |
654 miNoInlining | miAggressiveInlining |
655 miNoOptimization | miAggressiveOptimization,
656
657 miMaxMethodImplVal = 0xffff, // Range check value
658} CorMethodImpl;
659
660// Macros for accesing the members of CorMethodImpl.
661#define IsMiIL(x) (((x) & miCodeTypeMask) == miIL)
662#define IsMiNative(x) (((x) & miCodeTypeMask) == miNative)
663#define IsMiOPTIL(x) (((x) & miCodeTypeMask) == miOPTIL)
664#define IsMiRuntime(x) (((x) & miCodeTypeMask) == miRuntime)
665
666#define IsMiUnmanaged(x) (((x) & miManagedMask) == miUnmanaged)
667#define IsMiManaged(x) (((x) & miManagedMask) == miManaged)
668
669#define IsMiForwardRef(x) ((x) & miForwardRef)
670#define IsMiPreserveSig(x) ((x) & miPreserveSig)
671
672#define IsMiInternalCall(x) ((x) & miInternalCall)
673
674#define IsMiSynchronized(x) ((x) & miSynchronized)
675#define IsMiNoInlining(x) ((x) & miNoInlining)
676#define IsMiAggressiveInlining(x) ((x) & miAggressiveInlining)
677#define IsMiNoOptimization(x) ((x) & miNoOptimization)
678#define IsMiAggressiveOptimization(x) (((x) & (miAggressiveOptimization | miNoOptimization)) == miAggressiveOptimization)
679
680// PinvokeMap attr bits, used by DefinePinvokeMap.
681typedef enum CorPinvokeMap
682{
683 pmNoMangle = 0x0001, // Pinvoke is to use the member name as specified.
684
685 // Use this mask to retrieve the CharSet information.
686 pmCharSetMask = 0x0006,
687 pmCharSetNotSpec = 0x0000,
688 pmCharSetAnsi = 0x0002,
689 pmCharSetUnicode = 0x0004,
690 pmCharSetAuto = 0x0006,
691
692
693 pmBestFitUseAssem = 0x0000,
694 pmBestFitEnabled = 0x0010,
695 pmBestFitDisabled = 0x0020,
696 pmBestFitMask = 0x0030,
697
698 pmThrowOnUnmappableCharUseAssem = 0x0000,
699 pmThrowOnUnmappableCharEnabled = 0x1000,
700 pmThrowOnUnmappableCharDisabled = 0x2000,
701 pmThrowOnUnmappableCharMask = 0x3000,
702
703 pmSupportsLastError = 0x0040, // Information about target function. Not relevant for fields.
704
705 // None of the calling convention flags is relevant for fields.
706 pmCallConvMask = 0x0700,
707 pmCallConvWinapi = 0x0100, // Pinvoke will use native callconv appropriate to target windows platform.
708 pmCallConvCdecl = 0x0200,
709 pmCallConvStdcall = 0x0300,
710 pmCallConvThiscall = 0x0400, // In M9, pinvoke will raise exception.
711 pmCallConvFastcall = 0x0500,
712
713 pmMaxValue = 0xFFFF,
714} CorPinvokeMap;
715
716// Macros for accessing the members of CorPinvokeMap
717#define IsPmNoMangle(x) ((x) & pmNoMangle)
718
719#define IsPmCharSetNotSpec(x) (((x) & pmCharSetMask) == pmCharSetNotSpec)
720#define IsPmCharSetAnsi(x) (((x) & pmCharSetMask) == pmCharSetAnsi)
721#define IsPmCharSetUnicode(x) (((x) & pmCharSetMask) == pmCharSetUnicode)
722#define IsPmCharSetAuto(x) (((x) & pmCharSetMask) == pmCharSetAuto)
723
724#define IsPmSupportsLastError(x) ((x) & pmSupportsLastError)
725
726#define IsPmCallConvWinapi(x) (((x) & pmCallConvMask) == pmCallConvWinapi)
727#define IsPmCallConvCdecl(x) (((x) & pmCallConvMask) == pmCallConvCdecl)
728#define IsPmCallConvStdcall(x) (((x) & pmCallConvMask) == pmCallConvStdcall)
729#define IsPmCallConvThiscall(x) (((x) & pmCallConvMask) == pmCallConvThiscall)
730#define IsPmCallConvFastcall(x) (((x) & pmCallConvMask) == pmCallConvFastcall)
731
732#define IsPmBestFitEnabled(x) (((x) & pmBestFitMask) == pmBestFitEnabled)
733#define IsPmBestFitDisabled(x) (((x) & pmBestFitMask) == pmBestFitDisabled)
734#define IsPmBestFitUseAssem(x) (((x) & pmBestFitMask) == pmBestFitUseAssem)
735
736#define IsPmThrowOnUnmappableCharEnabled(x) (((x) & pmThrowOnUnmappableCharMask) == pmThrowOnUnmappableCharEnabled)
737#define IsPmThrowOnUnmappableCharDisabled(x) (((x) & pmThrowOnUnmappableCharMask) == pmThrowOnUnmappableCharDisabled)
738#define IsPmThrowOnUnmappableCharUseAssem(x) (((x) & pmThrowOnUnmappableCharMask) == pmThrowOnUnmappableCharUseAssem)
739
740// Assembly attr bits, used by DefineAssembly.
741typedef enum CorAssemblyFlags
742{
743 afPublicKey = 0x0001, // The assembly ref holds the full (unhashed) public key.
744
745 afPA_None = 0x0000, // Processor Architecture unspecified
746 afPA_MSIL = 0x0010, // Processor Architecture: neutral (PE32)
747 afPA_x86 = 0x0020, // Processor Architecture: x86 (PE32)
748 afPA_IA64 = 0x0030, // Processor Architecture: Itanium (PE32+)
749 afPA_AMD64 = 0x0040, // Processor Architecture: AMD X64 (PE32+)
750 afPA_ARM = 0x0050, // Processor Architecture: ARM (PE32)
751 afPA_ARM64 = 0x0060, // Processor Architecture: ARM64 (PE32+)
752 afPA_NoPlatform = 0x0070, // applies to any platform but cannot run on any (e.g. reference assembly), should not have "specified" set
753 afPA_Specified = 0x0080, // Propagate PA flags to AssemblyRef record
754 afPA_Mask = 0x0070, // Bits describing the processor architecture
755 afPA_FullMask = 0x00F0, // Bits describing the PA incl. Specified
756 afPA_Shift = 0x0004, // NOT A FLAG, shift count in PA flags <--> index conversion
757
758 afEnableJITcompileTracking = 0x8000, // From "DebuggableAttribute".
759 afDisableJITcompileOptimizer = 0x4000, // From "DebuggableAttribute".
760 afDebuggableAttributeMask = 0xc000,
761
762 afRetargetable = 0x0100, // The assembly can be retargeted (at runtime) to an
763 // assembly from a different publisher.
764
765 afContentType_Default = 0x0000,
766 afContentType_WindowsRuntime = 0x0200,
767 afContentType_Mask = 0x0E00, // Bits describing ContentType
768} CorAssemblyFlags;
769
770// Macros for accessing the members of CorAssemblyFlags.
771#define IsAfRetargetable(x) ((x) & afRetargetable)
772#define IsAfContentType_Default(x) (((x) & afContentType_Mask) == afContentType_Default)
773#define IsAfContentType_WindowsRuntime(x) (((x) & afContentType_Mask) == afContentType_WindowsRuntime)
774
775// Macros for accessing the Processor Architecture flags of CorAssemblyFlags.
776#define IsAfPA_MSIL(x) (((x) & afPA_Mask) == afPA_MSIL)
777#define IsAfPA_x86(x) (((x) & afPA_Mask) == afPA_x86)
778#define IsAfPA_IA64(x) (((x) & afPA_Mask) == afPA_IA64)
779#define IsAfPA_AMD64(x) (((x) & afPA_Mask) == afPA_AMD64)
780#define IsAfPA_ARM(x) (((x) & afPA_Mask) == afPA_ARM)
781#define IsAfPA_ARM64(x) (((x) & afPA_Mask) == afPA_ARM64)
782#define IsAfPA_NoPlatform(x) (((x) & afPA_FullMask) == afPA_NoPlatform)
783#define IsAfPA_Specified(x) ((x) & afPA_Specified)
784#define PAIndex(x) (((x) & afPA_Mask) >> afPA_Shift)
785#define PAFlag(x) (((x) << afPA_Shift) & afPA_Mask)
786#define PrepareForSaving(x) ((x) & (((x) & afPA_Specified) ? ~afPA_Specified : ~afPA_FullMask))
787
788#define IsAfEnableJITcompileTracking(x) ((x) & afEnableJITcompileTracking)
789#define IsAfDisableJITcompileOptimizer(x) ((x) & afDisableJITcompileOptimizer)
790
791// Macros for accessing the public key flags of CorAssemblyFlags.
792#define IsAfPublicKey(x) ((x) & afPublicKey)
793#define IsAfPublicKeyToken(x) (((x) & afPublicKey) == 0)
794
795
796// ManifestResource attr bits, used by DefineManifestResource.
797typedef enum CorManifestResourceFlags
798{
799 mrVisibilityMask = 0x0007,
800 mrPublic = 0x0001, // The Resource is exported from the Assembly.
801 mrPrivate = 0x0002, // The Resource is private to the Assembly.
802} CorManifestResourceFlags;
803
804// Macros for accessing the members of CorManifestResourceFlags.
805#define IsMrPublic(x) (((x) & mrVisibilityMask) == mrPublic)
806#define IsMrPrivate(x) (((x) & mrVisibilityMask) == mrPrivate)
807
808
809// File attr bits, used by DefineFile.
810typedef enum CorFileFlags
811{
812 ffContainsMetaData = 0x0000, // This is not a resource file
813 ffContainsNoMetaData = 0x0001, // This is a resource file or other non-metadata-containing file
814} CorFileFlags;
815
816// Macros for accessing the members of CorFileFlags.
817#define IsFfContainsMetaData(x) (!((x) & ffContainsNoMetaData))
818#define IsFfContainsNoMetaData(x) ((x) & ffContainsNoMetaData)
819
820// PE file kind bits, returned by IMetaDataImport2::GetPEKind()
821typedef enum CorPEKind
822{
823 peNot = 0x00000000, // not a PE file
824 peILonly = 0x00000001, // flag IL_ONLY is set in COR header
825 pe32BitRequired=0x00000002, // flag 32BITREQUIRED is set and 32BITPREFERRED is clear in COR header
826 pe32Plus = 0x00000004, // PE32+ file (64 bit)
827 pe32Unmanaged=0x00000008, // PE32 without COR header
828 pe32BitPreferred=0x00000010 // flags 32BITREQUIRED and 32BITPREFERRED are set in COR header
829} CorPEKind;
830
831
832// GenericParam bits, used by DefineGenericParam.
833typedef enum CorGenericParamAttr
834{
835 // Variance of type parameters, only applicable to generic parameters
836 // for generic interfaces and delegates
837 gpVarianceMask = 0x0003,
838 gpNonVariant = 0x0000,
839 gpCovariant = 0x0001,
840 gpContravariant = 0x0002,
841
842 // Special constraints, applicable to any type parameters
843 gpSpecialConstraintMask = 0x001C,
844 gpNoSpecialConstraint = 0x0000,
845 gpReferenceTypeConstraint = 0x0004, // type argument must be a reference type
846 gpNotNullableValueTypeConstraint = 0x0008, // type argument must be a value type but not Nullable
847 gpDefaultConstructorConstraint = 0x0010, // type argument must have a public default constructor
848} CorGenericParamAttr;
849
850// structures and enums moved from COR.H
851typedef unsigned __int8 COR_SIGNATURE;
852
853typedef COR_SIGNATURE* PCOR_SIGNATURE; // pointer to a cor sig. Not void* so that
854 // the bytes can be incremented easily
855typedef const COR_SIGNATURE* PCCOR_SIGNATURE;
856
857
858typedef const char * MDUTF8CSTR;
859typedef char * MDUTF8STR;
860
861//*****************************************************************************
862//
863// Element type for Cor signature
864//
865//*****************************************************************************
866
867typedef enum CorElementType
868{
869 ELEMENT_TYPE_END = 0x00,
870 ELEMENT_TYPE_VOID = 0x01,
871 ELEMENT_TYPE_BOOLEAN = 0x02,
872 ELEMENT_TYPE_CHAR = 0x03,
873 ELEMENT_TYPE_I1 = 0x04,
874 ELEMENT_TYPE_U1 = 0x05,
875 ELEMENT_TYPE_I2 = 0x06,
876 ELEMENT_TYPE_U2 = 0x07,
877 ELEMENT_TYPE_I4 = 0x08,
878 ELEMENT_TYPE_U4 = 0x09,
879 ELEMENT_TYPE_I8 = 0x0a,
880 ELEMENT_TYPE_U8 = 0x0b,
881 ELEMENT_TYPE_R4 = 0x0c,
882 ELEMENT_TYPE_R8 = 0x0d,
883 ELEMENT_TYPE_STRING = 0x0e,
884
885 // every type above PTR will be simple type
886 ELEMENT_TYPE_PTR = 0x0f, // PTR <type>
887 ELEMENT_TYPE_BYREF = 0x10, // BYREF <type>
888
889 // Please use ELEMENT_TYPE_VALUETYPE. ELEMENT_TYPE_VALUECLASS is deprecated.
890 ELEMENT_TYPE_VALUETYPE = 0x11, // VALUETYPE <class Token>
891 ELEMENT_TYPE_CLASS = 0x12, // CLASS <class Token>
892 ELEMENT_TYPE_VAR = 0x13, // a class type variable VAR <number>
893 ELEMENT_TYPE_ARRAY = 0x14, // MDARRAY <type> <rank> <bcount> <bound1> ... <lbcount> <lb1> ...
894 ELEMENT_TYPE_GENERICINST = 0x15, // GENERICINST <generic type> <argCnt> <arg1> ... <argn>
895 ELEMENT_TYPE_TYPEDBYREF = 0x16, // TYPEDREF (it takes no args) a typed referece to some other type
896
897 ELEMENT_TYPE_I = 0x18, // native integer size
898 ELEMENT_TYPE_U = 0x19, // native unsigned integer size
899 ELEMENT_TYPE_FNPTR = 0x1b, // FNPTR <complete sig for the function including calling convention>
900 ELEMENT_TYPE_OBJECT = 0x1c, // Shortcut for System.Object
901 ELEMENT_TYPE_SZARRAY = 0x1d, // Shortcut for single dimension zero lower bound array
902 // SZARRAY <type>
903 ELEMENT_TYPE_MVAR = 0x1e, // a method type variable MVAR <number>
904
905 // This is only for binding
906 ELEMENT_TYPE_CMOD_REQD = 0x1f, // required C modifier : E_T_CMOD_REQD <mdTypeRef/mdTypeDef>
907 ELEMENT_TYPE_CMOD_OPT = 0x20, // optional C modifier : E_T_CMOD_OPT <mdTypeRef/mdTypeDef>
908
909 // This is for signatures generated internally (which will not be persisted in any way).
910 ELEMENT_TYPE_INTERNAL = 0x21, // INTERNAL <typehandle>
911
912 // Note that this is the max of base type excluding modifiers
913 ELEMENT_TYPE_MAX = 0x22, // first invalid element type
914
915
916 ELEMENT_TYPE_MODIFIER = 0x40,
917 ELEMENT_TYPE_SENTINEL = 0x01 | ELEMENT_TYPE_MODIFIER, // sentinel for varargs
918 ELEMENT_TYPE_PINNED = 0x05 | ELEMENT_TYPE_MODIFIER,
919
920} CorElementType;
921
922
923//*****************************************************************************
924//
925// Serialization types for Custom attribute support
926//
927//*****************************************************************************
928
929typedef enum CorSerializationType
930{
931 SERIALIZATION_TYPE_UNDEFINED = 0,
932 SERIALIZATION_TYPE_BOOLEAN = ELEMENT_TYPE_BOOLEAN,
933 SERIALIZATION_TYPE_CHAR = ELEMENT_TYPE_CHAR,
934 SERIALIZATION_TYPE_I1 = ELEMENT_TYPE_I1,
935 SERIALIZATION_TYPE_U1 = ELEMENT_TYPE_U1,
936 SERIALIZATION_TYPE_I2 = ELEMENT_TYPE_I2,
937 SERIALIZATION_TYPE_U2 = ELEMENT_TYPE_U2,
938 SERIALIZATION_TYPE_I4 = ELEMENT_TYPE_I4,
939 SERIALIZATION_TYPE_U4 = ELEMENT_TYPE_U4,
940 SERIALIZATION_TYPE_I8 = ELEMENT_TYPE_I8,
941 SERIALIZATION_TYPE_U8 = ELEMENT_TYPE_U8,
942 SERIALIZATION_TYPE_R4 = ELEMENT_TYPE_R4,
943 SERIALIZATION_TYPE_R8 = ELEMENT_TYPE_R8,
944 SERIALIZATION_TYPE_STRING = ELEMENT_TYPE_STRING,
945 SERIALIZATION_TYPE_SZARRAY = ELEMENT_TYPE_SZARRAY, // Shortcut for single dimension zero lower bound array
946 SERIALIZATION_TYPE_TYPE = 0x50,
947 SERIALIZATION_TYPE_TAGGED_OBJECT= 0x51,
948 SERIALIZATION_TYPE_FIELD = 0x53,
949 SERIALIZATION_TYPE_PROPERTY = 0x54,
950 SERIALIZATION_TYPE_ENUM = 0x55
951} CorSerializationType;
952
953//
954// Calling convention flags.
955//
956
957
958typedef enum CorCallingConvention
959{
960 IMAGE_CEE_CS_CALLCONV_DEFAULT = 0x0,
961
962 IMAGE_CEE_CS_CALLCONV_VARARG = 0x5,
963 IMAGE_CEE_CS_CALLCONV_FIELD = 0x6,
964 IMAGE_CEE_CS_CALLCONV_LOCAL_SIG = 0x7,
965 IMAGE_CEE_CS_CALLCONV_PROPERTY = 0x8,
966 IMAGE_CEE_CS_CALLCONV_UNMGD = 0x9,
967 IMAGE_CEE_CS_CALLCONV_GENERICINST = 0xa, // generic method instantiation
968 IMAGE_CEE_CS_CALLCONV_NATIVEVARARG = 0xb, // used ONLY for 64bit vararg PInvoke calls
969 IMAGE_CEE_CS_CALLCONV_MAX = 0xc, // first invalid calling convention
970
971
972 // The high bits of the calling convention convey additional info
973 IMAGE_CEE_CS_CALLCONV_MASK = 0x0f, // Calling convention is bottom 4 bits
974 IMAGE_CEE_CS_CALLCONV_HASTHIS = 0x20, // Top bit indicates a 'this' parameter
975 IMAGE_CEE_CS_CALLCONV_EXPLICITTHIS = 0x40, // This parameter is explicitly in the signature
976 IMAGE_CEE_CS_CALLCONV_GENERIC = 0x10, // Generic method sig with explicit number of type arguments (precedes ordinary parameter count)
977 // 0x80 is reserved for internal use
978} CorCallingConvention;
979
980#define IMAGE_CEE_CS_CALLCONV_INSTANTIATION IMAGE_CEE_CS_CALLCONV_GENERICINST
981
982typedef enum CorUnmanagedCallingConvention
983{
984 IMAGE_CEE_UNMANAGED_CALLCONV_C = 0x1,
985 IMAGE_CEE_UNMANAGED_CALLCONV_STDCALL = 0x2,
986 IMAGE_CEE_UNMANAGED_CALLCONV_THISCALL = 0x3,
987 IMAGE_CEE_UNMANAGED_CALLCONV_FASTCALL = 0x4,
988
989 IMAGE_CEE_CS_CALLCONV_C = IMAGE_CEE_UNMANAGED_CALLCONV_C,
990 IMAGE_CEE_CS_CALLCONV_STDCALL = IMAGE_CEE_UNMANAGED_CALLCONV_STDCALL,
991 IMAGE_CEE_CS_CALLCONV_THISCALL = IMAGE_CEE_UNMANAGED_CALLCONV_THISCALL,
992 IMAGE_CEE_CS_CALLCONV_FASTCALL = IMAGE_CEE_UNMANAGED_CALLCONV_FASTCALL,
993
994} CorUnmanagedCallingConvention;
995
996
997typedef enum CorArgType
998{
999 IMAGE_CEE_CS_END = 0x0,
1000 IMAGE_CEE_CS_VOID = 0x1,
1001 IMAGE_CEE_CS_I4 = 0x2,
1002 IMAGE_CEE_CS_I8 = 0x3,
1003 IMAGE_CEE_CS_R4 = 0x4,
1004 IMAGE_CEE_CS_R8 = 0x5,
1005 IMAGE_CEE_CS_PTR = 0x6,
1006 IMAGE_CEE_CS_OBJECT = 0x7,
1007 IMAGE_CEE_CS_STRUCT4 = 0x8,
1008 IMAGE_CEE_CS_STRUCT32 = 0x9,
1009 IMAGE_CEE_CS_BYVALUE = 0xA,
1010} CorArgType;
1011
1012
1013//*****************************************************************************
1014//
1015// Native type for N-Direct
1016//
1017//*****************************************************************************
1018
1019typedef enum CorNativeType
1020{
1021
1022 // Kepp this in-synch with ndp\clr\src\BCL\System\runtime\interopservices\attributes.cs
1023
1024 NATIVE_TYPE_END = 0x0, //DEPRECATED
1025 NATIVE_TYPE_VOID = 0x1, //DEPRECATED
1026 NATIVE_TYPE_BOOLEAN = 0x2, // (4 byte boolean value: TRUE = non-zero, FALSE = 0)
1027 NATIVE_TYPE_I1 = 0x3,
1028 NATIVE_TYPE_U1 = 0x4,
1029 NATIVE_TYPE_I2 = 0x5,
1030 NATIVE_TYPE_U2 = 0x6,
1031 NATIVE_TYPE_I4 = 0x7,
1032 NATIVE_TYPE_U4 = 0x8,
1033 NATIVE_TYPE_I8 = 0x9,
1034 NATIVE_TYPE_U8 = 0xa,
1035 NATIVE_TYPE_R4 = 0xb,
1036 NATIVE_TYPE_R8 = 0xc,
1037 NATIVE_TYPE_SYSCHAR = 0xd, //DEPRECATED
1038 NATIVE_TYPE_VARIANT = 0xe, //DEPRECATED
1039 NATIVE_TYPE_CURRENCY = 0xf,
1040 NATIVE_TYPE_PTR = 0x10, //DEPRECATED
1041
1042 NATIVE_TYPE_DECIMAL = 0x11, //DEPRECATED
1043 NATIVE_TYPE_DATE = 0x12, //DEPRECATED
1044 NATIVE_TYPE_BSTR = 0x13, //COMINTEROP
1045 NATIVE_TYPE_LPSTR = 0x14,
1046 NATIVE_TYPE_LPWSTR = 0x15,
1047 NATIVE_TYPE_LPTSTR = 0x16,
1048 NATIVE_TYPE_FIXEDSYSSTRING = 0x17,
1049 NATIVE_TYPE_OBJECTREF = 0x18, //DEPRECATED
1050 NATIVE_TYPE_IUNKNOWN = 0x19, //COMINTEROP
1051 NATIVE_TYPE_IDISPATCH = 0x1a, //COMINTEROP
1052 NATIVE_TYPE_STRUCT = 0x1b,
1053 NATIVE_TYPE_INTF = 0x1c, //COMINTEROP
1054 NATIVE_TYPE_SAFEARRAY = 0x1d, //COMINTEROP
1055 NATIVE_TYPE_FIXEDARRAY = 0x1e,
1056 NATIVE_TYPE_INT = 0x1f,
1057 NATIVE_TYPE_UINT = 0x20,
1058
1059 NATIVE_TYPE_NESTEDSTRUCT = 0x21, //DEPRECATED (use NATIVE_TYPE_STRUCT)
1060
1061 NATIVE_TYPE_BYVALSTR = 0x22, //COMINTEROP
1062
1063 NATIVE_TYPE_ANSIBSTR = 0x23, //COMINTEROP
1064
1065 NATIVE_TYPE_TBSTR = 0x24, // select BSTR or ANSIBSTR depending on platform
1066 //COMINTEROP
1067
1068 NATIVE_TYPE_VARIANTBOOL = 0x25, // (2-byte boolean value: TRUE = -1, FALSE = 0)
1069 //COMINTEROP
1070 NATIVE_TYPE_FUNC = 0x26,
1071
1072 NATIVE_TYPE_ASANY = 0x28,
1073
1074 NATIVE_TYPE_ARRAY = 0x2a,
1075 NATIVE_TYPE_LPSTRUCT = 0x2b,
1076
1077 NATIVE_TYPE_CUSTOMMARSHALER = 0x2c, // Custom marshaler native type. This must be followed
1078 // by a string of the following format:
1079 // "Native type name/0Custom marshaler type name/0Optional cookie/0"
1080 // Or
1081 // "{Native type GUID}/0Custom marshaler type name/0Optional cookie/0"
1082
1083 NATIVE_TYPE_ERROR = 0x2d, // This native type coupled with ELEMENT_TYPE_I4 will map to VT_HRESULT
1084 //COMINTEROP
1085
1086 NATIVE_TYPE_IINSPECTABLE = 0x2e,
1087 NATIVE_TYPE_HSTRING = 0x2f,
1088 NATIVE_TYPE_LPUTF8STR = 0x30, // utf-8 string
1089 NATIVE_TYPE_MAX = 0x50, // first invalid element type
1090} CorNativeType;
1091
1092
1093enum
1094{
1095 DESCR_GROUP_METHODDEF = 0, // DESCR group for MethodDefs
1096 DESCR_GROUP_METHODIMPL, // DESCR group for MethodImpls
1097};
1098
1099/***********************************************************************************/
1100// a COR_ILMETHOD_SECT is a generic container for attributes that are private
1101// to a particular method. The COR_ILMETHOD structure points to one of these
1102// (see GetSect()). COR_ILMETHOD_SECT can decode the Kind of attribute (but not
1103// its internal data layout, and can skip past the current attibute to find the
1104// Next one. The overhead for COR_ILMETHOD_SECT is a minimum of 2 bytes.
1105
1106typedef enum CorILMethodSect // codes that identify attributes
1107{
1108 CorILMethod_Sect_Reserved = 0,
1109 CorILMethod_Sect_EHTable = 1,
1110 CorILMethod_Sect_OptILTable = 2,
1111
1112 CorILMethod_Sect_KindMask = 0x3F, // The mask for decoding the type code
1113 CorILMethod_Sect_FatFormat = 0x40, // fat format
1114 CorILMethod_Sect_MoreSects = 0x80, // there is another attribute after this one
1115} CorILMethodSect;
1116
1117/************************************/
1118/* NOTE this structure must be DWORD aligned!! */
1119
1120typedef struct IMAGE_COR_ILMETHOD_SECT_SMALL
1121{
1122 BYTE Kind;
1123 BYTE DataSize;
1124
1125} IMAGE_COR_ILMETHOD_SECT_SMALL;
1126
1127
1128
1129/************************************/
1130/* NOTE this structure must be DWORD aligned!! */
1131typedef struct IMAGE_COR_ILMETHOD_SECT_FAT
1132{
1133 unsigned Kind : 8;
1134 unsigned DataSize : 24;
1135
1136} IMAGE_COR_ILMETHOD_SECT_FAT;
1137
1138
1139
1140/***********************************************************************************/
1141/* If COR_ILMETHOD_SECT_HEADER::Kind() = CorILMethod_Sect_EHTable then the attribute
1142 is a list of exception handling clauses. There are two formats, fat or small
1143*/
1144typedef enum CorExceptionFlag // definitions for the Flags field below (for both big and small)
1145{
1146 COR_ILEXCEPTION_CLAUSE_NONE, // This is a typed handler
1147 COR_ILEXCEPTION_CLAUSE_OFFSETLEN = 0x0000, // Deprecated
1148 COR_ILEXCEPTION_CLAUSE_DEPRECATED = 0x0000, // Deprecated
1149 COR_ILEXCEPTION_CLAUSE_FILTER = 0x0001, // If this bit is on, then this EH entry is for a filter
1150 COR_ILEXCEPTION_CLAUSE_FINALLY = 0x0002, // This clause is a finally clause
1151 COR_ILEXCEPTION_CLAUSE_FAULT = 0x0004, // Fault clause (finally that is called on exception only)
1152 COR_ILEXCEPTION_CLAUSE_DUPLICATED = 0x0008, // duplicated clause. This clause was duplicated to a funclet which was pulled out of line
1153} CorExceptionFlag;
1154
1155/***********************************/
1156typedef struct IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT
1157{
1158 CorExceptionFlag Flags;
1159 DWORD TryOffset;
1160 DWORD TryLength; // relative to start of try block
1161 DWORD HandlerOffset;
1162 DWORD HandlerLength; // relative to start of handler
1163 union {
1164 DWORD ClassToken; // use for type-based exception handlers
1165 DWORD FilterOffset; // use for filter-based exception handlers (COR_ILEXCEPTION_FILTER is set)
1166 };
1167} IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT;
1168
1169typedef struct IMAGE_COR_ILMETHOD_SECT_EH_FAT
1170{
1171 IMAGE_COR_ILMETHOD_SECT_FAT SectFat;
1172 IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT Clauses[1]; // actually variable size
1173} IMAGE_COR_ILMETHOD_SECT_EH_FAT;
1174
1175/***********************************/
1176typedef struct IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_SMALL
1177{
1178#ifdef _WIN64
1179 unsigned Flags : 16;
1180#else // !_WIN64
1181 CorExceptionFlag Flags : 16;
1182#endif
1183 unsigned TryOffset : 16;
1184 unsigned TryLength : 8; // relative to start of try block
1185 unsigned HandlerOffset : 16;
1186 unsigned HandlerLength : 8; // relative to start of handler
1187 union {
1188 DWORD ClassToken;
1189 DWORD FilterOffset;
1190 };
1191} IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_SMALL;
1192
1193/***********************************/
1194typedef struct IMAGE_COR_ILMETHOD_SECT_EH_SMALL
1195{
1196 IMAGE_COR_ILMETHOD_SECT_SMALL SectSmall;
1197 WORD Reserved;
1198 IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_SMALL Clauses[1]; // actually variable size
1199} IMAGE_COR_ILMETHOD_SECT_EH_SMALL;
1200
1201
1202
1203typedef union IMAGE_COR_ILMETHOD_SECT_EH
1204{
1205 IMAGE_COR_ILMETHOD_SECT_EH_SMALL Small;
1206 IMAGE_COR_ILMETHOD_SECT_EH_FAT Fat;
1207} IMAGE_COR_ILMETHOD_SECT_EH;
1208
1209
1210/***********************************************************************************/
1211// Legal values for
1212// * code:IMAGE_COR_ILMETHOD_FAT::Flags or
1213// * code:IMAGE_COR_ILMETHOD_TINY::Flags_CodeSize fields.
1214//
1215// The only semantic flag at present is CorILMethod_InitLocals
1216typedef enum CorILMethodFlags
1217{
1218 CorILMethod_InitLocals = 0x0010, // call default constructor on all local vars
1219 CorILMethod_MoreSects = 0x0008, // there is another attribute after this one
1220
1221 CorILMethod_CompressedIL = 0x0040, // Not used.
1222
1223 // Indicates the format for the COR_ILMETHOD header
1224 CorILMethod_FormatShift = 3,
1225 CorILMethod_FormatMask = ((1 << CorILMethod_FormatShift) - 1),
1226 CorILMethod_TinyFormat = 0x0002, // use this code if the code size is even
1227 CorILMethod_SmallFormat = 0x0000,
1228 CorILMethod_FatFormat = 0x0003,
1229 CorILMethod_TinyFormat1 = 0x0006, // use this code if the code size is odd
1230} CorILMethodFlags;
1231
1232/***************************************************************************/
1233/* Used when the method is tiny (< 64 bytes), and there are no local vars */
1234typedef struct IMAGE_COR_ILMETHOD_TINY
1235{
1236 BYTE Flags_CodeSize;
1237} IMAGE_COR_ILMETHOD_TINY;
1238
1239/************************************/
1240// This strucuture is the 'fat' layout, where no compression is attempted.
1241// Note that this structure can be added on at the end, thus making it extensible
1242typedef struct IMAGE_COR_ILMETHOD_FAT
1243{
1244 unsigned Flags : 12; // Flags see code:CorILMethodFlags
1245 unsigned Size : 4; // size in DWords of this structure (currently 3)
1246 unsigned MaxStack : 16; // maximum number of items (I4, I, I8, obj ...), on the operand stack
1247 DWORD CodeSize; // size of the code
1248 mdSignature LocalVarSigTok; // token that indicates the signature of the local vars (0 means none)
1249
1250} IMAGE_COR_ILMETHOD_FAT;
1251
1252// an IMAGE_COR_ILMETHOD holds the IL instructions for a individual method. To save space they come in two
1253// flavors Fat and Tiny. Conceptually Tiny is just a compressed version of Fat, so code:IMAGE_COR_ILMETHOD_FAT
1254// is the logical structure for all headers. Conceptually this blob holds the IL, the Exception Handling
1255// Tables, the local variable information and some flags.
1256typedef union IMAGE_COR_ILMETHOD
1257{
1258 IMAGE_COR_ILMETHOD_TINY Tiny;
1259 IMAGE_COR_ILMETHOD_FAT Fat;
1260} IMAGE_COR_ILMETHOD;
1261
1262//*****************************************************************************
1263// Non VOS v-table entries. Define an array of these pointed to by
1264// IMAGE_COR20_HEADER.VTableFixups. Each entry describes a contiguous array of
1265// v-table slots. The slots start out initialized to the meta data token value
1266// for the method they need to call. At image load time, the CLR Loader will
1267// turn each entry into a pointer to machine code for the CPU and can be
1268// called directly.
1269//*****************************************************************************
1270
1271typedef struct IMAGE_COR_VTABLEFIXUP
1272{
1273 ULONG RVA; // Offset of v-table array in image.
1274 USHORT Count; // How many entries at location.
1275 USHORT Type; // COR_VTABLE_xxx type of entries.
1276} IMAGE_COR_VTABLEFIXUP;
1277
1278
1279
1280
1281
1282//*****************************************************************************
1283//*****************************************************************************
1284//
1285// M E T A - D A T A D E C L A R A T I O N S
1286//
1287//*****************************************************************************
1288//*****************************************************************************
1289
1290//*****************************************************************************
1291//
1292// Enums for SetOption API.
1293//
1294//*****************************************************************************
1295
1296// flags for MetaDataCheckDuplicatesFor
1297typedef enum CorCheckDuplicatesFor
1298{
1299 MDDupAll = 0xffffffff,
1300 MDDupENC = MDDupAll,
1301 MDNoDupChecks = 0x00000000,
1302 MDDupTypeDef = 0x00000001,
1303 MDDupInterfaceImpl = 0x00000002,
1304 MDDupMethodDef = 0x00000004,
1305 MDDupTypeRef = 0x00000008,
1306 MDDupMemberRef = 0x00000010,
1307 MDDupCustomAttribute = 0x00000020,
1308 MDDupParamDef = 0x00000040,
1309 MDDupPermission = 0x00000080,
1310 MDDupProperty = 0x00000100,
1311 MDDupEvent = 0x00000200,
1312 MDDupFieldDef = 0x00000400,
1313 MDDupSignature = 0x00000800,
1314 MDDupModuleRef = 0x00001000,
1315 MDDupTypeSpec = 0x00002000,
1316 MDDupImplMap = 0x00004000,
1317 MDDupAssemblyRef = 0x00008000,
1318 MDDupFile = 0x00010000,
1319 MDDupExportedType = 0x00020000,
1320 MDDupManifestResource = 0x00040000,
1321 MDDupGenericParam = 0x00080000,
1322 MDDupMethodSpec = 0x00100000,
1323 MDDupGenericParamConstraint = 0x00200000,
1324 // gap for debug junk
1325 MDDupAssembly = 0x10000000,
1326
1327 // This is the default behavior on metadata. It will check duplicates for TypeRef, MemberRef, Signature, TypeSpec and MethodSpec.
1328 MDDupDefault = MDNoDupChecks | MDDupTypeRef | MDDupMemberRef | MDDupSignature | MDDupTypeSpec | MDDupMethodSpec,
1329} CorCheckDuplicatesFor;
1330
1331// flags for MetaDataRefToDefCheck
1332typedef enum CorRefToDefCheck
1333{
1334 // default behavior is to always perform TypeRef to TypeDef and MemberRef to MethodDef/FieldDef optimization
1335 MDRefToDefDefault = 0x00000003,
1336 MDRefToDefAll = 0xffffffff,
1337 MDRefToDefNone = 0x00000000,
1338 MDTypeRefToDef = 0x00000001,
1339 MDMemberRefToDef = 0x00000002
1340} CorRefToDefCheck;
1341
1342
1343// MetaDataNotificationForTokenMovement
1344typedef enum CorNotificationForTokenMovement
1345{
1346 // default behavior is to notify TypeRef, MethodDef, MemberRef, and FieldDef token remaps
1347 MDNotifyDefault = 0x0000000f,
1348 MDNotifyAll = 0xffffffff,
1349 MDNotifyNone = 0x00000000,
1350 MDNotifyMethodDef = 0x00000001,
1351 MDNotifyMemberRef = 0x00000002,
1352 MDNotifyFieldDef = 0x00000004,
1353 MDNotifyTypeRef = 0x00000008,
1354
1355 MDNotifyTypeDef = 0x00000010,
1356 MDNotifyParamDef = 0x00000020,
1357 MDNotifyInterfaceImpl = 0x00000040,
1358 MDNotifyProperty = 0x00000080,
1359 MDNotifyEvent = 0x00000100,
1360 MDNotifySignature = 0x00000200,
1361 MDNotifyTypeSpec = 0x00000400,
1362 MDNotifyCustomAttribute = 0x00000800,
1363 MDNotifySecurityValue = 0x00001000,
1364 MDNotifyPermission = 0x00002000,
1365 MDNotifyModuleRef = 0x00004000,
1366
1367 MDNotifyNameSpace = 0x00008000,
1368
1369 MDNotifyAssemblyRef = 0x01000000,
1370 MDNotifyFile = 0x02000000,
1371 MDNotifyExportedType = 0x04000000,
1372 MDNotifyResource = 0x08000000,
1373} CorNotificationForTokenMovement;
1374
1375
1376typedef enum CorSetENC
1377{
1378 MDSetENCOn = 0x00000001, // Deprecated name.
1379 MDSetENCOff = 0x00000002, // Deprecated name.
1380
1381 MDUpdateENC = 0x00000001, // ENC mode. Tokens don't move; can be updated.
1382 MDUpdateFull = 0x00000002, // "Normal" update mode.
1383 MDUpdateExtension = 0x00000003, // Extension mode. Tokens don't move, adds only.
1384 MDUpdateIncremental = 0x00000004, // Incremental compilation
1385 MDUpdateDelta = 0x00000005, // If ENC on, save only deltas.
1386 MDUpdateMask = 0x00000007,
1387
1388
1389} CorSetENC;
1390
1391#define IsENCDelta(x) (((x) & MDUpdateMask) == MDUpdateDelta)
1392
1393// flags used in SetOption when pair with MetaDataErrorIfEmitOutOfOrder guid
1394typedef enum CorErrorIfEmitOutOfOrder
1395{
1396 MDErrorOutOfOrderDefault = 0x00000000, // default not to generate any error
1397 MDErrorOutOfOrderNone = 0x00000000, // do not generate error for out of order emit
1398 MDErrorOutOfOrderAll = 0xffffffff, // generate out of order emit for method, field, param, property, and event
1399 MDMethodOutOfOrder = 0x00000001, // generate error when methods are emitted out of order
1400 MDFieldOutOfOrder = 0x00000002, // generate error when fields are emitted out of order
1401 MDParamOutOfOrder = 0x00000004, // generate error when params are emitted out of order
1402 MDPropertyOutOfOrder = 0x00000008, // generate error when properties are emitted out of order
1403 MDEventOutOfOrder = 0x00000010, // generate error when events are emitted out of order
1404} CorErrorIfEmitOutOfOrder;
1405
1406
1407// flags used in SetOption when pair with MetaDataImportOption guid
1408typedef enum CorImportOptions
1409{
1410 MDImportOptionDefault = 0x00000000, // default to skip over deleted records
1411 MDImportOptionAll = 0xFFFFFFFF, // Enumerate everything
1412 MDImportOptionAllTypeDefs = 0x00000001, // all of the typedefs including the deleted typedef
1413 MDImportOptionAllMethodDefs = 0x00000002, // all of the methoddefs including the deleted ones
1414 MDImportOptionAllFieldDefs = 0x00000004, // all of the fielddefs including the deleted ones
1415 MDImportOptionAllProperties = 0x00000008, // all of the properties including the deleted ones
1416 MDImportOptionAllEvents = 0x00000010, // all of the events including the deleted ones
1417 MDImportOptionAllCustomAttributes = 0x00000020, // all of the custom attributes including the deleted ones
1418 MDImportOptionAllExportedTypes = 0x00000040, // all of the ExportedTypes including the deleted ones
1419
1420} CorImportOptions;
1421
1422
1423// flags for MetaDataThreadSafetyOptions
1424typedef enum CorThreadSafetyOptions
1425{
1426 // default behavior is to have thread safety turn off. This means that MetaData APIs will not take reader/writer
1427 // lock. Clients is responsible to make sure the properly thread synchornization when using MetaData APIs.
1428 MDThreadSafetyDefault = 0x00000000,
1429 MDThreadSafetyOff = 0x00000000,
1430 MDThreadSafetyOn = 0x00000001,
1431} CorThreadSafetyOptions;
1432
1433
1434// flags for MetaDataLinkerOptions
1435typedef enum CorLinkerOptions
1436{
1437 // default behavior is not to keep private types
1438 MDAssembly = 0x00000000,
1439 MDNetModule = 0x00000001,
1440} CorLinkerOptions;
1441
1442// flags for MetaDataMergeOptions
1443typedef enum MergeFlags
1444{
1445 MergeFlagsNone = 0,
1446 MergeManifest = 0x00000001,
1447 DropMemberRefCAs = 0x00000002,
1448 NoDupCheck = 0x00000004,
1449 MergeExportedTypes = 0x00000008
1450} MergeFlags;
1451
1452// flags for MetaDataPreserveLocalRefs
1453typedef enum CorLocalRefPreservation
1454{
1455 MDPreserveLocalRefsNone = 0x00000000,
1456 MDPreserveLocalTypeRef = 0x00000001,
1457 MDPreserveLocalMemberRef = 0x00000002
1458} CorLocalRefPreservation;
1459
1460//
1461// struct used to retrieve field offset
1462// used by GetClassLayout and SetClassLayout
1463//
1464
1465#ifndef _COR_FIELD_OFFSET_
1466#define _COR_FIELD_OFFSET_
1467
1468typedef struct COR_FIELD_OFFSET
1469{
1470 mdFieldDef ridOfField;
1471 ULONG ulOffset;
1472} COR_FIELD_OFFSET;
1473
1474#endif
1475
1476
1477//
1478// Token tags.
1479//
1480typedef enum CorTokenType
1481{
1482 mdtModule = 0x00000000, //
1483 mdtTypeRef = 0x01000000, //
1484 mdtTypeDef = 0x02000000, //
1485 mdtFieldDef = 0x04000000, //
1486 mdtMethodDef = 0x06000000, //
1487 mdtParamDef = 0x08000000, //
1488 mdtInterfaceImpl = 0x09000000, //
1489 mdtMemberRef = 0x0a000000, //
1490 mdtCustomAttribute = 0x0c000000, //
1491 mdtPermission = 0x0e000000, //
1492 mdtSignature = 0x11000000, //
1493 mdtEvent = 0x14000000, //
1494 mdtProperty = 0x17000000, //
1495 mdtMethodImpl = 0x19000000, //
1496 mdtModuleRef = 0x1a000000, //
1497 mdtTypeSpec = 0x1b000000, //
1498 mdtAssembly = 0x20000000, //
1499 mdtAssemblyRef = 0x23000000, //
1500 mdtFile = 0x26000000, //
1501 mdtExportedType = 0x27000000, //
1502 mdtManifestResource = 0x28000000, //
1503 mdtGenericParam = 0x2a000000, //
1504 mdtMethodSpec = 0x2b000000, //
1505 mdtGenericParamConstraint = 0x2c000000,
1506
1507 mdtString = 0x70000000, //
1508 mdtName = 0x71000000, //
1509 mdtBaseType = 0x72000000, // Leave this on the high end value. This does not correspond to metadata table
1510} CorTokenType;
1511
1512//
1513// Build / decompose tokens.
1514//
1515#define RidToToken(rid,tktype) ((rid) |= (tktype))
1516#define TokenFromRid(rid,tktype) ((rid) | (tktype))
1517#define RidFromToken(tk) ((RID) ((tk) & 0x00ffffff))
1518#define TypeFromToken(tk) ((ULONG32)((tk) & 0xff000000))
1519#define IsNilToken(tk) ((RidFromToken(tk)) == 0)
1520
1521//
1522// Nil tokens
1523//
1524#define mdTokenNil ((mdToken)0)
1525#define mdModuleNil ((mdModule)mdtModule)
1526#define mdTypeRefNil ((mdTypeRef)mdtTypeRef)
1527#define mdTypeDefNil ((mdTypeDef)mdtTypeDef)
1528#define mdFieldDefNil ((mdFieldDef)mdtFieldDef)
1529#define mdMethodDefNil ((mdMethodDef)mdtMethodDef)
1530#define mdParamDefNil ((mdParamDef)mdtParamDef)
1531#define mdInterfaceImplNil ((mdInterfaceImpl)mdtInterfaceImpl)
1532#define mdMemberRefNil ((mdMemberRef)mdtMemberRef)
1533#define mdCustomAttributeNil ((mdCustomAttribute)mdtCustomAttribute)
1534#define mdPermissionNil ((mdPermission)mdtPermission)
1535#define mdSignatureNil ((mdSignature)mdtSignature)
1536#define mdEventNil ((mdEvent)mdtEvent)
1537#define mdPropertyNil ((mdProperty)mdtProperty)
1538#define mdModuleRefNil ((mdModuleRef)mdtModuleRef)
1539#define mdTypeSpecNil ((mdTypeSpec)mdtTypeSpec)
1540#define mdAssemblyNil ((mdAssembly)mdtAssembly)
1541#define mdAssemblyRefNil ((mdAssemblyRef)mdtAssemblyRef)
1542#define mdFileNil ((mdFile)mdtFile)
1543#define mdExportedTypeNil ((mdExportedType)mdtExportedType)
1544#define mdManifestResourceNil ((mdManifestResource)mdtManifestResource)
1545
1546#define mdGenericParamNil ((mdGenericParam)mdtGenericParam)
1547#define mdGenericParamConstraintNil ((mdGenericParamConstraint)mdtGenericParamConstraint)
1548#define mdMethodSpecNil ((mdMethodSpec)mdtMethodSpec)
1549
1550#define mdStringNil ((mdString)mdtString)
1551
1552//
1553// Open bits.
1554//
1555typedef enum CorOpenFlags
1556{
1557 ofRead = 0x00000000, // Open scope for read
1558 ofWrite = 0x00000001, // Open scope for write.
1559 ofReadWriteMask = 0x00000001, // Mask for read/write bit.
1560
1561 ofCopyMemory = 0x00000002, // Open scope with memory. Ask metadata to maintain its own copy of memory.
1562
1563 ofReadOnly = 0x00000010, // Open scope for read. Will be unable to QI for a IMetadataEmit* interface
1564 ofTakeOwnership = 0x00000020, // The memory was allocated with CoTaskMemAlloc and will be freed by the metadata
1565
1566 // These are obsolete and are ignored.
1567 // ofCacheImage = 0x00000004, // EE maps but does not do relocations or verify image
1568 // ofManifestMetadata = 0x00000008, // Open scope on ngen image, return the manifest metadata instead of the IL metadata
1569 ofNoTypeLib = 0x00000080, // Don't OpenScope on a typelib.
1570 ofNoTransform = 0x00001000, // Disable automatic transforms of .winmd files.
1571
1572 // Internal bits
1573 ofReserved1 = 0x00000100, // Reserved for internal use.
1574 ofReserved2 = 0x00000200, // Reserved for internal use.
1575 ofReserved3 = 0x00000400, // Reserved for internal use.
1576 ofReserved = 0xffffef40 // All the reserved bits.
1577
1578} CorOpenFlags;
1579
1580#define IsOfRead(x) (((x) & ofReadWriteMask) == ofRead)
1581#define IsOfReadWrite(x) (((x) & ofReadWriteMask) == ofWrite)
1582
1583#define IsOfCopyMemory(x) ((x) & ofCopyMemory)
1584
1585#define IsOfReadOnly(x) ((x) & ofReadOnly)
1586#define IsOfTakeOwnership(x) ((x) & ofTakeOwnership)
1587
1588#define IsOfReserved(x) (((x) & ofReserved) != 0)
1589
1590//
1591// Type of file mapping returned by code:IMetaDataInfo::GetFileMapping.
1592//
1593typedef enum CorFileMapping
1594{
1595 fmFlat = 0, // Flat file mapping - file is mapped as data file (code:SEC_IMAGE flag was not
1596 // passed to code:CreateFileMapping).
1597 fmExecutableImage = 1, // Executable image file mapping - file is mapped for execution
1598 // (either via code:LoadLibrary or code:CreateFileMapping with code:SEC_IMAGE flag).
1599} CorFileMapping;
1600
1601
1602typedef CorTypeAttr CorRegTypeAttr;
1603
1604//
1605// Opaque type for an enumeration handle.
1606//
1607typedef void *HCORENUM;
1608
1609
1610// Note that this must be kept in sync with System.AttributeTargets.
1611typedef enum CorAttributeTargets
1612{
1613 catAssembly = 0x0001,
1614 catModule = 0x0002,
1615 catClass = 0x0004,
1616 catStruct = 0x0008,
1617 catEnum = 0x0010,
1618 catConstructor = 0x0020,
1619 catMethod = 0x0040,
1620 catProperty = 0x0080,
1621 catField = 0x0100,
1622 catEvent = 0x0200,
1623 catInterface = 0x0400,
1624 catParameter = 0x0800,
1625 catDelegate = 0x1000,
1626 catGenericParameter = 0x4000,
1627
1628 catAll = catAssembly | catModule | catClass | catStruct | catEnum | catConstructor |
1629 catMethod | catProperty | catField | catEvent | catInterface | catParameter | catDelegate | catGenericParameter,
1630 catClassMembers = catClass | catStruct | catEnum | catConstructor | catMethod | catProperty | catField | catEvent | catDelegate | catInterface,
1631
1632} CorAttributeTargets;
1633
1634#ifndef MACROS_NOT_SUPPORTED
1635//
1636// Some well-known custom attributes
1637//
1638#ifndef IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS
1639 #define IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS (IMAGE_CEE_CS_CALLCONV_DEFAULT | IMAGE_CEE_CS_CALLCONV_HASTHIS)
1640#endif
1641
1642#define INTEROP_DISPID_TYPE_W L"System.Runtime.InteropServices.DispIdAttribute"
1643#define INTEROP_DISPID_TYPE "System.Runtime.InteropServices.DispIdAttribute"
1644#define INTEROP_DISPID_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I4}
1645
1646#define INTEROP_INTERFACETYPE_TYPE_W L"System.Runtime.InteropServices.InterfaceTypeAttribute"
1647#define INTEROP_INTERFACETYPE_TYPE "System.Runtime.InteropServices.InterfaceTypeAttribute"
1648#define INTEROP_INTERFACETYPE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I2}
1649
1650#define INTEROP_CLASSINTERFACE_TYPE_W L"System.Runtime.InteropServices.ClassInterfaceAttribute"
1651#define INTEROP_CLASSINTERFACE_TYPE "System.Runtime.InteropServices.ClassInterfaceAttribute"
1652#define INTEROP_CLASSINTERFACE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I2}
1653
1654#define INTEROP_COMVISIBLE_TYPE_W L"System.Runtime.InteropServices.ComVisibleAttribute"
1655#define INTEROP_COMVISIBLE_TYPE "System.Runtime.InteropServices.ComVisibleAttribute"
1656#define INTEROP_COMVISIBLE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_BOOLEAN}
1657
1658#define INTEROP_COMREGISTERFUNCTION_TYPE_W L"System.Runtime.InteropServices.ComRegisterFunctionAttribute"
1659#define INTEROP_COMREGISTERFUNCTION_TYPE "System.Runtime.InteropServices.ComRegisterFunctionAttribute"
1660#define INTEROP_COMREGISTERFUNCTION_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
1661
1662#define INTEROP_COMUNREGISTERFUNCTION_TYPE_W L"System.Runtime.InteropServices.ComUnregisterFunctionAttribute"
1663#define INTEROP_COMUNREGISTERFUNCTION_TYPE "System.Runtime.InteropServices.ComUnregisterFunctionAttribute"
1664#define INTEROP_COMUNREGISTERFUNCTION_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
1665
1666#define INTEROP_IMPORTEDFROMTYPELIB_TYPE_W L"System.Runtime.InteropServices.ImportedFromTypeLibAttribute"
1667#define INTEROP_IMPORTEDFROMTYPELIB_TYPE "System.Runtime.InteropServices.ImportedFromTypeLibAttribute"
1668#define INTEROP_IMPORTEDFROMTYPELIB_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_STRING}
1669
1670#define INTEROP_PRIMARYINTEROPASSEMBLY_TYPE_W L"System.Runtime.InteropServices.PrimaryInteropAssemblyAttribute"
1671#define INTEROP_PRIMARYINTEROPASSEMBLY_TYPE "System.Runtime.InteropServices.PrimaryInteropAssemblyAttribute"
1672#define INTEROP_PRIMARYINTEROPASSEMBLY_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 2, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I4, ELEMENT_TYPE_I4}
1673
1674#define INTEROP_IDISPATCHIMPL_TYPE_W L"System.Runtime.InteropServices.IDispatchImplAttribute"
1675#define INTEROP_IDISPATCHIMPL_TYPE "System.Runtime.InteropServices.IDispatchImplAttribute"
1676#define INTEROP_IDISPATCHIMPL_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I2}
1677
1678#define INTEROP_COMSOURCEINTERFACES_TYPE_W L"System.Runtime.InteropServices.ComSourceInterfacesAttribute"
1679#define INTEROP_COMSOURCEINTERFACES_TYPE "System.Runtime.InteropServices.ComSourceInterfacesAttribute"
1680#define INTEROP_COMSOURCEINTERFACES_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_STRING}
1681
1682#define INTEROP_COMDEFAULTINTERFACE_TYPE_W L"System.Runtime.InteropServices.ComDefaultInterfaceAttribute"
1683#define INTEROP_COMDEFAULTINTERFACE_TYPE "System.Runtime.InteropServices.ComDefaultInterfaceAttribute"
1684
1685#define INTEROP_COMCONVERSIONLOSS_TYPE_W L"System.Runtime.InteropServices.ComConversionLossAttribute"
1686#define INTEROP_COMCONVERSIONLOSS_TYPE "System.Runtime.InteropServices.ComConversionLossAttribute"
1687#define INTEROP_COMCONVERSIONLOSS_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
1688
1689#define INTEROP_BESTFITMAPPING_TYPE_W L"System.Runtime.InteropServices.BestFitMappingAttribute"
1690#define INTEROP_BESTFITMAPPING_TYPE "System.Runtime.InteropServices.BestFitMappingAttribute"
1691#define INTEROP_BESTFITMAPPING_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 2, ELEMENT_TYPE_VOID, ELEMENT_TYPE_BOOLEAN, ELEMENT_TYPE_BOOLEAN}
1692
1693#define INTEROP_TYPELIBTYPE_TYPE_W L"System.Runtime.InteropServices.TypeLibTypeAttribute"
1694#define INTEROP_TYPELIBTYPE_TYPE "System.Runtime.InteropServices.TypeLibTypeAttribute"
1695#define INTEROP_TYPELIBTYPE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I2}
1696
1697#define INTEROP_TYPELIBFUNC_TYPE_W L"System.Runtime.InteropServices.TypeLibFuncAttribute"
1698#define INTEROP_TYPELIBFUNC_TYPE "System.Runtime.InteropServices.TypeLibFuncAttribute"
1699#define INTEROP_TYPELIBFUNC_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I2}
1700
1701#define INTEROP_TYPELIBVAR_TYPE_W L"System.Runtime.InteropServices.TypeLibVarAttribute"
1702#define INTEROP_TYPELIBVAR_TYPE "System.Runtime.InteropServices.TypeLibVarAttribute"
1703#define INTEROP_TYPELIBVAR_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I2}
1704
1705#define INTEROP_MARSHALAS_TYPE_W L"System.Runtime.InteropServices.MarshalAsAttribute"
1706#define INTEROP_MARSHALAS_TYPE "System.Runtime.InteropServices.MarshalAsAttribute"
1707#define INTEROP_MARSHALAS_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I2}
1708
1709#define INTEROP_COMIMPORT_TYPE_W L"System.Runtime.InteropServices.ComImportAttribute"
1710#define INTEROP_COMIMPORT_TYPE "System.Runtime.InteropServices.ComImportAttribute"
1711#define INTEROP_COMIMPORT_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
1712
1713#define INTEROP_GUID_TYPE_W W("System.Runtime.InteropServices.GuidAttribute")
1714#define INTEROP_GUID_TYPE "System.Runtime.InteropServices.GuidAttribute"
1715#define INTEROP_GUID_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_STRING}
1716
1717#define INTEROP_DEFAULTMEMBER_TYPE_W L"System.Reflection.DefaultMemberAttribute"
1718#define INTEROP_DEFAULTMEMBER_TYPE "System.Reflection.DefaultMemberAttribute"
1719#define INTEROP_DEFAULTMEMBER_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_STRING}
1720
1721#define INTEROP_COMEMULATE_TYPE_W L"System.Runtime.InteropServices.ComEmulateAttribute"
1722#define INTEROP_COMEMULATE_TYPE "System.Runtime.InteropServices.ComEmulateAttribute"
1723#define INTEROP_COMEMULATE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_STRING}
1724
1725#define INTEROP_PRESERVESIG_TYPE_W L"System.Runtime.InteropServices.PreserveSigAttribure"
1726#define INTEROP_PRESERVESIG_TYPE "System.Runtime.InteropServices.PreserveSigAttribure"
1727#define INTEROP_PRESERVESIG_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_BOOLEAN}
1728
1729#define INTEROP_IN_TYPE_W L"System.Runtime.InteropServices.InAttribute"
1730#define INTEROP_IN_TYPE "System.Runtime.InteropServices.InAttribute"
1731#define INTEROP_IN_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
1732
1733#define INTEROP_OUT_TYPE_W L"System.Runtime.InteropServices.OutAttribute"
1734#define INTEROP_OUT_TYPE "System.Runtime.InteropServices.OutAttribute"
1735#define INTEROP_OUT_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
1736
1737#define INTEROP_COMALIASNAME_TYPE_W L"System.Runtime.InteropServices.ComAliasNameAttribute"
1738#define INTEROP_COMALIASNAME_TYPE "System.Runtime.InteropServices.ComAliasNameAttribute"
1739#define INTEROP_COMALIASNAME_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_STRING}
1740
1741#define INTEROP_PARAMARRAY_TYPE_W L"System.ParamArrayAttribute"
1742#define INTEROP_PARAMARRAY_TYPE "System.ParamArrayAttribute"
1743#define INTEROP_PARAMARRAY_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
1744
1745#define INTEROP_LCIDCONVERSION_TYPE_W L"System.Runtime.InteropServices.LCIDConversionAttribute"
1746#define INTEROP_LCIDCONVERSION_TYPE "System.Runtime.InteropServices.LCIDConversionAttribute"
1747#define INTEROP_LCIDCONVERSION_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I4}
1748
1749#define INTEROP_COMSUBSTITUTABLEINTERFACE_TYPE_W L"System.Runtime.InteropServices.ComSubstitutableInterfaceAttribute"
1750#define INTEROP_COMSUBSTITUTABLEINTERFACE_TYPE "System.Runtime.InteropServices.ComSubstitutableInterfaceAttribute"
1751#define INTEROP_COMSUBSTITUTABLEINTERFACE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
1752
1753#define INTEROP_DECIMALVALUE_TYPE_W L"System.Runtime.CompilerServices.DecimalConstantAttribute"
1754#define INTEROP_DECIMALVALUE_TYPE "System.Runtime.CompilerServices.DecimalConstantAttribute"
1755#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}
1756
1757#define INTEROP_DATETIMEVALUE_TYPE_W L"System.Runtime.CompilerServices.DateTimeConstantAttribute"
1758#define INTEROP_DATETIMEVALUE_TYPE "System.Runtime.CompilerServices.DateTimeConstantAttribute"
1759#define INTEROP_DATETIMEVALUE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I8}
1760
1761#define INTEROP_IUNKNOWNVALUE_TYPE_W L"System.Runtime.CompilerServices.IUnknownConstantAttribute"
1762#define INTEROP_IUNKNOWNVALUE_TYPE "System.Runtime.CompilerServices.IUnknownConstantAttribute"
1763#define INTEROP_IUNKNOWNVALUE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
1764
1765#define INTEROP_IDISPATCHVALUE_TYPE_W L"System.Runtime.CompilerServices.IDispatchConstantAttribute"
1766#define INTEROP_IDISPATCHVALUE_TYPE "System.Runtime.CompilerServices.IDispatchConstantAttribute"
1767#define INTEROP_IDISPATCHVALUE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
1768
1769#define INTEROP_AUTOPROXY_TYPE_W L"System.Runtime.InteropServices.AutomationProxyAttribute"
1770#define INTEROP_AUTOPROXY_TYPE "System.Runtime.InteropServices.AutomationProxyAttribute"
1771#define INTEROP_AUTOPROXY_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_BOOLEAN}
1772
1773#define INTEROP_TYPELIBIMPORTCLASS_TYPE_W L"System.Runtime.InteropServices.TypeLibImportClassAttribute"
1774#define INTEROP_TYPELIBIMPORTCLASS_TYPE "System.Runtime.InteropServices.TypeLibImportClassAttribute"
1775
1776
1777#define INTEROP_TYPELIBVERSION_TYPE_W L"System.Runtime.InteropServices.TypeLibVersionAttribute"
1778#define INTEROP_TYPELIBVERSION_TYPE "System.Runtime.InteropServices.TypeLibVersionAttribute"
1779#define INTEROP_TYPELIBVERSION_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 2, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I2, ELEMENT_TYPE_I2}
1780
1781#define INTEROP_COMCOMPATIBLEVERSION_TYPE_W L"System.Runtime.InteropServices.ComCompatibleVersionAttribute"
1782#define INTEROP_COMCOMPATIBLEVERSION_TYPE "System.Runtime.InteropServices.ComCompatibleVersionAttribute"
1783#define INTEROP_COMCOMPATIBLEVERSION_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 4, ELEMENT_TYPE_VOID, ELEMENT_TYPE_I2, ELEMENT_TYPE_I2, ELEMENT_TYPE_I2, ELEMENT_TYPE_I2}
1784
1785#define INTEROP_COMEVENTINTERFACE_TYPE_W L"System.Runtime.InteropServices.ComEventInterfaceAttribute"
1786#define INTEROP_COMEVENTINTERFACE_TYPE "System.Runtime.InteropServices.ComEventInterfaceAttribute"
1787
1788#define INTEROP_COCLASS_TYPE_W L"System.Runtime.InteropServices.CoClassAttribute"
1789#define INTEROP_COCLASS_TYPE "System.Runtime.InteropServices.CoClassAttribute"
1790
1791#define INTEROP_SERIALIZABLE_TYPE_W L"System.SerializableAttribute"
1792#define INTEROP_SERIALIZABLE_TYPE "System.SerializableAttribute"
1793#define INTEROP_SERIALIZABLE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
1794
1795#define INTEROP_SETWIN32CONTEXTINIDISPATCHATTRIBUTE_TYPE_W L"System.Runtime.InteropServices.SetWin32ContextInIDispatchAttribute"
1796#define INTEROP_SETWIN32CONTEXTINIDISPATCHATTRIBUTE_TYPE "System.Runtime.InteropServices.SetWin32ContextInIDispatchAttribute"
1797#define INTEROP_SETWIN32CONTEXTINIDISPATCHATTRIBUTE_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
1798
1799#define FORWARD_INTEROP_STUB_METHOD_TYPE_W L"System.Runtime.InteropServices.ManagedToNativeComInteropStubAttribute"
1800#define FORWARD_INTEROP_STUB_METHOD_TYPE "System.Runtime.InteropServices.ManagedToNativeComInteropStubAttribute"
1801
1802#define FRIEND_ASSEMBLY_TYPE_W L"System.Runtime.CompilerServices.InternalsVisibleToAttribute"
1803#define FRIEND_ASSEMBLY_TYPE "System.Runtime.CompilerServices.InternalsVisibleToAttribute"
1804#define FRIEND_ASSEMBLY_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 2, ELEMENT_TYPE_VOID, ELEMENT_TYPE_STRING, ELEMENT_TYPE_BOOLEAN}
1805
1806#define SUBJECT_ASSEMBLY_TYPE_W L"System.Runtime.CompilerServices.IgnoresAccessChecksToAttribute"
1807#define SUBJECT_ASSEMBLY_TYPE "System.Runtime.CompilerServices.IgnoresAccessChecksToAttribute"
1808#define SUBJECT_ASSEMBLY_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_STRING}
1809
1810#define DISABLED_PRIVATE_REFLECTION_TYPE_W L"System.Runtime.CompilerServices.DisablePrivateReflectionAttribute"
1811#define DISABLED_PRIVATE_REFLECTION_TYPE "System.Runtime.CompilerServices.DisablePrivateReflectionAttribute"
1812#define DISABLED_PRIVATE_REFLECTION_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
1813
1814#define DEFAULTDOMAIN_STA_TYPE_W L"System.STAThreadAttribute"
1815#define DEFAULTDOMAIN_STA_TYPE "System.STAThreadAttribute"
1816#define DEFAULTDOMAIN_STA_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
1817
1818#define DEFAULTDOMAIN_MTA_TYPE_W L"System.MTAThreadAttribute"
1819#define DEFAULTDOMAIN_MTA_TYPE "System.MTAThreadAttribute"
1820#define DEFAULTDOMAIN_MTA_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
1821
1822#define NONVERSIONABLE_TYPE_W L"System.Runtime.Versioning.NonVersionableAttribute"
1823#define NONVERSIONABLE_TYPE "System.Runtime.Versioning.NonVersionableAttribute"
1824
1825// Keep in sync with CompilationRelaxations.cs
1826typedef enum CompilationRelaxationsEnum
1827{
1828 CompilationRelaxations_NoStringInterning = 0x0008,
1829
1830} CompilationRelaxationEnum;
1831
1832#define COMPILATIONRELAXATIONS_TYPE_W L"System.Runtime.CompilerServices.CompilationRelaxationsAttribute"
1833#define COMPILATIONRELAXATIONS_TYPE "System.Runtime.CompilerServices.CompilationRelaxationsAttribute"
1834
1835
1836// Keep in sync with RuntimeCompatibilityAttribute.cs
1837#define RUNTIMECOMPATIBILITY_TYPE_W L"System.Runtime.CompilerServices.RuntimeCompatibilityAttribute"
1838#define RUNTIMECOMPATIBILITY_TYPE "System.Runtime.CompilerServices.RuntimeCompatibilityAttribute"
1839
1840
1841// Keep in sync with AssemblySettingAttributes.cs
1842
1843typedef enum NGenHintEnum
1844{
1845 NGenDefault = 0x0000, // No preference specified
1846
1847 NGenEager = 0x0001, // NGen at install time
1848 NGenLazy = 0x0002, // NGen after install time
1849 NGenNever = 0x0003 // Assembly should not be ngened
1850} NGenHintEnum;
1851
1852typedef enum LoadHintEnum
1853{
1854 LoadDefault = 0x0000, // No preference specified
1855
1856 LoadAlways = 0x0001, // Dependency is always loaded
1857 LoadSometimes = 0x0002, // Dependency is sometimes loaded
1858 LoadNever = 0x0003 // Dependency is never loaded
1859} LoadHintEnum;
1860
1861#define DEFAULTDEPENDENCY_TYPE_W L"System.Runtime.CompilerServices.DefaultDependencyAttribute"
1862#define DEFAULTDEPENDENCY_TYPE "System.Runtime.CompilerServices.DefaultDependencyAttribute"
1863
1864#define DEPENDENCY_TYPE_W L"System.Runtime.CompilerServices.DependencyAttribute"
1865#define DEPENDENCY_TYPE "System.Runtime.CompilerServices.DependencyAttribute"
1866
1867#define TARGET_FRAMEWORK_TYPE_W L"System.Runtime.Versioning.TargetFrameworkAttribute"
1868#define TARGET_FRAMEWORK_TYPE "System.Runtime.Versioning.TargetFrameworkAttribute"
1869
1870#define ASSEMBLY_METADATA_TYPE_W L"System.Reflection.AssemblyMetadataAttribute"
1871#define ASSEMBLY_METADATA_TYPE "System.Reflection.AssemblyMetadataAttribute"
1872
1873
1874#define CMOD_CALLCONV_NAMESPACE_OLD "System.Runtime.InteropServices"
1875#define CMOD_CALLCONV_NAMESPACE "System.Runtime.CompilerServices"
1876#define CMOD_CALLCONV_NAME_CDECL "CallConvCdecl"
1877#define CMOD_CALLCONV_NAME_STDCALL "CallConvStdcall"
1878#define CMOD_CALLCONV_NAME_THISCALL "CallConvThiscall"
1879#define CMOD_CALLCONV_NAME_FASTCALL "CallConvFastcall"
1880
1881#endif // MACROS_NOT_SUPPORTED
1882
1883//
1884// GetSaveSize accuracy
1885//
1886#ifndef _CORSAVESIZE_DEFINED_
1887#define _CORSAVESIZE_DEFINED_
1888typedef enum CorSaveSize
1889{
1890 cssAccurate = 0x0000, // Find exact save size, accurate but slower.
1891 cssQuick = 0x0001, // Estimate save size, may pad estimate, but faster.
1892 cssDiscardTransientCAs = 0x0002, // remove all of the CAs of discardable types
1893} CorSaveSize;
1894#endif
1895
1896#define COR_IS_METHOD_MANAGED_IL(flags) ((flags & 0xf) == (miIL | miManaged))
1897#define COR_IS_METHOD_MANAGED_OPTIL(flags) ((flags & 0xf) == (miOPTIL | miManaged))
1898#define COR_IS_METHOD_MANAGED_NATIVE(flags) ((flags & 0xf) == (miNative | miManaged))
1899#define COR_IS_METHOD_UNMANAGED_NATIVE(flags) ((flags & 0xf) == (miNative | miUnmanaged))
1900
1901//
1902// Enum used with NATIVE_TYPE_ARRAY.
1903//
1904typedef enum NativeTypeArrayFlags
1905{
1906 ntaSizeParamIndexSpecified = 0x0001,
1907 ntaReserved = 0xfffe // All the reserved bits.
1908} NativeTypeArrayFlags;
1909
1910//
1911// Opaque types for security properties and values.
1912//
1913typedef void * PSECURITY_PROPS ;
1914typedef void * PSECURITY_VALUE ;
1915typedef void ** PPSECURITY_PROPS ;
1916typedef void ** PPSECURITY_VALUE ;
1917
1918//-------------------------------------
1919//--- Security data structures
1920//-------------------------------------
1921
1922// Descriptor for a single security custom attribute.
1923typedef struct COR_SECATTR {
1924 mdMemberRef tkCtor; // Ref to constructor of security attribute.
1925 const void *pCustomAttribute; // Blob describing ctor args and field/property values.
1926 ULONG cbCustomAttribute; // Length of the above blob.
1927} COR_SECATTR;
1928
1929#endif // __CORHDR_H__
1930
1931