Skip to content

Commit

Permalink
Make Zygote injection optional for Zygisk modules
Browse files Browse the repository at this point in the history
This is useful when a module has Zygisk features, but also has other
features which can work without Zygisk, such as TrickyStore.
  • Loading branch information
aviraxp committed Jul 27, 2024
1 parent 3b27de3 commit a2a7a37
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ class LocalModuleRvItem(
val isZygisk = item.isZygisk
val isRiru = item.isRiru
val zygiskUnloaded = isZygisk && item.zygiskUnloaded
val isZygiskOptional = item.isZygiskOptional

showNotice = zygiskUnloaded ||
(Info.isZygiskEnabled && isRiru) ||
(!Info.isZygiskEnabled && isZygisk)
(!Info.isZygiskEnabled && isZygisk && !isZygiskOptional)
noticeText =
when {
zygiskUnloaded -> CoreR.string.zygisk_module_unloaded.asText()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ data class LocalModule(
private val riruFolder = RootUtils.fs.getFile(path, "riru")
private val zygiskFolder = RootUtils.fs.getFile(path, "zygisk")
private val unloaded = RootUtils.fs.getFile(zygiskFolder, "unloaded")
private val zygiskOptional = RootUtils.fs.getFile(zygiskFolder, "optional")

val updated: Boolean get() = updateFile.exists()
val isRiru: Boolean get() = (id == "riru-core") || riruFolder.exists()
val isZygisk: Boolean get() = zygiskFolder.exists()
val zygiskUnloaded: Boolean get() = unloaded.exists()
val isZygiskOptional: Boolean get() = zygiskOptional.exists()

var enable: Boolean
get() = !disableFile.exists()
Expand Down
3 changes: 2 additions & 1 deletion native/src/core/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,8 @@ static void collect_modules(bool open_zygisk) {
}
} else {
// Ignore zygisk modules when zygisk is not enabled
if (faccessat(modfd, "zygisk", F_OK, 0) == 0) {
if (faccessat(modfd, "zygisk", F_OK, 0) == 0 &&
faccessat(modfd, "zygisk/optional", F_OK, 0) != 0) {
LOGI("%s: ignore\n", entry->d_name);
return;
}
Expand Down

0 comments on commit a2a7a37

Please sign in to comment.