diff --git a/loader/src/injector/hook.cpp b/loader/src/injector/hook.cpp index c00d832..b29ce23 100644 --- a/loader/src/injector/hook.cpp +++ b/loader/src/injector/hook.cpp @@ -66,7 +66,6 @@ struct ZygiskContext { } args; const char *process; - list modules; int pid; bitset flags; @@ -124,6 +123,10 @@ struct ZygiskContext { // Global variables vector> *plt_hook_list; map> *jni_hook_list; + +bool modules_loaded = false; +list modules; + bool should_unmap_zygisk = false; bool enable_unloader = false; bool hooked_unloader = false; @@ -824,15 +827,6 @@ void ZygiskContext::app_specialize_pre() { setenv("ZYGISK_ENABLED", "1", 1); } - /* INFO: Because we load directly from the file, we need to do it before we umount - the mounts, or else it won't have access to /data/adb anymore. - */ - if (!load_modules_only()) { - LOGE("Failed to load modules"); - - return; - } - /* INFO: Modules only have two "start off" points from Zygisk, preSpecialize and postSpecialize. In preSpecialize, the process still has privileged permissions, and therefore can execute mount/umount/setns functions. @@ -908,11 +902,15 @@ void ZygiskContext::nativeForkSystemServer_pre() { LOGV("pre forkSystemServer"); flags[SERVER_FORK_AND_SPECIALIZE] = true; + if (!modules_loaded) { + load_modules_only(); + modules_loaded = true; + } + fork_pre(); if (!is_child()) return; - load_modules_only(); run_modules_pre(); rezygiskd_system_server_started();