diff --git a/include/hex.hpp b/include/hex.hpp index 420a8d367..d8300d539 100644 --- a/include/hex.hpp +++ b/include/hex.hpp @@ -18,6 +18,9 @@ using s128 = __int128_t; #include "lang/result.hpp" #include "lang/results.hpp" +extern int mainArgc; +extern char **mainArgv; + #if defined(__EMX__) || defined (WIN32) #define MAGIC_PATH_SEPARATOR ";" #else diff --git a/source/helpers/loader_script_handler.cpp b/source/helpers/loader_script_handler.cpp index e11429a2c..69c51e7cb 100644 --- a/source/helpers/loader_script_handler.cpp +++ b/source/helpers/loader_script_handler.cpp @@ -148,10 +148,10 @@ namespace hex { } bool LoaderScript::processFile(std::string_view scriptPath) { - Py_SetProgramName(Py_DecodeLocale(__argv[0], nullptr)); + Py_SetProgramName(Py_DecodeLocale(mainArgv[0], nullptr)); - if (std::filesystem::exists(std::filesystem::path(__argv[0]).parent_path().string() + "/lib/python3.8")) - Py_SetPythonHome(Py_DecodeLocale(std::filesystem::path(__argv[0]).parent_path().string().c_str(), nullptr)); + if (std::filesystem::exists(std::filesystem::path(mainArgv[0]).parent_path().string() + "/lib/python3.8")) + Py_SetPythonHome(Py_DecodeLocale(std::filesystem::path(mainArgv[0]).parent_path().string().c_str(), nullptr)); PyImport_AppendInittab("_imhex", []() -> PyObject* { diff --git a/source/main.cpp b/source/main.cpp index 99176c511..2c3bad1fa 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -18,7 +18,13 @@ #include -int main() { +int mainArgc; +char **mainArgv; + +int main(int argc, char **argv) { + mainArgc = argc; + mainArgv = argv; + hex::Window window; // Shared Data