From ff16fdcf95d9836ad186dbb28382d72728be3790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=9010?= <0w0@0w0.pw> Date: Sun, 14 Aug 2022 00:27:13 +0800 Subject: [PATCH 1/2] Fix macos support. Optimize run script. --- assets/nix/run.sh | 15 ++++++++++++--- src/nix/entrypoint.c | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) 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..892006e 100644 --- a/src/nix/entrypoint.c +++ b/src/nix/entrypoint.c @@ -75,7 +75,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! " From ad71cae42aa005b12f5cd4ed919e83f35970a541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=9010?= <0w0@0w0.pw> Date: Sun, 14 Aug 2022 00:35:12 +0800 Subject: [PATCH 2/2] Finished TODO --- src/nix/entrypoint.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/nix/entrypoint.c b/src/nix/entrypoint.c index 892006e..1bf4556 100644 --- a/src/nix/entrypoint.c +++ b/src/nix/entrypoint.c @@ -74,7 +74,6 @@ __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_handle(&hook, unity_player) == 0) { LOG("Found UnityPlayer, hooking into it instead"); } else if (plthook_open(&hook, NULL) != 0) {