Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
restart zygote should be reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
RikkaW committed Mar 13, 2019
1 parent 3a1231c commit 3ab8e25
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
25 changes: 20 additions & 5 deletions riru-core/jni/zygote_restart/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,28 @@ int main(int argc, char **argv) {
}

if (!is_path_in_maps(pid, CHECK_LIB_NAME)) {
LOGW("no Riru found in " ZYGOTE_NAME ", restart " RESTART_NAME);

// restart zygote_secondary will also restart zygote, see init.zygote64_32.rc
__system_property_set("ctl.restart", const_cast<char *>(RESTART_NAME));
LOGW("no Riru found in %s (pid=%d), restart required", ZYGOTE_NAME, pid);
} else {
LOGI("found Riru in " ZYGOTE_NAME);
LOGI("found Riru in %s (pid=%d)", ZYGOTE_NAME, pid);
return 0;
}

// wait for magisk mount
while (access(CHECK_LIB_NAME, F_OK) != 0) {
LOGV("not mounted, wait 1s");
sleep(1);
}

// check if zygote is restarted by other
if ((pid = get_pid_by_name_and_uid(ZYGOTE_NAME, 0)) != -1
&& is_path_in_maps(pid, CHECK_LIB_NAME)) {
LOGI("found Riru in %s (pid=%d), abort restart", ZYGOTE_NAME, pid);
return 0;
}

LOGI("restart " RESTART_NAME);
// restart zygote_secondary will also restart zygote, see init.zygote64_32.rc
__system_property_set("ctl.restart", const_cast<char *>(RESTART_NAME));

return 0;
}
4 changes: 2 additions & 2 deletions riru-core/template_override/module.prop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id=riru-core
name=Riru - Core
version=v17
versionCode=17
version=v17.1
versionCode=17.1
author=Rikka
description=Inject zygote process by replace libmemtrack.so, provide interface to other Riru modules.
minMagisk=17000

0 comments on commit 3ab8e25

Please sign in to comment.