-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
corhdr.h
1781 lines (1455 loc) · 81.3 KB
/
corhdr.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/*****************************************************************************
** **
** CorHdr.h - contains definitions for the Runtime structures, **
**
** needed to work with metadata. **
** **
*****************************************************************************/
//
// The top most managed code structure in a EXE or DLL is the IMAGE_COR20_HEADER
// see code:#ManagedHeader for more
#ifndef __CORHDR_H__
#define __CORHDR_H__
#include <stdint.h>
#ifdef _MSC_VER
#pragma warning(disable:4200) // nonstandard extension used : zero-sized array in struct/union.
#endif
typedef void* mdScope; // Obsolete; not used in the runtime.
typedef uint32_t mdToken; // Generic token
// Token definitions
typedef mdToken mdModule; // Module token (roughly, a scope)
typedef mdToken mdTypeRef; // TypeRef reference (this or other scope)
typedef mdToken mdTypeDef; // TypeDef in this scope
typedef mdToken mdFieldDef; // Field in this scope
typedef mdToken mdMethodDef; // Method in this scope
typedef mdToken mdParamDef; // param token
typedef mdToken mdInterfaceImpl; // interface implementation token
typedef mdToken mdMemberRef; // MemberRef (this or other scope)
typedef mdToken mdCustomAttribute; // attribute token
typedef mdToken mdPermission; // DeclSecurity
typedef mdToken mdSignature; // Signature object
typedef mdToken mdEvent; // event token
typedef mdToken mdProperty; // property token
typedef mdToken mdModuleRef; // Module reference (for the imported modules)
// Assembly tokens.
typedef mdToken mdAssembly; // Assembly token.
typedef mdToken mdAssemblyRef; // AssemblyRef token.
typedef mdToken mdFile; // File token.
typedef mdToken mdExportedType; // ExportedType token.
typedef mdToken mdManifestResource; // ManifestResource token.
typedef mdToken mdTypeSpec; // TypeSpec object
typedef mdToken mdGenericParam; // formal parameter to generic type or method
typedef mdToken mdMethodSpec; // instantiation of a generic method
typedef mdToken mdGenericParamConstraint; // constraint on a formal generic parameter
// Application string.
typedef mdToken mdString; // User literal string token.
typedef mdToken mdCPToken; // constantpool token
#ifndef MACROS_NOT_SUPPORTED
typedef uint32_t RID;
#else
typedef unsigned RID;
#endif // MACROS_NOT_SUPPORTED
typedef enum ReplacesGeneralNumericDefines
{
// Directory entry macro for CLR data.
#ifndef IMAGE_DIRECTORY_ENTRY_COMHEADER
IMAGE_DIRECTORY_ENTRY_COMHEADER =14,
#endif // IMAGE_DIRECTORY_ENTRY_COMHEADER
} ReplacesGeneralNumericDefines;
// The COMIMAGE_FLAGS_32BITREQUIRED and COMIMAGE_FLAGS_32BITPREFERRED flags defined below interact as a pair
// in order to get the performance profile we desire for platform neutral assemblies while retaining backwards
// compatibility with pre-4.5 runtimes/OSs, which don't know about COMIMAGE_FLAGS_32BITPREFERRED.
//
// COMIMAGE_FLAGS_32BITREQUIRED originally meant "this assembly is x86-only" (required to distinguish platform
// neutral assemblies which also mark their PE MachineType as IMAGE_FILE_MACHINE_I386).
//
// COMIMAGE_FLAGS_32BITPREFERRED has been added so we can create a sub-class of platform neutral assembly that
// prefers to be loaded into 32-bit environment for perf reasons, but is still compatible with 64-bit
// environments.
//
// In order to retain maximum backwards compatibility you cannot simply read or write one of these flags.
// You must treat them as a pair, a two-bit field with the following meanings:
//
// 32BITREQUIRED 32BITPREFERRED
// 0 0 : no special meaning, MachineType and ILONLY flag determine image requirements
// 0 1 : illegal, reserved for future use
// 1 0 : image is x86-specific
// 1 1 : image is platform neutral and prefers to be loaded 32-bit when possible
//
// To simplify manipulation of these flags the following macros are provided below.
#define COR_IS_32BIT_REQUIRED(_flags) \
(((_flags) & (COMIMAGE_FLAGS_32BITREQUIRED|COMIMAGE_FLAGS_32BITPREFERRED)) == (COMIMAGE_FLAGS_32BITREQUIRED))
#define COR_IS_32BIT_PREFERRED(_flags) \
(((_flags) & (COMIMAGE_FLAGS_32BITREQUIRED|COMIMAGE_FLAGS_32BITPREFERRED)) == (COMIMAGE_FLAGS_32BITREQUIRED|COMIMAGE_FLAGS_32BITPREFERRED))
#define COR_SET_32BIT_REQUIRED(_flagsfield) \
do { _flagsfield = (_flagsfield & ~COMIMAGE_FLAGS_32BITPREFERRED) | COMIMAGE_FLAGS_32BITREQUIRED; } while (false)
#define COR_SET_32BIT_PREFERRED(_flagsfield) \
do { _flagsfield |= COMIMAGE_FLAGS_32BITPREFERRED|COMIMAGE_FLAGS_32BITREQUIRED; } while (false)
#define COR_CLEAR_32BIT_REQUIRED(_flagsfield) \
do { _flagsfield &= ~(COMIMAGE_FLAGS_32BITREQUIRED|COMIMAGE_FLAGS_32BITPREFERRED); } while (false)
#define COR_CLEAR_32BIT_PREFERRED(_flagsfield) \
do { _flagsfield &= ~(COMIMAGE_FLAGS_32BITREQUIRED|COMIMAGE_FLAGS_32BITPREFERRED); } while (false)
#ifndef __IMAGE_COR20_HEADER_DEFINED__
#define __IMAGE_COR20_HEADER_DEFINED__
typedef enum ReplacesCorHdrNumericDefines
{
// COM+ Header entry point flags.
COMIMAGE_FLAGS_ILONLY =0x00000001,
COMIMAGE_FLAGS_32BITREQUIRED =0x00000002, // *** Do not manipulate this bit directly (see notes above)
COMIMAGE_FLAGS_IL_LIBRARY =0x00000004,
COMIMAGE_FLAGS_STRONGNAMESIGNED =0x00000008,
COMIMAGE_FLAGS_NATIVE_ENTRYPOINT =0x00000010,
COMIMAGE_FLAGS_TRACKDEBUGDATA =0x00010000,
COMIMAGE_FLAGS_32BITPREFERRED =0x00020000, // *** Do not manipulate this bit directly (see notes above)
// Version flags for image.
COR_VERSION_MAJOR_V2 =2,
COR_VERSION_MAJOR =COR_VERSION_MAJOR_V2,
COR_VERSION_MINOR =5,
COR_DELETED_NAME_LENGTH =8,
COR_VTABLEGAP_NAME_LENGTH =8,
// Maximum size of a NativeType descriptor.
NATIVE_TYPE_MAX_CB =1,
COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE=0xFF,
// V-table constants
COR_VTABLE_32BIT =0x01, // V-table slots are 32-bits in size.
COR_VTABLE_64BIT =0x02, // V-table slots are 64-bits in size.
COR_VTABLE_FROM_UNMANAGED =0x04, // If set, transition from unmanaged.
COR_VTABLE_FROM_UNMANAGED_RETAIN_APPDOMAIN=0x08, // NEW
COR_VTABLE_CALL_MOST_DERIVED =0x10, // Call most derived method described by
// EATJ constants
IMAGE_COR_EATJ_THUNK_SIZE = 32, // Size of a jump thunk reserved range.
// Max name lengths
//@todo: Change to unlimited name lengths.
MAX_CLASS_NAME =1024,
MAX_PACKAGE_NAME =1024,
} ReplacesCorHdrNumericDefines;
//
// Directory format.
//
#ifndef IMAGE_DATA_DIRECTORY_DEFINED
#define IMAGE_DATA_DIRECTORY_DEFINED
typedef struct _IMAGE_DATA_DIRECTORY {
uint32_t VirtualAddress;
uint32_t Size;
} IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
#endif // IMAGE_DATA_DIRECTORY_DEFINED
// #ManagedHeader
//
// A managed code EXE or DLL uses the same basic format that unmanaged executables use call the Portable
// Executable (PE) format. See http://en.wikipedia.org/wiki/Portable_Executable or
// http://msdn.microsoft.com/msdnmag/issues/02/02/PE/default.aspx for more on this format and RVAs.
//
// PE files define fixed table of well known entry pointers call Directory entries. Each entry holds the
// relative virtual address (RVA) and length of a blob of data within the PE file. You can see these using
// the command
//
// link /dump /headers <EXENAME>
//
//
// Managed code has defined one of these entries (the 14th see code:IMAGE_DIRECTORY_ENTRY_COMHEADER) and the RVA points
// that the IMAGE_COR20_HEADER. This header shows up in the previous dump as the following line
//
// // Managed code is identified by is following line
//
// 2008 [ 48] RVA [size] of COM Descriptor Directory
//
// The IMAGE_COR20_HEADER is mostly just RVA:Length pairs (pointers) to other interesting data structures.
// The most important of these is the MetaData tables. The easiest way of looking at meta-data is using
// the IlDasm.exe tool.
//
// MetaData holds most of the information in the IL image. The exceptions are resource blobs and the IL
// instructions streams for individual methods. Instead the Meta-data for a method holds an RVA to a
// code:IMAGE_COR_ILMETHOD which holds all the IL stream (and exception handling information).
//
// Precompiled (NGEN) images use the same IMAGE_COR20_HEADER but also use the ManagedNativeHeader field to
// point at structures that only exist in precompiled images.
//
typedef struct IMAGE_COR20_HEADER
{
// Header versioning
uint32_t cb;
uint16_t MajorRuntimeVersion;
uint16_t MinorRuntimeVersion;
// Symbol table and startup information
IMAGE_DATA_DIRECTORY MetaData;
uint32_t Flags;
// The main program if it is an EXE (not used if a DLL?)
// If COMIMAGE_FLAGS_NATIVE_ENTRYPOINT is not set, EntryPointToken represents a managed entrypoint.
// If COMIMAGE_FLAGS_NATIVE_ENTRYPOINT is set, EntryPointRVA represents an RVA to a native entrypoint
// (deprecated for DLLs, use modules constructors instead).
union {
uint32_t EntryPointToken;
uint32_t EntryPointRVA;
};
// This is the blob of managed resources. Fetched using code:AssemblyNative.GetResource and
// code:PEAssembly.GetResource and accessible from managed code from
// System.Assembly.GetManifestResourceStream. The meta data has a table that maps names to offsets into
// this blob, so logically the blob is a set of resources.
IMAGE_DATA_DIRECTORY Resources;
// IL assemblies can be signed with a public-private key to validate who created it. The signature goes
// here if this feature is used.
IMAGE_DATA_DIRECTORY StrongNameSignature;
IMAGE_DATA_DIRECTORY CodeManagerTable; // Deprecated, not used
// Used for manged code that has unmanaged code inside it (or exports methods as unmanaged entry points)
IMAGE_DATA_DIRECTORY VTableFixups;
IMAGE_DATA_DIRECTORY ExportAddressTableJumps;
// null for ordinary IL images.
// In Ready2Run images it points to a READYTORUN_HEADER.
IMAGE_DATA_DIRECTORY ManagedNativeHeader;
} IMAGE_COR20_HEADER, *PIMAGE_COR20_HEADER;
#else // !__IMAGE_COR20_HEADER_DEFINED__
// <TODO>@TODO: This is required because we pull in the COM+ 2.0 PE header
// definition from WinNT.h, and these constants have not yet propagated to there.</TODO>
//
#define COR_VTABLE_FROM_UNMANAGED_RETAIN_APPDOMAIN 0x08
#define COMIMAGE_FLAGS_32BITPREFERRED 0x00020000
#endif // __IMAGE_COR20_HEADER_DEFINED__
// The most recent version.
#define COR_CTOR_METHOD_NAME ".ctor"
#define COR_CTOR_METHOD_NAME_W W(".ctor")
#define COR_CCTOR_METHOD_NAME ".cctor"
#define COR_CCTOR_METHOD_NAME_W W(".cctor")
#define COR_ENUM_FIELD_NAME "value__"
#define COR_ENUM_FIELD_NAME_W W("value__")
// The predefined name for deleting a typeDef,MethodDef, FieldDef, Property and Event
#define COR_DELETED_NAME_A "_Deleted"
#define COR_DELETED_NAME_W W("_Deleted")
#define COR_VTABLEGAP_NAME_A "_VtblGap"
#define COR_VTABLEGAP_NAME_W W("_VtblGap")
// We intentionally use strncmp so that we will ignore any suffix
#define IsDeletedName(strName) (strncmp(strName, COR_DELETED_NAME_A, COR_DELETED_NAME_LENGTH) == 0)
#define IsVtblGapName(strName) (strncmp(strName, COR_VTABLEGAP_NAME_A, COR_VTABLEGAP_NAME_LENGTH) == 0)
// TypeDef/ExportedType attr bits, used by DefineTypeDef.
typedef enum CorTypeAttr
{
// Use this mask to retrieve the type visibility information.
tdVisibilityMask = 0x00000007,
tdNotPublic = 0x00000000, // Class is not public scope.
tdPublic = 0x00000001, // Class is public scope.
tdNestedPublic = 0x00000002, // Class is nested with public visibility.
tdNestedPrivate = 0x00000003, // Class is nested with private visibility.
tdNestedFamily = 0x00000004, // Class is nested with family visibility.
tdNestedAssembly = 0x00000005, // Class is nested with assembly visibility.
tdNestedFamANDAssem = 0x00000006, // Class is nested with family and assembly visibility.
tdNestedFamORAssem = 0x00000007, // Class is nested with family or assembly visibility.
// Use this mask to retrieve class layout information
tdLayoutMask = 0x00000018,
tdAutoLayout = 0x00000000, // Class fields are auto-laid out
tdSequentialLayout = 0x00000008, // Class fields are laid out sequentially
tdExplicitLayout = 0x00000010, // Layout is supplied explicitly
// end layout mask
// Use this mask to retrieve class semantics information.
tdClassSemanticsMask = 0x00000020,
tdClass = 0x00000000, // Type is a class.
tdInterface = 0x00000020, // Type is an interface.
// end semantics mask
// Special semantics in addition to class semantics.
tdAbstract = 0x00000080, // Class is abstract
tdSealed = 0x00000100, // Class is concrete and may not be extended
tdSpecialName = 0x00000400, // Class name is special. Name describes how.
// Implementation attributes.
tdImport = 0x00001000, // Class / interface is imported
tdSerializable = 0x00002000, // The class is Serializable.
tdWindowsRuntime = 0x00004000, // The type is a Windows Runtime type
// Use tdStringFormatMask to retrieve string information for native interop
tdStringFormatMask = 0x00030000,
tdAnsiClass = 0x00000000, // LPTSTR is interpreted as ANSI in this class
tdUnicodeClass = 0x00010000, // LPTSTR is interpreted as UNICODE
tdAutoClass = 0x00020000, // LPTSTR is interpreted automatically
tdCustomFormatClass = 0x00030000, // A non-standard encoding specified by CustomFormatMask
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.
// end string format mask
tdBeforeFieldInit = 0x00100000, // Initialize the class any time before first static field access.
tdForwarder = 0x00200000, // This ExportedType is a type forwarder.
// Flags reserved for runtime use.
tdReservedMask = 0x00040800,
tdRTSpecialName = 0x00000800, // Runtime should check name encoding.
tdHasSecurity = 0x00040000, // Class has security associate with it.
} CorTypeAttr;
// Macros for accessing the members of the CorTypeAttr.
#define IsTdNotPublic(x) (((x) & tdVisibilityMask) == tdNotPublic)
#define IsTdPublic(x) (((x) & tdVisibilityMask) == tdPublic)
#define IsTdNestedPublic(x) (((x) & tdVisibilityMask) == tdNestedPublic)
#define IsTdNestedPrivate(x) (((x) & tdVisibilityMask) == tdNestedPrivate)
#define IsTdNestedFamily(x) (((x) & tdVisibilityMask) == tdNestedFamily)
#define IsTdNestedAssembly(x) (((x) & tdVisibilityMask) == tdNestedAssembly)
#define IsTdNestedFamANDAssem(x) (((x) & tdVisibilityMask) == tdNestedFamANDAssem)
#define IsTdNestedFamORAssem(x) (((x) & tdVisibilityMask) == tdNestedFamORAssem)
#define IsTdNested(x) (((x) & tdVisibilityMask) >= tdNestedPublic)
#define IsTdAutoLayout(x) (((x) & tdLayoutMask) == tdAutoLayout)
#define IsTdSequentialLayout(x) (((x) & tdLayoutMask) == tdSequentialLayout)
#define IsTdExplicitLayout(x) (((x) & tdLayoutMask) == tdExplicitLayout)
#define IsTdClass(x) (((x) & tdClassSemanticsMask) == tdClass)
#define IsTdInterface(x) (((x) & tdClassSemanticsMask) == tdInterface)
#define IsTdAbstract(x) ((x) & tdAbstract)
#define IsTdSealed(x) ((x) & tdSealed)
#define IsTdSpecialName(x) ((x) & tdSpecialName)
#define IsTdImport(x) ((x) & tdImport)
#define IsTdSerializable(x) ((x) & tdSerializable)
#define IsTdWindowsRuntime(x) ((x) & tdWindowsRuntime)
#define IsTdAnsiClass(x) (((x) & tdStringFormatMask) == tdAnsiClass)
#define IsTdUnicodeClass(x) (((x) & tdStringFormatMask) == tdUnicodeClass)
#define IsTdAutoClass(x) (((x) & tdStringFormatMask) == tdAutoClass)
#define IsTdCustomFormatClass(x) (((x) & tdStringFormatMask) == tdCustomFormatClass)
#define IsTdBeforeFieldInit(x) ((x) & tdBeforeFieldInit)
#define IsTdForwarder(x) ((x) & tdForwarder)
#define IsTdRTSpecialName(x) ((x) & tdRTSpecialName)
#define IsTdHasSecurity(x) ((x) & tdHasSecurity)
// MethodDef attr bits, Used by DefineMethod.
typedef enum CorMethodAttr
{
// member access mask - Use this mask to retrieve accessibility information.
mdMemberAccessMask = 0x0007,
mdPrivateScope = 0x0000, // Member not referencable.
mdPrivate = 0x0001, // Accessible only by the parent type.
mdFamANDAssem = 0x0002, // Accessible by sub-types only in this Assembly.
mdAssem = 0x0003, // Accessibly by anyone in the Assembly.
mdFamily = 0x0004, // Accessible only by type and sub-types.
mdFamORAssem = 0x0005, // Accessibly by sub-types anywhere, plus anyone in assembly.
mdPublic = 0x0006, // Accessibly by anyone who has visibility to this scope.
// end member access mask
// method contract attributes.
mdStatic = 0x0010, // Defined on type, else per instance.
mdFinal = 0x0020, // Method may not be overridden.
mdVirtual = 0x0040, // Method virtual.
mdHideBySig = 0x0080, // Method hides by name+sig, else just by name.
// vtable layout mask - Use this mask to retrieve vtable attributes.
mdVtableLayoutMask = 0x0100,
mdReuseSlot = 0x0000, // The default.
mdNewSlot = 0x0100, // Method always gets a new slot in the vtable.
// end vtable layout mask
// method implementation attributes.
mdCheckAccessOnOverride = 0x0200, // Overridability is the same as the visibility.
mdAbstract = 0x0400, // Method does not provide an implementation.
mdSpecialName = 0x0800, // Method is special. Name describes how.
// interop attributes
mdPinvokeImpl = 0x2000, // Implementation is forwarded through pinvoke.
mdUnmanagedExport = 0x0008, // Managed method exported via thunk to unmanaged code.
// Reserved flags for runtime use only.
mdReservedMask = 0xd000,
mdRTSpecialName = 0x1000, // Runtime should check name encoding.
mdHasSecurity = 0x4000, // Method has security associate with it.
mdRequireSecObject = 0x8000, // Method calls another method containing security code.
} CorMethodAttr;
// Macros for accessing the members of CorMethodAttr.
#define IsMdPrivateScope(x) (((x) & mdMemberAccessMask) == mdPrivateScope)
#define IsMdPrivate(x) (((x) & mdMemberAccessMask) == mdPrivate)
#define IsMdFamANDAssem(x) (((x) & mdMemberAccessMask) == mdFamANDAssem)
#define IsMdAssem(x) (((x) & mdMemberAccessMask) == mdAssem)
#define IsMdFamily(x) (((x) & mdMemberAccessMask) == mdFamily)
#define IsMdFamORAssem(x) (((x) & mdMemberAccessMask) == mdFamORAssem)
#define IsMdPublic(x) (((x) & mdMemberAccessMask) == mdPublic)
#define IsMdStatic(x) ((x) & mdStatic)
#define IsMdFinal(x) ((x) & mdFinal)
#define IsMdVirtual(x) ((x) & mdVirtual)
#define IsMdHideBySig(x) ((x) & mdHideBySig)
#define IsMdReuseSlot(x) (((x) & mdVtableLayoutMask) == mdReuseSlot)
#define IsMdNewSlot(x) (((x) & mdVtableLayoutMask) == mdNewSlot)
#define IsMdCheckAccessOnOverride(x) ((x) & mdCheckAccessOnOverride)
#define IsMdAbstract(x) ((x) & mdAbstract)
#define IsMdSpecialName(x) ((x) & mdSpecialName)
#define IsMdPinvokeImpl(x) ((x) & mdPinvokeImpl)
#define IsMdUnmanagedExport(x) ((x) & mdUnmanagedExport)
#define IsMdRTSpecialName(x) ((x) & mdRTSpecialName)
#define IsMdInstanceInitializer(x, str) (((x) & mdRTSpecialName) && !strcmp((str), COR_CTOR_METHOD_NAME))
#define IsMdInstanceInitializerW(x, str) (((x) & mdRTSpecialName) && !u16_strcmp((str), COR_CTOR_METHOD_NAME_W))
#define IsMdClassConstructor(x, str) (((x) & mdRTSpecialName) && !strcmp((str), COR_CCTOR_METHOD_NAME))
#define IsMdClassConstructorW(x, str) (((x) & mdRTSpecialName) && !u16_strcmp((str), COR_CCTOR_METHOD_NAME_W))
#define IsMdHasSecurity(x) ((x) & mdHasSecurity)
#define IsMdRequireSecObject(x) ((x) & mdRequireSecObject)
// FieldDef attr bits, used by DefineField.
typedef enum CorFieldAttr
{
// member access mask - Use this mask to retrieve accessibility information.
fdFieldAccessMask = 0x0007,
fdPrivateScope = 0x0000, // Member not referencable.
fdPrivate = 0x0001, // Accessible only by the parent type.
fdFamANDAssem = 0x0002, // Accessible by sub-types only in this Assembly.
fdAssembly = 0x0003, // Accessibly by anyone in the Assembly.
fdFamily = 0x0004, // Accessible only by type and sub-types.
fdFamORAssem = 0x0005, // Accessibly by sub-types anywhere, plus anyone in assembly.
fdPublic = 0x0006, // Accessibly by anyone who has visibility to this scope.
// end member access mask
// field contract attributes.
fdStatic = 0x0010, // Defined on type, else per instance.
fdInitOnly = 0x0020, // Field may only be initialized, not written to after init.
fdLiteral = 0x0040, // Value is compile time constant.
fdNotSerialized = 0x0080, // Field does not have to be serialized when type is remoted.
fdSpecialName = 0x0200, // field is special. Name describes how.
// interop attributes
fdPinvokeImpl = 0x2000, // Implementation is forwarded through pinvoke.
// Reserved flags for runtime use only.
fdReservedMask = 0x9500,
fdRTSpecialName = 0x0400, // Runtime(metadata internal APIs) should check name encoding.
fdHasFieldMarshal = 0x1000, // Field has marshalling information.
fdHasDefault = 0x8000, // Field has default.
fdHasFieldRVA = 0x0100, // Field has RVA.
} CorFieldAttr;
// Macros for accessing the members of CorFieldAttr.
#define IsFdPrivateScope(x) (((x) & fdFieldAccessMask) == fdPrivateScope)
#define IsFdPrivate(x) (((x) & fdFieldAccessMask) == fdPrivate)
#define IsFdFamANDAssem(x) (((x) & fdFieldAccessMask) == fdFamANDAssem)
#define IsFdAssembly(x) (((x) & fdFieldAccessMask) == fdAssembly)
#define IsFdFamily(x) (((x) & fdFieldAccessMask) == fdFamily)
#define IsFdFamORAssem(x) (((x) & fdFieldAccessMask) == fdFamORAssem)
#define IsFdPublic(x) (((x) & fdFieldAccessMask) == fdPublic)
#define IsFdStatic(x) ((x) & fdStatic)
#define IsFdInitOnly(x) ((x) & fdInitOnly)
#define IsFdLiteral(x) ((x) & fdLiteral)
#define IsFdNotSerialized(x) ((x) & fdNotSerialized)
#define IsFdPinvokeImpl(x) ((x) & fdPinvokeImpl)
#define IsFdSpecialName(x) ((x) & fdSpecialName)
#define IsFdHasFieldRVA(x) ((x) & fdHasFieldRVA)
#define IsFdRTSpecialName(x) ((x) & fdRTSpecialName)
#define IsFdHasFieldMarshal(x) ((x) & fdHasFieldMarshal)
#define IsFdHasDefault(x) ((x) & fdHasDefault)
// Param attr bits, used by DefineParam.
typedef enum CorParamAttr
{
pdIn = 0x0001, // Param is [In]
pdOut = 0x0002, // Param is [out]
pdOptional = 0x0010, // Param is optional
// Reserved flags for Runtime use only.
pdReservedMask = 0xf000,
pdHasDefault = 0x1000, // Param has default value.
pdHasFieldMarshal = 0x2000, // Param has FieldMarshal.
pdUnused = 0xcfe0,
} CorParamAttr;
// Macros for accessing the members of CorParamAttr.
#define IsPdIn(x) ((x) & pdIn)
#define IsPdOut(x) ((x) & pdOut)
#define IsPdOptional(x) ((x) & pdOptional)
#define IsPdHasDefault(x) ((x) & pdHasDefault)
#define IsPdHasFieldMarshal(x) ((x) & pdHasFieldMarshal)
// Property attr bits, used by DefineProperty.
typedef enum CorPropertyAttr
{
prSpecialName = 0x0200, // property is special. Name describes how.
// Reserved flags for Runtime use only.
prReservedMask = 0xf400,
prRTSpecialName = 0x0400, // Runtime(metadata internal APIs) should check name encoding.
prHasDefault = 0x1000, // Property has default
prUnused = 0xe9ff,
} CorPropertyAttr;
// Macros for accessing the members of CorPropertyAttr.
#define IsPrSpecialName(x) ((x) & prSpecialName)
#define IsPrRTSpecialName(x) ((x) & prRTSpecialName)
#define IsPrHasDefault(x) ((x) & prHasDefault)
// Event attr bits, used by DefineEvent.
typedef enum CorEventAttr
{
evSpecialName = 0x0200, // event is special. Name describes how.
// Reserved flags for Runtime use only.
evReservedMask = 0x0400,
evRTSpecialName = 0x0400, // Runtime(metadata internal APIs) should check name encoding.
} CorEventAttr;
// Macros for accessing the members of CorEventAttr.
#define IsEvSpecialName(x) ((x) & evSpecialName)
#define IsEvRTSpecialName(x) ((x) & evRTSpecialName)
// MethodSemantic attr bits, used by DefineProperty, DefineEvent.
typedef enum CorMethodSemanticsAttr
{
msSetter = 0x0001, // Setter for property
msGetter = 0x0002, // Getter for property
msOther = 0x0004, // other method for property or event
msAddOn = 0x0008, // AddOn method for event
msRemoveOn = 0x0010, // RemoveOn method for event
msFire = 0x0020, // Fire method for event
} CorMethodSemanticsAttr;
// Macros for accessing the members of CorMethodSemanticsAttr.
#define IsMsSetter(x) ((x) & msSetter)
#define IsMsGetter(x) ((x) & msGetter)
#define IsMsOther(x) ((x) & msOther)
#define IsMsAddOn(x) ((x) & msAddOn)
#define IsMsRemoveOn(x) ((x) & msRemoveOn)
#define IsMsFire(x) ((x) & msFire)
// DeclSecurity attr bits, used by DefinePermissionSet.
typedef enum CorDeclSecurity
{
dclActionMask = 0x001f, // Mask allows growth of enum.
dclActionNil = 0x0000, //
dclRequest = 0x0001, //
dclDemand = 0x0002, //
dclAssert = 0x0003, //
dclDeny = 0x0004, //
dclPermitOnly = 0x0005, //
dclLinktimeCheck = 0x0006, //
dclInheritanceCheck = 0x0007, //
dclRequestMinimum = 0x0008, //
dclRequestOptional = 0x0009, //
dclRequestRefuse = 0x000a, //
dclPrejitGrant = 0x000b, // Persisted grant set at prejit time
dclPrejitDenied = 0x000c, // Persisted denied set at prejit time
dclNonCasDemand = 0x000d, //
dclNonCasLinkDemand = 0x000e, //
dclNonCasInheritance = 0x000f, //
dclMaximumValue = 0x000f, // Maximum legal value
} CorDeclSecurity;
// Macros for accessing the members of CorDeclSecurity.
#define IsDclActionNil(x) (((x) & dclActionMask) == dclActionNil)
// Is this a demand that can trigger a stackwalk?
#define IsDclActionAnyStackModifier(x) ((((x) & dclActionMask) == dclAssert) || \
(((x) & dclActionMask) == dclDeny) || \
(((x) & dclActionMask) == dclPermitOnly))
// Is this an assembly level attribute (i.e. not applicable on Type/Member)?
#define IsAssemblyDclAction(x) (((x) >= dclRequestMinimum) && \
((x) <= dclRequestRefuse))
// Is this an NGen only attribute?
#define IsNGenOnlyDclAction(x) (((x) == dclPrejitGrant) || \
((x) == dclPrejitDenied))
// MethodImpl attr bits, used by DefineMethodImpl.
typedef enum CorMethodImpl
{
// code impl mask
miCodeTypeMask = 0x0003, // Flags about code type.
miIL = 0x0000, // Method impl is IL.
miNative = 0x0001, // Method impl is native.
miOPTIL = 0x0002, // Method impl is OPTIL
miRuntime = 0x0003, // Method impl is provided by the runtime.
// end code impl mask
// managed mask
miManagedMask = 0x0004, // Flags specifying whether the code is managed or unmanaged.
miUnmanaged = 0x0004, // Method impl is unmanaged, otherwise managed.
miManaged = 0x0000, // Method impl is managed.
// end managed mask
// implementation info and interop
miForwardRef = 0x0010, // Indicates method is defined; used primarily in merge scenarios.
miPreserveSig = 0x0080, // Indicates method sig is not to be mangled to do HRESULT conversion.
miInternalCall = 0x1000, // Reserved for internal use.
miSynchronized = 0x0020, // Method is single threaded through the body.
miNoInlining = 0x0008, // Method may not be inlined.
miAggressiveInlining = 0x0100, // Method should be inlined if possible.
miNoOptimization = 0x0040, // Method may not be optimized.
miAggressiveOptimization = 0x0200, // Method may contain hot code and should be aggressively optimized.
// These are the flags that are allowed in MethodImplAttribute's Value
// property. This should include everything above except the code impl
// flags (which are used for MethodImplAttribute's MethodCodeType field).
miUserMask = miManagedMask | miForwardRef | miPreserveSig |
miInternalCall | miSynchronized |
miNoInlining | miAggressiveInlining |
miNoOptimization | miAggressiveOptimization,
miMaxMethodImplVal = 0xffff, // Range check value
} CorMethodImpl;
// Macros for accessing the members of CorMethodImpl.
#define IsMiIL(x) (((x) & miCodeTypeMask) == miIL)
#define IsMiNative(x) (((x) & miCodeTypeMask) == miNative)
#define IsMiOPTIL(x) (((x) & miCodeTypeMask) == miOPTIL)
#define IsMiRuntime(x) (((x) & miCodeTypeMask) == miRuntime)
#define IsMiUnmanaged(x) (((x) & miManagedMask) == miUnmanaged)
#define IsMiManaged(x) (((x) & miManagedMask) == miManaged)
#define IsMiForwardRef(x) ((x) & miForwardRef)
#define IsMiPreserveSig(x) ((x) & miPreserveSig)
#define IsMiInternalCall(x) ((x) & miInternalCall)
#define IsMiSynchronized(x) ((x) & miSynchronized)
#define IsMiNoInlining(x) ((x) & miNoInlining)
#define IsMiAggressiveInlining(x) ((x) & miAggressiveInlining)
#define IsMiNoOptimization(x) ((x) & miNoOptimization)
#define IsMiAggressiveOptimization(x) (((x) & (miAggressiveOptimization | miNoOptimization)) == miAggressiveOptimization)
// PinvokeMap attr bits, used by DefinePinvokeMap.
typedef enum CorPinvokeMap
{
pmNoMangle = 0x0001, // Pinvoke is to use the member name as specified.
// Use this mask to retrieve the CharSet information.
pmCharSetMask = 0x0006,
pmCharSetNotSpec = 0x0000,
pmCharSetAnsi = 0x0002,
pmCharSetUnicode = 0x0004,
pmCharSetAuto = 0x0006,
pmBestFitUseAssem = 0x0000,
pmBestFitEnabled = 0x0010,
pmBestFitDisabled = 0x0020,
pmBestFitMask = 0x0030,
pmThrowOnUnmappableCharUseAssem = 0x0000,
pmThrowOnUnmappableCharEnabled = 0x1000,
pmThrowOnUnmappableCharDisabled = 0x2000,
pmThrowOnUnmappableCharMask = 0x3000,
pmSupportsLastError = 0x0040, // Information about target function. Not relevant for fields.
// None of the calling convention flags is relevant for fields.
pmCallConvMask = 0x0700,
pmCallConvWinapi = 0x0100, // Pinvoke will use native callconv appropriate to target windows platform.
pmCallConvCdecl = 0x0200,
pmCallConvStdcall = 0x0300,
pmCallConvThiscall = 0x0400, // In M9, pinvoke will raise exception.
pmCallConvFastcall = 0x0500,
pmMaxValue = 0xFFFF,
} CorPinvokeMap;
// Macros for accessing the members of CorPinvokeMap
#define IsPmNoMangle(x) ((x) & pmNoMangle)
#define IsPmCharSetNotSpec(x) (((x) & pmCharSetMask) == pmCharSetNotSpec)
#define IsPmCharSetAnsi(x) (((x) & pmCharSetMask) == pmCharSetAnsi)
#define IsPmCharSetUnicode(x) (((x) & pmCharSetMask) == pmCharSetUnicode)
#define IsPmCharSetAuto(x) (((x) & pmCharSetMask) == pmCharSetAuto)
#define IsPmSupportsLastError(x) ((x) & pmSupportsLastError)
#define IsPmCallConvWinapi(x) (((x) & pmCallConvMask) == pmCallConvWinapi)
#define IsPmCallConvCdecl(x) (((x) & pmCallConvMask) == pmCallConvCdecl)
#define IsPmCallConvStdcall(x) (((x) & pmCallConvMask) == pmCallConvStdcall)
#define IsPmCallConvThiscall(x) (((x) & pmCallConvMask) == pmCallConvThiscall)
#define IsPmCallConvFastcall(x) (((x) & pmCallConvMask) == pmCallConvFastcall)
#define IsPmBestFitEnabled(x) (((x) & pmBestFitMask) == pmBestFitEnabled)
#define IsPmBestFitDisabled(x) (((x) & pmBestFitMask) == pmBestFitDisabled)
#define IsPmBestFitUseAssem(x) (((x) & pmBestFitMask) == pmBestFitUseAssem)
#define IsPmThrowOnUnmappableCharEnabled(x) (((x) & pmThrowOnUnmappableCharMask) == pmThrowOnUnmappableCharEnabled)
#define IsPmThrowOnUnmappableCharDisabled(x) (((x) & pmThrowOnUnmappableCharMask) == pmThrowOnUnmappableCharDisabled)
#define IsPmThrowOnUnmappableCharUseAssem(x) (((x) & pmThrowOnUnmappableCharMask) == pmThrowOnUnmappableCharUseAssem)
// Assembly attr bits, used by DefineAssembly.
typedef enum CorAssemblyFlags
{
afPublicKey = 0x0001, // The assembly ref holds the full (unhashed) public key.
afPA_None = 0x0000, // Processor Architecture unspecified
afPA_MSIL = 0x0010, // Processor Architecture: neutral (PE32)
afPA_x86 = 0x0020, // Processor Architecture: x86 (PE32)
afPA_IA64 = 0x0030, // Processor Architecture: Itanium (PE32+)
afPA_AMD64 = 0x0040, // Processor Architecture: AMD X64 (PE32+)
afPA_ARM = 0x0050, // Processor Architecture: ARM (PE32)
afPA_ARM64 = 0x0060, // Processor Architecture: ARM64 (PE32+)
afPA_NoPlatform = 0x0070, // applies to any platform but cannot run on any (e.g. reference assembly), should not have "specified" set
afPA_Specified = 0x0080, // Propagate PA flags to AssemblyRef record
afPA_Mask = 0x0070, // Bits describing the processor architecture
afPA_FullMask = 0x00F0, // Bits describing the PA incl. Specified
afPA_Shift = 0x0004, // NOT A FLAG, shift count in PA flags <--> index conversion
afEnableJITcompileTracking = 0x8000, // From "DebuggableAttribute".
afDisableJITcompileOptimizer = 0x4000, // From "DebuggableAttribute".
afDebuggableAttributeMask = 0xc000,
afRetargetable = 0x0100, // The assembly can be retargeted (at runtime) to an
// assembly from a different publisher.
afContentType_Default = 0x0000,
afContentType_WindowsRuntime = 0x0200,
afContentType_Mask = 0x0E00, // Bits describing ContentType
} CorAssemblyFlags;
// Macros for accessing the members of CorAssemblyFlags.
#define IsAfRetargetable(x) ((x) & afRetargetable)
#define IsAfContentType_Default(x) (((x) & afContentType_Mask) == afContentType_Default)
#define IsAfContentType_WindowsRuntime(x) (((x) & afContentType_Mask) == afContentType_WindowsRuntime)
// Macros for accessing the Processor Architecture flags of CorAssemblyFlags.
#define IsAfPA_MSIL(x) (((x) & afPA_Mask) == afPA_MSIL)
#define IsAfPA_x86(x) (((x) & afPA_Mask) == afPA_x86)
#define IsAfPA_IA64(x) (((x) & afPA_Mask) == afPA_IA64)
#define IsAfPA_AMD64(x) (((x) & afPA_Mask) == afPA_AMD64)
#define IsAfPA_ARM(x) (((x) & afPA_Mask) == afPA_ARM)
#define IsAfPA_ARM64(x) (((x) & afPA_Mask) == afPA_ARM64)
#define IsAfPA_NoPlatform(x) (((x) & afPA_FullMask) == afPA_NoPlatform)
#define IsAfPA_Specified(x) ((x) & afPA_Specified)
#define PAIndex(x) (((x) & afPA_Mask) >> afPA_Shift)
#define PAFlag(x) (((x) << afPA_Shift) & afPA_Mask)
#define PrepareForSaving(x) ((x) & (((x) & afPA_Specified) ? ~afPA_Specified : ~afPA_FullMask))
#define IsAfEnableJITcompileTracking(x) ((x) & afEnableJITcompileTracking)
#define IsAfDisableJITcompileOptimizer(x) ((x) & afDisableJITcompileOptimizer)
// Macros for accessing the public key flags of CorAssemblyFlags.
#define IsAfPublicKey(x) ((x) & afPublicKey)
#define IsAfPublicKeyToken(x) (((x) & afPublicKey) == 0)
// ManifestResource attr bits, used by DefineManifestResource.
typedef enum CorManifestResourceFlags
{
mrVisibilityMask = 0x0007,
mrPublic = 0x0001, // The Resource is exported from the Assembly.
mrPrivate = 0x0002, // The Resource is private to the Assembly.
} CorManifestResourceFlags;
// Macros for accessing the members of CorManifestResourceFlags.
#define IsMrPublic(x) (((x) & mrVisibilityMask) == mrPublic)
#define IsMrPrivate(x) (((x) & mrVisibilityMask) == mrPrivate)
// File attr bits, used by DefineFile.
typedef enum CorFileFlags
{
ffContainsMetaData = 0x0000, // This is not a resource file
ffContainsNoMetaData = 0x0001, // This is a resource file or other non-metadata-containing file
} CorFileFlags;
// Macros for accessing the members of CorFileFlags.
#define IsFfContainsMetaData(x) (!((x) & ffContainsNoMetaData))
#define IsFfContainsNoMetaData(x) ((x) & ffContainsNoMetaData)
// PE file kind bits, returned by IMetaDataImport2::GetPEKind()
typedef enum CorPEKind
{
peNot = 0x00000000, // not a PE file
peILonly = 0x00000001, // flag IL_ONLY is set in COR header
pe32BitRequired=0x00000002, // flag 32BITREQUIRED is set and 32BITPREFERRED is clear in COR header
pe32Plus = 0x00000004, // PE32+ file (64 bit)
pe32Unmanaged=0x00000008, // PE32 without COR header
pe32BitPreferred=0x00000010 // flags 32BITREQUIRED and 32BITPREFERRED are set in COR header
} CorPEKind;
// GenericParam bits, used by DefineGenericParam.
typedef enum CorGenericParamAttr
{
// Variance of type parameters, only applicable to generic parameters
// for generic interfaces and delegates
gpVarianceMask = 0x0003,
gpNonVariant = 0x0000,
gpCovariant = 0x0001,
gpContravariant = 0x0002,
// Special constraints, applicable to any type parameters
gpSpecialConstraintMask = 0x003C,
gpNoSpecialConstraint = 0x0000,
gpReferenceTypeConstraint = 0x0004, // type argument must be a reference type
gpNotNullableValueTypeConstraint = 0x0008, // type argument must be a value type but not Nullable
gpDefaultConstructorConstraint = 0x0010, // type argument must have a public default constructor
gpAllowByRefLike = 0x0020, // type argument can be ByRefLike
} CorGenericParamAttr;
// structures and enums moved from COR.H
typedef uint8_t COR_SIGNATURE;
typedef COR_SIGNATURE* PCOR_SIGNATURE; // pointer to a cor sig. Not void* so that
// the bytes can be incremented easily
typedef const COR_SIGNATURE* PCCOR_SIGNATURE;
typedef const char * MDUTF8CSTR;
typedef char * MDUTF8STR;
//*****************************************************************************
//
// Element type for Cor signature
//
//*****************************************************************************
typedef enum CorElementType
{
ELEMENT_TYPE_END = 0x00,
ELEMENT_TYPE_VOID = 0x01,
ELEMENT_TYPE_BOOLEAN = 0x02,
ELEMENT_TYPE_CHAR = 0x03,
ELEMENT_TYPE_I1 = 0x04,
ELEMENT_TYPE_U1 = 0x05,
ELEMENT_TYPE_I2 = 0x06,
ELEMENT_TYPE_U2 = 0x07,
ELEMENT_TYPE_I4 = 0x08,
ELEMENT_TYPE_U4 = 0x09,
ELEMENT_TYPE_I8 = 0x0a,
ELEMENT_TYPE_U8 = 0x0b,
ELEMENT_TYPE_R4 = 0x0c,
ELEMENT_TYPE_R8 = 0x0d,
ELEMENT_TYPE_STRING = 0x0e,
// every type above PTR will be simple type
ELEMENT_TYPE_PTR = 0x0f, // PTR <type>
ELEMENT_TYPE_BYREF = 0x10, // BYREF <type>
// Please use ELEMENT_TYPE_VALUETYPE. ELEMENT_TYPE_VALUECLASS is deprecated.
ELEMENT_TYPE_VALUETYPE = 0x11, // VALUETYPE <class Token>
ELEMENT_TYPE_CLASS = 0x12, // CLASS <class Token>
ELEMENT_TYPE_VAR = 0x13, // a class type variable VAR <number>
ELEMENT_TYPE_ARRAY = 0x14, // MDARRAY <type> <rank> <bcount> <bound1> ... <lbcount> <lb1> ...
ELEMENT_TYPE_GENERICINST = 0x15, // GENERICINST <generic type> <argCnt> <arg1> ... <argn>
ELEMENT_TYPE_TYPEDBYREF = 0x16, // TYPEDREF (it takes no args) a typed reference to some other type
ELEMENT_TYPE_I = 0x18, // native integer size
ELEMENT_TYPE_U = 0x19, // native unsigned integer size
ELEMENT_TYPE_FNPTR = 0x1b, // FNPTR <complete sig for the function including calling convention>
ELEMENT_TYPE_OBJECT = 0x1c, // Shortcut for System.Object
ELEMENT_TYPE_SZARRAY = 0x1d, // Shortcut for single dimension zero lower bound array
// SZARRAY <type>
ELEMENT_TYPE_MVAR = 0x1e, // a method type variable MVAR <number>
// This is only for binding
ELEMENT_TYPE_CMOD_REQD = 0x1f, // required C modifier : E_T_CMOD_REQD <mdTypeRef/mdTypeDef>
ELEMENT_TYPE_CMOD_OPT = 0x20, // optional C modifier : E_T_CMOD_OPT <mdTypeRef/mdTypeDef>
// This is for signatures generated internally (which will not be persisted in any way).
ELEMENT_TYPE_INTERNAL = 0x21, // INTERNAL <typehandle>
// Note that this is the max of base type excluding modifiers
ELEMENT_TYPE_MAX = 0x22, // first invalid element type
ELEMENT_TYPE_MODIFIER = 0x40,
ELEMENT_TYPE_SENTINEL = 0x01 | ELEMENT_TYPE_MODIFIER, // sentinel for varargs
ELEMENT_TYPE_PINNED = 0x05 | ELEMENT_TYPE_MODIFIER,
} CorElementType;
//*****************************************************************************
//
// Serialization types for Custom attribute support
//
//*****************************************************************************
typedef enum CorSerializationType
{
SERIALIZATION_TYPE_UNDEFINED = 0,
SERIALIZATION_TYPE_BOOLEAN = ELEMENT_TYPE_BOOLEAN,
SERIALIZATION_TYPE_CHAR = ELEMENT_TYPE_CHAR,
SERIALIZATION_TYPE_I1 = ELEMENT_TYPE_I1,
SERIALIZATION_TYPE_U1 = ELEMENT_TYPE_U1,
SERIALIZATION_TYPE_I2 = ELEMENT_TYPE_I2,
SERIALIZATION_TYPE_U2 = ELEMENT_TYPE_U2,
SERIALIZATION_TYPE_I4 = ELEMENT_TYPE_I4,
SERIALIZATION_TYPE_U4 = ELEMENT_TYPE_U4,
SERIALIZATION_TYPE_I8 = ELEMENT_TYPE_I8,
SERIALIZATION_TYPE_U8 = ELEMENT_TYPE_U8,
SERIALIZATION_TYPE_R4 = ELEMENT_TYPE_R4,
SERIALIZATION_TYPE_R8 = ELEMENT_TYPE_R8,
SERIALIZATION_TYPE_STRING = ELEMENT_TYPE_STRING,
SERIALIZATION_TYPE_SZARRAY = ELEMENT_TYPE_SZARRAY, // Shortcut for single dimension zero lower bound array
SERIALIZATION_TYPE_TYPE = 0x50,
SERIALIZATION_TYPE_TAGGED_OBJECT= 0x51,
SERIALIZATION_TYPE_FIELD = 0x53,
SERIALIZATION_TYPE_PROPERTY = 0x54,
SERIALIZATION_TYPE_ENUM = 0x55
} CorSerializationType;
//
// Calling convention flags.
//
typedef enum CorUnmanagedCallingConvention
{
IMAGE_CEE_UNMANAGED_CALLCONV_C = 0x1,
IMAGE_CEE_UNMANAGED_CALLCONV_STDCALL = 0x2,
IMAGE_CEE_UNMANAGED_CALLCONV_THISCALL = 0x3,
IMAGE_CEE_UNMANAGED_CALLCONV_FASTCALL = 0x4,
} CorUnmanagedCallingConvention;
typedef enum CorCallingConvention
{
IMAGE_CEE_CS_CALLCONV_DEFAULT = 0x0,
IMAGE_CEE_CS_CALLCONV_C = IMAGE_CEE_UNMANAGED_CALLCONV_C,
IMAGE_CEE_CS_CALLCONV_STDCALL = IMAGE_CEE_UNMANAGED_CALLCONV_STDCALL,
IMAGE_CEE_CS_CALLCONV_THISCALL = IMAGE_CEE_UNMANAGED_CALLCONV_THISCALL,
IMAGE_CEE_CS_CALLCONV_FASTCALL = IMAGE_CEE_UNMANAGED_CALLCONV_FASTCALL,
IMAGE_CEE_CS_CALLCONV_VARARG = 0x5,
IMAGE_CEE_CS_CALLCONV_FIELD = 0x6,
IMAGE_CEE_CS_CALLCONV_LOCAL_SIG = 0x7,
IMAGE_CEE_CS_CALLCONV_PROPERTY = 0x8,
IMAGE_CEE_CS_CALLCONV_UNMANAGED = 0x9, // Unmanaged calling convention encoded as modopts
IMAGE_CEE_CS_CALLCONV_GENERICINST = 0xa, // generic method instantiation
IMAGE_CEE_CS_CALLCONV_NATIVEVARARG = 0xb, // used ONLY for 64bit vararg PInvoke calls
IMAGE_CEE_CS_CALLCONV_MAX = 0xc, // first invalid calling convention
// The high bits of the calling convention convey additional info
IMAGE_CEE_CS_CALLCONV_MASK = 0x0f, // Calling convention is bottom 4 bits
IMAGE_CEE_CS_CALLCONV_HASTHIS = 0x20, // Top bit indicates a 'this' parameter
IMAGE_CEE_CS_CALLCONV_EXPLICITTHIS = 0x40, // This parameter is explicitly in the signature
IMAGE_CEE_CS_CALLCONV_GENERIC = 0x10, // Generic method sig with explicit number of type arguments (precedes ordinary parameter count)
// 0x80 is reserved for internal use
} CorCallingConvention;
#define IMAGE_CEE_CS_CALLCONV_INSTANTIATION IMAGE_CEE_CS_CALLCONV_GENERICINST
typedef enum CorArgType
{
IMAGE_CEE_CS_END = 0x0,
IMAGE_CEE_CS_VOID = 0x1,
IMAGE_CEE_CS_I4 = 0x2,