You've already forked ReZygisk
mirror of
https://github.com/PerformanC/ReZygisk.git
synced 2025-09-06 06:37:01 +00:00
improve: preload modules globally
This commit makes Zygisk modules be preloaded globally in the main Zygote process, so that they don't need to reload all the time. This commit is authored by @nampud, and merged into mainline ReZygisk. Co-authored-by: nampud
This commit is contained in:
@@ -66,7 +66,6 @@ struct ZygiskContext {
|
||||
} args;
|
||||
|
||||
const char *process;
|
||||
list<ZygiskModule> modules;
|
||||
|
||||
int pid;
|
||||
bitset<FLAG_MAX> flags;
|
||||
@@ -124,6 +123,10 @@ struct ZygiskContext {
|
||||
// Global variables
|
||||
vector<tuple<dev_t, ino_t, const char *, void **>> *plt_hook_list;
|
||||
map<string, vector<JNINativeMethod>> *jni_hook_list;
|
||||
|
||||
bool modules_loaded = false;
|
||||
list<ZygiskModule> 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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user