debug info

This commit is contained in:
恍兮惚兮 2024-05-09 21:31:38 +08:00
parent efcae6a15d
commit 0aa0cc4868
3 changed files with 19 additions and 2 deletions

View File

@ -527,6 +527,7 @@ typedef const char* (*il2cpp_method_get_param_name_t)(const MethodInfo* method,
typedef Il2CppClass* (*il2cpp_class_get_parent_t)(Il2CppClass* klass); typedef Il2CppClass* (*il2cpp_class_get_parent_t)(Il2CppClass* klass);
typedef Il2CppClass* (*il2cpp_class_get_interfaces_t)(Il2CppClass* klass, void** iter); typedef Il2CppClass* (*il2cpp_class_get_interfaces_t)(Il2CppClass* klass, void** iter);
typedef const char* (*il2cpp_class_get_namespace_t)(Il2CppClass* klass); typedef const char* (*il2cpp_class_get_namespace_t)(Il2CppClass* klass);
typedef void* (*il2cpp_class_get_image_t)(Il2CppClass* klass);
typedef int (*il2cpp_class_get_flags_t)(const Il2CppClass* klass); typedef int (*il2cpp_class_get_flags_t)(const Il2CppClass* klass);
typedef bool (*il2cpp_class_is_valuetype_t)(const Il2CppClass* klass); typedef bool (*il2cpp_class_is_valuetype_t)(const Il2CppClass* klass);
typedef uint32_t(*il2cpp_property_get_flags_t) (PropertyInfo* prop); typedef uint32_t(*il2cpp_property_get_flags_t) (PropertyInfo* prop);

View File

@ -28,14 +28,16 @@ il2cpp_runtime_invoke_t il2cpp_runtime_invoke;
il2cpp_class_get_name_t il2cpp_class_get_name; il2cpp_class_get_name_t il2cpp_class_get_name;
il2cpp_class_get_namespace_t il2cpp_class_get_namespace; il2cpp_class_get_namespace_t il2cpp_class_get_namespace;
il2cpp_domain_get_assemblies_t il2cpp_domain_get_assemblies; il2cpp_domain_get_assemblies_t il2cpp_domain_get_assemblies;
il2cpp_class_get_image_t il2cpp_class_get_image;
il2cpp_image_get_name_t il2cpp_image_get_name;
namespace il2cpp_symbols namespace il2cpp_symbols
{ {
#define RESOLVE_IMPORT(name) name = reinterpret_cast<name##_t>(GetProcAddress(game_module, #name)) #define RESOLVE_IMPORT(name) name = reinterpret_cast<name##_t>(GetProcAddress(game_module, #name))
void init(HMODULE game_module) void init(HMODULE game_module)
{ {
RESOLVE_IMPORT(il2cpp_image_get_name);
RESOLVE_IMPORT(il2cpp_class_get_image);
RESOLVE_IMPORT(il2cpp_string_new_utf16); RESOLVE_IMPORT(il2cpp_string_new_utf16);
RESOLVE_IMPORT(il2cpp_string_new); RESOLVE_IMPORT(il2cpp_string_new);
RESOLVE_IMPORT(il2cpp_domain_get); RESOLVE_IMPORT(il2cpp_domain_get);
@ -135,11 +137,18 @@ namespace il2cpp_symbols
il2cpp_thread_detach(thread); il2cpp_thread_detach(thread);
} }
}; };
void tryprintimage(Il2CppClass* klass){
if(!(il2cpp_class_get_namespace&&il2cpp_class_get_image&&il2cpp_image_get_name))return;
auto image=il2cpp_class_get_image(klass);
if(!image)return;
ConsoleOutput("%s:%s",il2cpp_image_get_name(image),il2cpp_class_get_namespace(klass));
}
uintptr_t getmethodofklass(Il2CppClass* klass,const char* name, int argsCount){ uintptr_t getmethodofklass(Il2CppClass* klass,const char* name, int argsCount){
if(!(il2cpp_class_get_method_from_name))return NULL; if(!(il2cpp_class_get_method_from_name))return NULL;
if(!klass)return NULL; if(!klass)return NULL;
auto ret = il2cpp_class_get_method_from_name(klass, name, argsCount); auto ret = il2cpp_class_get_method_from_name(klass, name, argsCount);
if(!ret)return NULL; if(!ret)return NULL;
tryprintimage(klass);
return ret->methodPointer; return ret->methodPointer;
} }
uintptr_t get_method_pointer(const char* assemblyName, const char* namespaze, uintptr_t get_method_pointer(const char* assemblyName, const char* namespaze,

View File

@ -520,11 +520,18 @@ std::vector<MonoClass*> mono_findklassby_class(std::vector<MonoImage*>& images,c
} }
return maybes; 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){ uintptr_t getmethodofklass(MonoClass* klass,const char* name, int argsCount){
if(!(mono_class_get_method_from_name&&mono_compile_method))return NULL; if(!(mono_class_get_method_from_name&&mono_compile_method))return NULL;
if(!klass)return NULL; if(!klass)return NULL;
MonoMethod* MonoClassMethod = mono_class_get_method_from_name(klass, name, argsCount); MonoMethod* MonoClassMethod = mono_class_get_method_from_name(klass, name, argsCount);
if(!MonoClassMethod)return NULL; if(!MonoClassMethod)return NULL;
tryprintimage(klass);
return (uintptr_t)mono_compile_method((uintptr_t)MonoClassMethod); return (uintptr_t)mono_compile_method((uintptr_t)MonoClassMethod);
} }
struct AutoThread{ struct AutoThread{