geode/loader/src/hooks/DynamicCastFix.cpp

22 lines
896 B
C++
Raw Normal View History

#include <Geode/DefaultInclude.hpp>
2023-10-02 09:50:10 -04:00
#include <Geode/loader/Mod.hpp>
using namespace geode::prelude;
$execute {
// this replaces the call to __dynamic_cast with a call to our own
// this is needed because the transitions in cocos uses dynamic cast to check
// layers, which fail on user layers due to typeinfo not matching
2023-10-02 09:50:10 -04:00
#if defined(GEODE_IS_MACOS)
(void)Mod::get()->patch(
reinterpret_cast<void*>(base::get() + 0x603948), toByteArray(&cast::typeinfoCastInternal)
);
2023-12-23 08:10:23 -05:00
#elif defined(GEODE_IS_ANDROID32)
2023-12-21 12:44:22 -05:00
(void)Mod::get()->addHook(reinterpret_cast<void*>(base::get() + (0x720348 - 0x10000) + 1), &cast::typeinfoCastInternal, "__dynamic_cast");
2023-12-23 10:02:13 -05:00
#elif defined(GEODE_IS_ANDROID64)
(void)Mod::get()->addHook(reinterpret_cast<void*>(base::get() + (0xd6cb8c - 0x100000)), &cast::typeinfoCastInternal, "__dynamic_cast");
2023-10-02 09:50:10 -04:00
#endif
}