add geodeImplicitEntry and geodeCustomEntry

This commit is contained in:
altalk23 2024-06-08 15:57:50 +03:00
parent 87649f18da
commit 6b2ac24ccd
5 changed files with 51 additions and 2 deletions

View file

@ -13,9 +13,9 @@ namespace geode {
}
}
namespace {
GEODE_API void geodeImplicitEntry() {
// to make sure the instance is set into the sharedMod<> in load time
static auto mod = geode::getMod();
(void)geode::getMod();
}
#if defined(_DEBUG) && defined(GEODE_IS_WINDOWS)

View file

@ -5,6 +5,15 @@
using namespace geode::prelude;
template <typename T>
T findSymbolOrMangled(void* so, char const* name, char const* mangled) {
auto res = reinterpret_cast<T>(dlsym(so, name));
if (!res) {
res = reinterpret_cast<T>(dlsym(so, mangled));
}
return res;
}
Result<> Mod::Impl::loadPlatformBinary() {
auto so =
dlopen((m_tempDirName / m_metadata.getBinaryName()).string().c_str(), RTLD_LAZY);
@ -14,6 +23,16 @@ Result<> Mod::Impl::loadPlatformBinary() {
}
m_platformInfo = new PlatformInfo{so};
auto geodeImplicitEntry = findSymbolOrMangled<void(*)()>(so, "geodeImplicitEntry", "_geodeImplicitEntry@0");
if (geodeImplicitEntry) {
geodeImplicitEntry();
}
auto geodeCustomEntry = findSymbolOrMangled<void(*)()>(so, "geodeCustomEntry", "_geodeCustomEntry@0");
if (geodeCustomEntry) {
geodeCustomEntry();
}
return Ok();
}
std::string err = dlerror();

View file

@ -24,6 +24,16 @@ Result<> Mod::Impl::loadPlatformBinary() {
}
m_platformInfo = new PlatformInfo { dylib };
auto geodeImplicitEntry = findSymbolOrMangled<void(*)()>(dylib, "geodeImplicitEntry", "_geodeImplicitEntry@0");
if (geodeImplicitEntry) {
geodeImplicitEntry();
}
auto geodeCustomEntry = findSymbolOrMangled<void(*)()>(dylib, "geodeCustomEntry", "_geodeCustomEntry@0");
if (geodeCustomEntry) {
geodeCustomEntry();
}
return Ok();
}
std::string err = (char const*)dlerror();

View file

@ -24,6 +24,16 @@ Result<> Mod::Impl::loadPlatformBinary() {
}
m_platformInfo = new PlatformInfo { dylib };
auto geodeImplicitEntry = findSymbolOrMangled<void(*)()>(dylib, "geodeImplicitEntry", "_geodeImplicitEntry@0");
if (geodeImplicitEntry) {
geodeImplicitEntry();
}
auto geodeCustomEntry = findSymbolOrMangled<void(*)()>(dylib, "geodeCustomEntry", "_geodeCustomEntry@0");
if (geodeCustomEntry) {
geodeCustomEntry();
}
return Ok();
}
std::string err = (char const*)dlerror();

View file

@ -80,6 +80,16 @@ Result<> Mod::Impl::loadPlatformBinary() {
delete m_platformInfo;
}
m_platformInfo = new PlatformInfo { load };
auto geodeImplicitEntry = findSymbolOrMangled<void(*)()>(load, "geodeImplicitEntry", "_geodeImplicitEntry@0");
if (geodeImplicitEntry) {
geodeImplicitEntry();
}
auto geodeCustomEntry = findSymbolOrMangled<void(*)()>(load, "geodeCustomEntry", "_geodeCustomEntry@0");
if (geodeCustomEntry) {
geodeCustomEntry();
}
return Ok();
}
return Err("Unable to load the DLL: " + getLastWinError());