From b871c2a088aa50cab676e324c0c71fa598543956 Mon Sep 17 00:00:00 2001 From: qimiko <25387744+qimiko@users.noreply.github.com> Date: Mon, 15 Jan 2024 19:48:24 -0700 Subject: [PATCH] dynamically resolve dynamic_cast address --- loader/src/hooks/DynamicCastFix.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/loader/src/hooks/DynamicCastFix.cpp b/loader/src/hooks/DynamicCastFix.cpp index 9119b796..332a021f 100644 --- a/loader/src/hooks/DynamicCastFix.cpp +++ b/loader/src/hooks/DynamicCastFix.cpp @@ -12,10 +12,13 @@ $execute { (void)Mod::get()->patch( reinterpret_cast(base::get() + 0x603948), toByteArray(&cast::typeinfoCastInternal) ); - #elif defined(GEODE_IS_ANDROID32) - (void)Mod::get()->addHook(reinterpret_cast(base::get() + (0x720348 - 0x10000) + 1), &cast::typeinfoCastInternal, "__dynamic_cast"); - #elif defined(GEODE_IS_ANDROID64) - (void)Mod::get()->addHook(reinterpret_cast(base::get() + (0xd6cb8c - 0x100000)), &cast::typeinfoCastInternal, "__dynamic_cast"); + #elif defined(GEODE_IS_ANDROID) + void* handle = dlopen("libcocos2dcpp.so", RTLD_LAZY | RTLD_NOLOAD); + void* dynamicCastAddr = dlsym(handle, "__dynamic_cast"); + + (void)Mod::get()->addHook(dynamicCastAddr, &cast::typeinfoCastInternal, "__dynamic_cast"); + + dlclose(handle); #endif