LunaHook-mirror/LunaHook/engines/mono/impl_mono.cpp
恍兮惚兮 216f784790 mono
2024-05-14 10:32:10 +08:00

570 lines
43 KiB
C++

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