-
Notifications
You must be signed in to change notification settings - Fork 191
/
api.ts
1220 lines (1068 loc) · 29.8 KB
/
api.ts
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
import { cache } from "decorator-cache-getter";
import { createNF } from "frida-typed-extensions";
import { raise } from "./utils/console";
import UnityVersion from "./utils/unity-version";
/** @internal */
export default class Api {
private static readonly sources: (Module | CModule)[] = [];
@cache
static get _arrayGetElements() {
return createNF(this.r`array_elements`, "pointer", ["pointer"]);
}
@cache
static get _arrayGetLength() {
return createNF(this.r`array_length`, "uint32", ["pointer"]);
}
@cache
static get _arrayNew() {
return createNF(this.r`array_new`, "pointer", ["pointer", "uint32"]);
}
@cache
static get _assemblyGetImage() {
return createNF(this.r`assembly_get_image`, "pointer", ["pointer"]);
}
@cache
static get _assemblyGetName() {
return createNF(this.r`assembly_get_name`, "utf8string", ["pointer"]);
}
@cache
static get _classFromName() {
return createNF(this.r`class_from_name`, "pointer", ["pointer", "utf8string", "utf8string"]);
}
@cache
static get _classFromType() {
return createNF(this.r`class_from_type`, "pointer", ["pointer"]);
}
@cache
static get _classGetArrayClass() {
return createNF(this.r`array_class_get`, "pointer", ["pointer", "uint32"]);
}
@cache
static get _classGetArrayElementSize() {
return createNF(this.r`class_array_element_size`, "int", ["pointer"]);
}
@cache
static get _classGetAssemblyName() {
return createNF(this.r`class_get_assemblyname`, "utf8string", ["pointer"]);
}
@cache
static get _classGetDeclaringType() {
return createNF(this.r`class_get_declaring_type`, "pointer", ["pointer"]);
}
@cache
static get _classGetElementClass() {
return createNF(this.r`class_get_element_class`, "pointer", ["pointer"]);
}
@cache
static get _classGetFieldCount() {
return createNF(this.r`class_get_field_count`, "uint16", ["pointer"]);
}
@cache
static get _classGetFields() {
return createNF(this.r`class_get_fields`, "pointer", ["pointer", "pointer"]);
}
@cache
static get _classGetImage() {
return createNF(this.r`class_get_image`, "pointer", ["pointer"]);
}
@cache
static get _classGetInstanceSize() {
return createNF(this.r`class_instance_size`, "uint32", ["pointer"]);
}
@cache
static get _classGetInterfaceCount() {
return createNF(this.r`class_get_interface_count`, "uint16", ["pointer"]);
}
@cache
static get _classGetInterfaces() {
return createNF(this.r`class_get_interfaces`, "pointer", ["pointer", "pointer"]);
}
@cache
static get _classGetMethodCount() {
return createNF(this.r`class_get_method_count`, "uint16", ["pointer"]);
}
@cache
static get _classGetMethods() {
return createNF(this.r`class_get_methods`, "pointer", ["pointer", "pointer"]);
}
@cache
static get _classGetName() {
return createNF(this.r`class_get_name`, "utf8string", ["pointer"]);
}
@cache
static get _classGetNamespace() {
return createNF(this.r`class_get_namespace`, "utf8string", ["pointer"]);
}
@cache
static get _classGetParent() {
return createNF(this.r`class_get_parent`, "pointer", ["pointer"]);
}
@cache
static get _classGetStaticFieldData() {
return createNF(this.r`class_get_static_field_data`, "pointer", ["pointer"]);
}
@cache
static get _classGetType() {
return createNF(this.r`class_get_type`, "pointer", ["pointer"]);
}
@cache
static get _classHasStaticConstructor() {
return createNF(this.r`class_has_static_constructor`, "bool", ["pointer"]);
}
@cache
static get _classInit() {
return createNF(this.r`runtime_class_init`, "void", ["pointer"]);
}
@cache
static get _classIsEnum() {
return createNF(this.r`class_is_enum`, "bool", ["pointer"]);
}
@cache
static get _classIsInterface() {
return createNF(this.r`class_is_interface`, "bool", ["pointer"]);
}
@cache
static get _classIsStaticConstructorFinished() {
return createNF(this.r`class_is_static_constructor_finished`, "bool", ["pointer"]);
}
@cache
static get _classIsStruct() {
return createNF(this.r`class_is_valuetype`, "bool", ["pointer"]);
}
@cache
static get _domainGet() {
return createNF(this.r`domain_get`, "pointer", []);
}
@cache
static get _domainGetAssemblies() {
return createNF(this.r`domain_get_assemblies`, "pointer", ["pointer", "pointer"]);
}
@cache
static get _domainGetName() {
return createNF(this.r`domain_get_name`, "utf8string", ["pointer"]);
}
@cache
static get _fieldGetClass() {
return createNF(this.r`field_get_parent`, "pointer", ["pointer"]);
}
@cache
static get _fieldGetName() {
return createNF(this.r`field_get_name`, "utf8string", ["pointer"]);
}
@cache
static get _fieldGetOffset() {
return createNF(this.r`field_get_offset`, "int32", ["pointer"]);
}
@cache
static get _fieldGetStaticValue() {
return createNF(this.r`field_static_get_value`, "void", ["pointer", "pointer"]);
}
@cache
static get _fieldGetStaticValue2() {
return createNF(this.r`field_static_get_value`, "void", ["pointer", "pointer"]);
}
@cache
static get _fieldGetType() {
return createNF(this.r`field_get_type`, "pointer", ["pointer"]);
}
@cache
static get _fieldIsInstance() {
return createNF(this.r`field_is_instance`, "bool", ["pointer"]);
}
@cache
static get _fieldIsLiteral() {
return createNF(this.r`field_is_literal`, "bool", ["pointer"]);
}
@cache
static get _gcCollect() {
return createNF(this.r`gc_collect`, "void", ["int"]);
}
@cache
static get _gcCollectALittle() {
return createNF(this.r`gc_collect_a_little`, "void", []);
}
@cache
static get _gcDisable() {
return createNF(this.r`gc_disable`, "void", []);
}
@cache
static get _gcEnable() {
return createNF(this.r`gc_enable`, "void", []);
}
@cache
static get _gcIsDisabled() {
return createNF(this.r`gc_is_disabled`, "bool", []);
}
@cache
static get _genericClassGetCachedClass() {
return createNF(this.r`field_is_literal`, "pointer", ["pointer"]);
}
@cache
static get _imageGetClass() {
return createNF(this.r`image_get_class`, "pointer", ["pointer", "uint"]);
}
@cache
static get _imageGetClassCount() {
return createNF(this.r`image_get_class_count`, "uint32", ["pointer"]);
}
@cache
static get _imageGetClassStart() {
return createNF(this.r`image_get_class_start`, "uint32", ["pointer"]);
}
@cache
static get _imageGetName() {
return createNF(this.r`image_get_name`, "utf8string", ["pointer"]);
}
@cache
static get _init() {
return this.r`init`;
}
@cache
static get _livenessCalculationBegin() {
return createNF(this.r`unity_liveness_calculation_begin`, "pointer", [
"pointer",
"int",
"pointer",
"pointer",
"pointer",
"pointer"
]);
}
@cache
static get _livenessCalculationEnd() {
return createNF(this.r`unity_liveness_calculation_end`, "void", ["pointer"]);
}
@cache
static get _livenessCalculationFromStatics() {
return createNF(this.r`unity_liveness_calculation_from_statics`, "void", ["pointer"]);
}
@cache
static get _memorySnapshotCapture() {
return createNF(this.r`capture_memory_snapshot`, "pointer", []);
}
@cache
static get _memorySnapshotFree() {
return createNF(this.r`free_captured_memory_snapshot`, "void", ["pointer"]);
}
@cache
static get _memorySnapshotGetTrackedObjectCount() {
return createNF(this.r`memory_snapshot_get_tracked_object_count`, "uint64", ["pointer"]);
}
@cache
static get _memorySnapshotGetObjects() {
return createNF(this.r`memory_snapshot_get_objects`, "pointer", ["pointer"]);
}
@cache
static get _methodGetClass() {
return createNF(this.r`method_get_class`, "pointer", ["pointer"]);
}
@cache
static get _methodGetName() {
return createNF(this.r`method_get_name`, "utf8string", ["pointer"]);
}
@cache
static get _methodGetParamCount() {
return createNF(this.r`method_get_param_count`, "uint8", ["pointer"]);
}
@cache
static get _methodGetParameters() {
return createNF(this.r`method_get_parameters`, "pointer", ["pointer", "pointer"]);
}
@cache
static get _methodGetPointer() {
return createNF(this.r`method_get_pointer`, "pointer", ["pointer"]);
}
@cache
static get _methodGetReturnType() {
return createNF(this.r`method_get_return_type`, "pointer", ["pointer"]);
}
@cache
static get _methodIsGeneric() {
return createNF(this.r`method_is_generic`, "bool", ["pointer"]);
}
@cache
static get _methodIsInflated() {
return createNF(this.r`method_is_inflated`, "bool", ["pointer"]);
}
@cache
static get _methodIsInstance() {
return createNF(this.r`method_is_instance`, "bool", ["pointer"]);
}
@cache
static get _objectGetClass() {
return createNF(this.r`object_get_class`, "pointer", ["pointer"]);
}
@cache
static get _objectGetHeaderSize() {
return createNF(this.r`object_header_size`, "uint", []);
}
@cache
static get _objectNew() {
return createNF(this.r`object_new`, "pointer", ["pointer"]);
}
@cache
static get _objectUnbox() {
return createNF(this.r`object_unbox`, "pointer", ["pointer"]);
}
@cache
static get _parameterGetName() {
return createNF(this.r`parameter_get_name`, "utf8string", ["pointer"]);
}
@cache
static get _parameterGetPosition() {
return createNF(this.r`parameter_get_position`, "int32", ["pointer"]);
}
@cache
static get _parameterGetType() {
return createNF(this.r`parameter_get_type`, "pointer", ["pointer"]);
}
@cache
static get _stringChars() {
return createNF(this.r`string_chars`, "pointer", ["pointer"]);
}
@cache
static get _stringLength() {
return createNF(this.r`string_length`, "int32", ["pointer"]);
}
@cache
static get _stringNew() {
return createNF(this.r`string_new`, "pointer", ["utf8string"]);
}
@cache
static get _stringSetLength() {
return createNF(this.r`string_set_length`, "void", ["pointer", "int32"]);
}
@cache
static get _valueBox() {
return createNF(this.r`value_box`, "pointer", ["pointer", "pointer"]);
}
@cache
static get _threadAttach() {
return createNF(this.r`thread_attach`, "void", ["pointer"]);
}
@cache
static get _typeGetClassOrElementClass() {
return createNF(this.r`type_get_class_or_element_class`, "pointer", ["pointer"]);
}
@cache
static get _typeGetDataType() {
return createNF(this.r`type_get_data_type`, "pointer", ["pointer"]);
}
@cache
static get _typeGetGenericClass() {
return createNF(this.r`type_get_generic_class`, "pointer", ["pointer"]);
}
@cache
static get _typeGetName() {
return createNF(this.r`type_get_name`, "utf8string", ["pointer"]);
}
@cache
static get _typeGetTypeEnum() {
return createNF(this.r`type_get_type`, "int", ["pointer"]);
}
@cache
static get _typeIsByReference() {
return createNF(this.r`type_is_byref`, "bool", ["pointer"]);
}
@cache
static get _typeOffsetOfTypeEnum() {
return createNF(this.r`type_offset_of_type`, "uint16", []);
}
static initSources(library: Module, unityVersion: UnityVersion) {
this.sources.push(library, this.getMissingExports(unityVersion));
}
private static r(exportName: readonly string[]) {
const name = "il2cpp_" + exportName;
for (const source of this.sources) {
const result = source instanceof Module ? source.findExportByName(name) : source[name];
if (result) return result as NativePointer;
}
raise(`Couldn't resolve export "${exportName}".`);
}
private static getMissingExports(unityVersion: UnityVersion) {
return new CModule(`
#include <stdint.h>
#define FIELD_ATTRIBUTE_STATIC 0x0010
#define FIELD_ATTRIBUTE_LITERAL 0x0040
#define METHOD_ATTRIBUTE_STATIC 0x0010
typedef struct _Il2CppObject Il2CppObject;
typedef struct _Il2CppString Il2CppString;
typedef struct _Il2CppArray Il2CppArray;
#if ${unityVersion.isEqualOrAbove_5_3_3}
typedef struct _Il2CppArraySize Il2CppArraySize;
#endif
typedef struct _Il2CppDomain Il2CppDomain;
typedef struct _Il2CppAssemblyName Il2CppAssemblyName;
typedef struct _Il2CppAssembly Il2CppAssembly;
typedef struct _Il2CppImage Il2CppImage;
typedef struct _Il2CppClass Il2CppClass;
typedef struct _Il2CppType Il2CppType;
typedef struct _FieldInfo FieldInfo;
typedef struct _MethodInfo MethodInfo;
typedef struct _ParameterInfo ParameterInfo;
typedef enum _Il2CppTypeEnum Il2CppTypeEnum;
typedef struct _VirtualInvokeData VirtualInvokeData;
typedef struct _Il2CppGenericInst Il2CppGenericInst;
typedef struct _Il2CppGenericClass Il2CppGenericClass;
typedef struct _Il2CppGenericContext Il2CppGenericContext;
typedef uint16_t Il2CppChar;
typedef struct _Il2CppManagedMemorySnapshot Il2CppManagedMemorySnapshot;
typedef struct _Il2CppMetadataSnapshot Il2CppMetadataSnapshot;
typedef struct _Il2CppManagedMemorySection Il2CppManagedMemorySection;
typedef struct _Il2CppManagedHeap Il2CppManagedHeap;
typedef struct _Il2CppStacks Il2CppStacks;
typedef struct _Il2CppGCHandles Il2CppGCHandles;
typedef struct _Il2CppRuntimeInformation Il2CppRuntimeInformation;
enum _Il2CppTypeEnum
{
IL2CPP_TYPE_END = 0x00,
IL2CPP_TYPE_VOID = 0x01,
IL2CPP_TYPE_BOOLEAN = 0x02,
IL2CPP_TYPE_CHAR = 0x03,
IL2CPP_TYPE_I1 = 0x04,
IL2CPP_TYPE_U1 = 0x05,
IL2CPP_TYPE_I2 = 0x06,
IL2CPP_TYPE_U2 = 0x07,
IL2CPP_TYPE_I4 = 0x08,
IL2CPP_TYPE_U4 = 0x09,
IL2CPP_TYPE_I8 = 0x0a,
IL2CPP_TYPE_U8 = 0x0b,
IL2CPP_TYPE_R4 = 0x0c,
IL2CPP_TYPE_R8 = 0x0d,
IL2CPP_TYPE_STRING = 0x0e,
IL2CPP_TYPE_PTR = 0x0f,
IL2CPP_TYPE_BYREF = 0x10,
IL2CPP_TYPE_VALUETYPE = 0x11,
IL2CPP_TYPE_CLASS = 0x12,
IL2CPP_TYPE_VAR = 0x13,
IL2CPP_TYPE_ARRAY = 0x14,
IL2CPP_TYPE_GENERICINST = 0x15,
IL2CPP_TYPE_TYPEDBYREF = 0x16,
IL2CPP_TYPE_I = 0x18,
IL2CPP_TYPE_U = 0x19,
IL2CPP_TYPE_FNPTR = 0x1b,
IL2CPP_TYPE_OBJECT = 0x1c,
IL2CPP_TYPE_SZARRAY = 0x1d,
IL2CPP_TYPE_MVAR = 0x1e,
IL2CPP_TYPE_CMOD_REQD = 0x1f,
IL2CPP_TYPE_CMOD_OPT = 0x20,
IL2CPP_TYPE_INTERNAL = 0x21,
IL2CPP_TYPE_MODIFIER = 0x40,
IL2CPP_TYPE_SENTINEL = 0x41,
IL2CPP_TYPE_PINNED = 0x45,
IL2CPP_TYPE_ENUM = 0x55
};
struct _Il2CppObject
{
#if ${unityVersion.isEqualOrAbove_2018_1_0}
union
{
Il2CppClass * klass;
struct Il2CppVTable * vtable;
};
#else
Il2CppClass * klass;
#endif
struct MonitorData * monitor;
};
#if ${unityVersion.isBelow_2019_3_0}
size_t
il2cpp_object_header_size (void)
{
return sizeof (Il2CppObject);
}
#endif
struct _Il2CppDomain
{
struct Il2CppAppDomain * domain;
#if ${unityVersion.isEqualOrAbove_5_5_0}
struct Il2CppAppDomainSetup * setup;
#else
Il2CppObject * setup;
#endif
struct Il2CppAppContext * default_context;
const char * friendly_name;
uint32_t domain_id;
#if ${unityVersion.isEqualOrAbove_5_5_0}
volatile int threadpool_jobs;
#endif
#if ${unityVersion.isEqualOrAbove_2018_1_0}
void * agent_info;
#endif
};
const char *
il2cpp_domain_get_name (const Il2CppDomain* domain)
{
return domain->friendly_name;
}
struct _Il2CppAssemblyName
{
#if ${unityVersion.isEqualOrAbove_2018_1_0}
const char * name;
const char * culture;
const char * hash_value;
const char * public_key;
#else
int32_t nameIndex;
int32_t cultureIndex;
int32_t hashValueIndex;
int32_t publicKeyIndex;
#endif
uint32_t hash_alg;
int32_t hash_len;
uint32_t flags;
int32_t major;
int32_t minor;
int32_t build;
int32_t revision;
uint8_t publicKeyToken[8];
};
struct _Il2CppAssembly
{
#if ${unityVersion.isEqualOrAbove_2018_1_0}
Il2CppImage * image;
#else
int32_t imageIndex;
#endif
#if ${unityVersion.isEqualOrAbove_2018_3_0}
uint32_t token;
#else
int32_t customAttributeIndex;
#endif
#if ${unityVersion.isEqualOrAbove_5_3_3}
int32_t referencedAssemblyStart;
int32_t referencedAssemblyCount;
#endif
Il2CppAssemblyName aname;
};
#if ${unityVersion.isEqualOrAbove_2018_1_0}
const char *
il2cpp_assembly_get_name (const Il2CppAssembly * assembly)
{
return assembly->aname.name;
}
#endif
struct _Il2CppImage
{
const char * name;
#if ${unityVersion.isEqualOrAbove_2017_1_3 && unityVersion.isNotEqual_2017_2_0}
const char * nameNoExt;
#endif
#if ${unityVersion.isEqualOrAbove_2018_1_0}
Il2CppAssembly * assembly;
#else
int32_t assemblyIndex;
#endif
#if ${unityVersion.isBelow_2020_2_0}
int32_t typeStart;
#endif
uint32_t typeCount;
#if ${unityVersion.isEqualOrAbove_2017_1_0}
#if ${unityVersion.isBelow_2020_2_0}
int32_t exportedTypeStart;
#endif
uint32_t exportedTypeCount;
#endif
#if ${unityVersion.isEqualOrAbove_2018_3_0}
#if ${unityVersion.isBelow_2020_2_0}
int32_t customAttributeStart;
#endif
uint32_t customAttributeCount;
#endif
#if ${unityVersion.isEqualOrAbove_2020_2_0}
const struct Il2CppMetadataImageHandle * metadataHandle;
struct Il2CppNameToTypeHandleHashTable * nameToClassHashTable;
#else
int32_t entryPointIndex;
struct Il2CppNameToTypeDefinitionIndexHashTable * nameToClassHashTable;
#endif
#if ${unityVersion.isEqualOrAbove_2019_1_0}
const struct Il2CppCodeGenModule * codeGenModule;
#endif
#if ${unityVersion.isEqualOrAbove_5_3_2}
uint32_t token;
#endif
#if ${unityVersion.isEqualOrAbove_2018_1_0}
uint8_t dynamic;
#endif
};
#if ${unityVersion.isBelow_2020_2_0}
uint32_t
il2cpp_image_get_class_start (const Il2CppImage * image)
{
return image->typeStart;
}
#endif
#if ${unityVersion.isBelow_2018_3_0}
uint32_t
il2cpp_image_get_class_count (const Il2CppImage * image)
{
return image->typeCount;
}
#endif
struct _Il2CppType
{
union
{
void * dummy;
int32_t klassIndex;
#if ${unityVersion.isEqualOrAbove_2020_2_0}
const struct Il2CppMetadataTypeHandle * typeHandle;
#endif
const Il2CppType * type;
struct Il2CppArrayType * array;
int32_t genericParameterIndex;
#if ${unityVersion.isEqualOrAbove_2020_2_0}
const struct Il2CppMetadataGenericParameterHandle * genericParameterHandle;
#endif
Il2CppGenericClass * generic_class;
} data;
unsigned int attrs: 16;
Il2CppTypeEnum type: 8;
unsigned int num_mods: 6;
unsigned int byref: 1;
unsigned int pinned: 1;
};
uint16_t
il2cpp_type_offset_of_type (void)
{
return (uint16_t) offsetof (Il2CppType, type);
}
const Il2CppType *
il2cpp_type_get_data_type (const Il2CppType * type)
{
return type->data.type;
}
Il2CppGenericClass *
il2cpp_type_get_generic_class (const Il2CppType * type)
{
return type->data.generic_class;
}
#if ${unityVersion.isBelow_2018_1_0}
uint
il2cpp_type_is_byref (const Il2CppType * type)
{
return type->byref;
}
#endif
struct _VirtualInvokeData
{
void * methodPtr;
const MethodInfo * method;
};
struct _Il2CppClass
{
const Il2CppImage * image;
void * gc_desc;
const char * name;
const char * namespaze;
#if ${unityVersion.isEqualOrAbove_2018_1_0}
Il2CppType byval_arg;
Il2CppType this_arg;
#else
const Il2CppType* byval_arg;
const Il2CppType* this_arg;
#endif
Il2CppClass * element_class;
Il2CppClass * castClass;
Il2CppClass * declaringType;
Il2CppClass * parent;
Il2CppGenericClass * generic_class;
#if ${unityVersion.isEqualOrAbove_2020_2_0}
const struct Il2CppMetadataTypeHandle * typeMetadataHandle;
#else
const struct Il2CppTypeDefinition * typeDefinition;
#endif
#if ${unityVersion.isEqualOrAbove_5_6_0}
const struct Il2CppInteropData * interopData;
#endif
#if ${unityVersion.isEqualOrAbove_2018_1_0}
Il2CppClass * klass;
#endif
FieldInfo * fields;
const struct EventInfo* events;
const struct PropertyInfo * properties;
const MethodInfo ** methods;
Il2CppClass ** nestedTypes;
Il2CppClass ** implementedInterfaces;
#if ${unityVersion.isEqualOrAbove_5_3_6 && unityVersion.isBelow_5_5_0}
VirtualInvokeData * vtable;
#endif
#if ${unityVersion.isBelow_5_3_6}
const MethodInfo ** vtable;
#endif
struct Il2CppRuntimeInterfaceOffsetPair * interfaceOffsets;
void * static_fields;
const struct Il2CppRGCTXData * rgctx_data;
Il2CppClass ** typeHierarchy;
#if ${unityVersion.isEqualOrAbove_2019_1_0}
void * unity_user_data;
#endif
#if ${unityVersion.isEqualOrAbove_2018_2_0}
uint32_t initializationExceptionGCHandle;
#endif
uint32_t cctor_started;
uint32_t cctor_finished;
#if ${unityVersion.isEqualOrAbove_2019_1_0}
__attribute__((aligned(8))) size_t cctor_thread;
#else
__attribute__((aligned(8))) uint64_t cctor_thread;
#endif
#if ${unityVersion.isEqualOrAbove_2020_2_0}
const struct Il2CppMetadataGenericContainerHandle * genericContainerHandle;
#else
int32_t genericContainerIndex;
#endif
#if ${unityVersion.isBelow_2018_3_0}
int32_t customAttributeIndex;
#endif
uint32_t instance_size;
uint32_t actualSize;
uint32_t element_size;
int32_t native_size;
uint32_t static_fields_size;
uint32_t thread_static_fields_size;
int32_t thread_static_fields_offset;
uint32_t flags;
#if ${unityVersion.isEqualOrAbove_5_3_2}
uint32_t token;
#endif
uint16_t method_count;
uint16_t property_count;
uint16_t field_count;
uint16_t event_count;
uint16_t nested_type_count;
uint16_t vtable_count;
uint16_t interfaces_count;
uint16_t interface_offsets_count;
uint8_t typeHierarchyDepth;
#if ${unityVersion.isEqualOrAbove_5_4_4 && unityVersion.isNotEqual_5_5_0}
uint8_t genericRecursionDepth;
#endif
uint8_t rank;
uint8_t minimumAlignment;
#if ${unityVersion.isEqualOrAbove_2018_3_8}
uint8_t naturalAligment;
#endif
uint8_t packingSize;
#if ${unityVersion.isEqualOrAbove_2018_3_0}
uint8_t initialized_and_no_error: 1;
#endif
uint8_t valuetype: 1;
uint8_t initialized: 1;
uint8_t enumtype: 1;
uint8_t is_generic: 1;
uint8_t has_references: 1;
uint8_t init_pending: 1;
uint8_t size_inited: 1;
uint8_t has_finalize: 1;
uint8_t has_cctor: 1;
uint8_t is_blittable: 1;
#if ${unityVersion.isEqualOrAbove_5_3_3}
uint8_t is_import_or_windows_runtime: 1;
#endif
#if ${unityVersion.isEqualOrAbove_5_5_0}
uint8_t is_vtable_initialized: 1;
#endif
#if ${unityVersion.isEqualOrAbove_2018_2_0}
uint8_t has_initialization_error: 1;
#endif
#if ${unityVersion.isEqualOrAbove_5_5_0}
VirtualInvokeData vtable[32];
#endif
};
uint16_t
il2cpp_class_get_interface_count (const Il2CppClass * klass)
{
return klass->interfaces_count;
}
uint16_t
il2cpp_class_get_method_count (const Il2CppClass * klass)
{
return klass->method_count;
}
uint16_t
il2cpp_class_get_field_count (const Il2CppClass * klass)
{
return klass->field_count;
}
uint8_t
il2cpp_class_has_static_constructor (const Il2CppClass * klass)
{
return klass->has_cctor;
}
uint32_t
il2cpp_class_is_static_constructor_finished (const Il2CppClass * klass)
{
return klass->cctor_finished;
}
#if ${unityVersion.isBelow_2019_3_0}
void *
il2cpp_class_get_static_field_data (const Il2CppClass * klass)
{
return klass->static_fields;
}
#endif
struct _Il2CppGenericInst
{
uint32_t type_argc;
const Il2CppType ** type_argv;
};
struct _Il2CppGenericContext
{
const Il2CppGenericInst * class_inst;
const Il2CppGenericInst * method_inst;
};
struct _Il2CppGenericClass
{
#if ${unityVersion.isEqualOrAbove_2020_2_0}
const Il2CppType * type;
#else
int32_t typeDefinitionIndex;
#endif
Il2CppGenericContext context;
Il2CppClass * cached_class;
};
Il2CppClass *
il2cpp_generic_class_get_cached_class (Il2CppGenericClass * class)
{
return class->cached_class;
}
uint32_t
il2cpp_generic_class_get_types_count (Il2CppGenericClass * class)
{
return class->context.class_inst->type_argc;
}
const Il2CppType **
il2cpp_generic_class_get_types (Il2CppGenericClass * class)
{
return class->context.class_inst->type_argv;
}
struct _FieldInfo
{
const char * name;
const Il2CppType * type;
Il2CppClass * parent;
int32_t offset;
#if ${unityVersion.isBelow_2018_3_0}
int32_t customAttributeIndex;
#endif
#if ${unityVersion.isEqualOrAbove_5_3_2}
uint32_t token;
#endif
};
uint8_t
il2cpp_field_is_instance (FieldInfo * field)
{
return (field->type->attrs & FIELD_ATTRIBUTE_STATIC) == 0;
}
#if ${unityVersion.isBelow_2019_3_0}
uint8_t
il2cpp_field_is_literal (FieldInfo * field)
{
return field->type->attrs & FIELD_ATTRIBUTE_LITERAL;
}
#endif
struct _ParameterInfo
{
const char * name;
int32_t position;
uint32_t token;