Skip to content
This repository has been archived by the owner on Nov 17, 2024. It is now read-only.

Commit

Permalink
debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
HIllya51 committed May 9, 2024
1 parent efcae6a commit 0aa0cc4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions LunaHook/engines/mono/def_il2cpp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_interfaces_t)(Il2CppClass* klass, void** iter);
typedef const char* (*il2cpp_class_get_namespace_t)(Il2CppClass* klass);
typedef void* (*il2cpp_class_get_image_t)(Il2CppClass* klass);
typedef int (*il2cpp_class_get_flags_t)(const Il2CppClass* klass);
typedef bool (*il2cpp_class_is_valuetype_t)(const Il2CppClass* klass);
typedef uint32_t(*il2cpp_property_get_flags_t) (PropertyInfo* prop);
Expand Down
13 changes: 11 additions & 2 deletions LunaHook/engines/mono/impl_il2cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ il2cpp_runtime_invoke_t il2cpp_runtime_invoke;
il2cpp_class_get_name_t il2cpp_class_get_name;
il2cpp_class_get_namespace_t il2cpp_class_get_namespace;
il2cpp_domain_get_assemblies_t il2cpp_domain_get_assemblies;


il2cpp_class_get_image_t il2cpp_class_get_image;
il2cpp_image_get_name_t il2cpp_image_get_name;
namespace il2cpp_symbols
{
#define RESOLVE_IMPORT(name) name = reinterpret_cast<name##_t>(GetProcAddress(game_module, #name))

void init(HMODULE game_module)
{
RESOLVE_IMPORT(il2cpp_image_get_name);
RESOLVE_IMPORT(il2cpp_class_get_image);
RESOLVE_IMPORT(il2cpp_string_new_utf16);
RESOLVE_IMPORT(il2cpp_string_new);
RESOLVE_IMPORT(il2cpp_domain_get);
Expand Down Expand Up @@ -135,11 +137,18 @@ namespace il2cpp_symbols
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){
if(!(il2cpp_class_get_method_from_name))return NULL;
if(!klass)return NULL;
auto ret = il2cpp_class_get_method_from_name(klass, name, argsCount);
if(!ret)return NULL;
tryprintimage(klass);
return ret->methodPointer;
}
uintptr_t get_method_pointer(const char* assemblyName, const char* namespaze,
Expand Down
7 changes: 7 additions & 0 deletions LunaHook/engines/mono/impl_mono.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,18 @@ std::vector<MonoClass*> mono_findklassby_class(std::vector<MonoImage*>& images,c
}
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{
Expand Down

0 comments on commit 0aa0cc4

Please sign in to comment.