forked from focus-creative-games/il2cpp_plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathil2cpp-stubs.cpp
More file actions
1750 lines (1446 loc) · 55.7 KB
/
il2cpp-stubs.cpp
File metadata and controls
1750 lines (1446 loc) · 55.7 KB
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
#if defined(RUNTIME_IL2CPP) && !defined(IL2CPP_MONO_DEBUGGER_DISABLED)
#include "il2cpp-config.h"
#include <il2cpp-class-internals.h>
#include "gc/GCHandle.h"
#include "gc/GarbageCollector.h"
#include "gc/WriteBarrier.h"
#include "gc/gc_wrapper.h"
#include "metadata/FieldLayout.h"
#include "metadata/GenericMetadata.h"
#include "vm/Assembly.h"
#include "vm/AssemblyName.h"
#include "vm/Class.h"
#include "vm/ClassInlines.h"
#include "vm/Domain.h"
#include "vm/Field.h"
#include "vm/GenericContainer.h"
#include "vm/GenericClass.h"
#include "vm/Image.h"
#include "vm/Method.h"
#include "vm/Object.h"
#include "vm/Profiler.h"
#include "vm/Reflection.h"
#include "vm/Thread.h"
#include "vm/ThreadPoolMs.h"
#include "vm/Type.h"
#include "vm/Runtime.h"
#include "vm/String.h"
#include "vm-utils/Debugger.h"
#include "os/Thread.h"
#include <glib.h>
#include <mono/utils/mono-coop-mutex.h>
#include <mono/utils/mono-string.h>
#include <mono/metadata/handle.h>
#include <mono/metadata/object-internals.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/debug-mono-symfile.h>
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/profiler.h>
#include <mono/sgen/sgen-conf.h>
#include <mono/metadata/seq-points-data.h>
#include "il2cpp-c-types.h"
extern "C" {
Il2CppMonoDefaults il2cpp_mono_defaults;
Il2CppMonoDebugOptions il2cpp_mono_debug_options;
#include <mono/metadata/il2cpp-compat-metadata.h>
static MonoGHashTable *method_signatures;
static il2cpp::os::Mutex s_il2cpp_mono_loader_lock(false);
static uint64_t s_il2cpp_mono_loader_lock_tid = 0;
MonoDebugLocalsInfo* il2cpp_debug_lookup_locals(MonoMethod *method);
MonoMethod* il2cpp_mono_image_get_entry_point(MonoImage *image)
{
return (MonoMethod*)il2cpp::vm::Image::GetEntryPoint((Il2CppImage*)image);
}
const char* il2cpp_mono_image_get_filename(MonoImage *monoImage)
{
Il2CppImage *image = (Il2CppImage*)monoImage;
return image->name;
}
const char* il2cpp_mono_image_get_guid(MonoImage *image)
{
return "00000000-0000-0000-0000-000000000000"; //IL2CPP doesn't have image GUIDs
}
MonoClass* il2cpp_mono_type_get_class(MonoType *type)
{
return (MonoClass*)il2cpp::vm::Type::GetClass((Il2CppType*)type);
}
mono_bool il2cpp_mono_type_is_struct(MonoType *type)
{
return il2cpp::vm::Type::IsStruct((Il2CppType*)type);
}
mono_bool il2cpp_mono_type_is_reference(MonoType *type)
{
return il2cpp::vm::Type::IsReference((Il2CppType*)type);
}
void il2cpp_mono_metadata_free_mh(MonoMethodHeader *mh)
{
g_free(mh->locals);
g_free(mh);
}
Il2CppMonoMethodSignature* il2cpp_mono_method_signature(MonoMethod *m)
{
MethodInfo* method = (MethodInfo*)m;
if (method_signatures == NULL)
method_signatures = mono_g_hash_table_new_type(NULL, NULL, MONO_HASH_KEY_GC, MONO_ROOT_SOURCE_DEBUGGER, NULL, "method-to-signature for il2cpp table");
Il2CppMonoMethodSignature* existing_signature = (Il2CppMonoMethodSignature*)mono_g_hash_table_lookup(method_signatures, method);
if (existing_signature != NULL)
return existing_signature;
Il2CppMonoMethodSignature* sig = g_new(Il2CppMonoMethodSignature, 1);
sig->call_convention = MONO_CALL_DEFAULT;
sig->hasthis = il2cpp::vm::Method::IsInstance(method);
sig->ret = (MonoType*)il2cpp::vm::Method::GetReturnType(method);
sig->generic_param_count = 0;
if (method->is_generic)
{
sig->generic_param_count = il2cpp::vm::Method::GetGenericParamCount(method);
}
else if (method->is_inflated)
{
if (method->genericMethod->context.method_inst)
sig->generic_param_count += method->genericMethod->context.method_inst->type_argc;
if (method->genericMethod->context.class_inst)
sig->generic_param_count += method->genericMethod->context.class_inst->type_argc;
}
sig->param_count = il2cpp::vm::Method::GetParamCount(method);
sig->params = g_new(MonoType*, sig->param_count);
for (int i = 0; i < sig->param_count; ++i)
sig->params[i] = (MonoType*)il2cpp::vm::Method::GetParam(method, i);
mono_g_hash_table_insert(method_signatures, method, sig);
return sig;
}
static void il2cpp_mono_free_method_signature(gpointer unused1, gpointer value, gpointer unused2)
{
Il2CppMonoMethodSignature* sig = (Il2CppMonoMethodSignature*)value;
g_free(sig->params);
g_free(sig);
}
void il2cpp_mono_free_method_signatures()
{
if (method_signatures != NULL)
{
mono_g_hash_table_foreach(method_signatures, il2cpp_mono_free_method_signature, NULL);
mono_g_hash_table_destroy(method_signatures);
method_signatures = NULL;
}
}
void il2cpp_mono_method_get_param_names(MonoMethod *m, const char **names)
{
MethodInfo* method = (MethodInfo*)m;
uint32_t numberOfParameters = il2cpp::vm::Method::GetParamCount(method);
for (uint32_t i = 0; i < numberOfParameters; ++i)
names[i] = il2cpp::vm::Method::GetParamName(method, i);
}
mono_bool il2cpp_mono_type_generic_inst_is_valuetype(MonoType *monoType)
{
static const int kBitIsValueType = 1;
Il2CppType *type = (Il2CppType*)monoType;
Il2CppMetadataTypeHandle handle = il2cpp::vm::MetadataCache::GetTypeHandleFromType(type->data.generic_class->type);
return il2cpp::vm::MetadataCache::TypeIsValueType(handle);
}
MonoGenericContext* il2cpp_mono_method_get_context(MonoMethod* monoMethod);
const MonoType* il2cpp_get_type_from_index(int index);
MonoMethodHeader* il2cpp_mono_method_get_header_checked(MonoMethod *method, MonoError *error)
{
#if IL2CPP_MONO_DEBUGGER
if (error)
error_init(error);
uint32_t executionContextInfoCount;
const Il2CppMethodExecutionContextInfo *executionContextInfo;
const Il2CppMethodHeaderInfo *headerInfo;
const Il2CppMethodScope *scopes;
MonoGenericContext* context = il2cpp_mono_method_get_context(method);
MonoMethodHeader* header = g_new0(MonoMethodHeader, 1);
il2cpp::utils::Debugger::GetMethodExecutionContextInfo(method, &executionContextInfoCount, &executionContextInfo, &headerInfo, &scopes);
/*
uint32_t code_size;
uint16_t num_locals;
MonoType **locals;
*/
header->code_size = headerInfo->code_size;
header->num_locals = executionContextInfoCount;
header->locals = g_new0(MonoType*, executionContextInfoCount);
for (uint32_t i = 0; i < executionContextInfoCount; i++)
{
header->locals[i] = (Il2CppType*)il2cpp::metadata::GenericMetadata::InflateIfNeeded(il2cpp_get_type_from_index(executionContextInfo[i].typeIndex), context, true);
}
return header;
#else
MonoMethodHeader* header = g_new0(MonoMethodHeader, 1);
return NULL;
#endif
}
gboolean il2cpp_mono_class_init(MonoClass *klass)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
return 0;
}
MonoVTable* il2cpp_mono_class_vtable(MonoDomain *domain, MonoClass *klass)
{
return (MonoVTable*)((Il2CppClass*)klass)->vtable;
}
MonoClassField* il2cpp_mono_class_get_field_from_name(MonoClass *klass, const char *name)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
return NULL;
}
int32_t il2cpp_mono_array_element_size(MonoClass *monoClass)
{
Il2CppClass *klass = (Il2CppClass*)monoClass;
return klass->element_size;
}
int32_t il2cpp_mono_class_instance_size(MonoClass *klass)
{
il2cpp::vm::Class::Init(klass);
return il2cpp::vm::Class::GetInstanceSize((Il2CppClass*)klass);
}
int32_t il2cpp_mono_class_value_size(MonoClass *klass, uint32_t *align)
{
return il2cpp::vm::Class::GetValueSize((Il2CppClass*)klass, align);
}
gboolean il2cpp_mono_class_is_assignable_from(MonoClass *klass, MonoClass *oklass)
{
return il2cpp::vm::Class::IsAssignableFrom((Il2CppClass*)klass, (Il2CppClass*)oklass);
}
MonoClass* il2cpp_mono_class_from_mono_type(MonoType *type)
{
return (MonoClass*)il2cpp::vm::Class::FromIl2CppType((Il2CppType*)type);
}
int il2cpp_mono_class_num_fields(MonoClass *klass)
{
return (int)il2cpp::vm::Class::GetNumFields((Il2CppClass*)klass);
}
int il2cpp_mono_class_num_methods(MonoClass *klass)
{
return (int)il2cpp::vm::Class::GetNumMethods((Il2CppClass*)klass);
}
int il2cpp_mono_class_num_properties(MonoClass *klass)
{
return (int)il2cpp::vm::Class::GetNumProperties((Il2CppClass*)klass);
}
MonoClassField* il2cpp_mono_class_get_fields(MonoClass* klass, gpointer *iter)
{
return (MonoClassField*)il2cpp::vm::Class::GetFields((Il2CppClass*)klass, iter);
}
MonoMethod* il2cpp_mono_class_get_methods(MonoClass* klass, gpointer *iter)
{
return (MonoMethod*)il2cpp::vm::Class::GetMethods((Il2CppClass*)klass, iter);
}
MonoProperty* il2cpp_mono_class_get_properties(MonoClass* klass, gpointer *iter)
{
return (MonoProperty*)il2cpp::vm::Class::GetProperties((Il2CppClass*)klass, iter);
}
const char* il2cpp_mono_field_get_name(MonoClassField *field)
{
return il2cpp::vm::Field::GetName((FieldInfo*)field);
}
mono_unichar2* il2cpp_mono_string_chars(MonoString *monoStr)
{
Il2CppString *str = (Il2CppString*)monoStr;
return (mono_unichar2*)str->chars;
}
int il2cpp_mono_string_length(MonoString *monoStr)
{
Il2CppString *str = (Il2CppString*)monoStr;
return str->length;
}
char* il2cpp_mono_array_addr_with_size(MonoArray *array, int size, uintptr_t idx)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
return NULL;
}
uintptr_t il2cpp_mono_array_length(MonoArray *array)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
return 0;
}
MonoString* il2cpp_mono_string_new(MonoDomain *domain, const char *text)
{
return (MonoString*)il2cpp::vm::String::New(text);
}
MonoString* il2cpp_mono_string_new_checked(MonoDomain *domain, const char *text, MonoError *merror)
{
error_init(merror);
return il2cpp_mono_string_new(domain, text);
}
char* il2cpp_mono_string_to_utf8_checked(MonoString *string_obj, MonoError *error)
{
error_init(error);
Il2CppString *str = (Il2CppString*)string_obj;
std::string s = il2cpp::utils::StringUtils::Utf16ToUtf8(str->chars, str->length);
return g_strdup(s.c_str());
}
int il2cpp_mono_object_hash(MonoObject* obj)
{
return (int)((intptr_t)obj >> 3);
}
void* il2cpp_mono_object_unbox(MonoObject *monoObj)
{
Il2CppObject *obj = (Il2CppObject*)monoObj;
return il2cpp::vm::Object::Unbox(obj);
}
void il2cpp_mono_field_set_value(MonoObject *obj, MonoClassField *field, void *value)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
}
void il2cpp_mono_field_static_set_value(MonoVTable *vt, MonoClassField *field, void *value)
{
il2cpp::vm::Field::StaticSetValue((FieldInfo*)field, value);
}
uint32_t il2cpp_mono_gchandle_new_weakref(MonoObject *obj, mono_bool track_resurrection)
{
return il2cpp::gc::GCHandle::NewWeakref((Il2CppObject*)obj, track_resurrection == 0 ? false : true);
}
MonoObject* il2cpp_mono_gchandle_get_target(uint32_t gchandle)
{
return (MonoObject*)il2cpp::gc::GCHandle::GetTarget(gchandle);
}
void il2cpp_mono_gchandle_free(uint32_t gchandle)
{
il2cpp::gc::GCHandle::Free(gchandle);
}
void il2cpp_mono_gc_wbarrier_generic_store(void* ptr, MonoObject* value)
{
il2cpp::gc::WriteBarrier::GenericStore(ptr, (Il2CppObject*)value);
}
int il2cpp_mono_reflection_parse_type_checked(char *name, Il2CppMonoTypeNameParse *monoInfo, MonoError *error)
{
error_init(error);
il2cpp::vm::TypeNameParseInfo *pInfo = new il2cpp::vm::TypeNameParseInfo();
std::string nameStr = name;
std::replace(nameStr.begin(), nameStr.end(), '/', '+');
il2cpp::vm::TypeNameParser parser(nameStr, *pInfo, false);
monoInfo->assembly.name = NULL;
monoInfo->il2cppTypeNameParseInfo = pInfo;
return parser.Parse();
}
void il2cpp_mono_reflection_free_type_info(Il2CppMonoTypeNameParse *info)
{
delete (il2cpp::vm::TypeNameParseInfo*)info->il2cppTypeNameParseInfo;
}
MonoDomain* il2cpp_mono_get_root_domain(void)
{
return (MonoDomain*)il2cpp::vm::Domain::GetCurrent();
}
void il2cpp_mono_runtime_quit(void)
{
il2cpp::vm::Runtime::Shutdown();
}
gboolean il2cpp_mono_runtime_is_shutting_down(void)
{
return il2cpp::vm::Runtime::IsShuttingDown() ? TRUE : FALSE;
}
MonoDomain* il2cpp_mono_domain_get(void)
{
return il2cpp_mono_get_root_domain();
}
gboolean il2cpp_mono_domain_set(MonoDomain *domain, gboolean force)
{
IL2CPP_ASSERT(domain == il2cpp_mono_get_root_domain());
return TRUE;
}
void il2cpp_mono_domain_foreach(MonoDomainFunc func, gpointer user_data)
{
func((MonoDomain*)il2cpp_mono_get_root_domain(), user_data);
}
MonoJitInfo* il2cpp_mono_jit_info_table_find(MonoDomain* domain, char* addr)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
return NULL;
}
MonoMethod* il2cpp_mono_jit_info_get_method(MonoJitInfo* ji)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
return NULL;
}
MonoDebugMethodJitInfo* il2cpp_mono_debug_find_method(MonoMethod *method, MonoDomain *domain)
{
//IL2CPP_ASSERT(0 && "This method is not yet implemented");
MonoDebugMethodJitInfo* jit = g_new0(MonoDebugMethodJitInfo, 1);
MonoDebugLocalsInfo* locals_info = il2cpp_debug_lookup_locals(method);
jit->num_locals = locals_info->num_locals;
Il2CppMonoMethodSignature* sig = il2cpp_mono_method_signature(method);
jit->num_params = sig->param_count;
return jit;
}
gint32 il2cpp_mono_debug_il_offset_from_address(MonoMethod* method, MonoDomain* domain, guint32 native_offset)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
return 0;
}
void il2cpp_mono_set_is_debugger_attached(gboolean attached)
{
#if IL2CPP_MONO_DEBUGGER
il2cpp::utils::Debugger::SetIsDebuggerAttached(attached == TRUE);
#endif
}
char* il2cpp_mono_type_full_name(MonoType* type)
{
std::string name = il2cpp::vm::Type::GetName((Il2CppType*)type, IL2CPP_TYPE_NAME_FORMAT_FULL_NAME);
return g_strdup(name.c_str());
}
char* il2cpp_mono_method_full_name(MonoMethod* method, gboolean signature)
{
return g_strdup(((MethodInfo*)method)->name);
}
MonoThread* il2cpp_mono_thread_current()
{
return (MonoThread*)il2cpp::vm::Thread::Current();
}
MonoThread* il2cpp_mono_thread_get_main()
{
return (MonoThread*)il2cpp::vm::Thread::Main();
}
MonoThread* il2cpp_mono_thread_attach(MonoDomain* domain)
{
return (MonoThread*)il2cpp::vm::Thread::Attach((Il2CppDomain*)domain);
}
void il2cpp_mono_thread_detach(MonoThread* thread)
{
il2cpp::vm::Thread::Detach((Il2CppThread*)thread);
}
void il2cpp_mono_domain_lock(MonoDomain* domain)
{
}
void il2cpp_mono_domain_unlock(MonoDomain* domain)
{
}
MonoJitInfo* il2cpp_mono_jit_info_table_find_internal(MonoDomain* domain, char* addr, gboolean try_aot, gboolean allow_trampolines)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
return NULL;
}
guint il2cpp_mono_aligned_addr_hash(gconstpointer ptr)
{
return GPOINTER_TO_UINT(ptr) >> 3;
}
MonoGenericInst* il2cpp_mono_metadata_get_generic_inst(int type_argc, MonoType** type_argv)
{
return (MonoGenericInst*)il2cpp::vm::MetadataCache::GetGenericInst((Il2CppType**)type_argv, type_argc);
}
MonoMethod* il2cpp_mono_get_method_checked(MonoImage* image, guint32 token, MonoClass* klass, MonoGenericContext* context, MonoError* error)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
return NULL;
}
SgenDescriptor il2cpp_mono_gc_make_root_descr_all_refs(int numbits)
{
return NULL;
}
int il2cpp_mono_gc_register_root_wbarrier(char *start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, void *key, const char *msg)
{
il2cpp::gc::GarbageCollector::RegisterRoot(start, size);
return 1;
}
MonoGCDescriptor il2cpp_mono_gc_make_vector_descr(void)
{
return 0;
}
int il2cpp_mono_class_interface_offset_with_variance(MonoClass* klass, MonoClass* itf, gboolean* non_exact_match)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
return 0;
}
void il2cpp_mono_class_setup_supertypes(MonoClass* klass)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
}
void il2cpp_mono_class_setup_vtable(MonoClass* klass)
{
il2cpp::vm::Class::Init((Il2CppClass*)klass);
}
void il2cpp_mono_class_setup_methods(MonoClass* klass)
{
il2cpp::vm::Class::SetupMethods((Il2CppClass*)klass);
}
gboolean il2cpp_mono_class_field_is_special_static(MonoClassField* field)
{
return il2cpp::vm::Field::IsNormalStatic((FieldInfo*)field) ? FALSE : TRUE;
}
guint32 il2cpp_mono_class_field_get_special_static_type(MonoClassField* field)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
return 0;
}
MonoGenericContext* il2cpp_mono_class_get_context(MonoClass* klass)
{
return (MonoGenericContext*)&((Il2CppClass*)klass)->generic_class->context;
}
MonoGenericContext* il2cpp_mono_method_get_context(MonoMethod* monoMethod)
{
MethodInfo * method = (MethodInfo*)monoMethod;
if (!method->is_inflated || method->is_generic)
return NULL;
return (MonoGenericContext*)&((MethodInfo*)method)->genericMethod->context;
}
MonoGenericContainer* il2cpp_mono_method_get_generic_container(MonoMethod* monoMethod)
{
MethodInfo * method = (MethodInfo*)monoMethod;
if (method->is_inflated || !method->is_generic)
return NULL;
return (MonoGenericContainer*)method->genericContainerHandle;
}
MonoMethod* il2cpp_mono_class_inflate_generic_method_full_checked(MonoMethod* method, MonoClass* klass_hint, MonoGenericContext* context, MonoError* error)
{
error_init(error);
return (MonoMethod*)il2cpp::metadata::GenericMetadata::Inflate((MethodInfo*)method, (Il2CppGenericContext*)context);
}
MonoMethod* il2cpp_mono_class_inflate_generic_method_checked(MonoMethod* method, MonoGenericContext* context, MonoError* error)
{
error_init(error);
return (MonoMethod*)il2cpp::metadata::GenericMetadata::Inflate((MethodInfo*)method, (Il2CppGenericContext*)context);
}
void il2cpp_mono_loader_lock()
{
s_il2cpp_mono_loader_lock.Lock();
s_il2cpp_mono_loader_lock_tid = il2cpp::os::Thread::CurrentThreadId();
}
void il2cpp_mono_loader_unlock()
{
s_il2cpp_mono_loader_lock_tid = 0;
s_il2cpp_mono_loader_lock.Unlock();
}
void il2cpp_mono_loader_lock_track_ownership(gboolean track)
{
}
gboolean il2cpp_mono_loader_lock_is_owned_by_self()
{
return s_il2cpp_mono_loader_lock_tid == il2cpp::os::Thread::CurrentThreadId();
}
gpointer il2cpp_mono_method_get_wrapper_data(MonoMethod* method, guint32 id)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
return 0;
}
char* il2cpp_mono_type_get_name_full(MonoType* type, MonoTypeNameFormat format)
{
std::string name = il2cpp::vm::Type::GetName((Il2CppType*)type, (Il2CppTypeNameFormat)format);
return g_strdup(name.c_str());
}
gboolean il2cpp_mono_class_is_nullable(MonoClass* klass)
{
return il2cpp::vm::Class::IsNullable((Il2CppClass*)klass);
}
MonoGenericContainer* il2cpp_mono_class_get_generic_container(MonoClass* klass)
{
return (MonoGenericContainer*)il2cpp::vm::Class::GetGenericContainer((Il2CppClass*)klass);
}
void il2cpp_mono_class_setup_interfaces(MonoClass* klass, MonoError* error)
{
error_init(error);
il2cpp::vm::Class::SetupInterfaces((Il2CppClass*)klass);
}
enum
{
BFLAGS_IgnoreCase = 1,
BFLAGS_DeclaredOnly = 2,
BFLAGS_Instance = 4,
BFLAGS_Static = 8,
BFLAGS_Public = 0x10,
BFLAGS_NonPublic = 0x20,
BFLAGS_FlattenHierarchy = 0x40,
BFLAGS_InvokeMethod = 0x100,
BFLAGS_CreateInstance = 0x200,
BFLAGS_GetField = 0x400,
BFLAGS_SetField = 0x800,
BFLAGS_GetProperty = 0x1000,
BFLAGS_SetProperty = 0x2000,
BFLAGS_ExactBinding = 0x10000,
BFLAGS_SuppressChangeType = 0x20000,
BFLAGS_OptionalParamBinding = 0x40000
};
static gboolean
method_nonpublic(MethodInfo* method, gboolean start_klass)
{
switch (method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK)
{
case METHOD_ATTRIBUTE_ASSEM:
return (start_klass || il2cpp_defaults.generic_ilist_class);
case METHOD_ATTRIBUTE_PRIVATE:
return start_klass;
case METHOD_ATTRIBUTE_PUBLIC:
return FALSE;
default:
return TRUE;
}
}
GPtrArray* il2cpp_mono_class_get_methods_by_name(MonoClass* il2cppMonoKlass, const char* name, guint32 bflags, gboolean ignore_case, gboolean allow_ctors, MonoError* error)
{
GPtrArray *array;
Il2CppClass *klass = (Il2CppClass*)il2cppMonoKlass;
Il2CppClass *startklass;
MethodInfo *method;
gpointer iter;
int match;
/*FIXME, use MonoBitSet*/
/*guint32 method_slots_default [8];
guint32 *method_slots = NULL;*/
int (*compare_func) (const char *s1, const char *s2) = NULL;
array = g_ptr_array_new();
startklass = klass;
error_init(error);
if (name != NULL)
compare_func = (ignore_case) ? mono_utf8_strcasecmp : strcmp;
/*il2cpp_mono_class_setup_methods (klass);
il2cpp_mono_class_setup_vtable (klass);
if (is_generic_parameter (&klass->byval_arg))
nslots = mono_class_get_vtable_size (klass->parent);
else
nslots = MONO_CLASS_IS_INTERFACE (klass) ? mono_class_num_methods (klass) : mono_class_get_vtable_size (klass);
if (nslots >= sizeof (method_slots_default) * 8) {
method_slots = g_new0 (guint32, nslots / 32 + 1);
} else {
method_slots = method_slots_default;
memset (method_slots, 0, sizeof (method_slots_default));
}*/
handle_parent:
il2cpp_mono_class_setup_methods((MonoClass*)klass);
il2cpp_mono_class_setup_vtable((MonoClass*)klass);
iter = NULL;
while ((method = (MethodInfo*)il2cpp_mono_class_get_methods((MonoClass*)klass, &iter)))
{
match = 0;
/*if (method->slot != -1) {
g_assert (method->slot < nslots);
if (method_slots [method->slot >> 5] & (1 << (method->slot & 0x1f)))
continue;
if (!(method->flags & METHOD_ATTRIBUTE_NEW_SLOT))
method_slots [method->slot >> 5] |= 1 << (method->slot & 0x1f);
}*/
if (!allow_ctors && method->name[0] == '.' && (strcmp(method->name, ".ctor") == 0 || strcmp(method->name, ".cctor") == 0))
continue;
if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC)
{
if (bflags & BFLAGS_Public)
match++;
}
else if ((bflags & BFLAGS_NonPublic) && method_nonpublic(method, (klass == startklass)))
{
match++;
}
if (!match)
continue;
match = 0;
if (method->flags & METHOD_ATTRIBUTE_STATIC)
{
if (bflags & BFLAGS_Static)
if ((bflags & BFLAGS_FlattenHierarchy) || (klass == startklass))
match++;
}
else
{
if (bflags & BFLAGS_Instance)
match++;
}
if (!match)
continue;
if (name != NULL)
{
if (compare_func(name, method->name))
continue;
}
match = 0;
g_ptr_array_add(array, method);
}
if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
goto handle_parent;
/*if (method_slots != method_slots_default)
g_free (method_slots);*/
return array;
}
gpointer il2cpp_mono_ldtoken_checked(MonoImage* image, guint32 token, MonoClass** handle_class, MonoGenericContext* context, MonoError* error)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
return 0;
}
MonoClass* il2cpp_mono_class_from_generic_parameter_internal(MonoGenericParam* param)
{
return (MonoClass*)il2cpp::vm::Class::FromGenericParameter((Il2CppMetadataGenericParameterHandle)param);
}
MonoClass* il2cpp_mono_class_load_from_name(MonoImage* image, const char* name_space, const char* name)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
return NULL;
}
MonoGenericClass* il2cpp_mono_class_get_generic_class(MonoClass* monoClass)
{
Il2CppClass *klass = (Il2CppClass*)monoClass;
return (MonoGenericClass*)klass->generic_class;
}
MonoInternalThread* il2cpp_mono_thread_internal_current()
{
Il2CppThread* currentThread = (Il2CppThread*)il2cpp_mono_thread_current();
if (currentThread == NULL)
return NULL;
return (MonoInternalThread*)currentThread->internal_thread;
}
gboolean il2cpp_mono_thread_internal_is_current(MonoInternalThread* thread)
{
MonoInternalThread* currentThread = il2cpp_mono_thread_internal_current();
if (currentThread == NULL)
return FALSE;
return currentThread == thread;
}
void il2cpp_mono_thread_internal_abort(MonoInternalThread* thread, gboolean appdomain_unload)
{
il2cpp::vm::Thread::RequestAbort((Il2CppInternalThread*)thread);
}
void il2cpp_mono_thread_internal_reset_abort(MonoInternalThread* thread)
{
il2cpp::vm::Thread::ResetAbort((Il2CppInternalThread*)thread);
}
gunichar2* il2cpp_mono_thread_get_name(MonoInternalThread* this_obj, guint32* name_len)
{
std::string name = il2cpp::vm::Thread::GetName((Il2CppInternalThread*)this_obj);
if (name_len != NULL)
*name_len = (guint32)name.size();
if (name.empty())
return NULL;
return g_utf8_to_utf16(name.c_str(), (glong)name.size(), NULL, NULL, NULL);
}
void il2cpp_mono_thread_set_name_internal(MonoInternalThread* this_obj, MonoString* name, gboolean permanent, gboolean reset, MonoError* error)
{
il2cpp::vm::Thread::SetName((Il2CppInternalThread*)this_obj, (Il2CppString*)name);
error_init(error);
}
void il2cpp_mono_thread_suspend_all_other_threads()
{
}
void il2cpp_mono_stack_mark_record_size(MonoThreadInfo* info, HandleStackMark* stackmark, const char* func_name)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
}
Il2CppMonoRuntimeExceptionHandlingCallbacks* il2cpp_mono_get_eh_callbacks()
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
return NULL;
}
void il2cpp_mono_nullable_init(guint8* buf, MonoObject* value, MonoClass* klass)
{
il2cpp::vm::Object::NullableInit(buf, (Il2CppObject*)value, (Il2CppClass*)klass);
}
MonoObject* il2cpp_mono_value_box_checked(MonoDomain* domain, MonoClass* klass, gpointer value, MonoError* error)
{
error_init(error);
return (MonoObject*)il2cpp::vm::Object::Box((Il2CppClass*)klass, value);
}
void il2cpp_mono_field_static_get_value_checked(MonoVTable* vt, MonoClassField* field, void* value, MonoError* error)
{
error_init(error);
il2cpp::vm::Field::StaticGetValue((FieldInfo*)field, value);
}
void il2cpp_mono_field_static_get_value_for_thread(MonoInternalThread* thread, MonoVTable* vt, MonoClassField* field, void* value, MonoError* error)
{
error_init(error);
il2cpp::vm::Field::StaticGetValueForThread((FieldInfo*)field, value, (Il2CppInternalThread*)thread);
}
MonoObject* il2cpp_mono_field_get_value_object_checked(MonoDomain* domain, MonoClassField* field, MonoObject* obj, MonoError* error)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
return NULL;
}
MonoObject* il2cpp_mono_object_new_checked(MonoDomain* domain, MonoClass* klass, MonoError* error)
{
error_init(error);
return (MonoObject*)il2cpp::vm::Object::New((Il2CppClass*)klass);
}
MonoString* il2cpp_mono_ldstr_checked(MonoDomain* domain, MonoImage* image, guint32 idx, MonoError* error)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
return NULL;
}
MonoObject* il2cpp_mono_runtime_try_invoke(MonoMethod* method, void* obj, void** params, MonoObject** exc, MonoError* error)
{
error_init(error);
if (((MethodInfo*)method)->klass->valuetype)
obj = static_cast<Il2CppObject*>(obj) - 1;
return (MonoObject*)il2cpp::vm::Runtime::Invoke((MethodInfo*)method, obj, params, (Il2CppException**)exc);
}
MonoObject* il2cpp_mono_runtime_invoke_checked(MonoMethod* method, void* obj, void** params, MonoError* error)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
return NULL;
}
static MonoInterpCallbacks s_interp_callbacks;
static gpointer
il2cpp_frame_get_arg(MonoInterpFrameHandle frame, int pos)
{
Il2CppSequencePointExecutionContext* context = (Il2CppSequencePointExecutionContext*)frame;
return context->params[pos];
}
static gpointer
il2cpp_frame_get_local(MonoInterpFrameHandle frame, int pos)
{
Il2CppSequencePointExecutionContext* context = (Il2CppSequencePointExecutionContext*)frame;
return context->locals[pos];
}
static gpointer
il2cpp_frame_get_this(MonoInterpFrameHandle frame)
{
Il2CppSequencePointExecutionContext* context = (Il2CppSequencePointExecutionContext*)frame;
return *context->thisArg;
}
static void
il2cpp_interp_stub_init(void)
{
MonoInterpCallbacks c = { 0 };
/*c.create_method_pointer = stub_create_method_pointer;
c.runtime_invoke = stub_runtime_invoke;
c.init_delegate = stub_init_delegate;
#ifndef DISABLE_REMOTING
c.get_remoting_invoke = stub_get_remoting_invoke;
#endif
c.create_trampoline = stub_create_trampoline;
c.walk_stack_with_ctx = stub_walk_stack_with_ctx;
c.set_resume_state = stub_set_resume_state;
c.run_finally = stub_run_finally;
c.run_filter = stub_run_filter;
c.frame_iter_init = stub_frame_iter_init;
c.frame_iter_next = stub_frame_iter_next;
c.find_jit_info = stub_find_jit_info;
c.set_breakpoint = stub_set_breakpoint;
c.clear_breakpoint = stub_clear_breakpoint;
c.frame_get_jit_info = stub_frame_get_jit_info;
c.frame_get_ip = stub_frame_get_ip;*/
c.frame_get_arg = il2cpp_frame_get_arg;
c.frame_get_local = il2cpp_frame_get_local;
c.frame_get_this = il2cpp_frame_get_this;
/* c.frame_get_parent = stub_frame_get_parent;
c.start_single_stepping = stub_start_single_stepping;
c.stop_single_stepping = stub_stop_single_stepping;
mini_install_interp_callbacks (&c);*/
memcpy(&s_interp_callbacks, &c, sizeof(MonoInterpCallbacks));
}
void il2cpp_mono_gc_base_init()
{
il2cpp_interp_stub_init();
}
static il2cpp::os::Mutex s_il2cpp_gc_root_lock(false);
int il2cpp_mono_gc_register_root(char* start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, void* key, const char* msg)
{
il2cpp::gc::GarbageCollector::RegisterRoot(start, size);
return 1;
}
void il2cpp_mono_gc_deregister_root(char* addr)
{
il2cpp::gc::GarbageCollector::UnregisterRoot(addr);
}
#ifndef HOST_WIN32
int il2cpp_mono_gc_pthread_create(pthread_t *new_thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
{
IL2CPP_ASSERT(0 && "This method is not yet implemented");
return 0;
}