fix: Try search frameworks folder for nethost library on macOS
This commit is contained in:
parent
7400b9ce8a
commit
9dbae2051b
@ -71,23 +71,35 @@ namespace hex::script::loader {
|
|||||||
#elif defined(OS_LINUX)
|
#elif defined(OS_LINUX)
|
||||||
auto netHostLibrary = loadLibrary("libnethost.so");
|
auto netHostLibrary = loadLibrary("libnethost.so");
|
||||||
#elif defined(OS_MACOS)
|
#elif defined(OS_MACOS)
|
||||||
auto netHostLibrary = loadLibrary("libnethost.dylib");
|
void *netHostLibrary = nullptr;
|
||||||
|
for (const auto &pluginPath : fs::getDefaultPaths(fs::ImHexPath::Plugins)) {
|
||||||
|
auto frameworksPath = pluginPath.parent_path().parent_path() / "Frameworks";
|
||||||
|
|
||||||
|
netHostLibrary = loadLibrary((frameworksPath / "libnethost.dylib").c_str());
|
||||||
|
if (netHostLibrary != nullptr)
|
||||||
|
break;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (netHostLibrary == nullptr)
|
if (netHostLibrary == nullptr) {
|
||||||
|
log::error("Could not load libnethost!");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto get_hostfxr_path_ptr = getExport<get_hostfxr_path_fn>(netHostLibrary, "get_hostfxr_path");
|
auto get_hostfxr_path_ptr = getExport<get_hostfxr_path_fn>(netHostLibrary, "get_hostfxr_path");
|
||||||
|
|
||||||
std::array<char_t, 300> buffer = { 0 };
|
std::array<char_t, 300> buffer = { 0 };
|
||||||
size_t bufferSize = buffer.size();
|
size_t bufferSize = buffer.size();
|
||||||
if (get_hostfxr_path_ptr(buffer.data(), &bufferSize, nullptr) != 0) {
|
if (get_hostfxr_path_ptr(buffer.data(), &bufferSize, nullptr) != 0) {
|
||||||
|
log::error("Could not get hostfxr path!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *hostfxrLibrary = loadLibrary(buffer.data());
|
void *hostfxrLibrary = loadLibrary(buffer.data());
|
||||||
if (hostfxrLibrary == nullptr)
|
if (hostfxrLibrary == nullptr) {
|
||||||
|
log::error("Could not load hostfxr library!");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
hostfxr_initialize_for_runtime_config
|
hostfxr_initialize_for_runtime_config
|
||||||
|
Loading…
x
Reference in New Issue
Block a user