diff --git a/assets/nix/run.sh b/assets/nix/run.sh index 566edf4..257fb00 100755 --- a/assets/nix/run.sh +++ b/assets/nix/run.sh @@ -246,9 +246,18 @@ doorstop_directory="${BASEDIR}/" doorstop_name="libdoorstop.${lib_extension}" export LD_LIBRARY_PATH="${doorstop_directory}:${corlib_dir}:${LD_LIBRARY_PATH}" -export LD_PRELOAD="${doorstop_name}:${LD_PRELOAD}" -export DYLD_LIBRARY_PATH="${doorstop_directory}:${corlib_dir}:${DYLD_LIBRARY_PATH}" -export DYLD_INSERT_LIBRARIES="${doorstop_name}:${DYLD_INSERT_LIBRARIES}" +if [ -z "$LD_PRELOAD" ]; then + export LD_PRELOAD="${doorstop_name}" +else + export LD_PRELOAD="${doorstop_name}:${LD_PRELOAD}" +fi + +export DYLD_LIBRARY_PATH="${doorstop_directory}:${DYLD_LIBRARY_PATH}" +if [ -z "$DYLD_INSERT_LIBRARIES" ]; then + export DYLD_INSERT_LIBRARIES="${doorstop_name}" +else + export DYLD_INSERT_LIBRARIES="${doorstop_name}:${DYLD_INSERT_LIBRARIES}" +fi # shellcheck disable=SC2086 exec "$executable_path" $rest_args diff --git a/src/nix/entrypoint.c b/src/nix/entrypoint.c index d1f9978..1bf4556 100644 --- a/src/nix/entrypoint.c +++ b/src/nix/entrypoint.c @@ -74,8 +74,7 @@ __attribute__((constructor)) void doorstop_ctor() { void *unity_player = plthook_handle_by_name("UnityPlayer"); - // TODO: Chekc if this still works on macOS - if (unity_player && plthook_open_by_address(&hook, unity_player) == 0) { + if (unity_player && plthook_open_by_handle(&hook, unity_player) == 0) { LOG("Found UnityPlayer, hooking into it instead"); } else if (plthook_open(&hook, NULL) != 0) { LOG("Failed to open current process PLT! Cannot run Doorstop! "