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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
|
#ifndef __MONO_OBJECT_INTERNALS_H__
#define __MONO_OBJECT_INTERNALS_H__
#include <mono/metadata/object.h>
#include <mono/metadata/threads.h>
#include <mono/metadata/reflection.h>
#include <mono/metadata/mempool.h>
#include <mono/metadata/class-internals.h>
#include <mono/metadata/threads-types.h>
#include <mono/metadata/handle.h>
#include <mono/io-layer/io-layer.h>
#include "mono/utils/mono-compiler.h"
#include "mono/utils/mono-error.h"
#include "mono/utils/mono-error-internals.h"
#include "mono/utils/mono-stack-unwinding.h"
#include "mono/utils/mono-tls.h"
#include "mono/utils/mono-coop-mutex.h"
#if 1
#ifdef __GNUC__
#define mono_assert(expr) G_STMT_START{ \
if (!(expr)) \
{ \
MonoException *ex; \
char *msg = g_strdup_printf ("file %s: line %d (%s): " \
"assertion failed: (%s)", __FILE__, __LINE__, \
__PRETTY_FUNCTION__, #expr); \
ex = mono_get_exception_execution_engine (msg); \
g_free (msg); \
mono_raise_exception (ex); \
}; }G_STMT_END
#define mono_assert_not_reached() G_STMT_START{ \
MonoException *ex; \
char *msg = g_strdup_printf ("file %s: line %d (%s): " \
"should not be reached", __FILE__, __LINE__, __PRETTY_FUNCTION__); \
ex = mono_get_exception_execution_engine (msg); \
g_free (msg); \
mono_raise_exception (ex); \
}G_STMT_END
#else /* not GNUC */
#define mono_assert(expr) G_STMT_START{ \
if (!(expr)) \
{ \
MonoException *ex; \
char *msg = g_strdup_printf ("file %s: line %d: " \
"assertion failed: (%s)", __FILE__, __LINE__, \
#expr); \
ex = mono_get_exception_execution_engine (msg); \
g_free (msg); \
mono_raise_exception (ex); \
}; }G_STMT_END
#define mono_assert_not_reached() G_STMT_START{ \
MonoException *ex; \
char *msg = g_strdup_printf ("file %s: line %d): " \
"should not be reached", __FILE__, __LINE__); \
ex = mono_get_exception_execution_engine (msg); \
g_free (msg); \
mono_raise_exception (ex); \
}G_STMT_END
#endif
#else
#define mono_assert(expr) g_assert(expr)
#define mono_assert_not_reached() g_assert_not_reached()
#endif
/* Use this as MONO_CHECK_ARG_NULL (arg,expr,) in functions returning void */
#define MONO_CHECK_ARG(arg, expr, retval) G_STMT_START{ \
if (G_UNLIKELY (!(expr))) \
{ \
MonoException *ex; \
char *msg = g_strdup_printf ("assertion `%s' failed", \
#expr); \
if (arg) {} /* check if the name exists */ \
ex = mono_get_exception_argument (#arg, msg); \
g_free (msg); \
mono_set_pending_exception (ex); \
return retval; \
}; }G_STMT_END
/* Use this as MONO_CHECK_ARG_NULL (arg,) in functions returning void */
#define MONO_CHECK_ARG_NULL(arg, retval) G_STMT_START{ \
if (G_UNLIKELY (arg == NULL)) \
{ \
MonoException *ex; \
if (arg) {} /* check if the name exists */ \
ex = mono_get_exception_argument_null (#arg); \
mono_set_pending_exception (ex); \
return retval; \
}; }G_STMT_END
#define mono_string_builder_capacity(sb) sb->chunkOffset + sb->chunkChars->max_length
#define mono_string_builder_string_length(sb) sb->chunkOffset + sb->chunkLength
/*
* Macros which cache the results of lookups locally.
* These should be used instead of the original versions, if the __GNUC__
* restriction is acceptable.
*/
#ifdef __GNUC__
/* namespace and name should be a constant */
/* image must be mscorlib since other assemblies can be unloaded */
#define mono_class_from_name_cached(image,namespace,name) ({ \
static MonoClass *tmp_klass; \
if (!tmp_klass) { \
g_assert (image == mono_defaults.corlib); \
tmp_klass = mono_class_from_name ((image), (namespace), (name)); \
g_assert (tmp_klass); \
}; \
tmp_klass; })
/* name should be a compile-time constant */
#define mono_class_get_field_from_name_cached(klass,name) ({ \
static MonoClassField *tmp_field; \
if (!tmp_field) { \
tmp_field = mono_class_get_field_from_name ((klass), (name)); \
g_assert (tmp_field); \
}; \
tmp_field; })
/* eclass should be a run-time constant */
#define mono_array_class_get_cached(eclass,rank) ({ \
static MonoClass *tmp_klass; \
if (!tmp_klass) { \
tmp_klass = mono_array_class_get ((eclass), (rank)); \
g_assert (tmp_klass); \
}; \
tmp_klass; })
/* eclass should be a run-time constant */
#define mono_array_new_cached(domain, eclass, size) ({ \
MonoError __error; \
MonoVTable *__vtable = mono_class_vtable ((domain), mono_array_class_get_cached ((eclass), 1)); \
MonoArray *__arr = mono_array_new_specific_checked (__vtable, (size), &__error); \
mono_error_raise_exception (&__error); /* FIXME don't raise here */ \
__arr; })
#else
#define mono_class_from_name_cached(image,namespace,name) mono_class_from_name ((image), (namespace), (name))
#define mono_class_get_field_from_name_cached(klass,name) mono_class_get_field_from_name ((klass), (name))
#define mono_array_class_get_cached(eclass,rank) mono_array_class_get ((eclass), (rank))
#define mono_array_new_cached(domain, eclass, size) mono_array_new_specific (mono_class_vtable ((domain), mono_array_class_get_cached ((eclass), 1)), (size))
#endif
#ifdef MONO_BIG_ARRAYS
typedef uint64_t mono_array_size_t;
typedef int64_t mono_array_lower_bound_t;
#define MONO_ARRAY_MAX_INDEX G_MAXINT64
#define MONO_ARRAY_MAX_SIZE G_MAXUINT64
#else
typedef uint32_t mono_array_size_t;
typedef int32_t mono_array_lower_bound_t;
#define MONO_ARRAY_MAX_INDEX ((int32_t) 0x7fffffff)
#define MONO_ARRAY_MAX_SIZE ((uint32_t) 0xffffffff)
#endif
typedef struct {
mono_array_size_t length;
mono_array_lower_bound_t lower_bound;
} MonoArrayBounds;
struct _MonoArray {
MonoObject obj;
/* bounds is NULL for szarrays */
MonoArrayBounds *bounds;
/* total number of elements of the array */
mono_array_size_t max_length;
/* we use double to ensure proper alignment on platforms that need it */
double vector [MONO_ZERO_LEN_ARRAY];
};
#define MONO_SIZEOF_MONO_ARRAY (sizeof (MonoArray) - MONO_ZERO_LEN_ARRAY * sizeof (double))
struct _MonoString {
MonoObject object;
int32_t length;
mono_unichar2 chars [MONO_ZERO_LEN_ARRAY];
};
#define mono_object_class(obj) (((MonoObject*)(obj))->vtable->klass)
#define mono_object_domain(obj) (((MonoObject*)(obj))->vtable->domain)
#define mono_string_chars_fast(s) ((mono_unichar2*)(s)->chars)
#define mono_string_length_fast(s) ((s)->length)
#define mono_array_length_fast(array) ((array)->max_length)
#define mono_array_addr_with_size_fast(array,size,index) ( ((char*)(array)->vector) + (size) * (index) )
#define mono_array_addr_fast(array,type,index) ((type*)(void*) mono_array_addr_with_size_fast (array, sizeof (type), index))
#define mono_array_get_fast(array,type,index) ( *(type*)mono_array_addr_fast ((array), type, (index)) )
#define mono_array_set_fast(array,type,index,value) \
do { \
type *__p = (type *) mono_array_addr_fast ((array), type, (index)); \
*__p = (value); \
} while (0)
#define mono_array_setref_fast(array,index,value) \
do { \
void **__p = (void **) mono_array_addr_fast ((array), void*, (index)); \
mono_gc_wbarrier_set_arrayref ((array), __p, (MonoObject*)(value)); \
/* *__p = (value);*/ \
} while (0)
#define mono_array_memcpy_refs_fast(dest,destidx,src,srcidx,count) \
do { \
void **__p = (void **) mono_array_addr_fast ((dest), void*, (destidx)); \
void **__s = mono_array_addr_fast ((src), void*, (srcidx)); \
mono_gc_wbarrier_arrayref_copy (__p, __s, (count)); \
} while (0)
typedef struct {
MonoObject obj;
MonoObject *identity;
} MonoMarshalByRefObject;
/* This is a copy of System.AppDomain */
struct _MonoAppDomain {
MonoMarshalByRefObject mbr;
MonoDomain *data;
};
typedef struct _MonoStringBuilder MonoStringBuilder;
struct _MonoStringBuilder {
MonoObject object;
MonoArray *chunkChars;
MonoStringBuilder* chunkPrevious; // Link to the block logically before this block
int chunkLength; // The index in ChunkChars that represent the end of the block
int chunkOffset; // The logial offset (sum of all characters in previous blocks)
int maxCapacity;
};
typedef struct {
MonoType *type;
gpointer value;
MonoClass *klass;
} MonoTypedRef;
typedef struct {
gpointer args;
} MonoArgumentHandle;
typedef struct {
MonoMethodSignature *sig;
gpointer args;
gint32 next_arg;
gint32 num_args;
} MonoArgIterator;
struct _MonoException {
MonoObject object;
/* Stores the IPs and the generic sharing infos
(vtable/MRGCTX) of the frames. */
MonoArray *trace_ips;
MonoObject *inner_ex;
MonoString *message;
MonoString *help_link;
MonoString *class_name;
MonoString *stack_trace;
MonoString *remote_stack_trace;
gint32 remote_stack_index;
gint32 hresult;
MonoString *source;
MonoObject *_data;
MonoObject *captured_traces;
MonoArray *native_trace_ips;
/* Dynamic methods referenced by the stack trace */
MonoObject *dynamic_methods;
};
typedef struct {
MonoException base;
} MonoSystemException;
typedef struct {
MonoSystemException base;
MonoString *param_name;
} MonoArgumentException;
typedef struct {
MonoObject object;
MonoObject *async_state;
MonoObject *handle;
MonoObject *async_delegate;
gpointer *data;
MonoObject *object_data;
MonoBoolean sync_completed;
MonoBoolean completed;
MonoBoolean endinvoke_called;
MonoObject *async_callback;
MonoObject *execution_context;
MonoObject *original_context;
gint64 add_time;
} MonoAsyncResult;
typedef struct {
MonoMarshalByRefObject object;
gpointer handle;
MonoBoolean disposed;
} MonoWaitHandle;
/* This is a copy of System.Runtime.Remoting.Messaging.CallType */
typedef enum {
CallType_Sync = 0,
CallType_BeginInvoke = 1,
CallType_EndInvoke = 2,
CallType_OneWay = 3
} MonoCallType;
/* This corresponds to System.Type */
struct _MonoReflectionType {
MonoObject object;
MonoType *type;
};
typedef struct {
MonoReflectionType type;
MonoObject *type_info;
} MonoReflectionMonoType;
typedef struct {
MonoObject object;
MonoReflectionType *class_to_proxy;
MonoObject *context;
MonoObject *unwrapped_server;
gint32 target_domain_id;
MonoString *target_uri;
MonoObject *object_identity;
MonoObject *obj_TP;
MonoObject *stub_data;
} MonoRealProxy;
typedef struct {
MonoMarshalByRefObject object;
gpointer iunknown;
GHashTable* itf_hash;
MonoObject *synchronization_context;
} MonoComObject;
typedef struct {
MonoRealProxy real_proxy;
MonoComObject *com_object;
gint32 ref_count;
} MonoComInteropProxy;
typedef struct {
MonoObject object;
MonoRealProxy *rp;
MonoRemoteClass *remote_class;
MonoBoolean custom_type_info;
} MonoTransparentProxy;
typedef struct {
MonoObject obj;
MonoReflectionMethod *method;
MonoArray *args;
MonoArray *names;
MonoArray *arg_types;
MonoObject *ctx;
MonoObject *rval;
MonoObject *exc;
MonoAsyncResult *async_result;
guint32 call_type;
} MonoMethodMessage;
/* Keep in sync with the System.MonoAsyncCall */
typedef struct {
MonoObject object;
MonoMethodMessage *msg;
MonoMethod *cb_method;
MonoDelegate *cb_target;
MonoObject *state;
MonoObject *res;
MonoArray *out_args;
} MonoAsyncCall;
typedef struct {
MonoObject obj;
gint32 il_offset;
gint32 native_offset;
gint64 method_address;
gint32 method_index;
MonoReflectionMethod *method;
MonoString *filename;
gint32 line;
gint32 column;
MonoString *internal_method_name;
} MonoStackFrame;
typedef enum {
MONO_THREAD_FLAG_DONT_MANAGE = 1, // Don't wait for or abort this thread
MONO_THREAD_FLAG_NAME_SET = 2, // Thread name set from managed code
} MonoThreadFlags;
struct _MonoInternalThread {
MonoObject obj;
volatile int lock_thread_id; /* to be used as the pre-shifted thread id in thin locks. Used for appdomain_ref push/pop */
HANDLE handle;
MonoArray *cached_culture_info;
gunichar2 *name;
guint32 name_len;
guint32 state;
MonoException *abort_exc;
int abort_state_handle;
guint64 tid; /* This is accessed as a gsize in the code (so it can hold a 64bit pointer on systems that need it), but needs to reserve 64 bits of space on all machines as it corresponds to a field in managed code */
HANDLE start_notify;
gpointer stack_ptr;
gpointer *static_data;
void *thread_info; /*This is MonoThreadInfo*, but to simplify dependencies, let's make it a void* here. */
MonoAppContext *current_appcontext;
MonoException *pending_exception;
MonoThread *root_domain_thread;
MonoObject *_serialized_principal;
int _serialized_principal_version;
gpointer appdomain_refs;
/* This is modified using atomic ops, so keep it a gint32 */
gint32 interruption_requested;
MonoCoopMutex *synch_cs;
MonoBoolean threadpool_thread;
MonoBoolean thread_interrupt_requested;
int stack_size;
guint8 apartment_state;
gint32 critical_region_level;
gint32 managed_id;
guint32 small_id;
MonoThreadManageCallback manage_callback;
gpointer interrupt_on_stop;
gsize flags;
gpointer thread_pinning_ref;
/*
* These fields are used to avoid having to increment corlib versions
* when a new field is added to this structure.
* Please synchronize any changes with InternalThread in Thread.cs, i.e. add the
* same field there.
*/
gpointer unused1;
gpointer unused2;
};
struct _MonoThread {
MonoObject obj;
struct _MonoInternalThread *internal_thread;
MonoObject *start_obj;
};
typedef struct {
guint32 state;
MonoObject *additional;
} MonoStreamingContext;
typedef struct {
MonoObject obj;
MonoBoolean readOnly;
MonoString *AMDesignator;
MonoString *PMDesignator;
MonoString *DateSeparator;
MonoString *TimeSeparator;
MonoString *ShortDatePattern;
MonoString *LongDatePattern;
MonoString *ShortTimePattern;
MonoString *LongTimePattern;
MonoString *MonthDayPattern;
MonoString *YearMonthPattern;
guint32 FirstDayOfWeek;
guint32 CalendarWeekRule;
MonoArray *AbbreviatedDayNames;
MonoArray *DayNames;
MonoArray *MonthNames;
MonoArray *GenitiveMonthNames;
MonoArray *AbbreviatedMonthNames;
MonoArray *GenitiveAbbreviatedMonthNames;
MonoArray *ShortDatePatterns;
MonoArray *LongDatePatterns;
MonoArray *ShortTimePatterns;
MonoArray *LongTimePatterns;
MonoArray *MonthDayPatterns;
MonoArray *YearMonthPatterns;
MonoArray *ShortestDayNames;
} MonoDateTimeFormatInfo;
typedef struct
{
MonoObject obj;
MonoArray *numberGroupSizes;
MonoArray *currencyGroupSizes;
MonoArray *percentGroupSizes;
MonoString *positiveSign;
MonoString *negativeSign;
MonoString *numberDecimalSeparator;
MonoString *numberGroupSeparator;
MonoString *currencyGroupSeparator;
MonoString *currencyDecimalSeparator;
MonoString *currencySymbol;
MonoString *ansiCurrencySymbol; /* unused */
MonoString *naNSymbol;
MonoString *positiveInfinitySymbol;
MonoString *negativeInfinitySymbol;
MonoString *percentDecimalSeparator;
MonoString *percentGroupSeparator;
MonoString *percentSymbol;
MonoString *perMilleSymbol;
MonoString *nativeDigits; /* unused */
gint32 dataItem; /* unused */
guint32 numberDecimalDigits;
gint32 currencyDecimalDigits;
gint32 currencyPositivePattern;
gint32 currencyNegativePattern;
gint32 numberNegativePattern;
gint32 percentPositivePattern;
gint32 percentNegativePattern;
gint32 percentDecimalDigits;
} MonoNumberFormatInfo;
typedef struct {
MonoObject obj;
gint32 lcid;
MonoString *icu_name;
gpointer ICU_collator;
} MonoCompareInfo;
typedef struct {
MonoObject obj;
MonoString *NativeName;
MonoArray *ShortDatePatterns;
MonoArray *YearMonthPatterns;
MonoArray *LongDatePatterns;
MonoString *MonthDayPattern;
MonoArray *EraNames;
MonoArray *AbbreviatedEraNames;
MonoArray *AbbreviatedEnglishEraNames;
MonoArray *DayNames;
MonoArray *AbbreviatedDayNames;
MonoArray *SuperShortDayNames;
MonoArray *MonthNames;
MonoArray *AbbreviatedMonthNames;
MonoArray *GenitiveMonthNames;
MonoArray *GenitiveAbbreviatedMonthNames;
} MonoCalendarData;
typedef struct {
MonoObject obj;
MonoString *AMDesignator;
MonoString *PMDesignator;
MonoString *TimeSeparator;
MonoArray *LongTimePatterns;
MonoArray *ShortTimePatterns;
guint32 FirstDayOfWeek;
guint32 CalendarWeekRule;
} MonoCultureData;
typedef struct {
MonoObject obj;
MonoBoolean is_read_only;
gint32 lcid;
gint32 parent_lcid;
gint32 datetime_index;
gint32 number_index;
gint32 calendar_type;
MonoBoolean use_user_override;
MonoNumberFormatInfo *number_format;
MonoDateTimeFormatInfo *datetime_format;
MonoObject *textinfo;
MonoString *name;
MonoString *englishname;
MonoString *nativename;
MonoString *iso3lang;
MonoString *iso2lang;
MonoString *win3lang;
MonoString *territory;
MonoArray *native_calendar_names;
MonoCompareInfo *compareinfo;
const void* text_info_data;
} MonoCultureInfo;
typedef struct {
MonoObject obj;
gint32 geo_id;
MonoString *iso2name;
MonoString *iso3name;
MonoString *win3name;
MonoString *english_name;
MonoString *native_name;
MonoString *currency_symbol;
MonoString *iso_currency_symbol;
MonoString *currency_english_name;
MonoString *currency_native_name;
} MonoRegionInfo;
typedef struct {
MonoObject obj;
MonoString *str;
gint32 options;
MonoArray *key;
gint32 lcid;
} MonoSortKey;
typedef struct {
MonoObject object;
guint32 intType;
} MonoInterfaceTypeAttribute;
/*
* Callbacks supplied by the runtime and called by the modules in metadata/
* This interface is easier to extend than adding a new function type +
* a new 'install' function for every callback.
*/
typedef struct {
gpointer (*create_ftnptr) (MonoDomain *domain, gpointer addr);
gpointer (*get_addr_from_ftnptr) (gpointer descr);
char* (*get_runtime_build_info) (void);
gpointer (*get_vtable_trampoline) (MonoVTable *vtable, int slot_index);
gpointer (*get_imt_trampoline) (MonoVTable *vtable, int imt_slot_index);
gboolean (*imt_entry_inited) (MonoVTable *vtable, int imt_slot_index);
void (*set_cast_details) (MonoClass *from, MonoClass *to);
void (*debug_log) (int level, MonoString *category, MonoString *message);
gboolean (*debug_log_is_enabled) (void);
gboolean (*tls_key_supported) (MonoTlsKey key);
void (*init_delegate) (MonoDelegate *del);
MonoObject* (*runtime_invoke) (MonoMethod *method, void *obj, void **params, MonoError *error, MonoObject **exc);
} MonoRuntimeCallbacks;
typedef gboolean (*MonoInternalStackWalk) (MonoStackFrameInfo *frame, MonoContext *ctx, gpointer data);
typedef gboolean (*MonoInternalExceptionFrameWalk) (MonoMethod *method, gpointer ip, size_t native_offset, gboolean managed, gpointer user_data);
typedef struct {
void (*mono_walk_stack_with_ctx) (MonoInternalStackWalk func, MonoContext *ctx, MonoUnwindOptions options, void *user_data);
void (*mono_walk_stack_with_state) (MonoInternalStackWalk func, MonoThreadUnwindState *state, MonoUnwindOptions options, void *user_data);
void (*mono_raise_exception) (MonoException *ex);
void (*mono_raise_exception_with_ctx) (MonoException *ex, MonoContext *ctx);
gboolean (*mono_exception_walk_trace) (MonoException *ex, MonoInternalExceptionFrameWalk func, gpointer user_data);
gboolean (*mono_install_handler_block_guard) (MonoThreadUnwindState *unwind_state);
} MonoRuntimeExceptionHandlingCallbacks;
/* used to free a dynamic method */
typedef void (*MonoFreeMethodFunc) (MonoDomain *domain, MonoMethod *method);
/* Used to initialize the method pointers inside vtables */
typedef gboolean (*MonoInitVTableFunc) (MonoVTable *vtable);
MONO_COLD void mono_set_pending_exception (MonoException *exc);
/* remoting and async support */
MonoAsyncResult *
mono_async_result_new (MonoDomain *domain, HANDLE handle,
MonoObject *state, gpointer data, MonoObject *object_data);
MonoObject *
ves_icall_System_Runtime_Remoting_Messaging_AsyncResult_Invoke (MonoAsyncResult *ares);
MonoWaitHandle *
mono_wait_handle_new (MonoDomain *domain, HANDLE handle);
HANDLE
mono_wait_handle_get_handle (MonoWaitHandle *handle);
void
mono_message_init (MonoDomain *domain, MonoMethodMessage *this_obj,
MonoReflectionMethod *method, MonoArray *out_args);
MonoObject *
mono_message_invoke (MonoObject *target, MonoMethodMessage *msg,
MonoObject **exc, MonoArray **out_args);
MonoMethodMessage *
mono_method_call_message_new (MonoMethod *method, gpointer *params, MonoMethod *invoke,
MonoDelegate **cb, MonoObject **state);
void
mono_method_return_message_restore (MonoMethod *method, gpointer *params, MonoArray *out_args);
void
mono_delegate_ctor_with_method (MonoObject *this_obj, MonoObject *target, gpointer addr, MonoMethod *method);
void
mono_delegate_ctor (MonoObject *this_obj, MonoObject *target, gpointer addr);
void*
mono_class_get_allocation_ftn (MonoVTable *vtable, gboolean for_box, gboolean *pass_size_in_words);
void
mono_runtime_free_method (MonoDomain *domain, MonoMethod *method);
void
mono_install_compile_method (MonoCompileFunc func);
void
mono_install_free_method (MonoFreeMethodFunc func);
void
mono_install_callbacks (MonoRuntimeCallbacks *cbs);
MonoRuntimeCallbacks*
mono_get_runtime_callbacks (void);
void
mono_install_eh_callbacks (MonoRuntimeExceptionHandlingCallbacks *cbs);
MonoRuntimeExceptionHandlingCallbacks *
mono_get_eh_callbacks (void);
void
mono_raise_exception_with_context (MonoException *ex, MonoContext *ctx);
void
mono_type_initialization_init (void);
void
mono_type_initialization_cleanup (void);
int
mono_thread_kill (MonoInternalThread *thread, int signal);
MonoNativeTlsKey
mono_thread_get_tls_key (void);
gint32
mono_thread_get_tls_offset (void);
MonoNativeTlsKey
mono_domain_get_tls_key (void);
gint32
mono_domain_get_tls_offset (void);
/* Reflection and Reflection.Emit support */
/*
* Handling System.Type objects:
*
* Fields defined as System.Type in managed code should be defined as MonoObject*
* in unmanaged structures, and the monotype_cast () function should be used for
* casting them to MonoReflectionType* to avoid crashes/security issues when
* encountering instances of user defined subclasses of System.Type.
*/
#define IS_MONOTYPE(obj) (!(obj) || (((MonoObject*)(obj))->vtable->klass->image == mono_defaults.corlib && ((MonoReflectionType*)(obj))->type != NULL))
/*
* Make sure the argument, which should be a System.Type is a System.MonoType object
* or equivalent, and not an instance of
* a user defined subclass of System.Type. This should be used in places were throwing
* an exception is safe.
*/
#define CHECK_MONOTYPE(obj) do { \
if (!IS_MONOTYPE (obj)) \
mono_raise_exception (mono_get_exception_not_supported ("User defined subclasses of System.Type are not yet supported")); \
} while (0)
/* This should be used for accessing members of Type[] arrays */
#define mono_type_array_get(arr,index) monotype_cast (mono_array_get ((arr), gpointer, (index)))
/*
* Cast an object to MonoReflectionType, making sure it is a System.MonoType or
* a subclass of it.
*/
static inline MonoReflectionType*
monotype_cast (MonoObject *obj)
{
g_assert (IS_MONOTYPE (obj));
return (MonoReflectionType*)obj;
}
/*
* The following structure must match the C# implementation in our corlib.
*/
struct _MonoReflectionMethod {
MonoObject object;
MonoMethod *method;
MonoString *name;
MonoReflectionType *reftype;
};
typedef struct _MonoReflectionGenericMethod MonoReflectionGenericMethod;
struct _MonoReflectionGenericMethod {
MonoReflectionMethod method;
};
struct _MonoDelegate {
MonoObject object;
/* The compiled code of the target method */
gpointer method_ptr;
/* The invoke code */
gpointer invoke_impl;
MonoObject *target;
MonoMethod *method;
gpointer delegate_trampoline;
/* Extra argument passed to the target method in llvmonly mode */
gpointer extra_arg;
/*
* If non-NULL, this points to a memory location which stores the address of
* the compiled code of the method, or NULL if it is not yet compiled.
*/
guint8 **method_code;
MonoReflectionMethod *method_info;
MonoReflectionMethod *original_method_info;
MonoObject *data;
MonoBoolean method_is_virtual;
};
typedef struct _MonoMulticastDelegate MonoMulticastDelegate;
struct _MonoMulticastDelegate {
MonoDelegate delegate;
MonoArray *delegates;
};
struct _MonoReflectionField {
MonoObject object;
MonoClass *klass;
MonoClassField *field;
MonoString *name;
MonoReflectionType *type;
guint32 attrs;
};
struct _MonoReflectionProperty {
MonoObject object;
MonoClass *klass;
MonoProperty *property;
};
/*This is System.EventInfo*/
struct _MonoReflectionEvent {
MonoObject object;
MonoObject *cached_add_event;
};
typedef struct {
MonoReflectionEvent object;
MonoClass *klass;
MonoEvent *event;
} MonoReflectionMonoEvent;
typedef struct {
MonoObject object;
MonoReflectionType *ClassImpl;
MonoObject *DefaultValueImpl;
MonoObject *MemberImpl;
MonoString *NameImpl;
gint32 PositionImpl;
guint32 AttrsImpl;
MonoObject *MarshalAsImpl;
} MonoReflectionParameter;
struct _MonoReflectionMethodBody {
MonoObject object;
MonoArray *clauses;
MonoArray *locals;
MonoArray *il;
MonoBoolean init_locals;
guint32 local_var_sig_token;
guint32 max_stack;
};
struct _MonoReflectionAssembly {
MonoObject object;
MonoAssembly *assembly;
MonoObject *resolve_event_holder;
/* CAS related */
MonoObject *evidence; /* Evidence */
MonoObject *minimum; /* PermissionSet - for SecurityAction.RequestMinimum */
MonoObject *optional; /* PermissionSet - for SecurityAction.RequestOptional */
MonoObject *refuse; /* PermissionSet - for SecurityAction.RequestRefuse */
MonoObject *granted; /* PermissionSet - for the resolved assembly granted permissions */
MonoObject *denied; /* PermissionSet - for the resolved assembly denied permissions */
/* */
MonoBoolean from_byte_array;
MonoString *name;
};
typedef struct {
MonoReflectionType *utype;
MonoArray *values;
MonoArray *names;
} MonoEnumInfo;
typedef struct {
MonoReflectionType *parent;
MonoReflectionType *ret;
guint32 attrs;
guint32 implattrs;
guint32 callconv;
} MonoMethodInfo;
typedef struct {
MonoReflectionType *parent;
MonoReflectionType *declaring_type;
MonoString *name;
MonoReflectionMethod *get;
MonoReflectionMethod *set;
guint32 attrs;
} MonoPropertyInfo;
typedef struct {
MonoReflectionType *declaring_type;
MonoReflectionType *reflected_type;
MonoString *name;
MonoReflectionMethod *add_method;
MonoReflectionMethod *remove_method;
MonoReflectionMethod *raise_method;
guint32 attrs;
MonoArray *other_methods;
} MonoEventInfo;
typedef struct {
MonoString *name;
MonoString *name_space;
MonoReflectionType *etype;
MonoReflectionType *nested_in;
MonoReflectionAssembly *assembly;
guint32 rank;
MonoBoolean isprimitive;
} MonoTypeInfo;
typedef struct {
MonoObject *member;
gint32 code_pos;
} MonoReflectionILTokenInfo;
typedef struct {
MonoObject object;
MonoArray *code;
gint32 code_len;
gint32 max_stack;
gint32 cur_stack;
MonoArray *locals;
MonoArray *ex_handlers;
gint32 num_token_fixups;
MonoArray *token_fixups;
} MonoReflectionILGen;
typedef struct {
MonoArray *handlers;
gint32 start;
gint32 len;
gint32 label;
} MonoILExceptionInfo;
typedef struct {
MonoObject *extype;
gint32 type;
gint32 start;
gint32 len;
gint32 filter_offset;
} MonoILExceptionBlock;
typedef struct {
MonoObject object;
MonoObject *catch_type;
gint32 filter_offset;
gint32 flags;
gint32 try_offset;
gint32 try_length;
gint32 handler_offset;
gint32 handler_length;
} MonoReflectionExceptionHandlingClause;
typedef struct {
MonoObject object;
MonoReflectionType *local_type;
MonoBoolean is_pinned;
guint16 local_index;
} MonoReflectionLocalVariableInfo;
typedef struct {
/*
* Must have the same layout as MonoReflectionLocalVariableInfo, since
* LocalBuilder inherits from it under net 2.0.
*/
MonoObject object;
MonoObject *type;
MonoBoolean is_pinned;
guint16 local_index;
MonoString *name;
} MonoReflectionLocalBuilder;
typedef struct {
MonoObject object;
gint32 count;
gint32 type;
gint32 eltype;
MonoString *guid;
MonoString *mcookie;
MonoString *marshaltype;
MonoObject *marshaltyperef;
gint32 param_num;
MonoBoolean has_size;
} MonoReflectionMarshal;
typedef struct {
MonoObject object;
MonoObject* methodb;
MonoString *name;
MonoArray *cattrs;
MonoReflectionMarshal *marshal_info;
guint32 attrs;
int position;
guint32 table_idx;
MonoObject *def_value;
} MonoReflectionParamBuilder;
typedef struct {
MonoObject object;
MonoMethod *mhandle;
MonoReflectionILGen *ilgen;
MonoArray *parameters;
guint32 attrs;
guint32 iattrs;
guint32 table_idx;
guint32 call_conv;
MonoObject *type;
MonoArray *pinfo;
MonoArray *cattrs;
MonoBoolean init_locals;
MonoArray *param_modreq;
MonoArray *param_modopt;
MonoArray *permissions;
} MonoReflectionCtorBuilder;
typedef struct {
MonoObject object;
MonoMethod *mhandle;
MonoObject *rtype;
MonoArray *parameters;
guint32 attrs;
guint32 iattrs;
MonoString *name;
guint32 table_idx;
MonoArray *code;
MonoReflectionILGen *ilgen;
MonoObject *type;
MonoArray *pinfo;
MonoArray *cattrs;
MonoArray *override_methods;
MonoString *dll;
MonoString *dllentry;
guint32 charset;
guint32 extra_flags;
guint32 native_cc;
guint32 call_conv;
MonoBoolean init_locals;
MonoGenericContainer *generic_container;
MonoArray *generic_params;
MonoArray *return_modreq;
MonoArray *return_modopt;
MonoArray *param_modreq;
MonoArray *param_modopt;
MonoArray *permissions;
} MonoReflectionMethodBuilder;
typedef struct {
MonoObject object;
MonoMethod *mhandle;
MonoReflectionType *parent;
MonoReflectionType *ret;
MonoArray *parameters;
MonoString *name;
guint32 table_idx;
guint32 call_conv;
} MonoReflectionArrayMethod;
typedef struct {
MonoArray *data;
MonoString *name;
MonoString *filename;
guint32 attrs;
guint32 offset;
MonoObject *stream;
} MonoReflectionResource;
typedef struct {
guint32 res_type;
guint32 res_id;
guint32 lang_id;
MonoArray *res_data;
} MonoReflectionWin32Resource;
typedef struct {
guint32 action;
MonoString *pset;
} MonoReflectionPermissionSet;
typedef struct {
MonoReflectionAssembly assembly;
MonoDynamicAssembly *dynamic_assembly;
MonoReflectionMethod *entry_point;
MonoArray *modules;
MonoString *name;
MonoString *dir;
MonoArray *cattrs;
MonoArray *resources;
MonoArray *public_key;
MonoString *version;
MonoString *culture;
guint32 algid;
guint32 flags;
guint32 pekind;
MonoBoolean delay_sign;
guint32 access;
MonoArray *loaded_modules;
MonoArray *win32_resources;
/* CAS related */
MonoArray *permissions_minimum;
MonoArray *permissions_optional;
MonoArray *permissions_refused;
gint32 pe_kind;
gint32 machine;
MonoBoolean corlib_internal;
MonoArray *type_forwarders;
MonoArray *pktoken; /* as hexadecimal byte[] */
} MonoReflectionAssemblyBuilder;
typedef struct {
MonoObject object;
guint32 attrs;
MonoObject *type;
MonoString *name;
MonoObject *def_value;
gint32 offset;
gint32 table_idx;
MonoReflectionType *typeb;
MonoArray *rva_data;
MonoArray *cattrs;
MonoReflectionMarshal *marshal_info;
MonoClassField *handle;
MonoArray *modreq;
MonoArray *modopt;
} MonoReflectionFieldBuilder;
typedef struct {
MonoObject object;
guint32 attrs;
MonoString *name;
MonoObject *type;
MonoArray *parameters;
MonoArray *cattrs;
MonoObject *def_value;
MonoReflectionMethodBuilder *set_method;
MonoReflectionMethodBuilder *get_method;
gint32 table_idx;
MonoObject *type_builder;
MonoArray *returnModReq;
MonoArray *returnModOpt;
MonoArray *paramModReq;
MonoArray *paramModOpt;
guint32 call_conv;
} MonoReflectionPropertyBuilder;
struct _MonoReflectionModule {
MonoObject obj;
MonoImage *image;
MonoReflectionAssembly *assembly;
MonoString *fqname;
MonoString *name;
MonoString *scopename;
MonoBoolean is_resource;
guint32 token;
};
typedef struct {
MonoReflectionModule module;
MonoDynamicImage *dynamic_image;
gint32 num_types;
MonoArray *types;
MonoArray *cattrs;
MonoArray *guid;
guint32 table_idx;
MonoReflectionAssemblyBuilder *assemblyb;
MonoArray *global_methods;
MonoArray *global_fields;
gboolean is_main;
MonoArray *resources;
} MonoReflectionModuleBuilder;
typedef struct {
MonoReflectionType type;
MonoString *name;
MonoString *nspace;
MonoObject *parent;
MonoReflectionType *nesting_type;
MonoArray *interfaces;
gint32 num_methods;
MonoArray *methods;
MonoArray *ctors;
MonoArray *properties;
gint32 num_fields;
MonoArray *fields;
MonoArray *events;
MonoArray *cattrs;
MonoArray *subtypes;
guint32 attrs;
guint32 table_idx;
MonoReflectionModuleBuilder *module;
gint32 class_size;
gint32 packing_size;
MonoGenericContainer *generic_container;
MonoArray *generic_params;
MonoArray *permissions;
MonoReflectionType *created;
} MonoReflectionTypeBuilder;
typedef struct {
MonoReflectionType type;
MonoReflectionType *element_type;
int rank;
} MonoReflectionArrayType;
typedef struct {
MonoReflectionType type;
MonoReflectionType *element_type;
} MonoReflectionDerivedType;
typedef struct {
MonoReflectionType type;
MonoReflectionTypeBuilder *tbuilder;
MonoReflectionMethodBuilder *mbuilder;
MonoString *name;
guint32 index;
MonoReflectionType *base_type;
MonoArray *iface_constraints;
MonoArray *cattrs;
guint32 attrs;
} MonoReflectionGenericParam;
typedef struct _MonoReflectionGenericClass MonoReflectionGenericClass;
struct _MonoReflectionGenericClass {
MonoReflectionType type;
MonoReflectionType *generic_type; /*Can be either a MonoType or a TypeBuilder*/
MonoArray *type_arguments;
guint32 initialized;
};
typedef struct {
MonoObject obj;
MonoString *name;
MonoString *codebase;
gint32 major, minor, build, revision;
MonoObject *cultureInfo;
guint32 flags;
guint32 hashalg;
MonoObject *keypair;
MonoArray *publicKey;
MonoArray *keyToken;
guint32 versioncompat;
MonoObject *version;
guint32 processor_architecture;
} MonoReflectionAssemblyName;
typedef struct {
MonoObject obj;
MonoString *name;
MonoReflectionType *type;
MonoReflectionTypeBuilder *typeb;
MonoArray *cattrs;
MonoReflectionMethodBuilder *add_method;
MonoReflectionMethodBuilder *remove_method;
MonoReflectionMethodBuilder *raise_method;
MonoArray *other_methods;
guint32 attrs;
guint32 table_idx;
} MonoReflectionEventBuilder;
typedef struct {
MonoObject obj;
MonoReflectionMethod *ctor;
MonoArray *data;
} MonoReflectionCustomAttr;
typedef struct {
MonoObject object;
MonoString *marshal_cookie;
MonoString *marshal_type;
MonoReflectionType *marshal_type_ref;
MonoReflectionType *marshal_safe_array_user_defined_subtype;
guint32 utype;
guint32 array_subtype;
gint32 safe_array_subtype;
gint32 size_const;
gint32 IidParameterIndex;
gint16 size_param_index;
} MonoReflectionMarshalAsAttribute;
typedef struct {
MonoObject object;
gint32 call_conv;
gint32 charset;
MonoBoolean best_fit_mapping;
MonoBoolean throw_on_unmappable;
MonoBoolean set_last_error;
} MonoReflectionUnmanagedFunctionPointerAttribute;
typedef struct {
MonoObject object;
MonoString *guid;
} MonoReflectionGuidAttribute;
typedef struct {
MonoObject object;
MonoMethod *mhandle;
MonoString *name;
MonoReflectionType *rtype;
MonoArray *parameters;
guint32 attrs;
guint32 call_conv;
MonoReflectionModule *module;
MonoBoolean skip_visibility;
MonoBoolean init_locals;
MonoReflectionILGen *ilgen;
gint32 nrefs;
MonoArray *refs;
GSList *referenced_by;
MonoReflectionType *owner;
} MonoReflectionDynamicMethod;
typedef struct {
MonoObject object;
MonoReflectionModuleBuilder *module;
MonoArray *arguments;
guint32 type;
MonoReflectionType *return_type;
guint32 call_conv;
guint32 unmanaged_call_conv;
MonoArray *modreqs;
MonoArray *modopts;
} MonoReflectionSigHelper;
typedef struct {
MonoObject object;
MonoReflectionGenericClass *inst;
MonoObject *fb; /*can be either a MonoField or a FieldBuilder*/
} MonoReflectionFieldOnTypeBuilderInst;
typedef struct {
MonoObject object;
MonoReflectionGenericClass *inst;
MonoObject *cb; /*can be either a MonoCMethod or ConstructorBuilder*/
} MonoReflectionCtorOnTypeBuilderInst;
typedef struct {
MonoObject object;
MonoReflectionType *inst;
MonoObject *mb; /*can be either a MonoMethod or MethodBuilder*/
MonoArray *method_args;
MonoReflectionMethodBuilder *generic_method_definition;
} MonoReflectionMethodOnTypeBuilderInst;
typedef struct {
MonoObject object;
MonoBoolean visible;
} MonoReflectionComVisibleAttribute;
enum {
RESOURCE_LOCATION_EMBEDDED = 1,
RESOURCE_LOCATION_ANOTHER_ASSEMBLY = 2,
RESOURCE_LOCATION_IN_MANIFEST = 4
};
typedef struct {
MonoObject object;
MonoReflectionAssembly *assembly;
MonoString *filename;
guint32 location;
} MonoManifestResourceInfo;
/* A boxed IntPtr */
typedef struct {
MonoObject object;
gpointer m_value;
} MonoIntPtr;
/* Keep in sync with System.GenericParameterAttributes */
typedef enum {
GENERIC_PARAMETER_ATTRIBUTE_NON_VARIANT = 0,
GENERIC_PARAMETER_ATTRIBUTE_COVARIANT = 1,
GENERIC_PARAMETER_ATTRIBUTE_CONTRAVARIANT = 2,
GENERIC_PARAMETER_ATTRIBUTE_VARIANCE_MASK = 3,
GENERIC_PARAMETER_ATTRIBUTE_NO_SPECIAL_CONSTRAINT = 0,
GENERIC_PARAMETER_ATTRIBUTE_REFERENCE_TYPE_CONSTRAINT = 4,
GENERIC_PARAMETER_ATTRIBUTE_VALUE_TYPE_CONSTRAINT = 8,
GENERIC_PARAMETER_ATTRIBUTE_CONSTRUCTOR_CONSTRAINT = 16,
GENERIC_PARAMETER_ATTRIBUTE_SPECIAL_CONSTRAINTS_MASK = 28
} GenericParameterAttributes;
typedef struct {
MonoType *type;
MonoClassField *field;
MonoProperty *prop;
} CattrNamedArg;
void mono_image_create_pefile (MonoReflectionModuleBuilder *module, HANDLE file);
void mono_image_basic_init (MonoReflectionAssemblyBuilder *assembly);
MonoReflectionModule * mono_image_load_module_dynamic (MonoReflectionAssemblyBuilder *assembly, MonoString *file_name);
guint32 mono_image_insert_string (MonoReflectionModuleBuilder *module, MonoString *str);
guint32 mono_image_create_token (MonoDynamicImage *assembly, MonoObject *obj, gboolean create_methodspec, gboolean register_token);
guint32 mono_image_create_method_token (MonoDynamicImage *assembly, MonoObject *obj, MonoArray *opt_param_types);
void mono_image_module_basic_init (MonoReflectionModuleBuilder *module);
void mono_image_register_token (MonoDynamicImage *assembly, guint32 token, MonoObject *obj);
void mono_dynamic_image_free (MonoDynamicImage *image);
void mono_dynamic_image_free_image (MonoDynamicImage *image);
void mono_image_set_wrappers_type (MonoReflectionModuleBuilder *mb, MonoReflectionType *type);
void mono_dynamic_image_release_gc_roots (MonoDynamicImage *image);
void mono_reflection_setup_internal_class (MonoReflectionTypeBuilder *tb);
void mono_reflection_create_internal_class (MonoReflectionTypeBuilder *tb);
void mono_reflection_setup_generic_class (MonoReflectionTypeBuilder *tb);
void mono_reflection_create_generic_class (MonoReflectionTypeBuilder *tb);
MonoReflectionType* mono_reflection_create_runtime_class (MonoReflectionTypeBuilder *tb);
void mono_reflection_get_dynamic_overrides (MonoClass *klass, MonoMethod ***overrides, int *num_overrides);
void mono_reflection_create_dynamic_method (MonoReflectionDynamicMethod *m);
void mono_reflection_destroy_dynamic_method (MonoReflectionDynamicMethod *mb);
void mono_reflection_initialize_generic_parameter (MonoReflectionGenericParam *gparam);
void mono_reflection_create_unmanaged_type (MonoReflectionType *type);
void mono_reflection_register_with_runtime (MonoReflectionType *type);
void mono_reflection_create_custom_attr_data_args (MonoImage *image, MonoMethod *method, const guchar *data, guint32 len, MonoArray **typed_args, MonoArray **named_args, CattrNamedArg **named_arg_info, MonoError *error);
MonoMethodSignature * mono_reflection_lookup_signature (MonoImage *image, MonoMethod *method, guint32 token, MonoError *error);
MonoArray* mono_param_get_objects_internal (MonoDomain *domain, MonoMethod *method, MonoClass *refclass);
MonoClass*
mono_class_bind_generic_parameters (MonoClass *klass, int type_argc, MonoType **types, gboolean is_dynamic);
MonoType*
mono_reflection_bind_generic_parameters (MonoReflectionType *type, int type_argc, MonoType **types);
MonoReflectionMethod*
mono_reflection_bind_generic_method_parameters (MonoReflectionMethod *method, MonoArray *types);
void
mono_reflection_generic_class_initialize (MonoReflectionGenericClass *type, MonoArray *fields);
MonoReflectionEvent *
mono_reflection_event_builder_get_event_info (MonoReflectionTypeBuilder *tb, MonoReflectionEventBuilder *eb);
MonoArray *mono_reflection_sighelper_get_signature_local (MonoReflectionSigHelper *sig);
MonoArray *mono_reflection_sighelper_get_signature_field (MonoReflectionSigHelper *sig);
MonoReflectionMarshalAsAttribute* mono_reflection_marshal_as_attribute_from_marshal_spec (MonoDomain *domain, MonoClass *klass, MonoMarshalSpec *spec);
gpointer
mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token, gboolean valid_token, MonoClass **handle_class, MonoGenericContext *context);
gboolean
mono_reflection_call_is_assignable_to (MonoClass *klass, MonoClass *oklass);
gboolean
mono_reflection_is_valid_dynamic_token (MonoDynamicImage *image, guint32 token);
void
mono_reflection_resolve_custom_attribute_data (MonoReflectionMethod *method, MonoReflectionAssembly *assembly, gpointer data, guint32 data_length, MonoArray **ctor_args, MonoArray ** named_args);
MonoType*
mono_reflection_type_get_handle (MonoReflectionType *ref);
void
mono_reflection_free_dynamic_generic_class (MonoGenericClass *gclass);
void
mono_image_build_metadata (MonoReflectionModuleBuilder *module);
int
mono_get_constant_value_from_blob (MonoDomain* domain, MonoTypeEnum type, const char *blob, void *value);
void
mono_release_type_locks (MonoInternalThread *thread);
char *
mono_string_to_utf8_mp (MonoMemPool *mp, MonoString *s, MonoError *error);
char *
mono_string_to_utf8_image (MonoImage *image, MonoString *s, MonoError *error);
MonoArray*
mono_array_clone_in_domain (MonoDomain *domain, MonoArray *array);
void
mono_array_full_copy (MonoArray *src, MonoArray *dest);
gboolean
mono_array_calc_byte_len (MonoClass *klass, uintptr_t len, uintptr_t *res);
MonoArray*
mono_array_new_full_checked (MonoDomain *domain, MonoClass *array_class, uintptr_t *lengths, intptr_t *lower_bounds, MonoError *error);
MonoArray*
mono_array_new_specific_checked (MonoVTable *vtable, uintptr_t n, MonoError *error);
MonoArray*
ves_icall_array_new_specific (MonoVTable *vtable, uintptr_t n);
#ifndef DISABLE_REMOTING
MonoObject *
mono_remoting_invoke (MonoObject *real_proxy, MonoMethodMessage *msg,
MonoObject **exc, MonoArray **out_args);
gpointer
mono_remote_class_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, MonoRealProxy *real_proxy);
void
mono_upgrade_remote_class (MonoDomain *domain, MonoObject *tproxy, MonoClass *klass);
#endif
gpointer
mono_create_ftnptr (MonoDomain *domain, gpointer addr);
gpointer
mono_get_addr_from_ftnptr (gpointer descr);
void
mono_nullable_init (guint8 *buf, MonoObject *value, MonoClass *klass);
MonoObject*
mono_nullable_box (guint8 *buf, MonoClass *klass);
#ifdef MONO_SMALL_CONFIG
#define MONO_IMT_SIZE 9
#else
#define MONO_IMT_SIZE 19
#endif
typedef union {
int vtable_slot;
gpointer target_code;
} MonoImtItemValue;
typedef struct _MonoImtBuilderEntry {
gpointer key;
struct _MonoImtBuilderEntry *next;
MonoImtItemValue value;
int children;
guint8 has_target_code : 1;
} MonoImtBuilderEntry;
typedef struct _MonoIMTCheckItem MonoIMTCheckItem;
struct _MonoIMTCheckItem {
gpointer key;
int check_target_idx;
MonoImtItemValue value;
guint8 *jmp_code;
guint8 *code_target;
guint8 is_equals;
guint8 compare_done;
guint8 chunk_size;
guint8 short_branch;
guint8 has_target_code;
};
typedef gpointer (*MonoImtThunkBuilder) (MonoVTable *vtable, MonoDomain *domain,
MonoIMTCheckItem **imt_entries, int count, gpointer fail_trunk);
void
mono_install_imt_thunk_builder (MonoImtThunkBuilder func);
void
mono_set_always_build_imt_thunks (gboolean value);
void
mono_vtable_build_imt_slot (MonoVTable* vtable, int imt_slot);
guint32
mono_method_get_imt_slot (MonoMethod *method);
void
mono_method_add_generic_virtual_invocation (MonoDomain *domain, MonoVTable *vtable,
gpointer *vtable_slot,
MonoMethod *method, gpointer code);
gpointer
mono_method_alloc_generic_virtual_thunk (MonoDomain *domain, int size);
typedef enum {
MONO_UNHANDLED_POLICY_LEGACY,
MONO_UNHANDLED_POLICY_CURRENT
} MonoRuntimeUnhandledExceptionPolicy;
MonoRuntimeUnhandledExceptionPolicy
mono_runtime_unhandled_exception_policy_get (void);
void
mono_runtime_unhandled_exception_policy_set (MonoRuntimeUnhandledExceptionPolicy policy);
MonoVTable *
mono_class_try_get_vtable (MonoDomain *domain, MonoClass *klass);
MonoException *
mono_runtime_class_init_full (MonoVTable *vtable, gboolean raise_exception);
void
mono_method_clear_object (MonoDomain *domain, MonoMethod *method);
void
mono_class_compute_gc_descriptor (MonoClass *klass);
gsize*
mono_class_compute_bitmap (MonoClass *klass, gsize *bitmap, int size, int offset, int *max_set, gboolean static_fields);
MonoObject*
mono_object_xdomain_representation (MonoObject *obj, MonoDomain *target_domain, MonoObject **exc);
gboolean
mono_class_is_reflection_method_or_constructor (MonoClass *klass);
MonoObject *
mono_get_object_from_blob (MonoDomain *domain, MonoType *type, const char *blob);
gpointer
mono_class_get_ref_info (MonoClass *klass);
void
mono_class_set_ref_info (MonoClass *klass, gpointer obj);
void
mono_class_free_ref_info (MonoClass *klass);
MonoObject *
mono_object_new_pinned (MonoDomain *domain, MonoClass *klass, MonoError *error);
MonoObject *
mono_object_new_specific_checked (MonoVTable *vtable, MonoError *error);
MonoObject *
ves_icall_object_new_specific (MonoVTable *vtable);
MonoObject *
mono_object_new_alloc_specific_checked (MonoVTable *vtable, MonoError *error);
void
mono_field_static_get_value_for_thread (MonoInternalThread *thread, MonoVTable *vt, MonoClassField *field, void *value);
/* exported, used by the debugger */
MONO_API void *
mono_vtable_get_static_field_data (MonoVTable *vt);
char *
mono_string_to_utf8_ignore (MonoString *s);
char *
mono_string_to_utf8_image_ignore (MonoImage *image, MonoString *s);
char *
mono_string_to_utf8_mp_ignore (MonoMemPool *mp, MonoString *s);
gboolean
mono_monitor_is_il_fastpath_wrapper (MonoMethod *method);
char *
mono_exception_get_native_backtrace (MonoException *exc);
MonoString *
ves_icall_Mono_Runtime_GetNativeStackTrace (MonoException *exc);
char *
mono_exception_get_managed_backtrace (MonoException *exc);
void
mono_copy_value (MonoType *type, void *dest, void *value, int deref_pointer);
void
mono_error_raise_exception (MonoError *target_error);
void
mono_error_set_pending_exception (MonoError *error);
MonoArray *
mono_glist_to_array (GList *list, MonoClass *eclass);
MonoObject*
mono_object_new_mature (MonoVTable *vtable, MonoError *error);
MonoObject*
mono_object_new_fast_checked (MonoVTable *vtable, MonoError *error);
MonoObject *
ves_icall_object_new_fast (MonoVTable *vtable);
MonoObject *
mono_object_clone_checked (MonoObject *obj, MonoError *error);
MonoString *
mono_string_new_size_checked (MonoDomain *domain, gint32 len, MonoError *error);
#endif /* __MONO_OBJECT_INTERNALS_H__ */
|