forked from loongly/PureScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathicall_binding.c
More file actions
373 lines (294 loc) · 12.5 KB
/
icall_binding.c
File metadata and controls
373 lines (294 loc) · 12.5 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
#include "engine_include.h"
#include "wrapper.h"
MonoObject* MonoGetObject(void* ptr)
{
Il2CppObject * i2Obj = (Il2CppObject *)ptr;
return get_mono_object_impl(i2Obj, NULL,TRUE);
}
void* MonoStoreObject(MonoObject* obj, void* ptr)
{
if (ptr == NULL)
{
Il2CppClass* i2Class = get_il2cpp_class(mono_object_get_class(obj));
ptr = get_il2cpp_object(obj, i2Class);
if (ptr == NULL)
return NULL;
}
bind_mono_il2cpp_object(obj, (Il2CppObject*)ptr);
return ptr;
}
Il2CppObject* Il2cppGetObject(void* ptr)
{
return (Il2CppObject *)ptr;
}
void* Il2cppGetObjectPtr(Il2CppObject * obj)
{
return obj;
}
/*
MonoObject* NewObject(MonoReflectionType* type)
{
MonoType* monoType = mono_reflection_type_get_type(type);
MonoClass * mclass = mono_class_from_mono_type(monoType);
MonoObject* monoObj = mono_object_new(mono_domain_get(), mclass);
return monoObj;
}*/
/*
MonoObject* UnityEngine_GameObject_CreatePrimitive(int32_t type)
{
typedef Il2CppObject * (*ICallMethod) (int32_t);
static ICallMethod icall;
if (!icall)
icall = (ICallMethod)il2cpp_resolve_icall("UnityEngine.GameObject::CreatePrimitive");
Il2CppObject* il2cppObj = icall(type);
MonoClass* m_class = mono_search_class("UnityEngine.CoreModule.dll", "UnityEngine", "GameObject");
MonoObject* monoObj = get_mono_object(il2cppObj, m_class);
return monoObj;
}*/
/*
void UnityEngine_DebugLogHandler_Internal_Log(int32_t logType, MonoString* str, MonoObject* obj)
{
typedef void (*ICallMethod) (int32_t, Il2CppString*, Il2CppObject *);
static ICallMethod icall;
if (!icall)
icall = (ICallMethod)il2cpp_resolve_icall("UnityEngine.DebugLogHandler::Internal_Log(UnityEngine.LogType,System.String,UnityEngine.Object)");
icall(logType, get_il2cpp_string(str),obj);
return ;
}*/
/*
MonoObject* UnityEngine_GameObject_get_transform(MonoObject* monoObj)
{
typedef Il2CppObject * (*GameObject_get_transform) (Il2CppObject *);
static GameObject_get_transform icall;
if(!icall)
icall = (GameObject_get_transform)il2cpp_resolve_icall("UnityEngine.GameObject::get_transform()");
Il2CppObject * il2cppObj = get_il2cpp_object(monoObj);
Il2CppObject * newObj = icall(il2cppObj);
MonoClass* m_class = mono_search_class("UnityEngine.CoreModule.dll", "UnityEngine", "Transform");
MonoObject* newMonoObj = get_mono_object(newObj, m_class);
return newMonoObj;
}*/
/*
MonoObject* UnityEngine_Component_get_transform(MonoObject* monoObj)
{
typedef Il2CppObject * (*Component_get_transform) (Il2CppObject *);
static Component_get_transform icall;
if (!icall)
icall = (Component_get_transform)il2cpp_resolve_icall("UnityEngine.Component::get_transform()");
Il2CppObject * il2cppObj = get_il2cpp_object(monoObj);
Il2CppObject * newObj = icall(il2cppObj);
MonoClass* m_class = mono_search_class("UnityEngine.CoreModule.dll", "UnityEngine", "Transform");
MonoObject* newMonoObj = get_mono_object(newObj, m_class);
return newMonoObj;
}*/
/*
MonoObject* UnityEngine_Component_get_gameobject(MonoObject* monoObj)
{
typedef Il2CppObject * (*Component_get_transform) (Il2CppObject *);
static Component_get_transform icall;
if (!icall)
icall = (Component_get_transform)il2cpp_resolve_icall("UnityEngine.Component::get_gameObject");
Il2CppObject * il2cppObj = get_il2cpp_object(monoObj);
Il2CppObject * newObj = icall(il2cppObj);
MonoClass* m_class = mono_search_class("UnityEngine.CoreModule.dll", "UnityEngine", "GameObject");
MonoObject* newMonoObj = get_mono_object(newObj, m_class);
return newMonoObj;
}*/
/*
void UnityEngine_Transform_set_position_Injected(MonoObject* _thiz ,void* pos)
{
typedef void (*Transform_set_position) (Il2CppObject*, void*);
static Transform_set_position icall;
if (!icall)
icall = (Transform_set_position)il2cpp_resolve_icall("UnityEngine.Transform::set_position_Injected(UnityEngine.Vector3&)");
Il2CppObject* il2cppObj = get_il2cpp_object(_thiz);
icall(il2cppObj, pos);
return;
}*/
/*
void UnityEngine_Transform_get_position_Injected(MonoObject* _thiz, void* pos)
{
typedef void(*Transform_get_position) (Il2CppObject*, void*);
static Transform_get_position icall;
if (!icall)
icall = (Transform_get_position)il2cpp_resolve_icall("UnityEngine.Transform::get_position_Injected(UnityEngine.Vector3&)");
Il2CppObject* il2cppObj = get_il2cpp_object(_thiz);
icall(il2cppObj, pos);
return;
}*/
/*
MonoString* UnityEngine_Object_GetName(MonoObject* obj)
{
typedef Il2CppString* (*Transform_set_position) (Il2CppObject*);
static Transform_set_position icall;
if (!icall)
icall = (Transform_set_position)il2cpp_resolve_icall("UnityEngine.Object::GetName(UnityEngine.Object)");
Il2CppObject* il2cppObj = get_il2cpp_object(obj);
Il2CppString* res = icall(il2cppObj);
MonoString* monoStr = get_mono_string(res);
return monoStr;
}*/
/*
float UnityEngine_Time_Get_deltaTime()
{
typedef float (*Time_Get_deltaTime) ();
static Time_Get_deltaTime icall;
if (!icall)
icall = (Time_Get_deltaTime)il2cpp_resolve_icall("UnityEngine.Time::get_deltaTime()");
float res = icall();
return res;
}*/
/*
float UnityEngine_Time_GetTime()
{
typedef float(*Time_Get_deltaTime) ();
static Time_Get_deltaTime icall;
if (!icall)
icall = (Time_Get_deltaTime)il2cpp_resolve_icall("UnityEngine.Time::get_time()");
float res = icall();
return res;
}*/
MonoObject* UnityEngine_GameObject_Internal_AddComponentWithType(MonoObject* obj, MonoReflectionType* type)
{
typedef Il2CppObject* (*AddComponentWithType) (Il2CppObject*, Il2CppReflectionType*);
static AddComponentWithType icall;
if (!icall)
icall = (AddComponentWithType)il2cpp_resolve_icall("UnityEngine.GameObject::Internal_AddComponentWithType");
Il2CppObject* il2cppObj = get_il2cpp_object(obj,NULL);
MonoType* monoType = mono_reflection_type_get_type(type);
MonoClass * mclass = mono_class_from_mono_type(monoType);
Il2CppReflectionType* il2cppType = get_il2cpp_reflection_type(type);
Il2CppObject* res = icall(il2cppObj, il2cppType);
MonoObject* monoObj = get_mono_object(res, mclass);
return monoObj;
}
MonoArray* UnityEngine_GameObject_GetComponentsInternal(MonoObject* obj, MonoReflectionType* type, bool useSearchTypeAsArrayReturnType, bool recursive, bool includeInactive, bool reverse, MonoObject* resultList)
{
typedef Il2CppArray* (*GetComponentsInternal) (Il2CppObject*, Il2CppReflectionType*, bool , bool , bool , bool , Il2CppObject* );
static GetComponentsInternal icall;
if (!icall)
icall = (GetComponentsInternal)il2cpp_resolve_icall("UnityEngine.GameObject::GetComponentsInternal");
Il2CppObject* il2cppObj = get_il2cpp_object(obj, NULL);
Il2CppReflectionType* il2cppType = get_il2cpp_reflection_type(type);
Il2CppArray* res = icall(il2cppObj, il2cppType, useSearchTypeAsArrayReturnType, recursive, includeInactive, reverse, NULL);//resultList
MonoArray* monoRes = get_mono_array(res);
return monoRes;
}
void UnityEngine_GameObject_GetComponentFastPath(MonoObject* obj, MonoReflectionType* type, intptr_t ptr)
{
MonoType* monoType = mono_reflection_type_get_type(type);
MonoClass * mclass = mono_class_from_mono_type(monoType);
//ptr = *ptr;
void* objPtr = (char*)ptr - sizeof(void*);
//objPtr = NULL;
MonoArray* objs = UnityEngine_GameObject_GetComponentsInternal(obj, type, TRUE, FALSE, TRUE, FALSE, NULL);
if (objs != NULL)
{
size_t len = mono_array_length(objs);
for (int i = 0; i < len; i++)
{
MonoObject* monoObj = mono_array_get(objs, MonoObject*, i);
if (monoObj == NULL)
continue;
MonoClass * tclass = mono_object_get_class(monoObj);
if (mono_object_isinst(monoObj, mclass))
{
mono_gc_wbarrier_generic_store(objPtr, monoObj);
break;
}
}
}
}
MonoObject* UnityEngine_Component_get_gameObject(MonoObject* thiz);
void UnityEngine_Component_GetComponentFastPath(MonoObject* obj, MonoReflectionType* type, intptr_t ptr)
{
MonoObject* gameObj = UnityEngine_Component_get_gameObject(obj);
UnityEngine_GameObject_GetComponentFastPath(gameObj, type, ptr);
}
/*
bool UnityEngine_MonoBehaviour_IsObjectMonoBehaviour(MonoObject* obj)
{
Il2CppObject* il2cpp = get_il2cpp_object(obj);
typedef bool(*IsObjectMonoBehaviour) (Il2CppObject*);
static IsObjectMonoBehaviour icall;
if (!icall)
icall = (IsObjectMonoBehaviour)il2cpp_resolve_icall("UnityEngine.MonoBehaviour::IsObjectMonoBehaviour");
bool res = icall(il2cpp);
return res;
}*/
MonoObject* UnityEngine_MonoBehaviour_StartCoroutineManaged2(MonoObject* obj,MonoObject* enumerator)
{
Il2CppObject* il2cpp = get_il2cpp_object(obj, NULL);
typedef Il2CppObject*(*StartCoroutineManaged2) (Il2CppObject*, Il2CppObject*);
static StartCoroutineManaged2 icall;
if (!icall)
icall = (StartCoroutineManaged2)il2cpp_resolve_icall("UnityEngine.MonoBehaviour::StartCoroutineManaged2");
Il2CppObject* il2cppEnum = create_il2cpp_enumerator_wrapper(enumerator);
Il2CppObject* res = icall(il2cpp, il2cppEnum);
MonoClass* m_class = get_coroutine_class();
MonoObject* newMonoObj = get_mono_object(res, m_class);
return newMonoObj;
}
void UnityEngine_Coroutine_ReleaseCoroutine(void* ptr)
{
typedef void(*ReleaseCoroutine) (void*);
static ReleaseCoroutine icall;
if (!icall)
icall = (ReleaseCoroutine)il2cpp_resolve_icall("UnityEngine.Coroutine::ReleaseCoroutine");
/*Il2CppObject* il2cppObj = get_il2cpp_object_with_ptr(ptr);
void* internal_ptr = get_il2cpp_internal_ptr(il2cppObj);*/
icall(ptr);
return;
}
/*
void UnityEngine_Application_SetLogCallbackDefined(bool defined)
{
typedef void(*SetLogCallbackDefined) (bool);
static SetLogCallbackDefined icall;
if (!icall)
icall = (SetLogCallbackDefined)il2cpp_resolve_icall("UnityEngine.Application::SetLogCallbackDefined");
icall(defined);
}*/
/*
MonoString* UnityEngine_Application_get_persistentDataPath()
{
typedef Il2CppString* (*get_persistentDataPath) ();
static get_persistentDataPath icall;
if (!icall)
icall = (get_persistentDataPath)il2cpp_resolve_icall("UnityEngine.Application::get_persistentDataPath");
Il2CppString* res = icall();
MonoString* monoRes = get_mono_string(res);
return monoRes;
}*/
void init_event();
void regist_icall_gen();
void mono_register_icall(void)
{
init_il2cpp();
init_wrapper();
init_event();
regist_icall_gen();
il2cpp_add_internal_call("ObjectStore::GetObject", (Il2CppMethodPointer)Il2cppGetObject);
il2cpp_add_internal_call("ObjectStore::GetObjectPtr", (Il2CppMethodPointer)Il2cppGetObjectPtr);
mono_add_internal_call("ObjectStore::GetObject", MonoGetObject);
mono_add_internal_call("ObjectStore::StoreObject", MonoStoreObject);
//Aono_add_internal_call("UnityEngine.GameObject::CreatePrimitive", (void*)UnityEngine_GameObject_CreatePrimitive);
//Aono_add_internal_call("UnityEngine.DebugLogHandler::Internal_Log", (void*)UnityEngine_DebugLogHandler_Internal_Log);
//Aono_add_internal_call("UnityEngine.GameObject::get_transform", (void*)UnityEngine_GameObject_get_transform);
//Aono_add_internal_call("UnityEngine.Component::get_transform", (void*)UnityEngine_Component_get_transform);
//Aono_add_internal_call("UnityEngine.Component::get_gameObject", (void*)UnityEngine_Component_get_gameobject);
//Aono_add_internal_call("UnityEngine.Transform::set_position_Injected", (void*)UnityEngine_Transform_set_position_Injected);
//Aono_add_internal_call("UnityEngine.Transform::get_position_Injected", (void*)UnityEngine_Transform_get_position_Injected);
//Aono_add_internal_call("UnityEngine.Object::GetName", (void*)UnityEngine_Object_GetName);
//Aono_add_internal_call("UnityEngine.Time::get_deltaTime", (void*)UnityEngine_Time_Get_deltaTime);
//Aono_add_internal_call("UnityEngine.Time::get_time", (void*)UnityEngine_Time_GetTime);
mono_add_internal_call("UnityEngine.GameObject::Internal_AddComponentWithType", (void*)UnityEngine_GameObject_Internal_AddComponentWithType);
mono_add_internal_call("UnityEngine.GameObject::GetComponentFastPath", (void*)UnityEngine_GameObject_GetComponentFastPath);
mono_add_internal_call("UnityEngine.Component::GetComponentFastPath", (void*)UnityEngine_Component_GetComponentFastPath);
mono_add_internal_call("UnityEngine.GameObject::GetComponentsInternal", (void*)UnityEngine_GameObject_GetComponentsInternal);
//Aono_add_internal_call("UnityEngine.MonoBehaviour::IsObjectMonoBehaviour", (void*)UnityEngine_MonoBehaviour_IsObjectMonoBehaviour);
mono_add_internal_call("UnityEngine.MonoBehaviour::StartCoroutineManaged2", (void*)UnityEngine_MonoBehaviour_StartCoroutineManaged2);
mono_add_internal_call("UnityEngine.Coroutine::ReleaseCoroutine", (void*)UnityEngine_Coroutine_ReleaseCoroutine);
//Aono_add_internal_call("UnityEngine.Application::SetLogCallbackDefined", (void*)UnityEngine_Application_SetLogCallbackDefined);
//Aono_add_internal_call("UnityEngine.Application::get_persistentDataPath", (void*)UnityEngine_Application_get_persistentDataPath);
}