Compare commits

...

2 Commits

Author SHA1 Message Date
WerWolv d86be9d9b3 sys: `putenv` sucks. Use `setenv` instead 2023-01-07 10:56:03 +01:00
WerWolv c26bed894b sys: Add `imhex/lib` path to plugin libraries search paths 2023-01-07 10:32:01 +01:00
6 changed files with 25 additions and 0 deletions

View File

@ -101,6 +101,7 @@ namespace hex::fs {
Scripts,
Inspectors,
Themes,
Libraries,
END
};

View File

@ -226,6 +226,9 @@ namespace hex::fs {
case ImHexPath::Plugins:
result = appendPath(getPluginPaths(), "plugins");
break;
case ImHexPath::Libraries:
result = appendPath(getPluginPaths(), "lib");
break;
case ImHexPath::Resources:
result = appendPath(getDataPaths(), "resources");
break;

View File

@ -18,6 +18,12 @@
namespace hex {
void Window::initNative() {
// Add plugin library folders to dll search path
for (const auto &path : hex::fs::getDefaultPaths(fs::ImHexPath::Libraries)) {
if (std::fs::exists(path))
setenv("LD_LIBRARY_PATH", hex::format("{};{}", hex::getEnvironmentVariable("LD_LIBRARY_PATH").value_or(""), path.string().c_str()).c_str(), true);
}
if (!isatty(STDOUT_FILENO)) {
log::redirectToFile();
}

View File

@ -17,6 +17,12 @@
namespace hex {
void Window::initNative() {
// Add plugin library folders to dll search path
for (const auto &path : hex::fs::getDefaultPaths(fs::ImHexPath::Libraries)) {
if (std::fs::exists(path))
setenv("LD_LIBRARY_PATH", hex::format("{};{}", hex::getEnvironmentVariable("LD_LIBRARY_PATH").value_or(""), path.string().c_str()).c_str(), true);
}
if (!isatty(STDOUT_FILENO)) {
log::redirectToFile();
}

View File

@ -18,6 +18,7 @@
#include <GLFW/glfw3native.h>
#undef GLFW_EXPOSE_NATIVE_WIN32
#include <winbase.h>
#include <winuser.h>
#include <dwmapi.h>
#include <windowsx.h>
@ -187,6 +188,13 @@ namespace hex {
void Window::initNative() {
// Add plugin library folders to dll search path
for (const auto &path : hex::fs::getDefaultPaths(fs::ImHexPath::Libraries)) {
if (std::fs::exists(path))
AddDllDirectory(path.c_str());
}
// Attach to parent console if one exists
if (AttachConsole(ATTACH_PARENT_PROCESS)) {

View File

@ -148,6 +148,7 @@ namespace hex::plugin::builtin {
{ "Patterns Includes", fs::ImHexPath::PatternsInclude },
{ "Magic", fs::ImHexPath::Magic },
{ "Plugins", fs::ImHexPath::Plugins },
{ "Libraries", fs::ImHexPath::Libraries },
{ "Yara Patterns", fs::ImHexPath::Yara },
{ "Config", fs::ImHexPath::Config },
{ "Resources", fs::ImHexPath::Resources },