This commit is contained in:
altalk23 2024-01-01 21:17:46 +03:00
commit da72e5cdfe
6 changed files with 41 additions and 20 deletions

View file

@ -109,10 +109,11 @@ elseif (GEODE_TARGET_PLATFORM STREQUAL "Android64")
)
target_link_libraries(${PROJECT_NAME} INTERFACE
# ${GEODE_LOADER_PATH}/include/link/android64/libcurl.a
# ${GEODE_LOADER_PATH}/include/link/android64/libssl.a
# ${GEODE_LOADER_PATH}/include/link/android64/libcrypto.a
${GEODE_LOADER_PATH}/include/link/android64/libcurl.a
${GEODE_LOADER_PATH}/include/link/android64/libssl.a
${GEODE_LOADER_PATH}/include/link/android64/libcrypto.a
${GEODE_LOADER_PATH}/include/link/android64/libcocos2dcpp.so
GLESv2
log
)

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -692,10 +692,10 @@ void Loader::Impl::addUninitializedHook(Hook* hook, Mod* mod) {
bool Loader::Impl::loadHooks() {
m_readyToHook = true;
bool hadErrors = false;
for (auto const& hook : m_uninitializedHooks) {
auto res = hook.second->addHook(hook.first);
for (auto const& [hook, mod] : m_uninitializedHooks) {
auto res = mod->addHook(hook);
if (!res) {
log::logImpl(Severity::Error, hook.second, "{}", res.unwrapErr());
log::logImpl(Severity::Error, mod, "{}", res.unwrapErr());
hadErrors = true;
}
}

View file

@ -5,20 +5,20 @@
#if defined(GEODE_IS_ANDROID32)
static constexpr ptrdiff_t MENULAYER_SCENE = 0x309068 - 0x10000;
static constexpr ptrdiff_t STRING_EMPTY = 0xaa1c48 - 0x10000 - 0xc; // the internal struct size
static constexpr ptrdiff_t STRING_DTOR = 0x7514c8 - 0x10000 + 1;
static constexpr ptrdiff_t OPERATOR_NEW = 0x721308 - 0x10000 + 1;
static auto constexpr NEW_SYM = "_Znwj";
static constexpr uintptr_t MENULAYER_SCENE = 0x309068 - 0x10000;
static constexpr uintptr_t STRING_EMPTY = 0xaa1c48 - 0x10000 - 0xc; // the internal struct size
#elif defined(GEODE_IS_ANDROID64)
static constexpr ptrdiff_t MENULAYER_SCENE = 0x6a62ec - 0x100000;
static constexpr ptrdiff_t STRING_EMPTY = 0x12d8568 - 0x100000 - 0x18; // the internal struct size
static constexpr ptrdiff_t STRING_DTOR = 0xdb9778 - 0x100000; // it's inlined but it exists !!!!
static constexpr ptrdiff_t OPERATOR_NEW = 0xd6dfe8 - 0x100000;
static auto constexpr NEW_SYM = "_Znwm";
static constexpr uintptr_t MENULAYER_SCENE = 0x6a62ec - 0x100000;
static constexpr uintptr_t STRING_EMPTY = 0x12d8568 - 0x100000 - 0x18; // the internal struct size
#endif
static auto constexpr DELETE_SYM = "_ZdlPv";
// 2.2 addition
// zmx please fix this
@ -30,6 +30,21 @@ namespace geode::base {
}
}
static void* getLibHandle() {
static void* handle = dlopen("libcocos2dcpp.so", RTLD_LAZY | RTLD_NOLOAD);
return handle;
}
static void* gdOperatorNew(size_t size) {
static auto fnPtr = reinterpret_cast<void*(*)(size_t)>(dlsym(getLibHandle(), NEW_SYM));
return fnPtr(size);
}
static void gdOperatorDelete(void* ptr) {
static auto fnPtr = reinterpret_cast<void(*)(void*)>(dlsym(getLibHandle(), DELETE_SYM));
return fnPtr(ptr);
}
namespace geode::stl {
static inline auto emptyInternalString() {
return reinterpret_cast<StringData::Internal*>(
@ -43,8 +58,13 @@ namespace geode::stl {
void StringImpl::free() {
if (data.m_data == nullptr || data.m_data == emptyInternalString()) return;
// TODO: reimplement this
reinterpret_cast<void (*)(StringData*)>(geode::base::get() + STRING_DTOR)(&data);
if (data.m_data[-1].m_refcount <= 0) {
gdOperatorDelete(&data.m_data[-1]);
data.m_data = nullptr;
} else {
--data.m_data[-1].m_refcount;
}
}
char* StringImpl::getStorage() {
@ -65,13 +85,13 @@ namespace geode::stl {
internal.m_capacity = str.size();
internal.m_refcount = 0;
auto* buffer = reinterpret_cast<char*(*)(size_t)>(geode::base::get() + OPERATOR_NEW)(str.size() + 1 + sizeof(internal));
// auto* buffer = static_cast<char*>(operator new(str.size() + 1 + sizeof(internal)));
// use char* so we can do easy pointer arithmetic with it
auto* buffer = static_cast<char*>(gdOperatorNew(str.size() + 1 + sizeof(internal)));
std::memcpy(buffer, &internal, sizeof(internal));
std::memcpy(buffer + sizeof(internal), str.data(), str.size());
buffer[sizeof(internal) + str.size()] = 0;
data.m_data = reinterpret_cast<StringData::Internal*>(buffer + sizeof(internal));
this->getStorage()[str.size()] = 0;
}
size_t StringImpl::getSize() {