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

Commit

Permalink
0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
canyie committed Apr 4, 2021
1 parent 57457d3 commit 36b1987
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Many applications now detect Magisk for security, Magisk provided "Magisk Hide"
Features:
| Config name | Description |
| ---- | ---- |
| isolated | Apply Magisk Hide for isolated process and app zygotes. This feature is deprecated because it will unmount Magisk modified files for every isolated processes, and the unmounting time cannot be well controlled, which may cause some modules to not work. [Magisk alpha](https://github.com/vvb2060/magisk/trees/alpha) or the latest Magisk canary + [Riru-Unshare](https://github.com/vvb2060/riru-unshare) is recommended|
| isolated | Apply Magisk Hide for isolated process and app zygotes. This feature is deprecated because it will unmount Magisk modified files for every isolated processes, and the unmounting time cannot be well controlled, which may cause some modules to not work. [Magisk Alpha](https://github.com/vvb2060/magisk/tree/alpha) or the latest Magisk canary + [Riru-Unshare](https://github.com/vvb2060/riru-unshare) is recommended.|
| app_zygote_magic | Make a app named "Momo" cannot detect Magisk hide is running. |
| initrc | Hide the modified traces of init.rc |

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ task clean(type: Delete) {
}

ext {
versionCode = 3
versionName = '0.0.3'
versionCode = 4
versionName = '0.0.4'
minMagisk = 19000
riruApiVersion = 5 // For Riru v21
riruNewApiVersion = 25 // For Riru v22+
Expand Down
11 changes: 9 additions & 2 deletions module/src/main/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,26 @@ void MaybeInitNsHolder(JNIEnv* env) {
// We're in the "cleaned" ns, notify the zygote we're ready and stop us
WriteIntAndClose(write_fd, 0);

// All done, but we should keep alive, because we need to keep the namespace
// If a fd references the namespace, the ns won't be destroyed
// but we need to open a fd in zygote, and Google don't want we opened new fd across fork,
// zygote will abort with error like "Not whitelisted (41): mnt:[4026533391]"
// We can manually call the Zygote.nativeAllowAcrossFork(), but this can be detected by app;
// or, we can use the "fdsToIgnore" argument, but for usap, forkApp() haven't the argument.
// To keep it simple, just let fd not opened in zygote
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
for (;;) {
pause();
LOGW("nsholder wakes up unexpectedly, sleep again");
}
#pragma clang diagnostic pop

} else { // parent, wait the nsholder enter a "clean" ns
close(write_fd);
int status = ReadIntAndClose(read_fd);
if (status == 0) {
kill(nsholder_pid_, SIGSTOP);
kill(nsholder_pid_, SIGSTOP); // make nsholder is stopped again
char mnt[32];
snprintf(mnt, sizeof(mnt), "/proc/%d/ns/mnt", nsholder_pid_);
LOGI("The nsholder is cleaned and stopped, mnt_ns is %s", mnt);
Expand Down Expand Up @@ -336,7 +344,6 @@ failed = failed || RegisterHook(#NAME, reinterpret_cast<void*>(REPLACE), reinter

HOOK(fork, ForkReplace);
if (hide_isolated_) {
LOGI("registering unshare hook");
HOOK(unshare, UnshareReplace);
}

Expand Down
7 changes: 2 additions & 5 deletions template/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ else
ui_print "- Android API level: $API"
fi

if [ "$MAGISK_VER_CODE" -ge 21000 ]; then
MAGISK_CURRENT_RIRU_MODULE_PATH=$(magisk --path)/.magisk/modules/riru-core
else
MAGISK_CURRENT_RIRU_MODULE_PATH=/sbin/.magisk/modules/riru-core
fi
MAGISK_TMP=$(magisk --path) || MAGISK_TMP="/sbin"
MAGISK_CURRENT_RIRU_MODULE_PATH=$MAGISK_TMP/.magisk/modules/riru-core

if [ -f $MAGISK_CURRENT_RIRU_MODULE_PATH/util_functions.sh ]; then
# Riru V24+, api version is provided in util_functions.sh
Expand Down

0 comments on commit 36b1987

Please sign in to comment.