This commit is contained in:
恍兮惚兮 2024-05-14 20:37:48 +08:00
parent d34ed3473d
commit 1c60d6c4cc
11 changed files with 674 additions and 1028 deletions

View File

@ -62,7 +62,7 @@ include(generate_product_version)
set(VERSION_MAJOR 3)
set(VERSION_MINOR 2)
set(VERSION_PATCH 2)
set(VERSION_PATCH 3)
set(VERSION_REVISION 0)
if(BUILD_CORE)

View File

@ -1,4 +1,4 @@
add_library(commonengine mono/impl_mono.cpp mono/impl_il2cpp.cpp ppsspp/ppsspp.cpp mages/mages.cpp v8/v8.cpp python/python2.cpp python/python3.cpp python/python.cpp pchooks/pchooks.cpp)
add_library(commonengine mono/impl_mono.cpp mono/monoil2cpp.cpp mono/impl_il2cpp.cpp ppsspp/ppsspp.cpp mages/mages.cpp v8/v8.cpp python/python2.cpp python/python3.cpp python/python.cpp pchooks/pchooks.cpp)
target_precompile_headers(commonengine REUSE_FROM pchhook)

View File

@ -483,96 +483,6 @@ typedef struct MulticastDelegate : Il2CppDelegate {
Il2CppArraySize* delegates;
} MulticastDelegate;
// function types
typedef Il2CppString* (*il2cpp_string_new_utf16_t)(const wchar_t* str, unsigned int len);
typedef Il2CppString* (*il2cpp_string_new_t)(const char* str);
typedef void* (*il2cpp_domain_get_t)();
typedef void** (*il2cpp_domain_get_assemblies_t)(void* domain, std::size_t* size);
typedef void* (*il2cpp_domain_assembly_open_t)(void* domain, const char* name);
typedef void* (*il2cpp_assembly_get_image_t)(void* assembly);
typedef Il2CppClass* (*il2cpp_class_from_name_t)(void* image, const char* namespaze, const char* name);
typedef MethodInfo* (*il2cpp_class_get_methods_t)(Il2CppClass* klass, void** iter);
typedef MethodInfo* (*il2cpp_class_get_method_from_name_t)(Il2CppClass* klass, const char* name, int argsCount);
typedef MethodInfo* (*il2cpp_method_get_from_reflection_t)(Il2CppObject* ref);
typedef const Il2CppType* (*il2cpp_method_get_param_t)(const MethodInfo* method, uint32_t index);
typedef Il2CppObject* (*il2cpp_object_new_t)(Il2CppClass* klass);
typedef void (*il2cpp_add_internal_call_t)(const char* name, uintptr_t pointer);
typedef void* (*il2cpp_resolve_icall_t)(const char* name);
typedef Il2CppArraySize* (*il2cpp_array_new_t)(Il2CppClass* klass, uintptr_t count);
typedef void* (*il2cpp_thread_attach_t)(void* domain);
typedef void (*il2cpp_thread_detach_t)(void* thread);
typedef const Il2CppType* (*il2cpp_class_get_type_t)(Il2CppClass* klass);
typedef uint32_t(*il2cpp_class_get_type_token_t)(Il2CppClass* klass);
typedef FieldInfo* (*il2cpp_class_get_field_from_name_t)(Il2CppClass* klass, const char* name);
typedef void (*il2cpp_field_get_value_t)(Il2CppObject* obj, FieldInfo* field, void* value);
typedef void (*il2cpp_field_set_value_t)(Il2CppObject* obj, FieldInfo* field, void* value);
typedef void (*il2cpp_field_static_get_value_t)(FieldInfo* field, void* value);
typedef void (*il2cpp_field_static_set_value_t)(FieldInfo* field, void* value);
typedef const Il2CppType* (*il2cpp_field_get_type_t)(FieldInfo* field);
typedef Il2CppObject* (*il2cpp_type_get_object_t)(const Il2CppType* type);
typedef const char* (*il2cpp_image_get_name_t)(void* image);
typedef size_t(*il2cpp_image_get_class_count_t)(void* image);
typedef const Il2CppClass* (*il2cpp_image_get_class_t)(void* image, size_t index);
typedef bool (*il2cpp_type_is_byref_t)(const Il2CppType* type);
typedef uint32_t(*il2cpp_method_get_flags_t)(const MethodInfo* mehod, uint32_t* iflags);
typedef const Il2CppType* (*il2cpp_method_get_return_type_t)(const MethodInfo* method);
typedef Il2CppClass* (*il2cpp_class_from_type_t)(const Il2CppType* type);
typedef const char* (*il2cpp_class_get_name_t)(Il2CppClass* klass);
typedef const PropertyInfo* (*il2cpp_class_get_properties_t)(Il2CppClass* klass, void** iter);
typedef bool (*il2cpp_class_is_enum_t)(const Il2CppClass* klass);
typedef FieldInfo* (*il2cpp_class_get_fields_t)(Il2CppClass* klass, void** iter);
typedef const char* (*il2cpp_method_get_name_t)(const MethodInfo* method);
typedef uint32_t(*il2cpp_method_get_param_count_t)(const MethodInfo* method);
typedef const char* (*il2cpp_method_get_param_name_t)(const MethodInfo* method, uint32_t index);
typedef Il2CppClass* (*il2cpp_class_get_parent_t)(Il2CppClass* klass);
typedef Il2CppClass* (*il2cpp_class_get_interfaces_t)(Il2CppClass* klass, void** iter);
typedef const char* (*il2cpp_class_get_namespace_t)(Il2CppClass* klass);
typedef void* (*il2cpp_class_get_image_t)(Il2CppClass* klass);
typedef int (*il2cpp_class_get_flags_t)(const Il2CppClass* klass);
typedef bool (*il2cpp_class_is_valuetype_t)(const Il2CppClass* klass);
typedef uint32_t(*il2cpp_property_get_flags_t) (PropertyInfo* prop);
typedef const MethodInfo* (*il2cpp_property_get_get_method_t) (const PropertyInfo* prop);
typedef const MethodInfo* (*il2cpp_property_get_set_method_t) (const PropertyInfo* prop);
typedef const char* (*il2cpp_property_get_name_t) (const PropertyInfo* prop);
typedef Il2CppClass* (*il2cpp_property_get_parent_t) (const PropertyInfo* prop);
typedef int (*il2cpp_field_get_flags_t)(FieldInfo* field);
typedef const char* (*il2cpp_field_get_name_t)(FieldInfo* field);
typedef Il2CppClass* (*il2cpp_field_get_parent_t)(FieldInfo* field);
typedef size_t (*il2cpp_field_get_offset_t)(FieldInfo* field);
typedef const PropertyInfo* (*il2cpp_class_get_property_from_name_t)(Il2CppClass* klass, const char* name);
typedef void (*il2cpp_runtime_object_init_t)(Il2CppObject* obj);
typedef Il2CppObject* (*il2cpp_value_box_t)(Il2CppClass* klass, void* data);
typedef void* (*il2cpp_object_unbox_t)(Il2CppObject* obj);
char* il2cpp_array_addr_with_size(void* arr, int32_t size, uintptr_t idx);
// array macro
#define il2cpp_array_addr(array, type, index) ((type*)(void*) il2cpp_array_addr_with_size (array, sizeof (type), index))
#define il2cpp_array_setref(array, index, value) \
do { \
void* *__p = (void* *) il2cpp_array_addr ((array), void*, (index)); \
*__p = (value); \
} while (0)
namespace il2cpp_symbols
{
inline void* il2cpp_domain = nullptr;
void init(HMODULE game_module);
uintptr_t get_method_pointer(const char* assemblyName, const char* namespaze,
const char* klassName, const char* name, int argsCount,bool strict);
Il2CppClass* get_class(const char* assemblyName, const char* namespaze, const char* klassName);
MethodInfo* get_method(const char* assemblyName, const char* namespaze,
const char* klassName, const char* name, int argsCount);
Il2CppClass* find_class(const char* assemblyName, const char* namespaze, std::function<bool(Il2CppClass*)> predict);
uintptr_t find_method(const char* assemblyName, const char* namespaze,
const char* klassName, std::function<bool(const MethodInfo*)> predict);
}
// UnityEngine.Quaternion
struct Quaternion_t
@ -612,36 +522,81 @@ struct Il2CppReflectionType
};
// function types
typedef Il2CppString* (*il2cpp_string_new_utf16_t)(const wchar_t* str, unsigned int len);
typedef Il2CppString* (*il2cpp_string_new_t)(const char* str);
typedef void* (*il2cpp_domain_get_t)();
typedef void* (*il2cpp_domain_assembly_open_t)(void* domain, const char* name);
typedef void* (*il2cpp_assembly_get_image_t)(void* assembly);
inline void** (*il2cpp_domain_get_assemblies)(void* domain, std::size_t* size);
inline Il2CppClass* (*il2cpp_class_from_name)(void* image, const char* namespaze, const char* name);
inline MethodInfo* (*il2cpp_class_get_methods)(Il2CppClass* klass, void** iter);
inline MethodInfo* (*il2cpp_class_get_method_from_name)(Il2CppClass* klass, const char* name, int argsCount);
inline MethodInfo* (*il2cpp_method_get_from_reflection)(Il2CppObject* ref);
inline const Il2CppType* (*il2cpp_method_get_param)(const MethodInfo* method, uint32_t index);
inline Il2CppObject* (*il2cpp_object_new)(Il2CppClass* klass);
inline void (*il2cpp_add_internal_call)(const char* name, uintptr_t pointer);
inline Il2CppArraySize* (*il2cpp_array_new)(Il2CppClass* klass, uintptr_t count);
inline const Il2CppType* (*il2cpp_class_get_type)(Il2CppClass* klass);
inline uint32_t(*il2cpp_class_get_type_token)(Il2CppClass* klass);
inline FieldInfo* (*il2cpp_class_get_field_from_name)(Il2CppClass* klass, const char* name);
inline void (*il2cpp_field_get_value)(Il2CppObject* obj, FieldInfo* field, void* value);
inline void (*il2cpp_field_set_value)(Il2CppObject* obj, FieldInfo* field, void* value);
inline void (*il2cpp_field_static_get_value)(FieldInfo* field, void* value);
inline void (*il2cpp_field_static_set_value)(FieldInfo* field, void* value);
inline const Il2CppType* (*il2cpp_field_get_type)(FieldInfo* field);
inline Il2CppObject* (*il2cpp_type_get_object)(const Il2CppType* type);
inline const char* (*il2cpp_image_get_name)(void* image);
inline size_t(*il2cpp_image_get_class_count)(void* image);
inline const Il2CppClass* (*il2cpp_image_get_class)(void* image, size_t index);
inline bool (*il2cpp_type_is_byref)(const Il2CppType* type);
inline uint32_t(*il2cpp_method_get_flags)(const MethodInfo* mehod, uint32_t* iflags);
inline const Il2CppType* (*il2cpp_method_get_return_type)(const MethodInfo* method);
inline Il2CppClass* (*il2cpp_class_from_type)(const Il2CppType* type);
inline const char* (*il2cpp_class_get_name)(Il2CppClass* klass);
inline const PropertyInfo* (*il2cpp_class_get_properties)(Il2CppClass* klass, void** iter);
inline bool (*il2cpp_class_is_enum)(const Il2CppClass* klass);
inline FieldInfo* (*il2cpp_class_get_fields)(Il2CppClass* klass, void** iter);
inline const char* (*il2cpp_method_get_name)(const MethodInfo* method);
inline uint32_t(*il2cpp_method_get_param_count)(const MethodInfo* method);
inline const char* (*il2cpp_method_get_param_name)(const MethodInfo* method, uint32_t index);
inline Il2CppClass* (*il2cpp_class_get_parent)(Il2CppClass* klass);
inline Il2CppClass* (*il2cpp_class_get_interfaces)(Il2CppClass* klass, void** iter);
inline const char* (*il2cpp_class_get_namespace)(Il2CppClass* klass);
inline void* (*il2cpp_class_get_image)(Il2CppClass* klass);
inline int (*il2cpp_class_get_flags)(const Il2CppClass* klass);
inline bool (*il2cpp_class_is_valuetype)(const Il2CppClass* klass);
inline uint32_t(*il2cpp_property_get_flags) (PropertyInfo* prop);
inline const MethodInfo* (*il2cpp_property_get_get_method) (const PropertyInfo* prop);
inline const MethodInfo* (*il2cpp_property_get_set_method) (const PropertyInfo* prop);
inline const char* (*il2cpp_property_get_name) (const PropertyInfo* prop);
inline Il2CppClass* (*il2cpp_property_get_parent) (const PropertyInfo* prop);
inline int (*il2cpp_field_get_flags)(FieldInfo* field);
inline const char* (*il2cpp_field_get_name)(FieldInfo* field);
inline Il2CppClass* (*il2cpp_field_get_parent)(FieldInfo* field);
inline size_t (*il2cpp_field_get_offset)(FieldInfo* field);
inline const PropertyInfo* (*il2cpp_class_get_property_from_name)(Il2CppClass* klass, const char* name);
inline void (*il2cpp_runtime_object_init)(Il2CppObject* obj);
inline Il2CppObject* (*il2cpp_value_box)(Il2CppClass* klass, void* data);
inline void* (*il2cpp_object_unbox)(Il2CppObject* obj);
inline Il2CppString* (*il2cpp_string_new_utf16)(const wchar_t* str, unsigned int len);
inline Il2CppString* (*il2cpp_string_new)(const char* str);
inline void* (*il2cpp_domain_get)();
inline void* (*il2cpp_domain_assembly_open)(void* domain, const char* name);
inline void* (*il2cpp_assembly_get_image)(void* assembly);
inline void* (*il2cpp_resolve_icall)(const char* name);
inline void* (*il2cpp_thread_attach)(void* domain);
inline void (*il2cpp_thread_detach)(void* thread);
inline bool (*il2cpp_class_is_assignable_from)(void* klass, void* oklass);
inline void (*il2cpp_class_for_each)(void(*klassReportFunc)(Il2CppClass* klass, void* userData), void* userData);
inline void* (*il2cpp_class_get_nested_types)(void* klass, void** iter);
inline uint32_t(*il2cpp_gchandle_new)(void* obj, bool pinned);
inline void (*il2cpp_gchandle_free)(uint32_t gchandle);
inline void* (*il2cpp_gchandle_get_target)(uint32_t gchandle);
inline void (*il2cpp_runtime_class_init)(void* klass);
inline void* (*il2cpp_runtime_invoke)(MethodInfo* method, void* obj, void** params, Il2CppObject** exc);
inline Il2CppChar* (*il2cpp_string_chars)(Il2CppString* str);
inline int (*il2cpp_string_length)(Il2CppString* str);
typedef void* (*il2cpp_resolve_icall_t)(const char* name);
typedef void* (*il2cpp_thread_attach_t)(void* domain);
typedef void (*il2cpp_thread_detach_t)(void* thread);
typedef bool (*il2cpp_class_is_assignable_from_t)(void* klass, void* oklass);
typedef void (*il2cpp_class_for_each_t)(void(*klassReportFunc)(Il2CppClass* klass, void* userData), void* userData);
typedef void* (*il2cpp_class_get_nested_types_t)(void* klass, void** iter);
typedef uint32_t(*il2cpp_gchandle_new_t)(void* obj, bool pinned);
typedef void (*il2cpp_gchandle_free_t)(uint32_t gchandle);
typedef void* (*il2cpp_gchandle_get_target_t)(uint32_t gchandle);
typedef void (*il2cpp_runtime_class_init_t)(void* klass);
typedef void* (*il2cpp_runtime_invoke_t)(MethodInfo* method, void* obj, void** params, Il2CppObject** exc);
char* il2cpp_array_addr_with_size(void* arr, int32_t size, uintptr_t idx);
// array macro
#define il2cpp_array_addr(array, type, index) ((type*)(void*) il2cpp_array_addr_with_size (array, sizeof (type), index))
namespace il2cppfunctions{
void init(HMODULE dll);
uintptr_t get_method_pointer(const char* assemblyName, const char* namespaze,
const char* klassName, const char* name, int argsCount,bool strict);
std::optional<std::wstring_view> get_string(void*);
void* create_string(std::wstring_view ws);
}

View File

