This commit is contained in:
恍兮惚兮 2024-05-09 07:23:06 +08:00
parent f055baff99
commit 1db17d2279
22 changed files with 1309 additions and 426 deletions

View File

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

View File

@ -1,6 +1,5 @@
#include"mono.h" #include"mono.h"
#include"mono/monocommon.hpp" #include"mono/monocommon.hpp"
#include "mono/monoobject.h"
bool monobdwgc() { bool monobdwgc() {

View File

@ -1,5 +1,4 @@
#include"mono.h" #include"mono.h"
#include "mono/monoobject.h"
#include"mono/monocommon.hpp" #include"mono/monocommon.hpp"
namespace{ namespace{

View File

@ -58,8 +58,8 @@ bool vita3k::attach_function()
HookParam hp; HookParam hp;
hp.address=DoJitPtr; hp.address=DoJitPtr;
hp.text_fun=[](hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* split, size_t* len){ hp.text_fun=[](hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* split, size_t* len){
auto descriptor = *argidx(stack,idxDescriptor); // r8 auto descriptor = *argidx(stack,idxDescriptor+1); // r8
auto entrypoint = *argidx(stack,idxEntrypoint); // r9 auto entrypoint = *argidx(stack,idxEntrypoint+1); // r9
auto em_address = *(uint32_t*)descriptor; auto em_address = *(uint32_t*)descriptor;
if(!entrypoint)return; if(!entrypoint)return;
// ConsoleOutput("%p",em_address); // ConsoleOutput("%p",em_address);

View File

@ -144,8 +144,8 @@ bool yuzusuyu::attach_function()
HookParam hp; HookParam hp;
hp.address=DoJitPtr; hp.address=DoJitPtr;
hp.text_fun=[](hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* split, size_t* len){ hp.text_fun=[](hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* split, size_t* len){
auto descriptor = *argidx(stack,idxDescriptor); // r8 auto descriptor = *argidx(stack,idxDescriptor+1); // r8
auto entrypoint = *argidx(stack,idxEntrypoint); // r9 auto entrypoint = *argidx(stack,idxEntrypoint+1); // r9
auto em_address = *(uintptr_t*)descriptor; auto em_address = *(uintptr_t*)descriptor;
if(!entrypoint)return; if(!entrypoint)return;
jitaddraddr(em_address,entrypoint,JITTYPE::YUZU); jitaddraddr(em_address,entrypoint,JITTYPE::YUZU);

View File

@ -1,4 +1,4 @@
add_library(commonengine 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/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) target_precompile_headers(commonengine REUSE_FROM pchhook)

View File

@ -0,0 +1,403 @@
#pragma once
typedef signed long SInt32;
typedef unsigned long UInt32;
typedef signed short SInt16;
typedef unsigned short UInt16;
typedef unsigned char UInt8;
typedef signed char SInt8;
typedef unsigned long long UInt64;
typedef signed long long SInt64;
#define MONO_ZERO_LEN_ARRAY 1
#define MONO_TOKEN_TYPE_DEF 0x02000000
#define MONO_TABLE_TYPEDEF 0x2
struct MonoException;
struct MonoAssembly;
struct MonoClassField;
struct MonoClass;
struct MonoDomain;
struct MonoImage;
struct MonoType;
struct MonoMethodSignature;
struct MonoArray;
struct MonoThread;
struct MonoThreadsSync;
struct MonoVTable;
struct MonoProperty;
struct MonoReflectionAssembly;
struct MonoReflectionMethod;
struct MonoAppDomain;
struct MonoCustomAttrInfo;
struct MonoReflectionType { UInt32 offset[2]; MonoType* type;};
typedef void* gconstpointer;
typedef void* gpointer;
typedef int gboolean;
typedef unsigned int guint32;
typedef int gint32;
typedef long gint64;
typedef unsigned char guchar;
typedef UInt16 gunichar2;
struct MonoObject {
MonoVTable *vtable;
MonoThreadsSync *synchronisation;
};
typedef MonoObject* MonoStruct;
typedef MonoObject** MonoStruct_out;
struct MonoString {
MonoObject object;
gint32 length;
gunichar2 chars[0];
};
struct MonoMethod {
UInt16 flags;
UInt16 iflags;
};
typedef enum
{
MONO_VERIFIER_MODE_OFF,
MONO_VERIFIER_MODE_VALID,
MONO_VERIFIER_MODE_VERIFIABLE,
MONO_VERIFIER_MODE_STRICT
} MiniVerifierMode;
typedef enum {
MONO_SECURITY_MODE_NONE,
MONO_SECURITY_MODE_CORE_CLR,
MONO_SECURITY_MODE_CAS,
MONO_SECURITY_MODE_SMCS_HACK
} MonoSecurityMode;
typedef void GFuncRef (void*, void*);
typedef GFuncRef* GFunc;
typedef enum {
MONO_UNHANDLED_POLICY_LEGACY,
MONO_UNHANDLED_POLICY_CURRENT
} MonoRuntimeUnhandledExceptionPolicy;
struct MonoMethodDesc {
char *namespace2;
char *klass;
char *name;
char *args1;
UInt32 num_args;
gboolean include_namespace, klass_glob, name_glob;
};
struct MonoJitInfo;
struct MonoAssemblyName;
struct MonoDebugSourceLocation;
struct MonoLoaderError;
struct MonoDlFallbackHandler;
struct LivenessState;
struct MonoBreakPolicy;
typedef bool (*MonoCoreClrPlatformCB) (const char *image_name);
typedef unsigned int guint;
typedef void (*register_object_callback)(gpointer* arr, int size, void* callback_userdata);
typedef gboolean (*MonoStackWalk) (MonoMethod *method, gint32 native_offset, gint32 il_offset, gboolean managed, gpointer data);
typedef MonoBreakPolicy (*MonoBreakPolicyFunc) (MonoMethod *method);
typedef void* (*MonoDlFallbackLoad) (const char *name, int flags, char **err, void *user_data);
typedef void* (*MonoDlFallbackSymbol) (void *handle, const char *name, char **err, void *user_data);
typedef void* (*MonoDlFallbackClose) (void *handle, void *user_data);
typedef enum {
MONO_TYPE_NAME_FORMAT_IL,
MONO_TYPE_NAME_FORMAT_REFLECTION,
MONO_TYPE_NAME_FORMAT_FULL_NAME,
MONO_TYPE_NAME_FORMAT_ASSEMBLY_QUALIFIED
} MonoTypeNameFormat;
//typedef void (*vprintf_func)(const char* msg, va_list args);
struct MonoProfiler;
typedef void (*MonoProfileFunc) (MonoProfiler *prof);
typedef enum {
MONO_PROFILE_NONE = 0,
MONO_PROFILE_APPDOMAIN_EVENTS = 1 << 0,
MONO_PROFILE_ASSEMBLY_EVENTS = 1 << 1,
MONO_PROFILE_MODULE_EVENTS = 1 << 2,
MONO_PROFILE_CLASS_EVENTS = 1 << 3,
MONO_PROFILE_JIT_COMPILATION = 1 << 4,
MONO_PROFILE_INLINING = 1 << 5,
MONO_PROFILE_EXCEPTIONS = 1 << 6,
MONO_PROFILE_ALLOCATIONS = 1 << 7,
MONO_PROFILE_GC = 1 << 8,
MONO_PROFILE_THREADS = 1 << 9,
MONO_PROFILE_REMOTING = 1 << 10,
MONO_PROFILE_TRANSITIONS = 1 << 11,
MONO_PROFILE_ENTER_LEAVE = 1 << 12,
MONO_PROFILE_COVERAGE = 1 << 13,
MONO_PROFILE_INS_COVERAGE = 1 << 14,
MONO_PROFILE_STATISTICAL = 1 << 15,
MONO_PROFILE_METHOD_EVENTS = 1 << 16,
MONO_PROFILE_MONITOR_EVENTS = 1 << 17,
MONO_PROFILE_IOMAP_EVENTS = 1 << 18, /* this should likely be removed, too */
MONO_PROFILE_GC_MOVES = 1 << 19
} MonoProfileFlags;
typedef enum {
MONO_GC_EVENT_START,
MONO_GC_EVENT_MARK_START,
MONO_GC_EVENT_MARK_END,
MONO_GC_EVENT_RECLAIM_START,
MONO_GC_EVENT_RECLAIM_END,
MONO_GC_EVENT_END,
MONO_GC_EVENT_PRE_STOP_WORLD,
MONO_GC_EVENT_POST_STOP_WORLD,
MONO_GC_EVENT_PRE_START_WORLD,
MONO_GC_EVENT_POST_START_WORLD
} MonoGCEvent;
typedef void (*MonoProfileMethodFunc) (MonoProfiler *prof, MonoMethod *method);
typedef void (*MonoProfileGCFunc) (MonoProfiler *prof, MonoGCEvent event, int generation);
typedef void (*MonoProfileGCMoveFunc) (MonoProfiler *prof, void **objects, int num);
typedef void (*MonoProfileGCResizeFunc) (MonoProfiler *prof, gint64 new_size);
typedef void (*MonoProfileAllocFunc) (MonoProfiler *prof, MonoObject *obj, MonoClass *klass);
typedef void (*MonoProfileJitResult) (MonoProfiler *prof, MonoMethod *method, MonoJitInfo* jinfo, int result);
typedef void (*MonoProfileExceptionFunc) (MonoProfiler *prof, MonoObject *object);
typedef void (*MonoProfileExceptionClauseFunc) (MonoProfiler *prof, MonoMethod *method, int clause_type, int clause_num);
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);

View File

@ -0,0 +1,141 @@
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;
char* il2cpp_array_addr_with_size(void* array, int32_t size, uintptr_t idx)
{
return ((char*)array) + kIl2CppSizeOfArray + size * idx;
}
namespace il2cpp_symbols
{
#define RESOLVE_IMPORT(name) name = reinterpret_cast<name##_t>(GetProcAddress(game_module, #name))
void init(HMODULE game_module)
{
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)
{
if(!(il2cpp_thread_attach&&il2cpp_domain_get&&il2cpp_assembly_get_image&&il2cpp_class_from_name))return NULL;
auto il2cpp_domain=il2cpp_domain_get();
if (!il2cpp_domain) return NULL;
il2cpp_thread_attach(il2cpp_domain);
void* assembly=0;
if(il2cpp_domain_assembly_open){
do{
assembly = il2cpp_domain_assembly_open(il2cpp_domain, assemblyName);
if(!assembly)break;
auto image = il2cpp_assembly_get_image(assembly);
if(!image)break;
auto klass = il2cpp_class_from_name(image, namespaze, klassName);
if(klass)return klass;
}while(0);
}
if(il2cpp_domain_get_assemblies&&il2cpp_assembly_get_image)
{
int _ = 0;
size_t sz = 0;
auto assemblies = il2cpp_domain_get_assemblies(il2cpp_domain, &sz);
for (auto i = 0; i < sz; i++, assemblies++) {
auto image = il2cpp_assembly_get_image(*assemblies);
auto cls = il2cpp_class_from_name(image, namespaze, klassName);
if(cls)return cls;
}
}
return NULL;
}
struct callbackstruct{
const char* classname;
const char* namespacename;
Il2CppClass* klass;
};
void foreach_func(Il2CppClass* klass, void* userData){
auto st=(callbackstruct*)userData;
auto classname = il2cpp_class_get_name(klass);
auto namespacename=il2cpp_class_get_namespace(klass);
if(strcmp(classname,st->classname)==0&&strcmp(namespacename,st->namespacename)==0)
st->klass=klass;
}
Il2CppClass* get_il2cppclass2(const char* namespaze,
const char* klassName)
{
if(!(il2cpp_class_for_each&&il2cpp_class_get_name&&il2cpp_class_get_namespace))return NULL;
callbackstruct st;
st.klass=NULL;
st.classname=klassName;
st.namespacename=namespaze;
il2cpp_class_for_each(foreach_func,&st);
return st.klass;
}
uintptr_t get_method_pointer(const char* assemblyName, const char* namespaze,
const char* klassName, const char* name, int argsCount)
{
if(!il2cpp_class_get_method_from_name)return NULL;
auto klass=get_il2cppclass1(assemblyName,namespaze,klassName);
if (!klass)
klass=get_il2cppclass2(namespaze,klassName);
if (!klass)
return NULL;
auto ret = il2cpp_class_get_method_from_name(klass, name, argsCount);
if (ret) return ret->methodPointer;
return NULL;
}
}

View File

@ -0,0 +1,528 @@
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;
void load_mono_functions_from_dll(HMODULE dll)
{
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"));
}
struct callbackstruct{
const char* _dll;
const char* _namespace;
const char* _class;
bool goodmatch;
MonoImage* Image;
MonoClass* klass;
};
static void MonoCallBack(void* assembly, void* userData) {
auto Image=mono_assembly_get_image((MonoAssembly*)assembly);
if(!Image)return;
auto st=reinterpret_cast<callbackstruct*>(userData);
if(st->goodmatch)return;
if(mono_image_get_name){
auto name=mono_image_get_name(Image);
if(strcmp(st->_dll,name)==0){
st->Image=Image;
st->goodmatch=true;
st->klass=mono_class_from_name(Image, st->_namespace,st->_class);
return;
}
}
if(!st->klass)
{
auto mono_class=mono_class_from_name(Image,st->_namespace,st->_class);
if(mono_class)
st->klass=mono_class;
}
}
// Function to invoke a dll method in a mono application
uintptr_t getmonofunctionptr(const char *_dll, const char *_namespace, const char *_class, const char *_method, int paramCount) {
if(!(mono_thread_attach&&mono_class_from_name&&mono_class_get_method_from_name&&mono_assembly_foreach&&mono_get_root_domain&&mono_compile_method))return NULL;
mono_thread_attach(mono_get_root_domain());
callbackstruct st;
st.Image=NULL;
st.klass=NULL;
st._dll=_dll;
st._namespace=_namespace;
st._class=_class;
st.goodmatch=false;
mono_assembly_foreach(MonoCallBack,(void*)&st);
#if 0
MonoDomain* domain = mono_get_root_domain();
if(!domain)return NULL;
//Opening a custom assembly in the domain.
MonoAssembly* domainassembly = mono_domain_assembly_open(domain, _dll);
if(!domainassembly)return NULL;
//Getting the assembly's Image(Binary image, essentially a file-module).
MonoImage* Image = mono_assembly_get_image(domainassembly);
#endif
auto pClass=st.klass;
if(!pClass)return NULL;
//Declaring the method, that attaches our assembly to the game. (Class, MethodName, Parameters)
MonoMethod* MonoClassMethod = mono_class_get_method_from_name(pClass, _method, paramCount);
if(!MonoClassMethod)return NULL;
return (uintptr_t)mono_compile_method((uintptr_t)MonoClassMethod);
}

View File

@ -1,46 +1,7 @@
#include"il2cpp.hpp" #include"monostringapis.h"
#include "monoobject.h"
#include"monofuncinfo.h"
namespace { namespace {
#define GetProcAddressXX(mm, func) auto func=(func##_t)GetProcAddress((mm), #func);
std::mutex mutex;
std::unordered_set<uint64_t>inserted_addr;
void NewHook_check(HookParam& hp,LPCSTR n){
std::lock_guard _(mutex);
if(inserted_addr.find(hp.address)==inserted_addr.end()){
auto succ=NewHook(hp,n);
#ifdef _WIN64
if(!succ){
hp.type|=BREAK_POINT;
NewHook(hp,n);
}
#endif
inserted_addr.insert(hp.address);
}
}
std::vector<std::vector<char*>> unity_ui_text={
{"TMPro","TMP_Text"},
{"UnityEngine.UI","Text"},
{"","UILabel"},
{"UnityEngine","GUIText"},
{"UnityEngine","TextMesh"},
{"UnityEngine.UIElements","TextElement"},
{"UnityEngine.UIElements","TextField","value"}
};
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;
}
void mscorlib_system_string_hook_fun(hook_stack* stack, HookParam *hp, uintptr_t *data, uintptr_t *split, size_t*len)
{
commonsolvemonostring(stack->ARG1,data,len);
}
void mscorlib_system_string_InternalSubString_hook_fun(hook_stack* stack, HookParam *hp, uintptr_t *data, uintptr_t *split, size_t*len) void mscorlib_system_string_InternalSubString_hook_fun(hook_stack* stack, HookParam *hp, uintptr_t *data, uintptr_t *split, size_t*len)
{ {
uintptr_t offset=stack->ARG1; uintptr_t offset=stack->ARG1;
@ -54,55 +15,10 @@ void mscorlib_system_string_InternalSubString_hook_fun(hook_stack* stack, HookP
*len = length * 2; *len = length * 2;
} }
auto mscorlib_system_string_funcs=std::unordered_map<std::string,void*>{ void mscorlib_system_string_hook_fun(hook_stack* stack, HookParam *hp, uintptr_t *data, uintptr_t *split, size_t*len)
{"ToCharArray",mscorlib_system_string_hook_fun},
{"Replace",mscorlib_system_string_hook_fun},
{"ToString",mscorlib_system_string_hook_fun},
{"IndexOf",mscorlib_system_string_hook_fun},
{"Substring",mscorlib_system_string_hook_fun},
{"op_Inequality",mscorlib_system_string_hook_fun},//[230901] [ILLGAMES] ハニカム
{"InternalSubString",mscorlib_system_string_InternalSubString_hook_fun} //[1000-REKA] 早咲きのくろゆり 不这样文本会很多会很卡
//https://learn.microsoft.com/zh-cn/dotnet/api/system.string.join?view=net-7.0
// "Join", "IndexOfAnyUnchecked", "LastIndexOfAny", "Split", "IndexOfAny", "Compare", "Concat", "TrimEnd", "op_Inequality", "InternalSplitKeepEmptyEntries", "CreateString", "FormatHelper", "FastAllocateString", "EndsWith", "ReplaceInternal", "CopyTo", "IndexOfUnchecked", "ConcatArray", "Trim", "ToLower", "MakeSeparatorList", ".ctor", "SplitInternal", "CharCopy", "LastIndexOfAnyUnchecked", "IsNullOrWhiteSpace", "CtorCharPtrStartLength", "FillStringChecked", "op_Equality", "StartsWith", "Contains", "ToLowerInvariant", "TrimHelper", "Equals", "wstrcpy", "CtorCharArrayStartLength", "ReplaceUnchecked", "InternalSplitOmitEmptyEntries", "LastIndexOf", "Format"
//String还有其他函数但一般这几个就可以了
};
void unity_ui_string_hook_fun(hook_stack* stack, HookParam *hp, uintptr_t *data, uintptr_t *split, size_t*len)
{ {
commonsolvemonostring(stack->ARG2,data,len); commonsolvemonostring(stack->ARG1,data,len);
} }
void unity_ui_string_hook_after(hook_stack* stack,void* data, size_t len)
{
MonoString* string = (MonoString*)stack->ARG2;
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;
stack->ARG2=(uintptr_t)newstring;
}
void MONO_IL2CPP_NEW_HOOK(void* text_fun,void* hook_after, uintptr_t addr,const char*name){
if(addr==0)return;
HookParam hp;
hp.address = addr;
hp.type = USING_STRING | CODEC_UTF16|FULL_STRING;
hp.text_fun =(decltype(hp.text_fun))text_fun;
if(hook_after)
{
hp.type|=EMBED_ABLE|EMBED_BEFORE_SIMPLE;
hp.hook_after=(decltype(hp.hook_after))hook_after;
}
NewHook_check(hp, name);
}
auto unity_ui_string_hook=std::bind(MONO_IL2CPP_NEW_HOOK,unity_ui_string_hook_fun,unity_ui_string_hook_after,std::placeholders::_1,std::placeholders::_2);
auto mscorlib_system_string_hook=[](uintptr_t addr,std::pair<std::string,void*>func){
MONO_IL2CPP_NEW_HOOK(func.second,0,addr,func.first.c_str());
};
/** jichi 12/26/2014 Mono /** jichi 12/26/2014 Mono
* Sample game: [141226] <EFBFBD><EFBFBD> * Sample game: [141226] <EFBFBD><EFBFBD>
@ -124,176 +40,7 @@ void SpecialHookMonoString(hook_stack* stack, HookParam *hp, uintptr_t *data, u
#endif #endif
} }
}
namespace il2cpp_func{
void insertsystemstringfunc(Il2CppClass*klass,HMODULE module){
GetProcAddressXX(module,il2cpp_class_get_method_from_name);
if(il2cpp_class_get_method_from_name==0)return ;
for(auto func:mscorlib_system_string_funcs){
auto ToCharArray= il2cpp_class_get_method_from_name(klass,func.first.c_str(),-1);
if(ToCharArray==0)continue;
mscorlib_system_string_hook(ToCharArray->methodPointer,func);
}
}
bool withimage(HMODULE module){
GetProcAddressXX(module,il2cpp_domain_get);
GetProcAddressXX(module,il2cpp_thread_attach);
GetProcAddressXX(module,il2cpp_domain_get_assemblies);
GetProcAddressXX(module,il2cpp_assembly_get_image);
GetProcAddressXX(module,il2cpp_class_from_name);
GetProcAddressXX(module,il2cpp_class_get_method_from_name);
if (!(il2cpp_domain_get && il2cpp_thread_attach && il2cpp_assembly_get_image && il2cpp_domain_get_assemblies && il2cpp_class_from_name && il2cpp_class_get_method_from_name))return false;
auto domain = il2cpp_domain_get();
il2cpp_thread_attach(domain);
int _ = 0;
size_t sz = 0;
auto assemblies = il2cpp_domain_get_assemblies(domain, &sz);
for (auto i = 0; i < sz; i++, assemblies++) {
auto image = il2cpp_assembly_get_image(*assemblies);
do{
auto cls = il2cpp_class_from_name(image, "System", "String");
if (cls==0)break;
il2cpp_func::insertsystemstringfunc(cls,module);
}while(0);
for(auto _:unity_ui_text){
auto cls = il2cpp_class_from_name(image, _[0], _[1]);
if (cls == 0) continue;
auto method = il2cpp_class_get_method_from_name(cls, "set_text", 1);
if (method == 0) continue;
unity_ui_string_hook(method->methodPointer,_[1]);
}
}
return true;
}
void foreach_func(Il2CppClass* klass, void* userData){
HMODULE module = GetModuleHandleW(L"GameAssembly.dll");
GetProcAddressXX(module,il2cpp_class_get_name);
GetProcAddressXX(module,il2cpp_method_get_name);
GetProcAddressXX(module,il2cpp_class_get_methods);
GetProcAddressXX(module,il2cpp_class_get_namespace);
GetProcAddressXX(module,il2cpp_class_get_method_from_name);
if (!(il2cpp_class_get_name ))return;
auto classname = il2cpp_class_get_name(klass);
std::string cln = classname;
do{
if(!(il2cpp_class_get_namespace && il2cpp_class_get_method_from_name))break;
std::string names=il2cpp_class_get_namespace(klass);
if(cln=="String" && names=="System"){
il2cpp_func::insertsystemstringfunc(klass,module);
}
}while(0);
do{
if (!( il2cpp_class_get_methods && il2cpp_method_get_name))break;
if (!(cln.size() >= 4 && (cln.substr(cln.size() - 4, 4) == "Text" || cln.substr(0, 4) == "Text"))) break;
void* iter = 0;
while (true) {
auto methods = il2cpp_class_get_methods(klass, &iter);
if (methods == 0)break;
auto methodname = il2cpp_method_get_name(methods);
if (std::string(methodname) == "set_text") {
unity_ui_string_hook(methods->methodPointer,classname);
}
}
}while(0);
}
bool foreach(HMODULE module){
GetProcAddressXX(module,il2cpp_class_for_each);
if (il2cpp_class_for_each==0)return false;
il2cpp_class_for_each(foreach_func, 0);
return true;
}
}
namespace{
HMODULE monodllhandle=0;
void MonoCallBack(uintptr_t assembly, void* userData) {
GetProcAddressXX(monodllhandle,mono_get_root_domain);
GetProcAddressXX(monodllhandle,mono_thread_attach);
GetProcAddressXX(monodllhandle,mono_assembly_get_image);
GetProcAddressXX(monodllhandle,mono_class_get_property_from_name);
GetProcAddressXX(monodllhandle,mono_class_from_name);
GetProcAddressXX(monodllhandle,mono_property_get_set_method);
GetProcAddressXX(monodllhandle,mono_compile_method);
GetProcAddressXX(monodllhandle,mono_image_get_name);
GetProcAddressXX(monodllhandle,mono_image_get_table_info);
GetProcAddressXX(monodllhandle,mono_table_info_get_rows);
GetProcAddressXX(monodllhandle,mono_class_get);
GetProcAddressXX(monodllhandle,mono_class_get_name);
GetProcAddressXX(monodllhandle,mono_class_get_method_from_name);
if(mono_assembly_get_image==0)return ;
uintptr_t image = mono_assembly_get_image(assembly);
if(!(mono_thread_attach&&mono_get_root_domain&&mono_compile_method))return ;
if((mono_class_from_name&&mono_class_get_property_from_name&&mono_property_get_set_method))
for(auto _:unity_ui_text){
auto mono_class=mono_class_from_name(image,_[0],_[1]);
if(mono_class==0)continue;
uintptr_t mono_property=mono_class_get_property_from_name(mono_class,_.size()==3?_[2] :"text");
if (mono_property == 0)continue;
auto mono_set_method = mono_property_get_set_method(mono_property);
mono_thread_attach(mono_get_root_domain());
if(mono_set_method==0)continue;
uint64_t* method_pointer = mono_compile_method(mono_set_method);
if (method_pointer==0)continue;
unity_ui_string_hook((uintptr_t)method_pointer,_[1]);
}
if((mono_image_get_name&&mono_image_get_table_info&&mono_table_info_get_rows&&mono_class_get&&mono_class_get_name&&mono_class_get_method_from_name)){
//遍历image中的类根据类名判断。
//x86下遍历mono_class_get会中途卡死故放弃仅保留预设。
//这个仅用于hook String
std::string mscorlib=mono_image_get_name(image);
if(mscorlib=="mscorlib"){
auto _1=mono_image_get_table_info((void*)image,MONO_TABLE_TYPEDEF);
auto tdefcount=mono_table_info_get_rows(_1);
for (int i = 0; i < tdefcount; i++)
{
void *klass = mono_class_get((void*)image, MONO_TOKEN_TYPE_DEF | i+1);
char *name=mono_class_get_name(klass);
std::string cln = name;
if(cln=="String"){
for(auto func:mscorlib_system_string_funcs){
auto ToCharArray= mono_class_get_method_from_name(klass,func.first.c_str(),-1);
if(ToCharArray==0)continue;
auto ToCharArrayAddr=mono_compile_method((uintptr_t)ToCharArray);
mscorlib_system_string_hook((uint64_t)ToCharArrayAddr,func);
}
}
}
}
}
}
bool InsertMonoHooksByAssembly(HMODULE module) {
monodllhandle=module;
GetProcAddressXX(monodllhandle,mono_assembly_foreach);
if(mono_assembly_foreach==0)return false;
mono_assembly_foreach(MonoCallBack, NULL);
return true;
}
} }
namespace { namespace {
bool monodllhook(HMODULE module) { bool monodllhook(HMODULE module) {
@ -308,7 +55,7 @@ namespace {
hp.length_offset = func.lengthIndex * 4; hp.length_offset = func.lengthIndex * 4;
hp.text_fun = (decltype(hp.text_fun))func.text_fun; hp.text_fun = (decltype(hp.text_fun))func.text_fun;
ConsoleOutput("Mono: INSERT"); ConsoleOutput("Mono: INSERT");
NewHook_check(hp, func.functionName); NewHook(hp, func.functionName);
} }
} }
return true; return true;
@ -316,15 +63,99 @@ namespace {
} }
namespace monocommon{ namespace monocommon{
bool il2cpp() {
bool monodllhook(HMODULE module) {
HookParam hp;
const MonoFunction funcs[] = { MONO_FUNCTIONS_INITIALIZER };
for (auto func : funcs) {
if (FARPROC addr = GetProcAddress(module, func.functionName)) {
hp.address =(uintptr_t) addr;
hp.type =USING_STRING| func.hookType;
hp.filter_fun =all_ascii_Filter;
hp.offset = func.textIndex * 4;
hp.length_offset = func.lengthIndex * 4;
hp.text_fun = (decltype(hp.text_fun))func.text_fun;
NewHook(hp, func.functionName);
}
}
return true;
}
struct functioninfo{
const char* assemblyName;const char* namespaze;
const char* klassName; const char* name;int argsCount;
int argidx;void* text_fun;bool Embed;
std::string hookname(){
char tmp[1024];
sprintf(tmp,"%s:%s",klassName,name);
return tmp;
}
std::string info(){
char tmp[1024];
sprintf(tmp,"%s:%s:%s:%s:%d",assemblyName,namespaze,klassName,name,argsCount);
return tmp;
}
};
bool NewHook_check(uintptr_t addr,functioninfo&hook){
HookParam hp;
hp.address = addr;
hp.argidx=hook.argidx;
hp.type = USING_STRING | CODEC_UTF16|FULL_STRING;
hp.text_fun =(decltype(hp.text_fun))hook.text_fun;
hp.jittype=JITTYPE::UNITY;
strcpy(hp.unityfunctioninfo,hook.info().c_str());
if(hook.Embed)
hp.type|=EMBED_ABLE|EMBED_BEFORE_SIMPLE;
auto succ=NewHook(hp,hook.hookname().c_str());
#ifdef _WIN64
if(!succ){
hp.type|=BREAK_POINT;
succ|=NewHook(hp,hook.hookname().c_str());
}
#endif
return succ;
}
std::vector<functioninfo>commonhooks{
{"mscorlib","System","String","ToCharArray",0,1,nullptr,false},
{"mscorlib","System","String","Replace",2,1,nullptr,false},
{"mscorlib","System","String","ToString",0,1,nullptr,false},
{"mscorlib","System","String","IndexOf",1,1,nullptr,false},
{"mscorlib","System","String","Substring",1,1,nullptr,false},
{"mscorlib","System","String","Substring",2,1,nullptr,false},
{"mscorlib","System","String","op_Inequality",2,1,0,false},
{"mscorlib","System","String","InternalSubString",2,99999,mscorlib_system_string_InternalSubString_hook_fun,false},
{"Unity.TextMeshPro","TMPro","TMP_Text","set_text",1,2,nullptr,true},
{"UnityEngine.UI","UnityEngine.UI","Text","set_text",1,2,nullptr,true},
{"UnityEngine.UIElementsModule","UnityEngine.UIElements","TextElement","set_text",1,2,nullptr,true},
{"UnityEngine.UIElementsModule","UnityEngine.UIElements","TextField","set_value",1,2,nullptr,true},
{"UnityEngine.TextRenderingModule","UnityEngine","GUIText","set_text",1,2,nullptr,true},
{"UnityEngine.TextRenderingModule","UnityEngine","TextMesh","set_text",1,2,nullptr,true},
};
bool il2cpp() {
HMODULE module = GetModuleHandleW(L"GameAssembly.dll"); HMODULE module = GetModuleHandleW(L"GameAssembly.dll");
if (module == 0)return false; if (module == 0)return false;
bool _1=il2cpp_func::withimage(module); il2cpp_symbols::init(module);
bool _2=il2cpp_func::foreach(module); bool succ=false;
return _1||_2; for(auto hook:commonhooks){
auto addr=il2cpp_symbols::get_method_pointer(hook.assemblyName,hook.namespaze,hook.klassName,hook.name,hook.argsCount);
//ConsoleOutput("%s %p",hook.name,addr-(uintptr_t)module);
if(!addr)continue;
succ|=NewHook_check(addr,hook);
}
return succ;
}
bool InsertMonoHooksByAssembly(HMODULE module){
load_mono_functions_from_dll(module);
bool succ=false;
for(auto hook:commonhooks){
auto addr=getmonofunctionptr(hook.assemblyName,hook.namespaze,hook.klassName,hook.name,hook.argsCount);
if(!addr)continue;
succ|=NewHook_check(addr,hook);
}
return succ;
} }
bool hook_mono(){ bool hook_mono(){
for (const wchar_t* monoName : { L"mono.dll", L"mono-2.0-bdwgc.dll",L"GameAssembly.dll" }) for (const wchar_t* monoName : { L"mono.dll", L"mono-2.0-bdwgc.dll",L"GameAssembly.dll" })
if (HMODULE module = GetModuleHandleW(monoName)) { if (HMODULE module = GetModuleHandleW(monoName)) {

View File

@ -0,0 +1,35 @@
#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;
}
namespace il2cpp_symbols
{
void init(HMODULE game_module);
uintptr_t get_method_pointer(const char* assemblyName, const char* namespaze,
const char* klassName, const char* name, int argsCount);
}
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);

View File

@ -1,64 +0,0 @@
#ifndef MONOOBJECT_H
#define MONOOBJECT_H
// monoobject.h
// 12/26/2014 jichi
// https://github.com/mono/mono/blob/master/mono/metadata/object.h
// https://github.com/mono/mono/blob/master/mono/metadata/object-internals.h
// https://github.com/mono/mono/blob/master/mono/util/mono-publib.h
#include <cstdint>
#define MONO_ZERO_LEN_ARRAY 1
// mono/io-layer/uglify.h
//typedef int8_t gint8;
//typedef int32_t gint32;
//typedef wchar_t gunichar2; // either char or wchar_t, depending on how mono is compiled
typedef int32_t mono_bool;
typedef uint8_t mono_byte;
typedef uint16_t mono_unichar2;
typedef uint32_t mono_unichar4;
// mono/metadata/object.h
typedef mono_bool MonoBoolean;
struct MonoArray;
struct MonoDelegate;
struct MonoDomain;
struct MonoException;
struct MonoString;
struct MonoThreadsSync;
struct MonoThread;
struct MonoVTable;
struct MonoObject {
MonoVTable *vtable;
MonoThreadsSync *synchronisation;
};
struct MonoString {
MonoObject object;
int32_t length;
mono_unichar2 chars[MONO_ZERO_LEN_ARRAY];
};
#define MONO_TOKEN_TYPE_DEF 0x02000000
#define MONO_TABLE_TYPEDEF 0x2
typedef void (*mono_assembly_foreach_callback_t)(uintptr_t, void*);
typedef void (*mono_assembly_foreach_t)(mono_assembly_foreach_callback_t, uintptr_t);
typedef uintptr_t(*mono_assembly_get_image_t)(uintptr_t);
typedef char* (*mono_image_get_name_t)(uintptr_t);
typedef uintptr_t(*mono_class_from_name_t)(uintptr_t, char*, char*);
typedef uintptr_t(*mono_class_get_property_from_name_t)(uintptr_t, char*);
typedef uintptr_t(*mono_property_get_set_method_t)(uintptr_t);
typedef uint64_t* (*mono_compile_method_t)(uintptr_t);
typedef MonoDomain*(*mono_get_root_domain_t)();
typedef void (*mono_thread_attach_t)(MonoDomain*);
typedef void* (*mono_class_get_t)(void* image, uint32_t type_token);
typedef int (*mono_table_info_get_rows_t)(void*);
typedef void*(*mono_image_get_table_info_t)(void*,uint32_t);
typedef char*(*mono_class_get_name_t)(void*);
typedef void* (*mono_class_get_method_from_name_t)(void *klass, const char *name, int param_count);
#endif // MONOOBJECT_H

View File

@ -1,17 +0,0 @@
#ifndef MONOTYPE_H
#define MONOTYPE_H
// monotype.h
// 12/26/2014 jichi
// https://github.com/mono/mono/blob/master/mono/metadata/object.h
#include "mono/monoobject.h"
// Function typedefs
typedef MonoDomain *(* mono_object_get_domain_fun_t)(MonoObject *obj);
typedef MonoString *(* mono_string_new_utf16_fun_t)(MonoDomain *domain, const mono_unichar2 *text, int32_t len);
typedef char * (* mono_string_to_utf8_fun_t)(MonoString *string_obj);
#endif // MONOTYPE_H

View File

@ -1,41 +0,0 @@
#pragma once
// mono/types.h
// 12/26/2014
// https://github.com/mono/mono/blob/master/mono/metadata/object.h
// http://api.xamarin.com/index.aspx?link=xhtml%3Adeploy%2Fmono-api-string.html
#include <cstdint>
// mono/io-layer/uglify.h
typedef int8_t gint8;
typedef int32_t gint32;
typedef wchar_t gunichar2; // either char or wchar_t, depending on how mono is compiled
typedef gint8 mono_byte;
typedef gunichar2 mono_unichar2;
// mono/metadata/object.h
typedef mono_byte MonoBoolean;
struct MonoArray;
struct MonoDelegate;
struct MonoException;
struct MonoString;
struct MonoThreadsSync;
struct MonoThread;
struct MonoVTable;
struct MonoObject {
MonoVTable *vtable;
MonoThreadsSync *synchronisation;
};
struct MonoString {
MonoObject object;
gint32 length;
gunichar2 chars[0];
};
// EOF

View File

@ -205,6 +205,15 @@ void delayinsertNewHook(uintptr_t em_address){
bool NewHook(HookParam hp, LPCSTR name){ bool NewHook(HookParam hp, LPCSTR name){
if(hp.address||hp.jittype==JITTYPE::PC) if(hp.address||hp.jittype==JITTYPE::PC)
return NewHook_1(hp,name); return NewHook_1(hp,name);
if(hp.jittype==JITTYPE::UNITY){
auto spls=strSplit(hp.unityfunctioninfo,":");
hp.address = il2cpp_symbols::get_method_pointer(spls[0].c_str(),spls[1].c_str() ,spls[2].c_str(),spls[3].c_str(),std::stoi(spls[4]));
if(!hp.address)
hp.address=getmonofunctionptr(spls[0].c_str(),spls[1].c_str() ,spls[2].c_str(),spls[3].c_str(),std::stoi(spls[4]));
if(!hp.address)
return false;
return NewHook_1(hp,name);
}
//下面的是手动插入 //下面的是手动插入
if(emuaddr2jitaddr.find(hp.emu_addr)==emuaddr2jitaddr.end()){ if(emuaddr2jitaddr.find(hp.emu_addr)==emuaddr2jitaddr.end()){
delayinsertadd(hp,name); delayinsertadd(hp,name);

View File

@ -19,7 +19,7 @@
#include"Lang/Lang.h" #include"Lang/Lang.h"
#include"veh_hook.h" #include"veh_hook.h"
#include"engines/emujitarg.hpp" #include"engines/emujitarg.hpp"
#include"engines/mono/monoil2cpp.hpp"
#include "hookfinder.h" #include "hookfinder.h"
#include"util/textunion.h" #include"util/textunion.h"
#include"util/ntxpundef.h" #include"util/ntxpundef.h"

View File

@ -108,16 +108,21 @@ inline uintptr_t regof(regs reg,hook_stack* stack){
#define GETARG3 get_reg(regs::r8) #define GETARG3 get_reg(regs::r8)
#define GETARG4 get_reg(regs::r9) #define GETARG4 get_reg(regs::r9)
#endif
inline uintptr_t *argidx(hook_stack* stack,int idx){ inline uintptr_t *argidx(hook_stack* stack,int idx){
#ifdef _WIN64
auto offset=0; auto offset=0;
switch (idx) switch (idx)
{ {
case 0:offset=get_reg(regs::rcx);break; case 1:offset=get_reg(regs::rcx);break;
case 1:offset=get_reg(regs::rdx);break; case 2:offset=get_reg(regs::rdx);break;
case 2:offset=get_reg(regs::r8);break; case 3:offset=get_reg(regs::r8);break;
case 3:offset=get_reg(regs::r9);break; case 4:offset=get_reg(regs::r9);break;
} }
return (uintptr_t*)((uintptr_t)stack+sizeof(hook_stack)-sizeof(uintptr_t)+offset); return (uintptr_t*)((uintptr_t)stack+sizeof(hook_stack)-sizeof(uintptr_t)+offset);
} #else
return (uintptr_t*)((uintptr_t)stack+sizeof(hook_stack)-sizeof(uintptr_t)+get_stack(idx));
#endif #endif
}

View File

@ -122,15 +122,37 @@ bool TextHook::Insert(HookParam hp)
if (hp.type & BREAK_POINT) return InsertBreakPoint(); if (hp.type & BREAK_POINT) return InsertBreakPoint();
return InsertHookCode(); return InsertHookCode();
} }
uintptr_t win64find0000(uintptr_t addr){
uintptr_t queryrelativeret(uintptr_t retaddr){ uintptr_t r = 0;
__try{
addr &= ~0xf;
for (uintptr_t i = addr, j = addr - 0x10000; i > j; i-=0x10) {
DWORD k = *(DWORD *)(i-4);
if (k == 0x00000000
)
return i;
}
return 0;
}__except(EXCEPTION_EXECUTE_HANDLER) {}
return r;
}
uintptr_t queryrelativeret(HookParam&hp, uintptr_t retaddr){
//不需要区分是相对于哪个module的偏移只需要得到偏移就可以了用来确保重启程序后ret值恒定 //不需要区分是相对于哪个module的偏移只需要得到偏移就可以了用来确保重启程序后ret值恒定
static Synchronized<std::unordered_map<uintptr_t, uintptr_t>> retaddr2relative; static Synchronized<std::unordered_map<uintptr_t, uintptr_t>> retaddr2relative;
auto &re=retaddr2relative.Acquire().contents; auto &re=retaddr2relative.Acquire().contents;
if(re.find(retaddr)!=re.end())return re.at(retaddr); if(re.find(retaddr)!=re.end())return re.at(retaddr);
uintptr_t relative=retaddr; uintptr_t relative=retaddr;
if(hp.jittype==JITTYPE::UNITY){
#ifndef _WIN64
relative=retaddr-SafeFindEnclosingAlignedFunction(retaddr,0x10000);
#else
relative=retaddr-win64find0000(retaddr);
#endif
}
else{
if (MEMORY_BASIC_INFORMATION info = {}; VirtualQuery((LPCVOID)retaddr, &info, sizeof(info))) if (MEMORY_BASIC_INFORMATION info = {}; VirtualQuery((LPCVOID)retaddr, &info, sizeof(info)))
relative-=(uintptr_t)info.AllocationBase; relative-=(uintptr_t)info.AllocationBase;
}
re.insert(std::make_pair(retaddr,relative)); re.insert(std::make_pair(retaddr,relative));
return relative; return relative;
} }
@ -174,7 +196,7 @@ void TextHook::Send(uintptr_t lpDataBase)
plpdatain=(lpDataBase + hp.offset), plpdatain=(lpDataBase + hp.offset),
lpDataIn=*(uintptr_t*)plpdatain; lpDataIn=*(uintptr_t*)plpdatain;
bool isstring=false; bool isstring=false;
if(hp.jittype!=JITTYPE::PC) if(hp.jittype!=JITTYPE::PC&&hp.jittype!=JITTYPE::UNITY)
{ {
lpDataIn=jitgetaddr(stack,&hp); lpDataIn=jitgetaddr(stack,&hp);
plpdatain=(uintptr_t)&lpDataIn; plpdatain=(uintptr_t)&lpDataIn;
@ -192,6 +214,10 @@ void TextHook::Send(uintptr_t lpDataBase)
isstring=true; isstring=true;
hp.text_fun(stack, &hp, &lpDataIn, &lpSplit, &lpCount); hp.text_fun(stack, &hp, &lpDataIn, &lpSplit, &lpCount);
} }
else if(hp.jittype==JITTYPE::UNITY)
{
commonsolvemonostring(*argidx(stack,hp.argidx),&lpDataIn,&lpCount);
}
else else
{ {
if (hp.type & FIXING_SPLIT) lpSplit = FIXED_SPLIT_VALUE; // fuse all threads, and prevent floating if (hp.type & FIXING_SPLIT) lpSplit = FIXED_SPLIT_VALUE; // fuse all threads, and prevent floating
@ -243,7 +269,7 @@ void TextHook::Send(uintptr_t lpDataBase)
buffer->type=hp.type; buffer->type=hp.type;
lpRetn=queryrelativeret(lpRetn); lpRetn=queryrelativeret(hp,lpRetn);
ThreadParam tp{ GetCurrentProcessId(), address, lpRetn, lpSplit }; ThreadParam tp{ GetCurrentProcessId(), address, lpRetn, lpSplit };
parsenewlineseperator(pbData, &lpCount); parsenewlineseperator(pbData, &lpCount);
@ -272,8 +298,11 @@ void TextHook::Send(uintptr_t lpDataBase)
for(int i=lpCount;i<lpCountsave;i++) for(int i=lpCount;i<lpCountsave;i++)
((BYTE*)(lpDataIn))[i]=0; ((BYTE*)(lpDataIn))[i]=0;
} }
else else if(hp.hook_after)
hp.hook_after(stack,pbData,lpCount); hp.hook_after(stack,pbData,lpCount);
else if(hp.jittype==JITTYPE::UNITY){
unity_ui_string_hook_after(argidx(stack,hp.argidx),pbData,lpCount);
}
} }
} }
} }

View File

@ -64,6 +64,8 @@ namespace
hp.jittype=JITTYPE::VITA3K; hp.jittype=JITTYPE::VITA3K;
else if(endWith(HCode,L":JIT:RPCS3")) else if(endWith(HCode,L":JIT:RPCS3"))
hp.jittype=JITTYPE::RPCS3; hp.jittype=JITTYPE::RPCS3;
else if(endWith(HCode,L":JIT:UNITY"))
hp.jittype=JITTYPE::UNITY;
// {A|B|W|H|S|Q|V|M} // {A|B|W|H|S|Q|V|M}
switch (HCode[0]) switch (HCode[0])
@ -163,6 +165,19 @@ namespace
hp.split_index = ConsumeHexInt(); hp.split_index = ConsumeHexInt();
} }
} }
if(hp.jittype==JITTYPE::UNITY){
if(HCode[0]!=L'@')return {};
HCode.erase(0,1);
hp.argidx=hp.offset;
hp.offset=0;
hp.address=0;
hp.type &= ~MODULE_OFFSET;
hp.type &= ~FUNCTION_OFFSET;
strcpy(hp.function,"");
wcscpy(hp.module,L"");
strcpy(hp.unityfunctioninfo,wcasta(HCode).c_str());
}
else{
// @addr[:module[:func]] // @addr[:module[:func]]
if (!std::regex_match(HCode, match, std::wregex(L"^@([[:xdigit:]]+)(:.+?)?(:.+)?"))) return {}; if (!std::regex_match(HCode, match, std::wregex(L"^@([[:xdigit:]]+)(:.+?)?(:.+)?"))) return {};
@ -193,6 +208,7 @@ namespace
strcpy(hp.function,""); strcpy(hp.function,"");
wcscpy(hp.module,L""); wcscpy(hp.module,L"");
} }
}
return hp; return hp;
} }
@ -217,7 +233,7 @@ namespace
else if(code[0]==L'O') else if(code[0]==L'O')
hp.type|=EMBED_AFTER_OVERWRITE; hp.type|=EMBED_AFTER_OVERWRITE;
else else
return {}; return ParseHCode(code,hp);
code.erase(0,1); code.erase(0,1);
} }
@ -346,6 +362,13 @@ namespace
} }
else else
{ {
if(hp.jittype== JITTYPE::UNITY){
HCode+=L'@';
HCode+=acastw(hp.unityfunctioninfo);
HCode+=L":JIT:UNITY";
}
else{
HCode += L'@' + HexString(hp.emu_addr); HCode += L'@' + HexString(hp.emu_addr);
switch (hp.jittype) switch (hp.jittype)
{ {
@ -363,6 +386,7 @@ namespace
break; break;
} }
} }
}
return HCode; return HCode;
} }

View File

@ -81,7 +81,8 @@ enum class JITTYPE{
YUZU, YUZU,
PPSSPP, PPSSPP,
VITA3K, VITA3K,
RPCS3 RPCS3,
UNITY
}; };
struct HookParam struct HookParam
{ {
@ -113,6 +114,7 @@ struct HookParam
ALIGNPTR(uint64_t __10,uintptr_t emu_addr); ALIGNPTR(uint64_t __10,uintptr_t emu_addr);
int argidx; int argidx;
JITTYPE jittype; JITTYPE jittype;
char unityfunctioninfo[1024];
}; };
struct ThreadParam struct ThreadParam