diff --git a/native/jni/daemon/bootstages.cpp b/native/jni/daemon/bootstages.cpp index 111b5700a..6ecfd6644 100644 --- a/native/jni/daemon/bootstages.cpp +++ b/native/jni/daemon/bootstages.cpp @@ -576,7 +576,7 @@ static bool check_data() { return data; } -extern int launch_magiskhide(); +extern int launch_magiskhide(int client = -1); static void *start_magisk_hide(void *) { launch_magiskhide(); diff --git a/native/jni/magiskhide/magiskhide.cpp b/native/jni/magiskhide/magiskhide.cpp index 6dce20a80..efd9a798f 100644 --- a/native/jni/magiskhide/magiskhide.cpp +++ b/native/jni/magiskhide/magiskhide.cpp @@ -32,7 +32,7 @@ pthread_mutex_t list_lock; exit(1); } -int launch_magiskhide() { +int launch_magiskhide(int client) { if (hide_enabled) return HIDE_IS_ENABLED; @@ -62,9 +62,12 @@ int launch_magiskhide() { // Get thread reference proc_monitor_thread = pthread_self(); + if (client >= 0) { + write_int(client, DAEMON_SUCCESS); + close(client); + } // Start monitoring proc_monitor(); - return DAEMON_SUCCESS; error: hide_enabled = 0; @@ -101,7 +104,7 @@ void magiskhide_handler(int client) { switch (req) { case LAUNCH_MAGISKHIDE: - res = launch_magiskhide(); + res = launch_magiskhide(client); break; case STOP_MAGISKHIDE: res = stop_magiskhide(); diff --git a/native/jni/magiskhide/magiskhide.h b/native/jni/magiskhide/magiskhide.h index f180377c1..3e743c2fd 100644 --- a/native/jni/magiskhide/magiskhide.h +++ b/native/jni/magiskhide/magiskhide.h @@ -10,7 +10,7 @@ #define TERM_THREAD SIGUSR1 // Daemon entries -int launch_magiskhide(); +int launch_magiskhide(int client); int stop_magiskhide(); int add_list(int client); int rm_list(int client); diff --git a/native/jni/magiskhide/proc_monitor.cpp b/native/jni/magiskhide/proc_monitor.cpp index d54780251..56cf0669a 100644 --- a/native/jni/magiskhide/proc_monitor.cpp +++ b/native/jni/magiskhide/proc_monitor.cpp @@ -200,4 +200,5 @@ void proc_monitor() { if (fork_dont_care() == 0) hide_daemon(pid); } + pthread_exit(nullptr); }