@ -28,7 +28,7 @@ struct MonoReflectionAssembly;
struct MonoReflectionMethod;
struct MonoAppDomain;
struct MonoCustomAttrInfo;
struct MonoTableInfo;
struct MonoReflectionType { UInt32 offset[2]; MonoType* type;};
typedef void* gconstpointer;
@ -171,236 +171,246 @@ typedef void (*MonoProfileExceptionClauseFunc) (MonoProfiler *prof, MonoMethod *
typedef void (*MonoProfileThreadFunc) (MonoProfiler *prof, uint32_t tid);
typedef void (*mono_thread_suspend_all_other_threads_t)();
typedef void (*mono_thread_pool_cleanup_t)();
typedef void (*mono_threads_set_shutting_down_t)();
typedef void (*mono_runtime_set_shutting_down_t)();
typedef gboolean (*mono_domain_finalize_t)(MonoDomain *domain, int timeout);
typedef void (*mono_runtime_cleanup_t)(MonoDomain *domain);
typedef MonoMethodDesc *(*mono_method_desc_new_t)(const char *name, gboolean include_namespace);
typedef MonoMethod *(*mono_method_desc_search_in_image_t)(MonoMethodDesc *desc, MonoImage *image);
typedef void (*mono_verifier_set_mode_t)(MiniVerifierMode m);
typedef void (*mono_security_set_mode_t)(MonoSecurityMode m);
typedef void (*mono_add_internal_call_t)(const char *name, gconstpointer method);
typedef void (*mono_jit_cleanup_t)(MonoDomain *domain);
typedef MonoDomain *(*mono_jit_init_t)(const char *file);
typedef MonoDomain *(*mono_jit_init_version_t)(const char *file, const char *runtime_version);
typedef int (*mono_jit_exec_t)(MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[]);
typedef MonoClass *(*mono_class_from_name_t)(MonoImage *image, const char *name_space, const char *name);
typedef MonoAssembly *(*mono_domain_assembly_open_t)(MonoDomain *domain, const char *name);
typedef MonoDomain *(*mono_domain_create_appdomain_t)(const char *domainname, const char *configfile);
typedef void (*mono_domain_unload_t)(MonoDomain *domain);
typedef MonoObject *(*mono_object_new_t)(MonoDomain *domain, MonoClass *klass);
typedef void (*mono_runtime_object_init_t)(MonoObject *this_obj);
typedef MonoObject *(*mono_runtime_invoke_t)(MonoMethod *method, void *obj, void **params, MonoObject **exc);
typedef void (*mono_field_set_value_t)(MonoObject *obj, MonoClassField *field, void *value);
typedef void (*mono_field_get_value_t)(MonoObject *obj, MonoClassField *field, void *value);
typedef int (*mono_field_get_offset_t)(MonoClassField *field);
typedef MonoClassField *(*mono_class_get_fields_t)(MonoClass *klass, gpointer *iter);
typedef MonoMethod *(*mono_class_get_methods_t)(MonoClass *klass, gpointer *iter);
typedef MonoDomain *(*mono_domain_get_t)();
typedef MonoDomain *(*mono_get_root_domain_t)();
typedef gint32 (*mono_domain_get_id_t)(MonoDomain *domain);
typedef void (*mono_assembly_foreach_t)(GFunc func, gpointer user_data);
typedef void (*mono_image_close_t)(MonoImage *image);
typedef void (*mono_unity_socket_security_enabled_set_t)(gboolean b);
typedef const char *(*mono_image_get_name_t)(MonoImage *image);
typedef MonoClass *(*mono_get_object_class_t)();
typedef void (*mono_set_commandline_arguments_t)(int i, const char *argv[], const char *s);
typedef const char *(*mono_field_get_name_t)(MonoClassField *field);
typedef MonoType *(*mono_field_get_type_t)(MonoClassField *field);
typedef int (*mono_type_get_type_t)(MonoType *type);
typedef const char *(*mono_method_get_name_t)(MonoMethod *method);
typedef MonoImage *(*mono_assembly_get_image_t)(MonoAssembly *assembly);
typedef MonoClass *(*mono_method_get_class_t)(MonoMethod *method);
typedef MonoClass *(*mono_object_get_class_t)(MonoObject *obj);
typedef gboolean (*mono_class_is_valuetype_t)(MonoClass *klass);
typedef guint32 (*mono_signature_get_param_count_t)(MonoMethodSignature *sig);
typedef char *(*mono_string_to_utf8_t)(MonoString *string_obj);
typedef MonoString *(*mono_string_new_wrapper_t)(const char *text);
typedef MonoClass *(*mono_class_get_parent_t)(MonoClass *klass);
typedef const char *(*mono_class_get_namespace_t)(MonoClass *klass);
typedef gboolean (*mono_class_is_subclass_of_t)(MonoClass *klass, MonoClass *klassc, gboolean check_interfaces);
typedef const char *(*mono_class_get_name_t)(MonoClass *klass);
typedef char *(*mono_type_get_name_t)(MonoType *type);
typedef MonoClass *(*mono_type_get_class_t)(MonoType *type);
typedef MonoException *(*mono_exception_from_name_msg_t)(MonoImage *image, const char *name_space, const char *name, const char *msg);
typedef void (*mono_raise_exception_t)(MonoException *ex);
typedef MonoClass *(*mono_get_exception_class_t)();
typedef MonoClass *(*mono_get_array_class_t)();
typedef MonoClass *(*mono_get_string_class_t)();
typedef MonoClass *(*mono_get_int32_class_t)();
typedef MonoArray *(*mono_array_new_t)(MonoDomain *domain, MonoClass *eclass, guint32 n);
typedef MonoArray *(*mono_array_new_full_t)(MonoDomain *domain, MonoClass *array_class, guint32 *lengths, guint32 *lower_bounds);
typedef MonoClass *(*mono_array_class_get_t)(MonoClass *eclass, guint32 rank);
typedef gint32 (*mono_class_array_element_size_t)(MonoClass *ac);
typedef MonoObject *(*mono_type_get_object_t)(MonoDomain *domain, MonoType *type);
typedef MonoThread *(*mono_thread_attach_t)(MonoDomain *domain);
typedef void (*mono_thread_detach_t)(MonoThread *thread);
typedef MonoThread *(*mono_thread_exit_t)();
typedef MonoThread *(*mono_thread_current_t)();
typedef void (*mono_thread_set_main_t)(MonoThread *thread);
typedef void (*mono_set_find_plugin_callback_t)(gconstpointer method);
typedef void (*mono_security_enable_core_clr_t)();
typedef bool (*mono_security_set_core_clr_platform_callback_t)(MonoCoreClrPlatformCB a);
typedef MonoRuntimeUnhandledExceptionPolicy (*mono_runtime_unhandled_exception_policy_get_t)();
typedef void (*mono_runtime_unhandled_exception_policy_set_t)(MonoRuntimeUnhandledExceptionPolicy policy);
typedef MonoClass *(*mono_class_get_nesting_type_t)(MonoClass *klass);
typedef MonoVTable *(*mono_class_vtable_t)(MonoDomain *domain, MonoClass *klass);
typedef MonoReflectionMethod *(*mono_method_get_object_t)(MonoDomain *domain, MonoMethod *method, MonoClass *refclass);
typedef MonoMethodSignature *(*mono_method_signature_t)(MonoMethod *method);
typedef MonoType *(*mono_signature_get_params_t)(MonoMethodSignature *sig, gpointer *iter);
typedef MonoType *(*mono_signature_get_return_type_t)(MonoMethodSignature *sig);
typedef MonoType *(*mono_class_get_type_t)(MonoClass *klass);
typedef void (*mono_set_ignore_version_and_key_when_finding_assemblies_already_loaded_t)(gboolean value);
typedef void (*mono_debug_init_t)(int format);
typedef void (*mono_debug_open_image_from_memory_t)(MonoImage *image, const char *raw_contents, int size);
typedef guint32 (*mono_field_get_flags_t)(MonoClassField *field);
typedef MonoImage *(*mono_image_open_from_data_full_t)(const void *data, guint32 data_len, gboolean need_copy, int *status, gboolean ref_only);
typedef MonoImage *(*mono_image_open_from_data_with_name_t)(char *data, guint32 data_len, gboolean need_copy, int *status, gboolean refonly, const char *name);
typedef MonoAssembly *(*mono_assembly_load_from_t)(MonoImage *image, const char *fname, int *status);
typedef MonoObject *(*mono_value_box_t)(MonoDomain *domain, MonoClass *klass, gpointer val);
typedef MonoImage *(*mono_class_get_image_t)(MonoClass *klass);
typedef char (*mono_signature_is_instance_t)(MonoMethodSignature *signature);
typedef MonoMethod *(*mono_method_get_last_managed_t)();
typedef MonoClass *(*mono_get_enum_class_t)();
typedef MonoType *(*mono_class_get_byref_type_t)(MonoClass *klass);
typedef void (*mono_field_static_get_value_t)(MonoVTable *vt, MonoClassField *field, void *value);
typedef void (*mono_unity_set_embeddinghostname_t)(const char *name);
typedef void (*mono_set_assemblies_path_t)(const char *name);
typedef guint32 (*mono_gchandle_new_t)(MonoObject *obj, gboolean pinned);
typedef MonoObject *(*mono_gchandle_get_target_t)(guint32 gchandle);
typedef guint32 (*mono_gchandle_new_weakref_t)(MonoObject *obj, gboolean track_resurrection);
typedef MonoObject *(*mono_assembly_get_object_t)(MonoDomain *domain, MonoAssembly *assembly);
typedef void (*mono_gchandle_free_t)(guint32 gchandle);
typedef MonoProperty *(*mono_class_get_properties_t)(MonoClass *klass, gpointer *iter);
typedef MonoMethod *(*mono_property_get_get_method_t)(MonoProperty *prop);
typedef MonoObject *(*mono_object_new_alloc_specific_t)(MonoVTable *vtable);
typedef MonoObject *(*mono_object_new_specific_t)(MonoVTable *vtable);
typedef void (*mono_gc_collect_t)(int generation);
typedef int (*mono_gc_max_generation_t)();
typedef MonoAssembly *(*mono_image_get_assembly_t)(MonoImage *image);
typedef MonoAssembly *(*mono_assembly_open_t)(const char *filename, int *status);
typedef gboolean (*mono_class_is_enum_t)(MonoClass *klass);
typedef gint32 (*mono_class_instance_size_t)(MonoClass *klass);
typedef guint32 (*mono_object_get_size_t)(MonoObject *obj);
typedef const char *(*mono_image_get_filename_t)(MonoImage *image);
typedef MonoAssembly *(*mono_assembly_load_from_full_t)(MonoImage *image, const char *fname, int *status, gboolean refonly);
typedef MonoClass *(*mono_class_get_interfaces_t)(MonoClass *klass, gpointer *iter);
typedef void (*mono_assembly_close_t)(MonoAssembly *assembly);
typedef MonoProperty *(*mono_class_get_property_from_name_t)(MonoClass *klass, const char *name);
typedef MonoMethod *(*mono_class_get_method_from_name_t)(MonoClass *klass, const char *name, int param_count);
typedef MonoClass *(*mono_class_from_mono_type_t)(MonoType *image);
typedef gboolean (*mono_domain_set_t)(MonoDomain *domain, gboolean force);
typedef void (*mono_thread_push_appdomain_ref_t)(MonoDomain *domain);
typedef void (*mono_thread_pop_appdomain_ref_t)();
typedef int (*mono_runtime_exec_main_t)(MonoMethod *method, MonoArray *args, MonoObject **exc);
typedef MonoImage *(*mono_get_corlib_t)();
typedef MonoClassField *(*mono_class_get_field_from_name_t)(MonoClass *klass, const char *name);
typedef guint32 (*mono_class_get_flags_t)(MonoClass *klass);
typedef int (*mono_parse_default_optimizations_t)(const char *p);
typedef void (*mono_set_defaults_t)(int verbose_level, guint32 opts);
typedef void (*mono_set_dirs_t)(const char *assembly_dir, const char *config_dir);
typedef void (*mono_jit_parse_options_t)(int argc, char *argv[]);
typedef gpointer (*mono_object_unbox_t)(MonoObject *o);
typedef MonoObject *(*mono_custom_attrs_get_attr_t)(MonoCustomAttrInfo *ainfo, MonoClass *attr_klass);
typedef gboolean (*mono_custom_attrs_has_attr_t)(MonoCustomAttrInfo *ainfo, MonoClass *attr_klass);
typedef MonoCustomAttrInfo *(*mono_custom_attrs_from_field_t)(MonoClass *klass, MonoClassField *field);
typedef MonoCustomAttrInfo *(*mono_custom_attrs_from_method_t)(MonoMethod *method);
typedef MonoCustomAttrInfo *(*mono_custom_attrs_from_class_t)(MonoClass *klass);
typedef void (*mono_custom_attrs_free_t)(MonoCustomAttrInfo *attr);
typedef void (*g_free_t)(void *p);
typedef gboolean (*mono_runtime_is_shutting_down_t)();
typedef MonoMethod *(*mono_object_get_virtual_method_t)(MonoObject *obj, MonoMethod *method);
typedef gpointer (*mono_jit_info_get_code_start_t)(MonoJitInfo *ji);
typedef int (*mono_jit_info_get_code_size_t)(MonoJitInfo *ji);
typedef MonoClass *(*mono_class_from_name_case_t)(MonoImage *image, const char *name_space, const char *name);
typedef MonoClass *(*mono_class_get_nested_types_t)(MonoClass *klass, gpointer *iter);
typedef int (*mono_class_get_userdata_offset_t)();
typedef void *(*mono_class_get_userdata_t)(MonoClass *klass);
typedef void (*mono_class_set_userdata_t)(MonoClass *klass, void *userdata);
typedef void (*mono_set_signal_chaining_t)(gboolean chain_signals);
// typedef LONG( *mono_unity_seh_handler_t)(EXCEPTION_POINTERS* ep);
typedef void (*mono_unity_set_unhandled_exception_handler_t)(void *handler);
typedef MonoObject *(*mono_runtime_invoke_array_t)(MonoMethod *method, void *obj, MonoArray *params, MonoObject **exc);
typedef char *(*mono_array_addr_with_size_t)(MonoArray *array, int size, uintptr_t idx);
typedef gunichar2 *(*mono_string_to_utf16_t)(MonoString *string_obj);
typedef MonoClass *(*mono_field_get_parent_t)(MonoClassField *field);
typedef char *(*mono_method_full_name_t)(MonoMethod *method, gboolean signature);
typedef MonoObject *(*mono_object_isinst_t)(MonoObject *obj, MonoClass *klass);
typedef MonoString *(*mono_string_new_len_t)(MonoDomain *domain, const char *text, guint length);
typedef MonoString *(*mono_string_from_utf16_t)(gunichar2 *data);
typedef MonoException *(*mono_get_exception_argument_null_t)(const char *arg);
typedef MonoClass *(*mono_get_boolean_class_t)();
typedef MonoClass *(*mono_get_byte_class_t)();
typedef MonoClass *(*mono_get_char_class_t)();
typedef MonoClass *(*mono_get_int16_class_t)();
typedef MonoClass *(*mono_get_int64_class_t)();
typedef MonoClass *(*mono_get_single_class_t)();
typedef MonoClass *(*mono_get_double_class_t)();
typedef gboolean (*mono_class_is_generic_t)(MonoClass *klass);
typedef gboolean (*mono_class_is_inflated_t)(MonoClass *klass);
typedef gboolean (*unity_mono_method_is_generic_t)(MonoMethod *method);
typedef gboolean (*unity_mono_method_is_inflated_t)(MonoMethod *method);
typedef gboolean (*mono_is_debugger_attached_t)();
typedef gboolean (*mono_assembly_fill_assembly_name_t)(MonoImage *image, MonoAssemblyName *aname);
typedef char *(*mono_stringify_assembly_name_t)(MonoAssemblyName *aname);
typedef gboolean (*mono_assembly_name_parse_t)(const char *name, MonoAssemblyName *aname);
typedef MonoAssembly *(*mono_assembly_loaded_t)(MonoAssemblyName *aname);
typedef int (*mono_image_get_table_rows_t)(MonoImage *image, int table_id);
typedef MonoClass *(*mono_class_get_t)(MonoImage *image, guint32 type_token);
typedef gboolean (*mono_metadata_signature_equal_t)(MonoMethodSignature *sig1, MonoMethodSignature *sig2);
typedef gboolean (*mono_gchandle_is_in_domain_t)(guint32 gchandle, MonoDomain *domain);
typedef void (*mono_stack_walk_t)(MonoStackWalk func, gpointer user_data);
typedef char *(*mono_pmip_t)(void *ip);
typedef MonoObject *(*mono_runtime_delegate_invoke_t)(MonoObject *delegate, void **params, MonoObject **exc);
typedef MonoJitInfo *(*mono_jit_info_table_find_t)(MonoDomain *domain, char *addr);
typedef MonoDebugSourceLocation *(*mono_debug_lookup_source_location_t)(MonoMethod *method, guint32 address, MonoDomain *domain);
typedef void (*mono_debug_free_source_location_t)(MonoDebugSourceLocation *location);
typedef void (*mono_gc_wbarrier_generic_store_t)(gpointer ptr, MonoObject *value);
typedef MonoType *(*mono_class_enum_basetype_t)(MonoClass *klass);
typedef guint32 (*mono_class_get_type_token_t)(MonoClass *klass);
typedef int (*mono_class_get_rank_t)(MonoClass *klass);
typedef MonoClass *(*mono_class_get_element_class_t)(MonoClass *klass);
typedef gboolean (*mono_unity_class_is_interface_t)(MonoClass *klass);
typedef gboolean (*mono_unity_class_is_abstract_t)(MonoClass *klass);
typedef gint32 (*mono_array_element_size_t)(MonoClass *ac);
typedef void (*mono_config_parse_t)(const char *filename);
typedef void (*mono_set_break_policy_t)(MonoBreakPolicyFunc policy_callback);
typedef MonoArray *(*mono_custom_attrs_construct_t)(MonoCustomAttrInfo *cinfo);
typedef MonoCustomAttrInfo *(*mono_custom_attrs_from_assembly_t)(MonoAssembly *assembly);
typedef MonoArray *(*mono_reflection_get_custom_attrs_by_type_t)(MonoObject *obj, MonoClass *attr_klass);
typedef MonoLoaderError *(*mono_loader_get_last_error_t)();
typedef MonoException *(*mono_loader_error_prepare_exception_t)(MonoLoaderError *error);
typedef MonoDlFallbackHandler *(*mono_dl_fallback_register_t)(MonoDlFallbackLoad load_func, MonoDlFallbackSymbol symbol_func, MonoDlFallbackClose close_func, void *user_data);
typedef void (*mono_dl_fallback_unregister_t)(MonoDlFallbackHandler *handler);
typedef LivenessState *(*mono_unity_liveness_allocate_struct_t)(MonoClass *filter, guint max_count, register_object_callback callback, void *callback_userdata);
typedef void (*mono_unity_liveness_stop_gc_world_t)();
typedef void (*mono_unity_liveness_finalize_t)(LivenessState *state);
typedef void (*mono_unity_liveness_start_gc_world_t)();
typedef void (*mono_unity_liveness_free_struct_t)(LivenessState *state);
typedef LivenessState *(*mono_unity_liveness_calculation_begin_t)(MonoClass *filter, guint max_count, register_object_callback callback, void *callback_userdata);
typedef void (*mono_unity_liveness_calculation_end_t)(LivenessState *state);
typedef void (*mono_unity_liveness_calculation_from_root_t)(MonoObject *root, LivenessState *state);
typedef void (*mono_unity_liveness_calculation_from_statics_t)(LivenessState *state);
typedef void (*mono_trace_set_level_string_t)(const char *value);
typedef void (*mono_trace_set_mask_string_t)(char *value);
typedef gint64 (*mono_gc_get_used_size_t)();
typedef gint64 (*mono_gc_get_heap_size_t)();
typedef MonoMethod *(*mono_method_desc_search_in_class_t)(MonoMethodDesc *desc, MonoClass *klass);
typedef void (*mono_method_desc_free_t)(MonoMethodDesc *desc);
typedef char *(*mono_type_get_name_full_t)(MonoType *type, MonoTypeNameFormat format);
typedef void (*mono_unity_thread_clear_domain_fields_t)();
// typedef void( *mono_unity_set_vprintf_func_t)(vprintf_func func);
typedef void (*mono_profiler_install_t)(MonoProfiler *prof, MonoProfileFunc shutdown_callback);
typedef void (*mono_profiler_set_events_t)(MonoProfileFlags events);
typedef void (*mono_profiler_install_enter_leave_t)(MonoProfileMethodFunc enter, MonoProfileMethodFunc fleave);
typedef void (*mono_profiler_install_gc_t)(MonoProfileGCFunc callback, MonoProfileGCResizeFunc heap_resize_callback);
typedef void (*mono_profiler_install_allocation_t)(MonoProfileAllocFunc callback);
typedef void (*mono_profiler_install_jit_end_t)(MonoProfileJitResult end);
typedef void (*mono_profiler_install_exception_t)(MonoProfileExceptionFunc throw_callback, MonoProfileMethodFunc exc_method_leave, MonoProfileExceptionClauseFunc clause_callback);
typedef void (*mono_profiler_install_thread_t)(MonoProfileThreadFunc start, MonoProfileThreadFunc end);
typedef uint64_t* (*mono_compile_method_t)(uintptr_t);
inline void (*mono_thread_suspend_all_other_threads)();
inline void (*mono_thread_pool_cleanup)();
inline void (*mono_threads_set_shutting_down)();
inline void (*mono_runtime_set_shutting_down)();
inline gboolean (*mono_domain_finalize)(MonoDomain *domain, int timeout);
inline void (*mono_runtime_cleanup)(MonoDomain *domain);
inline MonoMethodDesc *(*mono_method_desc_new)(const char *name, gboolean include_namespace);
inline MonoMethod *(*mono_method_desc_search_in_image)(MonoMethodDesc *desc, MonoImage *image);
inline void (*mono_verifier_set_mode)(MiniVerifierMode m);
inline void (*mono_security_set_mode)(MonoSecurityMode m);
inline void (*mono_add_internal_call)(const char *name, gconstpointer method);
inline void (*mono_jit_cleanup)(MonoDomain *domain);
inline MonoDomain *(*mono_jit_init)(const char *file);
inline MonoDomain *(*mono_jit_init_version)(const char *file, const char *runtime_version);
inline int (*mono_jit_exec)(MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[]);
inline MonoClass *(*mono_class_from_name)(MonoImage *image, const char *name_space, const char *name);
inline MonoAssembly *(*mono_domain_assembly_open)(MonoDomain *domain, const char *name);
inline MonoDomain *(*mono_domain_create_appdomain)(const char *domainname, const char *configfile);
inline void (*mono_domain_unload)(MonoDomain *domain);
inline MonoObject *(*mono_object_new)(MonoDomain *domain, MonoClass *klass);
inline void (*mono_runtime_object_init)(MonoObject *this_obj);
inline MonoObject *(*mono_runtime_invoke)(MonoMethod *method, void *obj, void **params, MonoObject **exc);
inline void (*mono_field_set_value)(MonoObject *obj, MonoClassField *field, void *value);
inline void (*mono_field_get_value)(MonoObject *obj, MonoClassField *field, void *value);
inline int (*mono_field_get_offset)(MonoClassField *field);
inline MonoClassField *(*mono_class_get_fields)(MonoClass *klass, gpointer *iter);
inline MonoMethod *(*mono_class_get_methods)(MonoClass *klass, gpointer *iter);
inline MonoDomain *(*mono_domain_get)();
inline MonoDomain *(*mono_get_root_domain)();
inline gint32 (*mono_domain_get_id)(MonoDomain *domain);
inline void (*mono_assembly_foreach)(GFunc func, gpointer user_data);
inline void (*mono_image_close)(MonoImage *image);
inline void (*mono_unity_socket_security_enabled_set)(gboolean b);
inline const char *(*mono_image_get_name)(MonoImage *image);
inline MonoClass *(*mono_get_object_class)();
inline void (*mono_set_commandline_arguments)(int i, const char *argv[], const char *s);
inline const char *(*mono_field_get_name)(MonoClassField *field);
inline MonoType *(*mono_field_get_type)(MonoClassField *field);
inline int (*mono_type_get_type)(MonoType *type);
inline const char *(*mono_method_get_name)(MonoMethod *method);
inline MonoImage *(*mono_assembly_get_image)(MonoAssembly *assembly);
inline MonoClass *(*mono_method_get_class)(MonoMethod *method);
inline MonoClass *(*mono_object_get_class)(MonoObject *obj);
inline gboolean (*mono_class_is_valuetype)(MonoClass *klass);
inline guint32 (*mono_signature_get_param_count)(MonoMethodSignature *sig);
inline char *(*mono_string_to_utf8)(MonoString *string_obj);
inline MonoString *(*mono_string_new_wrapper)(const char *text);
inline MonoClass *(*mono_class_get_parent)(MonoClass *klass);
inline const char *(*mono_class_get_namespace)(MonoClass *klass);
inline gboolean (*mono_class_is_subclass_of)(MonoClass *klass, MonoClass *klassc, gboolean check_interfaces);
inline const char *(*mono_class_get_name)(MonoClass *klass);
inline char *(*mono_type_get_name)(MonoType *type);
inline MonoClass *(*mono_type_get_class)(MonoType *type);
inline MonoException *(*mono_exception_from_name_msg)(MonoImage *image, const char *name_space, const char *name, const char *msg);
inline void (*mono_raise_exception)(MonoException *ex);
inline MonoClass *(*mono_get_exception_class)();
inline MonoClass *(*mono_get_array_class)();
inline MonoClass *(*mono_get_string_class)();
inline MonoClass *(*mono_get_int32_class)();
inline MonoArray *(*mono_array_new)(MonoDomain *domain, MonoClass *eclass, guint32 n);
inline MonoArray *(*mono_array_new_full)(MonoDomain *domain, MonoClass *array_class, guint32 *lengths, guint32 *lower_bounds);
inline MonoClass *(*mono_array_class_get)(MonoClass *eclass, guint32 rank);
inline gint32 (*mono_class_array_element_size)(MonoClass *ac);
inline MonoObject *(*mono_type_get_object)(MonoDomain *domain, MonoType *type);
inline MonoThread *(*mono_thread_attach)(MonoDomain *domain);
inline void (*mono_thread_detach)(MonoThread *thread);
inline MonoThread *(*mono_thread_exit)();
inline MonoThread *(*mono_thread_current)();
inline void (*mono_thread_set_main)(MonoThread *thread);
inline void (*mono_set_find_plugin_callback)(gconstpointer method);
inline void (*mono_security_enable_core_clr)();
inline bool (*mono_security_set_core_clr_platform_callback)(MonoCoreClrPlatformCB a);
inline MonoRuntimeUnhandledExceptionPolicy (*mono_runtime_unhandled_exception_policy_get)();
inline void (*mono_runtime_unhandled_exception_policy_set)(MonoRuntimeUnhandledExceptionPolicy policy);
inline MonoClass *(*mono_class_get_nesting_type)(MonoClass *klass);
inline MonoVTable *(*mono_class_vtable)(MonoDomain *domain, MonoClass *klass);
inline MonoReflectionMethod *(*mono_method_get_object)(MonoDomain *domain, MonoMethod *method, MonoClass *refclass);
inline MonoMethodSignature *(*mono_method_signature)(MonoMethod *method);
inline MonoType *(*mono_signature_get_params)(MonoMethodSignature *sig, gpointer *iter);
inline MonoType *(*mono_signature_get_return_type)(MonoMethodSignature *sig);
inline MonoType *(*mono_class_get_type)(MonoClass *klass);
inline void (*mono_set_ignore_version_and_key_when_finding_assemblies_already_loaded)(gboolean value);
inline void (*mono_debug_init)(int format);
inline void (*mono_debug_open_image_from_memory)(MonoImage *image, const char *raw_contents, int size);
inline guint32 (*mono_field_get_flags)(MonoClassField *field);
inline MonoImage *(*mono_image_open_from_data_full)(const void *data, guint32 data_len, gboolean need_copy, int *status, gboolean ref_only);
inline MonoImage *(*mono_image_open_from_data_with_name)(char *data, guint32 data_len, gboolean need_copy, int *status, gboolean refonly, const char *name);
inline MonoAssembly *(*mono_assembly_load_from)(MonoImage *image, const char *fname, int *status);
inline MonoObject *(*mono_value_box)(MonoDomain *domain, MonoClass *klass, gpointer val);
inline MonoImage *(*mono_class_get_image)(MonoClass *klass);
inline char (*mono_signature_is_instance)(MonoMethodSignature *signature);
inline MonoMethod *(*mono_method_get_last_managed)();
inline MonoClass *(*mono_get_enum_class)();
inline MonoType *(*mono_class_get_byref_type)(MonoClass *klass);
inline void (*mono_field_static_get_value)(MonoVTable *vt, MonoClassField *field, void *value);
inline void (*mono_unity_set_embeddinghostname)(const char *name);
inline void (*mono_set_assemblies_path)(const char *name);
inline guint32 (*mono_gchandle_new)(MonoObject *obj, gboolean pinned);
inline MonoObject *(*mono_gchandle_get_target)(guint32 gchandle);
inline guint32 (*mono_gchandle_new_weakref)(MonoObject *obj, gboolean track_resurrection);
inline MonoObject *(*mono_assembly_get_object)(MonoDomain *domain, MonoAssembly *assembly);
inline void (*mono_gchandle_free)(guint32 gchandle);
inline MonoProperty *(*mono_class_get_properties)(MonoClass *klass, gpointer *iter);
inline MonoMethod *(*mono_property_get_get_method)(MonoProperty *prop);
inline MonoObject *(*mono_object_new_alloc_specific)(MonoVTable *vtable);
inline MonoObject *(*mono_object_new_specific)(MonoVTable *vtable);
inline void (*mono_gc_collect)(int generation);
inline int (*mono_gc_max_generation)();
inline MonoAssembly *(*mono_image_get_assembly)(MonoImage *image);
inline MonoAssembly *(*mono_assembly_open)(const char *filename, int *status);
inline gboolean (*mono_class_is_enum)(MonoClass *klass);
inline gint32 (*mono_class_instance_size)(MonoClass *klass);
inline guint32 (*mono_object_get_size)(MonoObject *obj);
inline const char *(*mono_image_get_filename)(MonoImage *image);
inline MonoAssembly *(*mono_assembly_load_from_full)(MonoImage *image, const char *fname, int *status, gboolean refonly);
inline MonoClass *(*mono_class_get_interfaces)(MonoClass *klass, gpointer *iter);
inline void (*mono_assembly_close)(MonoAssembly *assembly);
inline MonoProperty *(*mono_class_get_property_from_name)(MonoClass *klass, const char *name);
inline MonoMethod *(*mono_class_get_method_from_name)(MonoClass *klass, const char *name, int param_count);
inline MonoClass *(*mono_class_from_mono_type)(MonoType *image);
inline gboolean (*mono_domain_set)(MonoDomain *domain, gboolean force);
inline void (*mono_thread_push_appdomain_ref)(MonoDomain *domain);
inline void (*mono_thread_pop_appdomain_ref)();
inline int (*mono_runtime_exec_main)(MonoMethod *method, MonoArray *args, MonoObject **exc);
inline MonoImage *(*mono_get_corlib)();
inline MonoClassField *(*mono_class_get_field_from_name)(MonoClass *klass, const char *name);
inline guint32 (*mono_class_get_flags)(MonoClass *klass);
inline int (*mono_parse_default_optimizations)(const char *p);
inline void (*mono_set_defaults)(int verbose_level, guint32 opts);
inline void (*mono_set_dirs)(const char *assembly_dir, const char *config_dir);
inline void (*mono_jit_parse_options)(int argc, char *argv[]);
inline gpointer (*mono_object_unbox)(MonoObject *o);
inline MonoObject *(*mono_custom_attrs_get_attr)(MonoCustomAttrInfo *ainfo, MonoClass *attr_klass);
inline gboolean (*mono_custom_attrs_has_attr)(MonoCustomAttrInfo *ainfo, MonoClass *attr_klass);
inline MonoCustomAttrInfo *(*mono_custom_attrs_from_field)(MonoClass *klass, MonoClassField *field);
inline MonoCustomAttrInfo *(*mono_custom_attrs_from_method)(MonoMethod *method);
inline MonoCustomAttrInfo *(*mono_custom_attrs_from_class)(MonoClass *klass);
inline void (*mono_custom_attrs_free)(MonoCustomAttrInfo *attr);
inline void (*g_free)(void *p);
inline gboolean (*mono_runtime_is_shutting_down)();
inline MonoMethod *(*mono_object_get_virtual_method)(MonoObject *obj, MonoMethod *method);
inline gpointer (*mono_jit_info_get_code_start)(MonoJitInfo *ji);
inline int (*mono_jit_info_get_code_size)(MonoJitInfo *ji);
inline MonoClass *(*mono_class_from_name_case)(MonoImage *image, const char *name_space, const char *name);
inline MonoClass *(*mono_class_get_nested_types)(MonoClass *klass, gpointer *iter);
inline int (*mono_class_get_userdata_offset)();
inline void *(*mono_class_get_userdata)(MonoClass *klass);
inline void (*mono_class_set_userdata)(MonoClass *klass, void *userdata);
inline void (*mono_set_signal_chaining)(gboolean chain_signals);
inline void (*mono_unity_set_unhandled_exception_handler)(void *handler);
inline MonoObject *(*mono_runtime_invoke_array)(MonoMethod *method, void *obj, MonoArray *params, MonoObject **exc);
inline char *(*mono_array_addr_with_size)(MonoArray *array, int size, uintptr_t idx);
inline gunichar2 *(*mono_string_to_utf16)(MonoString *string_obj);
inline MonoClass *(*mono_field_get_parent)(MonoClassField *field);
inline char *(*mono_method_full_name)(MonoMethod *method, gboolean signature);
inline MonoObject *(*mono_object_isinst)(MonoObject *obj, MonoClass *klass);
inline MonoString *(*mono_string_new_len)(MonoDomain *domain, const char *text, guint length);
inline MonoString *(*mono_string_from_utf16)(gunichar2 *data);
inline MonoString* (*mono_string_new_utf16)(MonoDomain *domain, const gunichar2 *text, int32_t len);
inline MonoException *(*mono_get_exception_argument_null)(const char *arg);
inline MonoClass *(*mono_get_boolean_class)();
inline MonoClass *(*mono_get_byte_class)();
inline MonoClass *(*mono_get_char_class)();
inline MonoClass *(*mono_get_int16_class)();
inline MonoClass *(*mono_get_int64_class)();
inline MonoClass *(*mono_get_single_class)();
inline MonoClass *(*mono_get_double_class)();
inline gboolean (*mono_class_is_generic)(MonoClass *klass);
inline gboolean (*mono_class_is_inflated)(MonoClass *klass);
inline gboolean (*unity_mono_method_is_generic)(MonoMethod *method);
inline gboolean (*unity_mono_method_is_inflated)(MonoMethod *method);
inline gboolean (*mono_is_debugger_attached)();
inline gboolean (*mono_assembly_fill_assembly_name)(MonoImage *image, MonoAssemblyName *aname);
inline char *(*mono_stringify_assembly_name)(MonoAssemblyName *aname);
inline gboolean (*mono_assembly_name_parse)(const char *name, MonoAssemblyName *aname);
inline MonoAssembly *(*mono_assembly_loaded)(MonoAssemblyName *aname);
inline int (*mono_image_get_table_rows)(MonoImage *image, int table_id);
inline MonoClass *(*mono_class_get)(MonoImage *image, guint32 type_token);
inline gboolean (*mono_metadata_signature_equal)(MonoMethodSignature *sig1, MonoMethodSignature *sig2);
inline gboolean (*mono_gchandle_is_in_domain)(guint32 gchandle, MonoDomain *domain);
inline void (*mono_stack_walk)(MonoStackWalk func, gpointer user_data);
inline char *(*mono_pmip)(void *ip);
inline MonoObject *(*mono_runtime_delegate_invoke)(MonoObject *delegate, void **params, MonoObject **exc);
inline MonoJitInfo *(*mono_jit_info_table_find)(MonoDomain *domain, char *addr);
inline MonoDebugSourceLocation *(*mono_debug_lookup_source_location)(MonoMethod *method, guint32 address, MonoDomain *domain);
inline void (*mono_debug_free_source_location)(MonoDebugSourceLocation *location);
inline void (*mono_gc_wbarrier_generic_store)(gpointer ptr, MonoObject *value);
inline MonoType *(*mono_class_enum_basetype)(MonoClass *klass);
inline guint32 (*mono_class_get_type_token)(MonoClass *klass);
inline int (*mono_class_get_rank)(MonoClass *klass);
inline MonoClass *(*mono_class_get_element_class)(MonoClass *klass);
inline gboolean (*mono_unity_class_is_interface)(MonoClass *klass);
inline gboolean (*mono_unity_class_is_abstract)(MonoClass *klass);
inline gint32 (*mono_array_element_size)(MonoClass *ac);
inline void (*mono_config_parse)(const char *filename);
inline void (*mono_set_break_policy)(MonoBreakPolicyFunc policy_callback);
inline MonoArray *(*mono_custom_attrs_construct)(MonoCustomAttrInfo *cinfo);
inline MonoCustomAttrInfo *(*mono_custom_attrs_from_assembly)(MonoAssembly *assembly);
inline MonoArray *(*mono_reflection_get_custom_attrs_by_type)(MonoObject *obj, MonoClass *attr_klass);
inline MonoLoaderError *(*mono_loader_get_last_error)();
inline MonoException *(*mono_loader_error_prepare_exception)(MonoLoaderError *error);
inline MonoDlFallbackHandler *(*mono_dl_fallback_register)(MonoDlFallbackLoad load_func, MonoDlFallbackSymbol symbol_func, MonoDlFallbackClose close_func, void *user_data);
inline void (*mono_dl_fallback_unregister)(MonoDlFallbackHandler *handler);
inline LivenessState *(*mono_unity_liveness_allocate_struct)(MonoClass *filter, guint max_count, register_object_callback callback, void *callback_userdata);
inline void (*mono_unity_liveness_stop_gc_world)();
inline void (*mono_unity_liveness_finalize)(LivenessState *state);
inline void (*mono_unity_liveness_start_gc_world)();
inline void (*mono_unity_liveness_free_struct)(LivenessState *state);
inline LivenessState *(*mono_unity_liveness_calculation_begin)(MonoClass *filter, guint max_count, register_object_callback callback, void *callback_userdata);
inline void (*mono_unity_liveness_calculation_end)(LivenessState *state);
inline void (*mono_unity_liveness_calculation_from_root)(MonoObject *root, LivenessState *state);
inline void (*mono_unity_liveness_calculation_from_statics)(LivenessState *state);
inline void (*mono_trace_set_level_string)(const char *value);
inline void (*mono_trace_set_mask_string)(char *value);
inline gint64 (*mono_gc_get_used_size)();
inline gint64 (*mono_gc_get_heap_size)();
inline MonoMethod *(*mono_method_desc_search_in_class)(MonoMethodDesc *desc, MonoClass *klass);
inline void (*mono_method_desc_free)(MonoMethodDesc *desc);
inline char *(*mono_type_get_name_full)(MonoType *type, MonoTypeNameFormat format);
inline void (*mono_unity_thread_clear_domain_fields)();
inline void (*mono_profiler_install)(MonoProfiler *prof, MonoProfileFunc shutdown_callback);
inline void (*mono_profiler_set_events)(MonoProfileFlags events);
inline void (*mono_profiler_install_enter_leave)(MonoProfileMethodFunc enter, MonoProfileMethodFunc fleave);
inline void (*mono_profiler_install_gc)(MonoProfileGCFunc callback, MonoProfileGCResizeFunc heap_resize_callback);
inline void (*mono_profiler_install_allocation)(MonoProfileAllocFunc callback);
inline void (*mono_profiler_install_jit_end)(MonoProfileJitResult end);
inline void (*mono_profiler_install_exception)(MonoProfileExceptionFunc throw_callback, MonoProfileMethodFunc exc_method_leave, MonoProfileExceptionClauseFunc clause_callback);
inline void (*mono_profiler_install_thread)(MonoProfileThreadFunc start, MonoProfileThreadFunc end);
inline uint64_t* (*mono_compile_method)(MonoMethod*);
inline MonoTableInfo*(*mono_image_get_table_info)(MonoImage*,int);
inline int (*mono_table_info_get_rows)(MonoTableInfo*);
inline gunichar2* (*mono_string_chars)(MonoString* str);
inline int (*mono_string_length)(MonoString* str);
typedef void*(*mono_image_get_table_info_t)(void*,uint32_t);
typedef int (*mono_table_info_get_rows_t)(void*);
namespace monofunctions{
void init(HMODULE dll);
uintptr_t get_method_pointer(const char* assemblyName, const char* namespaze,
const char* klassName, const char* name, int argsCount,bool strict);
std::optional<std::wstring_view> get_string(void*);
void* create_string(std::wstring_view ws);
}

View File

@ -1,77 +1,11 @@
#include"def_il2cpp.hpp"
namespace{
il2cpp_string_new_utf16_t il2cpp_string_new_utf16;
il2cpp_string_new_t il2cpp_string_new;
il2cpp_domain_get_t il2cpp_domain_get;
il2cpp_domain_assembly_open_t il2cpp_domain_assembly_open;
il2cpp_assembly_get_image_t il2cpp_assembly_get_image;
il2cpp_class_from_name_t il2cpp_class_from_name;
il2cpp_class_get_methods_t il2cpp_class_get_methods;
il2cpp_class_get_method_from_name_t il2cpp_class_get_method_from_name;
il2cpp_method_get_param_t il2cpp_method_get_param;
il2cpp_object_new_t il2cpp_object_new;
il2cpp_resolve_icall_t il2cpp_resolve_icall;
il2cpp_array_new_t il2cpp_array_new;
il2cpp_thread_attach_t il2cpp_thread_attach;
il2cpp_thread_detach_t il2cpp_thread_detach;
il2cpp_class_get_field_from_name_t il2cpp_class_get_field_from_name;
il2cpp_class_is_assignable_from_t il2cpp_class_is_assignable_from;
il2cpp_class_for_each_t il2cpp_class_for_each;
il2cpp_class_get_nested_types_t il2cpp_class_get_nested_types;
il2cpp_class_get_type_t il2cpp_class_get_type;
il2cpp_type_get_object_t il2cpp_type_get_object;
il2cpp_gchandle_new_t il2cpp_gchandle_new;
il2cpp_gchandle_free_t il2cpp_gchandle_free;
il2cpp_gchandle_get_target_t il2cpp_gchandle_get_target;
il2cpp_class_from_type_t il2cpp_class_from_type;
il2cpp_runtime_class_init_t il2cpp_runtime_class_init;
il2cpp_runtime_invoke_t il2cpp_runtime_invoke;
il2cpp_class_get_name_t il2cpp_class_get_name;
il2cpp_class_get_namespace_t il2cpp_class_get_namespace;
il2cpp_domain_get_assemblies_t il2cpp_domain_get_assemblies;
il2cpp_class_get_image_t il2cpp_class_get_image;
il2cpp_image_get_name_t il2cpp_image_get_name;
namespace il2cpp_symbols
{
#define RESOLVE_IMPORT(name) name = reinterpret_cast<name##_t>(GetProcAddress(game_module, #name))
void init(HMODULE game_module)
{
RESOLVE_IMPORT(il2cpp_image_get_name);
RESOLVE_IMPORT(il2cpp_class_get_image);
RESOLVE_IMPORT(il2cpp_string_new_utf16);
RESOLVE_IMPORT(il2cpp_string_new);
RESOLVE_IMPORT(il2cpp_domain_get);
RESOLVE_IMPORT(il2cpp_domain_assembly_open);
RESOLVE_IMPORT(il2cpp_assembly_get_image);
RESOLVE_IMPORT(il2cpp_class_from_name);
RESOLVE_IMPORT(il2cpp_class_get_methods);
RESOLVE_IMPORT(il2cpp_class_get_method_from_name);
RESOLVE_IMPORT(il2cpp_method_get_param);
RESOLVE_IMPORT(il2cpp_object_new);
RESOLVE_IMPORT(il2cpp_resolve_icall);
RESOLVE_IMPORT(il2cpp_array_new);
RESOLVE_IMPORT(il2cpp_thread_attach);
RESOLVE_IMPORT(il2cpp_thread_detach);
RESOLVE_IMPORT(il2cpp_class_get_field_from_name);
RESOLVE_IMPORT(il2cpp_class_is_assignable_from);
RESOLVE_IMPORT(il2cpp_class_for_each);
RESOLVE_IMPORT(il2cpp_class_get_nested_types);
RESOLVE_IMPORT(il2cpp_class_get_type);
RESOLVE_IMPORT(il2cpp_type_get_object);
RESOLVE_IMPORT(il2cpp_gchandle_new);
RESOLVE_IMPORT(il2cpp_gchandle_free);
RESOLVE_IMPORT(il2cpp_gchandle_get_target);
RESOLVE_IMPORT(il2cpp_class_from_type);
RESOLVE_IMPORT(il2cpp_runtime_class_init);
RESOLVE_IMPORT(il2cpp_runtime_invoke);
RESOLVE_IMPORT(il2cpp_class_get_name);
RESOLVE_IMPORT(il2cpp_class_get_namespace);
RESOLVE_IMPORT(il2cpp_domain_get_assemblies);
}
Il2CppClass* get_il2cppclass1(const char* assemblyName, const char* namespaze,
const char* klassName,bool strict)
{
auto il2cpp_domain=(SafeFptr(il2cpp_domain_get))();
if (!il2cpp_domain) return NULL;
void* assembly=0;
do{
assembly = (SafeFptr(il2cpp_domain_assembly_open))(il2cpp_domain, assemblyName);
@ -148,21 +82,70 @@ namespace il2cpp_symbols
tryprintimage(klass);
return ret->methodPointer;
}
uintptr_t get_method_pointer(const char* assemblyName, const char* namespaze,
const char* klassName, const char* name, int argsCount,bool strict)
{
auto thread=AutoThread();
if(!thread.thread)return NULL;
auto klass=get_il2cppclass1(assemblyName,namespaze,klassName,strict);//正向查询assemblyName可以为空
if(klass)
return getmethodofklass(klass,name,argsCount);
if(strict)return NULL;
auto klasses=get_il2cppclass2(namespaze,klassName);//反向查询namespace可以为空
for(auto klass:klasses){
auto method= getmethodofklass(klass,name,argsCount);
if(method)return method;
}
return NULL;
}
}
void il2cppfunctions::init(HMODULE game_module)
{
RESOLVE_IMPORT(il2cpp_string_new_utf16);
RESOLVE_IMPORT(il2cpp_string_chars);
RESOLVE_IMPORT(il2cpp_string_length);
RESOLVE_IMPORT(il2cpp_image_get_name);
RESOLVE_IMPORT(il2cpp_class_get_image);
RESOLVE_IMPORT(il2cpp_string_new_utf16);
RESOLVE_IMPORT(il2cpp_string_new);
RESOLVE_IMPORT(il2cpp_domain_get);
RESOLVE_IMPORT(il2cpp_domain_assembly_open);
RESOLVE_IMPORT(il2cpp_assembly_get_image);
RESOLVE_IMPORT(il2cpp_class_from_name);
RESOLVE_IMPORT(il2cpp_class_get_methods);
RESOLVE_IMPORT(il2cpp_class_get_method_from_name);
RESOLVE_IMPORT(il2cpp_method_get_param);
RESOLVE_IMPORT(il2cpp_object_new);
RESOLVE_IMPORT(il2cpp_resolve_icall);
RESOLVE_IMPORT(il2cpp_array_new);
RESOLVE_IMPORT(il2cpp_thread_attach);
RESOLVE_IMPORT(il2cpp_thread_detach);
RESOLVE_IMPORT(il2cpp_class_get_field_from_name);
RESOLVE_IMPORT(il2cpp_class_is_assignable_from);
RESOLVE_IMPORT(il2cpp_class_for_each);
RESOLVE_IMPORT(il2cpp_class_get_nested_types);
RESOLVE_IMPORT(il2cpp_class_get_type);
RESOLVE_IMPORT(il2cpp_type_get_object);
RESOLVE_IMPORT(il2cpp_gchandle_new);
RESOLVE_IMPORT(il2cpp_gchandle_free);
RESOLVE_IMPORT(il2cpp_gchandle_get_target);
RESOLVE_IMPORT(il2cpp_class_from_type);
RESOLVE_IMPORT(il2cpp_runtime_class_init);
RESOLVE_IMPORT(il2cpp_runtime_invoke);
RESOLVE_IMPORT(il2cpp_class_get_name);
RESOLVE_IMPORT(il2cpp_class_get_namespace);
RESOLVE_IMPORT(il2cpp_domain_get_assemblies);
}
uintptr_t il2cppfunctions::get_method_pointer(const char* assemblyName, const char* namespaze,
const char* klassName, const char* name, int argsCount,bool strict)
{
auto thread=AutoThread();
if(!thread.thread)return NULL;
auto klass=get_il2cppclass1(assemblyName,namespaze,klassName,strict);//正向查询assemblyName可以为空
if(klass)
return getmethodofklass(klass,name,argsCount);
if(strict)return NULL;
auto klasses=get_il2cppclass2(namespaze,klassName);//反向查询namespace可以为空
for(auto klass:klasses){
auto method= getmethodofklass(klass,name,argsCount);
if(method)return method;
}
return NULL;
}
std::optional<std::wstring_view> il2cppfunctions::get_string(void* ptr){
auto str=reinterpret_cast<Il2CppString*>(ptr);
if(!str)return {};
auto wc=(SafeFptr(il2cpp_string_chars))(str);
auto len=(SafeFptr(il2cpp_string_length))(str);
if(!(wc&&len))return {};
return std::wstring_view(wc,len);
}
void* il2cppfunctions::create_string(std::wstring_view ws){
return (SafeFptr(il2cpp_string_new_utf16))(ws.data(),ws.length());
}

View File

@ -1,554 +1,218 @@
mono_compile_method_t mono_compile_method=nullptr;
mono_thread_suspend_all_other_threads_t mono_thread_suspend_all_other_threads = nullptr;
mono_thread_pool_cleanup_t mono_thread_pool_cleanup = nullptr;
mono_threads_set_shutting_down_t mono_threads_set_shutting_down = nullptr;
mono_runtime_set_shutting_down_t mono_runtime_set_shutting_down = nullptr;
mono_domain_finalize_t mono_domain_finalize = nullptr;
mono_runtime_cleanup_t mono_runtime_cleanup = nullptr;
mono_method_desc_new_t mono_method_desc_new = nullptr;
mono_method_desc_search_in_image_t mono_method_desc_search_in_image = nullptr;
mono_verifier_set_mode_t mono_verifier_set_mode = nullptr;
mono_security_set_mode_t mono_security_set_mode = nullptr;
mono_add_internal_call_t mono_add_internal_call = nullptr;
mono_jit_cleanup_t mono_jit_cleanup = nullptr;
mono_jit_init_t mono_jit_init = nullptr;
mono_jit_init_version_t mono_jit_init_version = nullptr;
mono_jit_exec_t mono_jit_exec = nullptr;
mono_class_from_name_t mono_class_from_name = nullptr;
mono_domain_assembly_open_t mono_domain_assembly_open = nullptr;
mono_domain_create_appdomain_t mono_domain_create_appdomain = nullptr;
mono_domain_unload_t mono_domain_unload = nullptr;
mono_object_new_t mono_object_new = nullptr;
mono_runtime_object_init_t mono_runtime_object_init = nullptr;
mono_runtime_invoke_t mono_runtime_invoke = nullptr;
mono_field_set_value_t mono_field_set_value = nullptr;
mono_field_get_value_t mono_field_get_value = nullptr;
mono_field_get_offset_t mono_field_get_offset = nullptr;
mono_class_get_fields_t mono_class_get_fields = nullptr;
mono_class_get_methods_t mono_class_get_methods = nullptr;
mono_domain_get_t mono_domain_get = nullptr;
mono_get_root_domain_t mono_get_root_domain = nullptr;
mono_domain_get_id_t mono_domain_get_id = nullptr;
mono_assembly_foreach_t mono_assembly_foreach = nullptr;
mono_image_close_t mono_image_close = nullptr;
mono_unity_socket_security_enabled_set_t mono_unity_socket_security_enabled_set = nullptr;
mono_image_get_name_t mono_image_get_name = nullptr;
mono_get_object_class_t mono_get_object_class = nullptr;
mono_set_commandline_arguments_t mono_set_commandline_arguments = nullptr;
mono_field_get_name_t mono_field_get_name = nullptr;
mono_field_get_type_t mono_field_get_type = nullptr;
mono_type_get_type_t mono_type_get_type = nullptr;
mono_method_get_name_t mono_method_get_name = nullptr;
mono_assembly_get_image_t mono_assembly_get_image = nullptr;
mono_method_get_class_t mono_method_get_class = nullptr;
mono_object_get_class_t mono_object_get_class = nullptr;
mono_class_is_valuetype_t mono_class_is_valuetype = nullptr;
mono_signature_get_param_count_t mono_signature_get_param_count = nullptr;
mono_string_to_utf8_t mono_string_to_utf8 = nullptr;
mono_string_new_wrapper_t mono_string_new_wrapper = nullptr;
mono_class_get_parent_t mono_class_get_parent = nullptr;
mono_class_get_namespace_t mono_class_get_namespace = nullptr;
mono_class_is_subclass_of_t mono_class_is_subclass_of = nullptr;
mono_class_get_name_t mono_class_get_name = nullptr;
mono_type_get_name_t mono_type_get_name = nullptr;
mono_type_get_class_t mono_type_get_class = nullptr;
mono_exception_from_name_msg_t mono_exception_from_name_msg = nullptr;
mono_raise_exception_t mono_raise_exception = nullptr;
mono_get_exception_class_t mono_get_exception_class = nullptr;
mono_get_array_class_t mono_get_array_class = nullptr;
mono_get_string_class_t mono_get_string_class = nullptr;
mono_get_int32_class_t mono_get_int32_class = nullptr;
mono_array_new_t mono_array_new = nullptr;
mono_array_new_full_t mono_array_new_full = nullptr;
mono_array_class_get_t mono_array_class_get = nullptr;
mono_class_array_element_size_t mono_class_array_element_size = nullptr;
mono_type_get_object_t mono_type_get_object = nullptr;
mono_thread_attach_t mono_thread_attach = nullptr;
mono_thread_detach_t mono_thread_detach = nullptr;
mono_thread_exit_t mono_thread_exit = nullptr;
mono_thread_current_t mono_thread_current = nullptr;
mono_thread_set_main_t mono_thread_set_main = nullptr;
mono_set_find_plugin_callback_t mono_set_find_plugin_callback = nullptr;
mono_security_enable_core_clr_t mono_security_enable_core_clr = nullptr;
mono_security_set_core_clr_platform_callback_t mono_security_set_core_clr_platform_callback = nullptr;
mono_runtime_unhandled_exception_policy_get_t mono_runtime_unhandled_exception_policy_get = nullptr;
mono_runtime_unhandled_exception_policy_set_t mono_runtime_unhandled_exception_policy_set = nullptr;
mono_class_get_nesting_type_t mono_class_get_nesting_type = nullptr;
mono_class_vtable_t mono_class_vtable = nullptr;
mono_method_get_object_t mono_method_get_object = nullptr;
mono_method_signature_t mono_method_signature = nullptr;
mono_signature_get_params_t mono_signature_get_params = nullptr;
mono_signature_get_return_type_t mono_signature_get_return_type = nullptr;
mono_class_get_type_t mono_class_get_type = nullptr;
mono_set_ignore_version_and_key_when_finding_assemblies_already_loaded_t mono_set_ignore_version_and_key_when_finding_assemblies_already_loaded = nullptr;
mono_debug_init_t mono_debug_init = nullptr;
mono_debug_open_image_from_memory_t mono_debug_open_image_from_memory = nullptr;
mono_field_get_flags_t mono_field_get_flags = nullptr;
mono_image_open_from_data_full_t mono_image_open_from_data_full = nullptr;
mono_image_open_from_data_with_name_t mono_image_open_from_data_with_name = nullptr;
mono_assembly_load_from_t mono_assembly_load_from = nullptr;
mono_value_box_t mono_value_box = nullptr;
mono_class_get_image_t mono_class_get_image = nullptr;
mono_signature_is_instance_t mono_signature_is_instance = nullptr;
mono_method_get_last_managed_t mono_method_get_last_managed = nullptr;
mono_get_enum_class_t mono_get_enum_class = nullptr;
mono_class_get_byref_type_t mono_class_get_byref_type = nullptr;
mono_field_static_get_value_t mono_field_static_get_value = nullptr;
mono_unity_set_embeddinghostname_t mono_unity_set_embeddinghostname = nullptr;
mono_set_assemblies_path_t mono_set_assemblies_path = nullptr;
mono_gchandle_new_t mono_gchandle_new = nullptr;
mono_gchandle_get_target_t mono_gchandle_get_target = nullptr;
mono_gchandle_new_weakref_t mono_gchandle_new_weakref = nullptr;
mono_assembly_get_object_t mono_assembly_get_object = nullptr;
mono_gchandle_free_t mono_gchandle_free = nullptr;
mono_class_get_properties_t mono_class_get_properties = nullptr;
mono_property_get_get_method_t mono_property_get_get_method = nullptr;
mono_object_new_alloc_specific_t mono_object_new_alloc_specific = nullptr;
mono_object_new_specific_t mono_object_new_specific = nullptr;
mono_gc_collect_t mono_gc_collect = nullptr;
mono_gc_max_generation_t mono_gc_max_generation = nullptr;
mono_image_get_assembly_t mono_image_get_assembly = nullptr;
mono_assembly_open_t mono_assembly_open = nullptr;
mono_class_is_enum_t mono_class_is_enum = nullptr;
mono_class_instance_size_t mono_class_instance_size = nullptr;
mono_object_get_size_t mono_object_get_size = nullptr;
mono_image_get_filename_t mono_image_get_filename = nullptr;
mono_assembly_load_from_full_t mono_assembly_load_from_full = nullptr;
mono_class_get_interfaces_t mono_class_get_interfaces = nullptr;
mono_assembly_close_t mono_assembly_close = nullptr;
mono_class_get_property_from_name_t mono_class_get_property_from_name = nullptr;
mono_class_get_method_from_name_t mono_class_get_method_from_name = nullptr;
mono_class_from_mono_type_t mono_class_from_mono_type = nullptr;
mono_domain_set_t mono_domain_set = nullptr;
mono_thread_push_appdomain_ref_t mono_thread_push_appdomain_ref = nullptr;
mono_thread_pop_appdomain_ref_t mono_thread_pop_appdomain_ref = nullptr;
mono_runtime_exec_main_t mono_runtime_exec_main = nullptr;
mono_get_corlib_t mono_get_corlib = nullptr;
mono_class_get_field_from_name_t mono_class_get_field_from_name = nullptr;
mono_class_get_flags_t mono_class_get_flags = nullptr;
mono_parse_default_optimizations_t mono_parse_default_optimizations = nullptr;
mono_set_defaults_t mono_set_defaults = nullptr;
mono_set_dirs_t mono_set_dirs = nullptr;
mono_jit_parse_options_t mono_jit_parse_options = nullptr;
mono_object_unbox_t mono_object_unbox = nullptr;
mono_custom_attrs_get_attr_t mono_custom_attrs_get_attr = nullptr;
mono_custom_attrs_has_attr_t mono_custom_attrs_has_attr = nullptr;
mono_custom_attrs_from_field_t mono_custom_attrs_from_field = nullptr;
mono_custom_attrs_from_method_t mono_custom_attrs_from_method = nullptr;
mono_custom_attrs_from_class_t mono_custom_attrs_from_class = nullptr;
mono_custom_attrs_free_t mono_custom_attrs_free = nullptr;
g_free_t g_free = nullptr;
mono_runtime_is_shutting_down_t mono_runtime_is_shutting_down = nullptr;
mono_object_get_virtual_method_t mono_object_get_virtual_method = nullptr;
mono_jit_info_get_code_start_t mono_jit_info_get_code_start = nullptr;
mono_jit_info_get_code_size_t mono_jit_info_get_code_size = nullptr;
mono_class_from_name_case_t mono_class_from_name_case = nullptr;
mono_class_get_nested_types_t mono_class_get_nested_types = nullptr;
mono_class_get_userdata_offset_t mono_class_get_userdata_offset = nullptr;
mono_class_get_userdata_t mono_class_get_userdata = nullptr;
mono_class_set_userdata_t mono_class_set_userdata = nullptr;
mono_set_signal_chaining_t mono_set_signal_chaining = nullptr;
// mono_unity_seh_handler_t mono_unity_seh_handler = nullptr;
mono_unity_set_unhandled_exception_handler_t mono_unity_set_unhandled_exception_handler = nullptr;
mono_runtime_invoke_array_t mono_runtime_invoke_array = nullptr;
mono_array_addr_with_size_t mono_array_addr_with_size = nullptr;
mono_string_to_utf16_t mono_string_to_utf16 = nullptr;
mono_field_get_parent_t mono_field_get_parent = nullptr;
mono_method_full_name_t mono_method_full_name = nullptr;
mono_object_isinst_t mono_object_isinst = nullptr;
mono_string_new_len_t mono_string_new_len = nullptr;
mono_string_from_utf16_t mono_string_from_utf16 = nullptr;
mono_get_exception_argument_null_t mono_get_exception_argument_null = nullptr;
mono_get_boolean_class_t mono_get_boolean_class = nullptr;
mono_get_byte_class_t mono_get_byte_class = nullptr;
mono_get_char_class_t mono_get_char_class = nullptr;
mono_get_int16_class_t mono_get_int16_class = nullptr;
mono_get_int64_class_t mono_get_int64_class = nullptr;
mono_get_single_class_t mono_get_single_class = nullptr;
mono_get_double_class_t mono_get_double_class = nullptr;
mono_class_is_generic_t mono_class_is_generic = nullptr;
mono_class_is_inflated_t mono_class_is_inflated = nullptr;
unity_mono_method_is_generic_t unity_mono_method_is_generic = nullptr;
unity_mono_method_is_inflated_t unity_mono_method_is_inflated = nullptr;
mono_is_debugger_attached_t mono_is_debugger_attached = nullptr;
mono_assembly_fill_assembly_name_t mono_assembly_fill_assembly_name = nullptr;
mono_stringify_assembly_name_t mono_stringify_assembly_name = nullptr;
mono_assembly_name_parse_t mono_assembly_name_parse = nullptr;
mono_assembly_loaded_t mono_assembly_loaded = nullptr;
mono_image_get_table_rows_t mono_image_get_table_rows = nullptr;
mono_class_get_t mono_class_get = nullptr;
mono_metadata_signature_equal_t mono_metadata_signature_equal = nullptr;
mono_gchandle_is_in_domain_t mono_gchandle_is_in_domain = nullptr;
mono_stack_walk_t mono_stack_walk = nullptr;
mono_pmip_t mono_pmip = nullptr;
mono_runtime_delegate_invoke_t mono_runtime_delegate_invoke = nullptr;
mono_jit_info_table_find_t mono_jit_info_table_find = nullptr;
mono_debug_lookup_source_location_t mono_debug_lookup_source_location = nullptr;
mono_debug_free_source_location_t mono_debug_free_source_location = nullptr;
mono_gc_wbarrier_generic_store_t mono_gc_wbarrier_generic_store = nullptr;
mono_class_enum_basetype_t mono_class_enum_basetype = nullptr;
mono_class_get_type_token_t mono_class_get_type_token = nullptr;
mono_class_get_rank_t mono_class_get_rank = nullptr;
mono_class_get_element_class_t mono_class_get_element_class = nullptr;
mono_unity_class_is_interface_t mono_unity_class_is_interface = nullptr;
mono_unity_class_is_abstract_t mono_unity_class_is_abstract = nullptr;
mono_array_element_size_t mono_array_element_size = nullptr;
mono_config_parse_t mono_config_parse = nullptr;
mono_set_break_policy_t mono_set_break_policy = nullptr;
mono_custom_attrs_construct_t mono_custom_attrs_construct = nullptr;
mono_custom_attrs_from_assembly_t mono_custom_attrs_from_assembly = nullptr;
mono_reflection_get_custom_attrs_by_type_t mono_reflection_get_custom_attrs_by_type = nullptr;
mono_loader_get_last_error_t mono_loader_get_last_error = nullptr;
mono_loader_error_prepare_exception_t mono_loader_error_prepare_exception = nullptr;
mono_dl_fallback_register_t mono_dl_fallback_register = nullptr;
mono_dl_fallback_unregister_t mono_dl_fallback_unregister = nullptr;
mono_unity_liveness_allocate_struct_t mono_unity_liveness_allocate_struct = nullptr;
mono_unity_liveness_stop_gc_world_t mono_unity_liveness_stop_gc_world = nullptr;
mono_unity_liveness_finalize_t mono_unity_liveness_finalize = nullptr;
mono_unity_liveness_start_gc_world_t mono_unity_liveness_start_gc_world = nullptr;
mono_unity_liveness_free_struct_t mono_unity_liveness_free_struct = nullptr;
mono_unity_liveness_calculation_begin_t mono_unity_liveness_calculation_begin = nullptr;
mono_unity_liveness_calculation_end_t mono_unity_liveness_calculation_end = nullptr;
mono_unity_liveness_calculation_from_root_t mono_unity_liveness_calculation_from_root = nullptr;
mono_unity_liveness_calculation_from_statics_t mono_unity_liveness_calculation_from_statics = nullptr;
mono_trace_set_level_string_t mono_trace_set_level_string = nullptr;
mono_trace_set_mask_string_t mono_trace_set_mask_string = nullptr;
mono_gc_get_used_size_t mono_gc_get_used_size = nullptr;
mono_gc_get_heap_size_t mono_gc_get_heap_size = nullptr;
mono_method_desc_search_in_class_t mono_method_desc_search_in_class = nullptr;
mono_method_desc_free_t mono_method_desc_free = nullptr;
mono_type_get_name_full_t mono_type_get_name_full = nullptr;
mono_unity_thread_clear_domain_fields_t mono_unity_thread_clear_domain_fields = nullptr;
// mono_unity_set_vprintf_func_t mono_unity_set_vprintf_func = nullptr;
mono_profiler_install_t mono_profiler_install = nullptr;
mono_profiler_set_events_t mono_profiler_set_events = nullptr;
mono_profiler_install_enter_leave_t mono_profiler_install_enter_leave = nullptr;
mono_profiler_install_gc_t mono_profiler_install_gc = nullptr;
mono_profiler_install_allocation_t mono_profiler_install_allocation = nullptr;
mono_profiler_install_jit_end_t mono_profiler_install_jit_end = nullptr;
mono_profiler_install_exception_t mono_profiler_install_exception = nullptr;
mono_profiler_install_thread_t mono_profiler_install_thread = nullptr;
mono_image_get_table_info_t mono_image_get_table_info=nullptr;
mono_table_info_get_rows_t mono_table_info_get_rows=nullptr;
void load_mono_functions_from_dll(HMODULE dll)
{
mono_table_info_get_rows=(mono_table_info_get_rows_t)(GetProcAddress(dll, "mono_table_info_get_rows"));
mono_image_get_table_info=(mono_image_get_table_info_t)(GetProcAddress(dll, "mono_image_get_table_info"));
mono_compile_method=(mono_compile_method_t)(GetProcAddress(dll, "mono_compile_method"));
mono_thread_suspend_all_other_threads = (mono_thread_suspend_all_other_threads_t)(GetProcAddress(dll, "mono_thread_suspend_all_other_threads"));
mono_thread_pool_cleanup = (mono_thread_pool_cleanup_t)(GetProcAddress(dll, "mono_thread_pool_cleanup"));
mono_threads_set_shutting_down = (mono_threads_set_shutting_down_t)(GetProcAddress(dll, "mono_threads_set_shutting_down"));
mono_runtime_set_shutting_down = (mono_runtime_set_shutting_down_t)(GetProcAddress(dll, "mono_runtime_set_shutting_down"));
mono_domain_finalize = (mono_domain_finalize_t)(GetProcAddress(dll, "mono_domain_finalize"));
mono_runtime_cleanup = (mono_runtime_cleanup_t)(GetProcAddress(dll, "mono_runtime_cleanup"));
mono_method_desc_new = (mono_method_desc_new_t)(GetProcAddress(dll, "mono_method_desc_new"));
mono_method_desc_search_in_image = (mono_method_desc_search_in_image_t)(GetProcAddress(dll, "mono_method_desc_search_in_image"));
mono_verifier_set_mode = (mono_verifier_set_mode_t)(GetProcAddress(dll, "mono_verifier_set_mode"));
mono_security_set_mode = (mono_security_set_mode_t)(GetProcAddress(dll, "mono_security_set_mode"));
mono_add_internal_call = (mono_add_internal_call_t)(GetProcAddress(dll, "mono_add_internal_call"));
mono_jit_cleanup = (mono_jit_cleanup_t)(GetProcAddress(dll, "mono_jit_cleanup"));
mono_jit_init = (mono_jit_init_t)(GetProcAddress(dll, "mono_jit_init"));
mono_jit_init_version = (mono_jit_init_version_t)(GetProcAddress(dll, "mono_jit_init_version"));
mono_jit_exec = (mono_jit_exec_t)(GetProcAddress(dll, "mono_jit_exec"));
mono_class_from_name = (mono_class_from_name_t)(GetProcAddress(dll, "mono_class_from_name"));
mono_domain_assembly_open = (mono_domain_assembly_open_t)(GetProcAddress(dll, "mono_domain_assembly_open"));
mono_domain_create_appdomain = (mono_domain_create_appdomain_t)(GetProcAddress(dll, "mono_domain_create_appdomain"));
mono_domain_unload = (mono_domain_unload_t)(GetProcAddress(dll, "mono_domain_unload"));
mono_object_new = (mono_object_new_t)(GetProcAddress(dll, "mono_object_new"));
mono_runtime_object_init = (mono_runtime_object_init_t)(GetProcAddress(dll, "mono_runtime_object_init"));
mono_runtime_invoke = (mono_runtime_invoke_t)(GetProcAddress(dll, "mono_runtime_invoke"));
mono_field_set_value = (mono_field_set_value_t)(GetProcAddress(dll, "mono_field_set_value"));
mono_field_get_value = (mono_field_get_value_t)(GetProcAddress(dll, "mono_field_get_value"));
mono_field_get_offset = (mono_field_get_offset_t)(GetProcAddress(dll, "mono_field_get_offset"));
mono_class_get_fields = (mono_class_get_fields_t)(GetProcAddress(dll, "mono_class_get_fields"));
mono_class_get_methods = (mono_class_get_methods_t)(GetProcAddress(dll, "mono_class_get_methods"));
mono_domain_get = (mono_domain_get_t)(GetProcAddress(dll, "mono_domain_get"));
mono_get_root_domain = (mono_get_root_domain_t)(GetProcAddress(dll, "mono_get_root_domain"));
mono_domain_get_id = (mono_domain_get_id_t)(GetProcAddress(dll, "mono_domain_get_id"));
mono_assembly_foreach = (mono_assembly_foreach_t)(GetProcAddress(dll, "mono_assembly_foreach"));
mono_image_close = (mono_image_close_t)(GetProcAddress(dll, "mono_image_close"));
mono_unity_socket_security_enabled_set = (mono_unity_socket_security_enabled_set_t)(GetProcAddress(dll, "mono_unity_socket_security_enabled_set"));
mono_image_get_name = (mono_image_get_name_t)(GetProcAddress(dll, "mono_image_get_name"));
mono_get_object_class = (mono_get_object_class_t)(GetProcAddress(dll, "mono_get_object_class"));
mono_set_commandline_arguments = (mono_set_commandline_arguments_t)(GetProcAddress(dll, "mono_set_commandline_arguments"));
mono_field_get_name = (mono_field_get_name_t)(GetProcAddress(dll, "mono_field_get_name"));
mono_field_get_type = (mono_field_get_type_t)(GetProcAddress(dll, "mono_field_get_type"));
mono_type_get_type = (mono_type_get_type_t)(GetProcAddress(dll, "mono_type_get_type"));
mono_method_get_name = (mono_method_get_name_t)(GetProcAddress(dll, "mono_method_get_name"));
mono_assembly_get_image = (mono_assembly_get_image_t)(GetProcAddress(dll, "mono_assembly_get_image"));
mono_method_get_class = (mono_method_get_class_t)(GetProcAddress(dll, "mono_method_get_class"));
mono_object_get_class = (mono_object_get_class_t)(GetProcAddress(dll, "mono_object_get_class"));
mono_class_is_valuetype = (mono_class_is_valuetype_t)(GetProcAddress(dll, "mono_class_is_valuetype"));
mono_signature_get_param_count = (mono_signature_get_param_count_t)(GetProcAddress(dll, "mono_signature_get_param_count"));
mono_string_to_utf8 = (mono_string_to_utf8_t)(GetProcAddress(dll, "mono_string_to_utf8"));
mono_string_new_wrapper = (mono_string_new_wrapper_t)(GetProcAddress(dll, "mono_string_new_wrapper"));
mono_class_get_parent = (mono_class_get_parent_t)(GetProcAddress(dll, "mono_class_get_parent"));
mono_class_get_namespace = (mono_class_get_namespace_t)(GetProcAddress(dll, "mono_class_get_namespace"));
mono_class_is_subclass_of = (mono_class_is_subclass_of_t)(GetProcAddress(dll, "mono_class_is_subclass_of"));
mono_class_get_name = (mono_class_get_name_t)(GetProcAddress(dll, "mono_class_get_name"));
mono_type_get_name = (mono_type_get_name_t)(GetProcAddress(dll, "mono_type_get_name"));
mono_type_get_class = (mono_type_get_class_t)(GetProcAddress(dll, "mono_type_get_class"));
mono_exception_from_name_msg = (mono_exception_from_name_msg_t)(GetProcAddress(dll, "mono_exception_from_name_msg"));
mono_raise_exception = (mono_raise_exception_t)(GetProcAddress(dll, "mono_raise_exception"));
mono_get_exception_class = (mono_get_exception_class_t)(GetProcAddress(dll, "mono_get_exception_class"));
mono_get_array_class = (mono_get_array_class_t)(GetProcAddress(dll, "mono_get_array_class"));
mono_get_string_class = (mono_get_string_class_t)(GetProcAddress(dll, "mono_get_string_class"));
mono_get_int32_class = (mono_get_int32_class_t)(GetProcAddress(dll, "mono_get_int32_class"));
mono_array_new = (mono_array_new_t)(GetProcAddress(dll, "mono_array_new"));
mono_array_new_full = (mono_array_new_full_t)(GetProcAddress(dll, "mono_array_new_full"));
mono_array_class_get = (mono_array_class_get_t)(GetProcAddress(dll, "mono_array_class_get"));
mono_class_array_element_size = (mono_class_array_element_size_t)(GetProcAddress(dll, "mono_class_array_element_size"));
mono_type_get_object = (mono_type_get_object_t)(GetProcAddress(dll, "mono_type_get_object"));
mono_thread_attach = (mono_thread_attach_t)(GetProcAddress(dll, "mono_thread_attach"));
mono_thread_detach = (mono_thread_detach_t)(GetProcAddress(dll, "mono_thread_detach"));
mono_thread_exit = (mono_thread_exit_t)(GetProcAddress(dll, "mono_thread_exit"));
mono_thread_current = (mono_thread_current_t)(GetProcAddress(dll, "mono_thread_current"));
mono_thread_set_main = (mono_thread_set_main_t)(GetProcAddress(dll, "mono_thread_set_main"));
mono_set_find_plugin_callback = (mono_set_find_plugin_callback_t)(GetProcAddress(dll, "mono_set_find_plugin_callback"));
mono_security_enable_core_clr = (mono_security_enable_core_clr_t)(GetProcAddress(dll, "mono_security_enable_core_clr"));
mono_security_set_core_clr_platform_callback = (mono_security_set_core_clr_platform_callback_t)(GetProcAddress(dll, "mono_security_set_core_clr_platform_callback"));
mono_runtime_unhandled_exception_policy_get = (mono_runtime_unhandled_exception_policy_get_t)(GetProcAddress(dll, "mono_runtime_unhandled_exception_policy_get"));
mono_runtime_unhandled_exception_policy_set = (mono_runtime_unhandled_exception_policy_set_t)(GetProcAddress(dll, "mono_runtime_unhandled_exception_policy_set"));
mono_class_get_nesting_type = (mono_class_get_nesting_type_t)(GetProcAddress(dll, "mono_class_get_nesting_type"));
mono_class_vtable = (mono_class_vtable_t)(GetProcAddress(dll, "mono_class_vtable"));
mono_method_get_object = (mono_method_get_object_t)(GetProcAddress(dll, "mono_method_get_object"));
mono_method_signature = (mono_method_signature_t)(GetProcAddress(dll, "mono_method_signature"));
mono_signature_get_params = (mono_signature_get_params_t)(GetProcAddress(dll, "mono_signature_get_params"));
mono_signature_get_return_type = (mono_signature_get_return_type_t)(GetProcAddress(dll, "mono_signature_get_return_type"));
mono_class_get_type = (mono_class_get_type_t)(GetProcAddress(dll, "mono_class_get_type"));
mono_set_ignore_version_and_key_when_finding_assemblies_already_loaded = (mono_set_ignore_version_and_key_when_finding_assemblies_already_loaded_t)(GetProcAddress(dll, "mono_set_ignore_version_and_key_when_finding_assemblies_already_loaded"));
mono_debug_init = (mono_debug_init_t)(GetProcAddress(dll, "mono_debug_init"));
mono_debug_open_image_from_memory = (mono_debug_open_image_from_memory_t)(GetProcAddress(dll, "mono_debug_open_image_from_memory"));
mono_field_get_flags = (mono_field_get_flags_t)(GetProcAddress(dll, "mono_field_get_flags"));
mono_image_open_from_data_full = (mono_image_open_from_data_full_t)(GetProcAddress(dll, "mono_image_open_from_data_full"));
mono_image_open_from_data_with_name = (mono_image_open_from_data_with_name_t)(GetProcAddress(dll, "mono_image_open_from_data_with_name"));
mono_assembly_load_from = (mono_assembly_load_from_t)(GetProcAddress(dll, "mono_assembly_load_from"));
mono_value_box = (mono_value_box_t)(GetProcAddress(dll, "mono_value_box"));
mono_class_get_image = (mono_class_get_image_t)(GetProcAddress(dll, "mono_class_get_image"));
mono_signature_is_instance = (mono_signature_is_instance_t)(GetProcAddress(dll, "mono_signature_is_instance"));
mono_method_get_last_managed = (mono_method_get_last_managed_t)(GetProcAddress(dll, "mono_method_get_last_managed"));
mono_get_enum_class = (mono_get_enum_class_t)(GetProcAddress(dll, "mono_get_enum_class"));
mono_class_get_byref_type = (mono_class_get_byref_type_t)(GetProcAddress(dll, "mono_class_get_byref_type"));
mono_field_static_get_value = (mono_field_static_get_value_t)(GetProcAddress(dll, "mono_field_static_get_value"));
mono_unity_set_embeddinghostname = (mono_unity_set_embeddinghostname_t)(GetProcAddress(dll, "mono_unity_set_embeddinghostname"));
mono_set_assemblies_path = (mono_set_assemblies_path_t)(GetProcAddress(dll, "mono_set_assemblies_path"));
mono_gchandle_new = (mono_gchandle_new_t)(GetProcAddress(dll, "mono_gchandle_new"));
mono_gchandle_get_target = (mono_gchandle_get_target_t)(GetProcAddress(dll, "mono_gchandle_get_target"));
mono_gchandle_new_weakref = (mono_gchandle_new_weakref_t)(GetProcAddress(dll, "mono_gchandle_new_weakref"));
mono_assembly_get_object = (mono_assembly_get_object_t)(GetProcAddress(dll, "mono_assembly_get_object"));
mono_gchandle_free = (mono_gchandle_free_t)(GetProcAddress(dll, "mono_gchandle_free"));
mono_class_get_properties = (mono_class_get_properties_t)(GetProcAddress(dll, "mono_class_get_properties"));
mono_property_get_get_method = (mono_property_get_get_method_t)(GetProcAddress(dll, "mono_property_get_get_method"));
mono_object_new_alloc_specific = (mono_object_new_alloc_specific_t)(GetProcAddress(dll, "mono_object_new_alloc_specific"));
mono_object_new_specific = (mono_object_new_specific_t)(GetProcAddress(dll, "mono_object_new_specific"));
mono_gc_collect = (mono_gc_collect_t)(GetProcAddress(dll, "mono_gc_collect"));
mono_gc_max_generation = (mono_gc_max_generation_t)(GetProcAddress(dll, "mono_gc_max_generation"));
mono_image_get_assembly = (mono_image_get_assembly_t)(GetProcAddress(dll, "mono_image_get_assembly"));
mono_assembly_open = (mono_assembly_open_t)(GetProcAddress(dll, "mono_assembly_open"));
mono_class_is_enum = (mono_class_is_enum_t)(GetProcAddress(dll, "mono_class_is_enum"));
mono_class_instance_size = (mono_class_instance_size_t)(GetProcAddress(dll, "mono_class_instance_size"));
mono_object_get_size = (mono_object_get_size_t)(GetProcAddress(dll, "mono_object_get_size"));
mono_image_get_filename = (mono_image_get_filename_t)(GetProcAddress(dll, "mono_image_get_filename"));
mono_assembly_load_from_full = (mono_assembly_load_from_full_t)(GetProcAddress(dll, "mono_assembly_load_from_full"));
mono_class_get_interfaces = (mono_class_get_interfaces_t)(GetProcAddress(dll, "mono_class_get_interfaces"));
mono_assembly_close = (mono_assembly_close_t)(GetProcAddress(dll, "mono_assembly_close"));
mono_class_get_property_from_name = (mono_class_get_property_from_name_t)(GetProcAddress(dll, "mono_class_get_property_from_name"));
mono_class_get_method_from_name = (mono_class_get_method_from_name_t)(GetProcAddress(dll, "mono_class_get_method_from_name"));
mono_class_from_mono_type = (mono_class_from_mono_type_t)(GetProcAddress(dll, "mono_class_from_mono_type"));
mono_domain_set = (mono_domain_set_t)(GetProcAddress(dll, "mono_domain_set"));
mono_thread_push_appdomain_ref = (mono_thread_push_appdomain_ref_t)(GetProcAddress(dll, "mono_thread_push_appdomain_ref"));
mono_thread_pop_appdomain_ref = (mono_thread_pop_appdomain_ref_t)(GetProcAddress(dll, "mono_thread_pop_appdomain_ref"));
mono_runtime_exec_main = (mono_runtime_exec_main_t)(GetProcAddress(dll, "mono_runtime_exec_main"));
mono_get_corlib = (mono_get_corlib_t)(GetProcAddress(dll, "mono_get_corlib"));
mono_class_get_field_from_name = (mono_class_get_field_from_name_t)(GetProcAddress(dll, "mono_class_get_field_from_name"));
mono_class_get_flags = (mono_class_get_flags_t)(GetProcAddress(dll, "mono_class_get_flags"));
mono_parse_default_optimizations = (mono_parse_default_optimizations_t)(GetProcAddress(dll, "mono_parse_default_optimizations"));
mono_set_defaults = (mono_set_defaults_t)(GetProcAddress(dll, "mono_set_defaults"));
mono_set_dirs = (mono_set_dirs_t)(GetProcAddress(dll, "mono_set_dirs"));
mono_jit_parse_options = (mono_jit_parse_options_t)(GetProcAddress(dll, "mono_jit_parse_options"));
mono_object_unbox = (mono_object_unbox_t)(GetProcAddress(dll, "mono_object_unbox"));
mono_custom_attrs_get_attr = (mono_custom_attrs_get_attr_t)(GetProcAddress(dll, "mono_custom_attrs_get_attr"));
mono_custom_attrs_has_attr = (mono_custom_attrs_has_attr_t)(GetProcAddress(dll, "mono_custom_attrs_has_attr"));
mono_custom_attrs_from_field = (mono_custom_attrs_from_field_t)(GetProcAddress(dll, "mono_custom_attrs_from_field"));
mono_custom_attrs_from_method = (mono_custom_attrs_from_method_t)(GetProcAddress(dll, "mono_custom_attrs_from_method"));
mono_custom_attrs_from_class = (mono_custom_attrs_from_class_t)(GetProcAddress(dll, "mono_custom_attrs_from_class"));
mono_custom_attrs_free = (mono_custom_attrs_free_t)(GetProcAddress(dll, "mono_custom_attrs_free"));
g_free = (g_free_t)(GetProcAddress(dll, "g_free"));
mono_runtime_is_shutting_down = (mono_runtime_is_shutting_down_t)(GetProcAddress(dll, "mono_runtime_is_shutting_down"));
mono_object_get_virtual_method = (mono_object_get_virtual_method_t)(GetProcAddress(dll, "mono_object_get_virtual_method"));
mono_jit_info_get_code_start = (mono_jit_info_get_code_start_t)(GetProcAddress(dll, "mono_jit_info_get_code_start"));
mono_jit_info_get_code_size = (mono_jit_info_get_code_size_t)(GetProcAddress(dll, "mono_jit_info_get_code_size"));
mono_class_from_name_case = (mono_class_from_name_case_t)(GetProcAddress(dll, "mono_class_from_name_case"));
mono_class_get_nested_types = (mono_class_get_nested_types_t)(GetProcAddress(dll, "mono_class_get_nested_types"));
mono_class_get_userdata_offset = (mono_class_get_userdata_offset_t)(GetProcAddress(dll, "mono_class_get_userdata_offset"));
mono_class_get_userdata = (mono_class_get_userdata_t)(GetProcAddress(dll, "mono_class_get_userdata"));
mono_class_set_userdata = (mono_class_set_userdata_t)(GetProcAddress(dll, "mono_class_set_userdata"));
mono_set_signal_chaining = (mono_set_signal_chaining_t)(GetProcAddress(dll, "mono_set_signal_chaining"));
// mono_unity_seh_handler = (mono_unity_seh_handler_t)(GetProcAddress(dll, "mono_unity_seh_handler"));
mono_unity_set_unhandled_exception_handler = (mono_unity_set_unhandled_exception_handler_t)(GetProcAddress(dll, "mono_unity_set_unhandled_exception_handler"));
mono_runtime_invoke_array = (mono_runtime_invoke_array_t)(GetProcAddress(dll, "mono_runtime_invoke_array"));
mono_array_addr_with_size = (mono_array_addr_with_size_t)(GetProcAddress(dll, "mono_array_addr_with_size"));
mono_string_to_utf16 = (mono_string_to_utf16_t)(GetProcAddress(dll, "mono_string_to_utf16"));
mono_field_get_parent = (mono_field_get_parent_t)(GetProcAddress(dll, "mono_field_get_parent"));
mono_method_full_name = (mono_method_full_name_t)(GetProcAddress(dll, "mono_method_full_name"));
mono_object_isinst = (mono_object_isinst_t)(GetProcAddress(dll, "mono_object_isinst"));
mono_string_new_len = (mono_string_new_len_t)(GetProcAddress(dll, "mono_string_new_len"));
mono_string_from_utf16 = (mono_string_from_utf16_t)(GetProcAddress(dll, "mono_string_from_utf16"));
mono_get_exception_argument_null = (mono_get_exception_argument_null_t)(GetProcAddress(dll, "mono_get_exception_argument_null"));
mono_get_boolean_class = (mono_get_boolean_class_t)(GetProcAddress(dll, "mono_get_boolean_class"));
mono_get_byte_class = (mono_get_byte_class_t)(GetProcAddress(dll, "mono_get_byte_class"));
mono_get_char_class = (mono_get_char_class_t)(GetProcAddress(dll, "mono_get_char_class"));
mono_get_int16_class = (mono_get_int16_class_t)(GetProcAddress(dll, "mono_get_int16_class"));
mono_get_int64_class = (mono_get_int64_class_t)(GetProcAddress(dll, "mono_get_int64_class"));
mono_get_single_class = (mono_get_single_class_t)(GetProcAddress(dll, "mono_get_single_class"));
mono_get_double_class = (mono_get_double_class_t)(GetProcAddress(dll, "mono_get_double_class"));
mono_class_is_generic = (mono_class_is_generic_t)(GetProcAddress(dll, "mono_class_is_generic"));
mono_class_is_inflated = (mono_class_is_inflated_t)(GetProcAddress(dll, "mono_class_is_inflated"));
unity_mono_method_is_generic = (unity_mono_method_is_generic_t)(GetProcAddress(dll, "unity_mono_method_is_generic"));
unity_mono_method_is_inflated = (unity_mono_method_is_inflated_t)(GetProcAddress(dll, "unity_mono_method_is_inflated"));
mono_is_debugger_attached = (mono_is_debugger_attached_t)(GetProcAddress(dll, "mono_is_debugger_attached"));
mono_assembly_fill_assembly_name = (mono_assembly_fill_assembly_name_t)(GetProcAddress(dll, "mono_assembly_fill_assembly_name"));
mono_stringify_assembly_name = (mono_stringify_assembly_name_t)(GetProcAddress(dll, "mono_stringify_assembly_name"));
mono_assembly_name_parse = (mono_assembly_name_parse_t)(GetProcAddress(dll, "mono_assembly_name_parse"));
mono_assembly_loaded = (mono_assembly_loaded_t)(GetProcAddress(dll, "mono_assembly_loaded"));
mono_image_get_table_rows = (mono_image_get_table_rows_t)(GetProcAddress(dll, "mono_image_get_table_rows"));
mono_class_get = (mono_class_get_t)(GetProcAddress(dll, "mono_class_get"));
mono_metadata_signature_equal = (mono_metadata_signature_equal_t)(GetProcAddress(dll, "mono_metadata_signature_equal"));
mono_gchandle_is_in_domain = (mono_gchandle_is_in_domain_t)(GetProcAddress(dll, "mono_gchandle_is_in_domain"));
mono_stack_walk = (mono_stack_walk_t)(GetProcAddress(dll, "mono_stack_walk"));
mono_pmip = (mono_pmip_t)(GetProcAddress(dll, "mono_pmip"));
mono_runtime_delegate_invoke = (mono_runtime_delegate_invoke_t)(GetProcAddress(dll, "mono_runtime_delegate_invoke"));
mono_jit_info_table_find = (mono_jit_info_table_find_t)(GetProcAddress(dll, "mono_jit_info_table_find"));
mono_debug_lookup_source_location = (mono_debug_lookup_source_location_t)(GetProcAddress(dll, "mono_debug_lookup_source_location"));
mono_debug_free_source_location = (mono_debug_free_source_location_t)(GetProcAddress(dll, "mono_debug_free_source_location"));
mono_gc_wbarrier_generic_store = (mono_gc_wbarrier_generic_store_t)(GetProcAddress(dll, "mono_gc_wbarrier_generic_store"));
mono_class_enum_basetype = (mono_class_enum_basetype_t)(GetProcAddress(dll, "mono_class_enum_basetype"));
mono_class_get_type_token = (mono_class_get_type_token_t)(GetProcAddress(dll, "mono_class_get_type_token"));
mono_class_get_rank = (mono_class_get_rank_t)(GetProcAddress(dll, "mono_class_get_rank"));
mono_class_get_element_class = (mono_class_get_element_class_t)(GetProcAddress(dll, "mono_class_get_element_class"));
mono_unity_class_is_interface = (mono_unity_class_is_interface_t)(GetProcAddress(dll, "mono_unity_class_is_interface"));
mono_unity_class_is_abstract = (mono_unity_class_is_abstract_t)(GetProcAddress(dll, "mono_unity_class_is_abstract"));
mono_array_element_size = (mono_array_element_size_t)(GetProcAddress(dll, "mono_array_element_size"));
mono_config_parse = (mono_config_parse_t)(GetProcAddress(dll, "mono_config_parse"));
mono_set_break_policy = (mono_set_break_policy_t)(GetProcAddress(dll, "mono_set_break_policy"));
mono_custom_attrs_construct = (mono_custom_attrs_construct_t)(GetProcAddress(dll, "mono_custom_attrs_construct"));
mono_custom_attrs_from_assembly = (mono_custom_attrs_from_assembly_t)(GetProcAddress(dll, "mono_custom_attrs_from_assembly"));
mono_reflection_get_custom_attrs_by_type = (mono_reflection_get_custom_attrs_by_type_t)(GetProcAddress(dll, "mono_reflection_get_custom_attrs_by_type"));
mono_loader_get_last_error = (mono_loader_get_last_error_t)(GetProcAddress(dll, "mono_loader_get_last_error"));
mono_loader_error_prepare_exception = (mono_loader_error_prepare_exception_t)(GetProcAddress(dll, "mono_loader_error_prepare_exception"));
mono_dl_fallback_register = (mono_dl_fallback_register_t)(GetProcAddress(dll, "mono_dl_fallback_register"));
mono_dl_fallback_unregister = (mono_dl_fallback_unregister_t)(GetProcAddress(dll, "mono_dl_fallback_unregister"));
mono_unity_liveness_allocate_struct = (mono_unity_liveness_allocate_struct_t)(GetProcAddress(dll, "mono_unity_liveness_allocate_struct"));
mono_unity_liveness_stop_gc_world = (mono_unity_liveness_stop_gc_world_t)(GetProcAddress(dll, "mono_unity_liveness_stop_gc_world"));
mono_unity_liveness_finalize = (mono_unity_liveness_finalize_t)(GetProcAddress(dll, "mono_unity_liveness_finalize"));
mono_unity_liveness_start_gc_world = (mono_unity_liveness_start_gc_world_t)(GetProcAddress(dll, "mono_unity_liveness_start_gc_world"));
mono_unity_liveness_free_struct = (mono_unity_liveness_free_struct_t)(GetProcAddress(dll, "mono_unity_liveness_free_struct"));
mono_unity_liveness_calculation_begin = (mono_unity_liveness_calculation_begin_t)(GetProcAddress(dll, "mono_unity_liveness_calculation_begin"));
mono_unity_liveness_calculation_end = (mono_unity_liveness_calculation_end_t)(GetProcAddress(dll, "mono_unity_liveness_calculation_end"));
mono_unity_liveness_calculation_from_root = (mono_unity_liveness_calculation_from_root_t)(GetProcAddress(dll, "mono_unity_liveness_calculation_from_root"));
mono_unity_liveness_calculation_from_statics = (mono_unity_liveness_calculation_from_statics_t)(GetProcAddress(dll, "mono_unity_liveness_calculation_from_statics"));
mono_trace_set_level_string = (mono_trace_set_level_string_t)(GetProcAddress(dll, "mono_trace_set_level_string"));
mono_trace_set_mask_string = (mono_trace_set_mask_string_t)(GetProcAddress(dll, "mono_trace_set_mask_string"));
mono_gc_get_used_size = (mono_gc_get_used_size_t)(GetProcAddress(dll, "mono_gc_get_used_size"));
mono_gc_get_heap_size = (mono_gc_get_heap_size_t)(GetProcAddress(dll, "mono_gc_get_heap_size"));
mono_method_desc_search_in_class = (mono_method_desc_search_in_class_t)(GetProcAddress(dll, "mono_method_desc_search_in_class"));
mono_method_desc_free = (mono_method_desc_free_t)(GetProcAddress(dll, "mono_method_desc_free"));
mono_type_get_name_full = (mono_type_get_name_full_t)(GetProcAddress(dll, "mono_type_get_name_full"));
mono_unity_thread_clear_domain_fields = (mono_unity_thread_clear_domain_fields_t)(GetProcAddress(dll, "mono_unity_thread_clear_domain_fields"));
// mono_unity_set_vprintf_func = (mono_unity_set_vprintf_func_t)(GetProcAddress(dll, "mono_unity_set_vprintf_func"));
mono_profiler_install = (mono_profiler_install_t)(GetProcAddress(dll, "mono_profiler_install"));
mono_profiler_set_events = (mono_profiler_set_events_t)(GetProcAddress(dll, "mono_profiler_set_events"));
mono_profiler_install_enter_leave = (mono_profiler_install_enter_leave_t)(GetProcAddress(dll, "mono_profiler_install_enter_leave"));
mono_profiler_install_gc = (mono_profiler_install_gc_t)(GetProcAddress(dll, "mono_profiler_install_gc"));
mono_profiler_install_allocation = (mono_profiler_install_allocation_t)(GetProcAddress(dll, "mono_profiler_install_allocation"));
mono_profiler_install_jit_end = (mono_profiler_install_jit_end_t)(GetProcAddress(dll, "mono_profiler_install_jit_end"));
mono_profiler_install_exception = (mono_profiler_install_exception_t)(GetProcAddress(dll, "mono_profiler_install_exception"));
mono_profiler_install_thread = (mono_profiler_install_thread_t)(GetProcAddress(dll, "mono_profiler_install_thread"));
}
#include"def_mono.hpp"
namespace{
void MonoCallBack(void* assembly, void* userData) {
auto Image=(SafeFptr(mono_assembly_get_image))((MonoAssembly*)assembly);
if(!Image)return;
auto st=reinterpret_cast<std::vector<MonoImage*>*>(userData);
st->push_back(Image);
}
std::vector<MonoImage*>mono_loop_images(){
std::vector<MonoImage*>images;
(SafeFptr(mono_assembly_foreach))(MonoCallBack,(void*)&images);
return images;
}
MonoClass* mono_findklassby_ass_namespace(std::vector<MonoImage*>& images,const char *_dll, const char *_namespace,const char *_class,bool strict){
MonoClass* maybe=NULL;
for(auto Image:images){
auto tmp=(SafeFptr(mono_class_from_name))(Image, _namespace,_class);
if(!tmp)continue;
maybe=tmp;
auto name=(SafeFptr(mono_image_get_name))(Image);
if(!name)continue;
if(strcmp(_dll,name)==0)return tmp;
void MonoCallBack(void* assembly, void* userData) {
auto Image=(SafeFptr(mono_assembly_get_image))((MonoAssembly*)assembly);
if(!Image)return;
auto st=reinterpret_cast<std::vector<MonoImage*>*>(userData);
st->push_back(Image);
}
if(strict)return NULL;
return maybe;
}
std::vector<MonoClass*> mono_findklassby_class(std::vector<MonoImage*>& images,const char *_namespace,const char *_class){
std::vector<MonoImage*>mono_loop_images(){
std::vector<MonoImage*>images;
(SafeFptr(mono_assembly_foreach))(MonoCallBack,(void*)&images);
return images;
}
MonoClass* mono_findklassby_ass_namespace(std::vector<MonoImage*>& images,const char *_dll, const char *_namespace,const char *_class,bool strict){
MonoClass* maybe=NULL;
std::vector<MonoClass*>maybes;
for(auto image:images){
auto _1=(SafeFptr(mono_image_get_table_info))((void*)image,MONO_TABLE_TYPEDEF);
if(!_1)continue;
auto tdefcount=(SafeFptr(mono_table_info_get_rows))(_1);
if(!tdefcount)continue;
for (int i = 0; i < tdefcount; i++)
{
auto klass = (MonoClass*)(SafeFptr(mono_class_get))(image, MONO_TOKEN_TYPE_DEF | i+1);
if(!klass)continue;
auto name=(SafeFptr(mono_class_get_name))(klass);
for(auto Image:images){
auto tmp=(SafeFptr(mono_class_from_name))(Image, _namespace,_class);
if(!tmp)continue;
maybe=tmp;
auto name=(SafeFptr(mono_image_get_name))(Image);
if(!name)continue;
if(strcmp(name,_class)!=0)continue;
maybes.push_back(klass);
auto namespacename=(SafeFptr(mono_class_get_namespace))(klass);
if(!namespacename)continue;
if(strlen(_namespace)&&(strcmp(namespacename,_namespace)==0)){
return {klass};
if(strcmp(_dll,name)==0)return tmp;
}
if(strict)return NULL;
return maybe;
}
std::vector<MonoClass*> mono_findklassby_class(std::vector<MonoImage*>& images,const char *_namespace,const char *_class){
std::vector<MonoClass*>maybes;
for(auto image:images){
auto _1=(SafeFptr(mono_image_get_table_info))(image,MONO_TABLE_TYPEDEF);
if(!_1)continue;
auto tdefcount=(SafeFptr(mono_table_info_get_rows))(_1);
if(!tdefcount)continue;
for (int i = 0; i < tdefcount; i++)
{
auto klass = (MonoClass*)(SafeFptr(mono_class_get))(image, MONO_TOKEN_TYPE_DEF | i+1);
if(!klass)continue;
auto name=(SafeFptr(mono_class_get_name))(klass);
if(!name)continue;
if(strcmp(name,_class)!=0)continue;
maybes.push_back(klass);
auto namespacename=(SafeFptr(mono_class_get_namespace))(klass);
if(!namespacename)continue;
if(strlen(_namespace)&&(strcmp(namespacename,_namespace)==0)){
return {klass};
}
}
}
return maybes;
}
return maybes;
}
void tryprintimage(MonoClass* klass){
auto image=(SafeFptr(mono_class_get_image))(klass);
if(!image)return;
auto imagen=(SafeFptr(mono_image_get_name))(image);
auto names=(SafeFptr(mono_class_get_namespace))(klass);
if(imagen&&names)
ConsoleOutput("%s:%s",imagen,names);
}
uintptr_t getmethodofklass(MonoClass* klass,const char* name, int argsCount){
if(!klass)return NULL;
auto MonoClassMethod = (SafeFptr(mono_class_get_method_from_name))(klass, name, argsCount);
if(!MonoClassMethod)return NULL;
tryprintimage(klass);
return (uintptr_t)(SafeFptr(mono_compile_method))((uintptr_t)MonoClassMethod);
}
struct AutoThread{
MonoThread *thread=NULL;
AutoThread(){
auto _root=(SafeFptr(mono_get_root_domain))();
if(!_root)return ;
thread= (SafeFptr(mono_thread_attach))(_root);
void tryprintimage(MonoClass* klass){
auto image=(SafeFptr(mono_class_get_image))(klass);
if(!image)return;
auto imagen=(SafeFptr(mono_image_get_name))(image);
auto names=(SafeFptr(mono_class_get_namespace))(klass);
if(imagen&&names)
ConsoleOutput("%s:%s",imagen,names);
}
~AutoThread(){
if(!thread)return;
(SafeFptr(mono_thread_detach))(thread);
uintptr_t getmethodofklass(MonoClass* klass,const char* name, int argsCount){
if(!klass)return NULL;
auto MonoClassMethod = (SafeFptr(mono_class_get_method_from_name))(klass, name, argsCount);
if(!MonoClassMethod)return NULL;
tryprintimage(klass);
return (uintptr_t)(SafeFptr(mono_compile_method))(MonoClassMethod);
}
};
struct AutoThread{
MonoThread *thread=NULL;
AutoThread(){
auto _root=(SafeFptr(mono_get_root_domain))();
if(!_root)return ;
thread= (SafeFptr(mono_thread_attach))(_root);
}
~AutoThread(){
if(!thread)return;
(SafeFptr(mono_thread_detach))(thread);
}
};
}
uintptr_t getmonofunctionptr(const char *_dll, const char *_namespace, const char *_class, const char *_method, int paramCount,bool strict) {
void monofunctions::init(HMODULE game_module)
{
RESOLVE_IMPORT(mono_string_chars);
RESOLVE_IMPORT(mono_string_length);
RESOLVE_IMPORT(mono_table_info_get_rows);
RESOLVE_IMPORT(mono_image_get_table_info);
RESOLVE_IMPORT(mono_compile_method);
RESOLVE_IMPORT(mono_class_from_name );
RESOLVE_IMPORT(mono_domain_get );
RESOLVE_IMPORT(mono_get_root_domain );
RESOLVE_IMPORT(mono_assembly_foreach );
RESOLVE_IMPORT(mono_image_get_name );
RESOLVE_IMPORT(mono_assembly_get_image );
RESOLVE_IMPORT(mono_class_is_valuetype );
RESOLVE_IMPORT(mono_signature_get_param_count );
RESOLVE_IMPORT(mono_string_to_utf8 );
RESOLVE_IMPORT(mono_string_new_wrapper );
RESOLVE_IMPORT(mono_class_get_parent );
RESOLVE_IMPORT(mono_class_get_namespace );
RESOLVE_IMPORT(mono_class_is_subclass_of );
RESOLVE_IMPORT(mono_class_get_name );
RESOLVE_IMPORT(mono_type_get_name );
RESOLVE_IMPORT(mono_type_get_class );
RESOLVE_IMPORT(mono_exception_from_name_msg );
RESOLVE_IMPORT(mono_raise_exception );
RESOLVE_IMPORT(mono_get_exception_class );
RESOLVE_IMPORT(mono_get_array_class );
RESOLVE_IMPORT(mono_get_string_class );
RESOLVE_IMPORT(mono_get_int32_class );
RESOLVE_IMPORT(mono_array_new );
RESOLVE_IMPORT(mono_array_new_full );
RESOLVE_IMPORT(mono_array_class_get );
RESOLVE_IMPORT(mono_class_array_element_size );
RESOLVE_IMPORT(mono_type_get_object );
RESOLVE_IMPORT(mono_thread_attach );
RESOLVE_IMPORT(mono_thread_detach );
RESOLVE_IMPORT(mono_thread_exit );
RESOLVE_IMPORT(mono_thread_current );
RESOLVE_IMPORT(mono_thread_set_main );
RESOLVE_IMPORT(mono_set_find_plugin_callback );
RESOLVE_IMPORT(mono_security_enable_core_clr );
RESOLVE_IMPORT(mono_security_set_core_clr_platform_callback );
RESOLVE_IMPORT(mono_runtime_unhandled_exception_policy_get );
RESOLVE_IMPORT(mono_runtime_unhandled_exception_policy_set );
RESOLVE_IMPORT(mono_class_get_nesting_type );
RESOLVE_IMPORT(mono_class_vtable );
RESOLVE_IMPORT(mono_method_get_object );
RESOLVE_IMPORT(mono_method_signature );
RESOLVE_IMPORT(mono_signature_get_params );
RESOLVE_IMPORT(mono_signature_get_return_type );
RESOLVE_IMPORT(mono_class_get_type );
RESOLVE_IMPORT(mono_set_ignore_version_and_key_when_finding_assemblies_already_loaded );
RESOLVE_IMPORT(mono_debug_init );
RESOLVE_IMPORT(mono_debug_open_image_from_memory );
RESOLVE_IMPORT(mono_field_get_flags );
RESOLVE_IMPORT(mono_image_open_from_data_full );
RESOLVE_IMPORT(mono_image_open_from_data_with_name );
RESOLVE_IMPORT(mono_assembly_load_from );
RESOLVE_IMPORT(mono_value_box );
RESOLVE_IMPORT(mono_class_get_image );
RESOLVE_IMPORT(mono_signature_is_instance );
RESOLVE_IMPORT(mono_method_get_last_managed );
RESOLVE_IMPORT(mono_get_enum_class );
RESOLVE_IMPORT(mono_class_get_byref_type );
RESOLVE_IMPORT(mono_field_static_get_value );
RESOLVE_IMPORT(mono_unity_set_embeddinghostname );
RESOLVE_IMPORT(mono_set_assemblies_path );
RESOLVE_IMPORT(mono_gchandle_new );
RESOLVE_IMPORT(mono_gchandle_get_target );
RESOLVE_IMPORT(mono_gchandle_new_weakref );
RESOLVE_IMPORT(mono_assembly_get_object );
RESOLVE_IMPORT(mono_gchandle_free );
RESOLVE_IMPORT(mono_class_get_properties );
RESOLVE_IMPORT(mono_property_get_get_method );
RESOLVE_IMPORT(mono_object_new_alloc_specific );
RESOLVE_IMPORT(mono_object_new_specific );
RESOLVE_IMPORT(mono_gc_collect );
RESOLVE_IMPORT(mono_gc_max_generation );
RESOLVE_IMPORT(mono_image_get_assembly );
RESOLVE_IMPORT(mono_assembly_open );
RESOLVE_IMPORT(mono_class_is_enum );
RESOLVE_IMPORT(mono_class_instance_size );
RESOLVE_IMPORT(mono_object_get_size );
RESOLVE_IMPORT(mono_image_get_filename );
RESOLVE_IMPORT(mono_assembly_load_from_full );
RESOLVE_IMPORT(mono_class_get_interfaces );
RESOLVE_IMPORT(mono_assembly_close );
RESOLVE_IMPORT(mono_class_get_property_from_name );
RESOLVE_IMPORT(mono_class_get_method_from_name );
RESOLVE_IMPORT(mono_class_from_mono_type );
RESOLVE_IMPORT(mono_domain_set );
RESOLVE_IMPORT(mono_thread_push_appdomain_ref );
RESOLVE_IMPORT(mono_thread_pop_appdomain_ref );
RESOLVE_IMPORT(mono_runtime_exec_main );
RESOLVE_IMPORT(mono_get_corlib );
RESOLVE_IMPORT(mono_class_get_field_from_name );
RESOLVE_IMPORT(mono_class_get_flags );
RESOLVE_IMPORT(mono_parse_default_optimizations );
RESOLVE_IMPORT(mono_set_defaults );
RESOLVE_IMPORT(mono_set_dirs );
RESOLVE_IMPORT(mono_jit_parse_options );
RESOLVE_IMPORT(mono_object_unbox );
RESOLVE_IMPORT(mono_custom_attrs_get_attr );
RESOLVE_IMPORT(mono_custom_attrs_has_attr );
RESOLVE_IMPORT(mono_custom_attrs_from_field );
RESOLVE_IMPORT(mono_custom_attrs_from_method );
RESOLVE_IMPORT(mono_custom_attrs_from_class );
RESOLVE_IMPORT(mono_custom_attrs_free );
RESOLVE_IMPORT(g_free );
RESOLVE_IMPORT(mono_runtime_is_shutting_down );
RESOLVE_IMPORT(mono_object_get_virtual_method );
RESOLVE_IMPORT(mono_jit_info_get_code_start );
RESOLVE_IMPORT(mono_jit_info_get_code_size );
RESOLVE_IMPORT(mono_class_from_name_case );
RESOLVE_IMPORT(mono_class_get_nested_types );
RESOLVE_IMPORT(mono_class_get_userdata_offset );
RESOLVE_IMPORT(mono_class_get_userdata );
RESOLVE_IMPORT(mono_class_set_userdata );
RESOLVE_IMPORT(mono_set_signal_chaining );
RESOLVE_IMPORT(mono_unity_set_unhandled_exception_handler );
RESOLVE_IMPORT(mono_runtime_invoke_array );
RESOLVE_IMPORT(mono_array_addr_with_size );
RESOLVE_IMPORT(mono_string_to_utf16 );
RESOLVE_IMPORT(mono_field_get_parent );
RESOLVE_IMPORT(mono_method_full_name );
RESOLVE_IMPORT(mono_object_isinst );
RESOLVE_IMPORT(mono_string_new_len );
RESOLVE_IMPORT(mono_string_from_utf16 );
RESOLVE_IMPORT(mono_class_get );
RESOLVE_IMPORT(mono_string_new_utf16 );
}
uintptr_t monofunctions::get_method_pointer(const char *_dll, const char *_namespace, const char *_class, const char *_method, int paramCount,bool strict) {
auto thread=AutoThread();
if(!thread.thread)return NULL;
@ -565,3 +229,17 @@ uintptr_t getmonofunctionptr(const char *_dll, const char *_namespace, const cha
}
return NULL;
}
std::optional<std::wstring_view> monofunctions::get_string(void* ptr){
auto str=reinterpret_cast<MonoString*>(ptr);
if(!str)return {};
auto wc=(SafeFptr(mono_string_chars))(str);
auto len=(SafeFptr(mono_string_length))(str);
if(!(wc&&len))return {};
return std::wstring_view((wchar_t*)wc,len);
}
void* monofunctions::create_string(std::wstring_view ws){
auto domain=(SafeFptr(mono_domain_get))();
if(!domain)return nullptr;
return (SafeFptr(mono_string_new_utf16))(domain,(gunichar2*)ws.data(),ws.length());
}

View File

@ -1,4 +1,5 @@
#include"def_mono.hpp"
#include"def_il2cpp.hpp"
#include"monostringapis.h"
namespace {
@ -145,9 +146,9 @@ namespace monocommon{
bool hook_mono_il2cpp(){
for (const wchar_t* monoName : { L"mono.dll", L"mono-2.0-bdwgc.dll",L"GameAssembly.dll" })
if (HMODULE module = GetModuleHandleW(monoName)) {
bool b2=monodllhook(module);
load_mono_functions_from_dll(module);
il2cpp_symbols::init(module);
//bool b2=monodllhook(module);
il2cppfunctions::init(module);
monofunctions::init(module);
bool succ=false;
for(auto hook:commonhooks){
auto addr=tryfindmonoil2cpp(hook.assemblyName,hook.namespaze,hook.klassName,hook.name,hook.argsCount);
@ -159,7 +160,7 @@ namespace monocommon{
if(!addr)continue;
succ|=NewHook_check(addr,hook);
}
if(succ||b2)return true;
if(succ)return true;
}
return false;
}

View File

@ -0,0 +1,47 @@
#include"def_mono.hpp"
#include"def_il2cpp.hpp"
namespace{
std::optional<std::wstring_view> readmonostring(void* ptr){
if(!ptr)return {};
MonoString* string = (MonoString*)ptr;
auto data = (wchar_t*)string->chars;
auto len=string->length;
if(!(len&&data))return {};
if(wcslen(data)!=len)return {};
return std::wstring_view(data,len);
}
void* createmonostring(std::wstring_view ws,MonoString* origin){
auto newstring=(MonoString*)malloc(sizeof(MonoString)+ws.size()+2);
memcpy(newstring,origin,sizeof(MonoString));
memcpy((wchar_t*)newstring->chars,ws.data(),ws.size()*2);
newstring->length=ws.size();
return newstring;
}
}
void commonsolvemonostring(uintptr_t offset,uintptr_t *data, size_t*len){
auto sw=il2cppfunctions::get_string((void*)offset);
if(!sw)sw=monofunctions::get_string((void*)offset);
if(!sw)sw=readmonostring((void*)offset);
if(!sw)return;
auto sw_v=sw.value();
*data=(uintptr_t)sw_v.data();
*len=sw_v.length()*sizeof(wchar_t);
//tostring|substring有时会会崩非法指针或者长度爆炸
if(wcslen(sw_v.data())!=sw_v.size())
*len=0;
}
void unity_ui_string_hook_after(uintptr_t *offset,void* data, size_t len)
{
auto view=std::wstring_view((wchar_t*)data,len/2);
auto newstring=il2cppfunctions::create_string(view);
if(!newstring)newstring=monofunctions::create_string(view);
if(!newstring)newstring=createmonostring(view,(MonoString*)*offset);
*offset=(uintptr_t)newstring;
}
uintptr_t tryfindmonoil2cpp(const char *_dll, const char *_namespace, const char *_class, const char *_method, int paramCoun,bool strict){
auto addr=il2cppfunctions::get_method_pointer(_dll,_namespace,_class,_method,paramCoun,strict);
if(addr)return addr;
return monofunctions::get_method_pointer(_dll,_namespace,_class,_method,paramCoun,strict);
}

View File

@ -0,0 +1,9 @@
#define RESOLVE_IMPORT(name) name = (decltype(name))(GetProcAddress(game_module, #name))
void commonsolvemonostring(uintptr_t offset,uintptr_t *data, size_t*len);
void unity_ui_string_hook_after(uintptr_t *offset,void* data, size_t len);
uintptr_t tryfindmonoil2cpp(const char *_dll, const char *_namespace, const char *_class, const char *_method, int paramCoun,bool strict=false);

View File

@ -1,37 +0,0 @@
#include"def_mono.hpp"
#include"def_il2cpp.hpp"
inline void commonsolvemonostring(uintptr_t offset,uintptr_t *data, size_t*len){
MonoString* string = (MonoString*)offset;
if(string==0)return;
*data = (uintptr_t)string->chars;
if(wcslen((wchar_t*)string->chars)!=string->length)return;
*len = string->length * 2;
}
inline void unity_ui_string_hook_after(uintptr_t *offset,void* data, size_t len)
{
MonoString* string = (MonoString*)*offset;
if(string==0)return;
if(wcslen((wchar_t*)string->chars)!=string->length)return;
//其实也可以直接覆写到原来的String上但重新创建一个是更安全的操作。
auto newstring=(MonoString*)malloc(sizeof(MonoString)+len+2);
memcpy(newstring,string,sizeof(MonoString));
wcscpy((wchar_t*)newstring->chars,(wchar_t*)data);
newstring->length=len/2;
*offset=(uintptr_t)newstring;
}
void load_mono_functions_from_dll(HMODULE dll);
uintptr_t getmonofunctionptr(const char *_dll, const char *_namespace, const char *_class, const char *_method, int paramCount,bool strict);
inline uintptr_t tryfindmonoil2cpp(const char *_dll, const char *_namespace, const char *_class, const char *_method, int paramCoun,bool strict=false){
auto addr=il2cpp_symbols::get_method_pointer(_dll,_namespace,_class,_method,paramCoun,strict);
if(addr)return addr;
return getmonofunctionptr(_dll,_namespace,_class,_method,paramCoun,strict);
}

View File

@ -25,7 +25,7 @@ enum { TEXT_BUFFER_SIZE = PIPE_BUFFER_SIZE - sizeof(TextOutput_T) };
#include"Lang/Lang.h"
#include"veh_hook.h"
#include"engines/emujitarg.hpp"
#include"engines/mono/monoil2cpp.hpp"
#include"engines/mono/monoil2cpp.h"
#include "hookfinder.h"
#include"util/textunion.h"
#include"util/ntxpundef.h"