mirror of
https://github.com/geode-sdk/geode.git
synced 2025-03-23 03:15:58 -04:00
Fix exceptions on android 32 maybe 64?
This commit is contained in:
parent
8473e5d9a3
commit
9c87d4c8dd
1 changed files with 28 additions and 0 deletions
28
loader/src/hooks/AndroidExceptionFix.cpp
Normal file
28
loader/src/hooks/AndroidExceptionFix.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include <Geode/Geode.hpp>
|
||||
|
||||
using namespace geode::prelude;
|
||||
|
||||
#ifdef GEODE_IS_ANDROID
|
||||
|
||||
// replaces https://github.com/llvm-mirror/libcxxabi/blob/master/src/private_typeinfo.cpp#L213
|
||||
// this is the function that checks if a type can catch an exception
|
||||
bool canCatchImpl(const std::type_info* self, const std::type_info* thrown, void*& adjustedPtr) {
|
||||
auto vtable = reinterpret_cast<geode::cast::VtableType*>(*(intptr_t*)adjustedPtr);
|
||||
auto complete = static_cast<geode::cast::CompleteVtableType*>(vtable);
|
||||
auto typeinfo = complete->m_typeinfo;
|
||||
return traverseTypeinfoFor(adjustedPtr, typeinfo, self->name());
|
||||
}
|
||||
|
||||
$execute {
|
||||
// we get the __class_type_info::can_catch address from the typeinfo of a dummy class
|
||||
geode::cast::DummyClass dummyClass;
|
||||
auto vtable = reinterpret_cast<geode::cast::VtableType*>(*(intptr_t*)&dummyClass);
|
||||
auto complete = static_cast<geode::cast::CompleteVtableType*>(vtable);
|
||||
auto typeinfo = complete->m_typeinfo;
|
||||
auto tiVtable = typeinfo->m_typeinfoVtable;
|
||||
auto hookAddr = tiVtable->m_vtable[4]; // 5th entry is can_catch
|
||||
|
||||
(void)Mod::get()->hook(hookAddr, &canCatchImpl, "__class_type_info::can_catch");
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue