mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-14 11:05:08 -05:00
add geodeImplicitEntry and geodeCustomEntry
This commit is contained in:
parent
87649f18da
commit
6b2ac24ccd
5 changed files with 51 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue