Skip to content

Commit

Permalink
fix: Try search frameworks folder for nethost library on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Oct 1, 2023
1 parent 7400b9c commit 9dbae20
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions plugins/script_loader/source/loaders/dotnet/dotnet_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,35 @@ namespace hex::script::loader {
#elif defined(OS_LINUX)
auto netHostLibrary = loadLibrary("libnethost.so");
#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

if (netHostLibrary == nullptr)
if (netHostLibrary == nullptr) {
log::error("Could not load libnethost!");
return false;
}

auto get_hostfxr_path_ptr = getExport<get_hostfxr_path_fn>(netHostLibrary, "get_hostfxr_path");

std::array<char_t, 300> buffer = { 0 };
size_t bufferSize = buffer.size();
if (get_hostfxr_path_ptr(buffer.data(), &bufferSize, nullptr) != 0) {
log::error("Could not get hostfxr path!");
return false;
}

void *hostfxrLibrary = loadLibrary(buffer.data());
if (hostfxrLibrary == nullptr)
if (hostfxrLibrary == nullptr) {
log::error("Could not load hostfxr library!");
return false;
}

{
hostfxr_initialize_for_runtime_config
Expand Down

0 comments on commit 9dbae20

Please sign in to comment.