Exclude WebViewLoader, webview_zygote and isolated processes
This commit is contained in:
parent
7eaae6d898
commit
ed968eb7cc
|
|
@ -4,8 +4,9 @@ import android.annotation.SuppressLint;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
|
|
||||||
import com.elderdrivers.riru.common.KeepAll;
|
import com.elderdrivers.riru.common.KeepAll;
|
||||||
import com.elderdrivers.riru.edxp.BuildConfig;
|
import com.elderdrivers.riru.edxp.common.BuildConfig;
|
||||||
import com.elderdrivers.riru.edxp.config.ConfigManager;
|
import com.elderdrivers.riru.edxp.config.ConfigManager;
|
||||||
|
import com.elderdrivers.riru.edxp.framework.ProcessHelper;
|
||||||
import com.elderdrivers.riru.edxp.util.Utils;
|
import com.elderdrivers.riru.edxp.util.Utils;
|
||||||
|
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
|
|
@ -18,6 +19,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||||
@SuppressLint("DefaultLocale")
|
@SuppressLint("DefaultLocale")
|
||||||
public class Main implements KeepAll {
|
public class Main implements KeepAll {
|
||||||
|
|
||||||
|
private static final boolean logEnabled = BuildConfig.DEBUG;
|
||||||
private static String forkAndSpecializePramsStr = "";
|
private static String forkAndSpecializePramsStr = "";
|
||||||
private static String forkSystemServerPramsStr = "";
|
private static String forkSystemServerPramsStr = "";
|
||||||
|
|
||||||
|
|
@ -36,11 +38,14 @@ public class Main implements KeepAll {
|
||||||
String niceName, int[] fdsToClose, int[] fdsToIgnore,
|
String niceName, int[] fdsToClose, int[] fdsToIgnore,
|
||||||
boolean startChildZygote, String instructionSet,
|
boolean startChildZygote, String instructionSet,
|
||||||
String appDataDir) {
|
String appDataDir) {
|
||||||
|
if (isBlackListedProcess(uid)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final EdxpImpl edxp = getEdxpImpl();
|
final EdxpImpl edxp = getEdxpImpl();
|
||||||
if (edxp == null || !edxp.isInitialized()) {
|
if (edxp == null || !edxp.isInitialized()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (BuildConfig.DEBUG) {
|
if (logEnabled) {
|
||||||
forkAndSpecializePramsStr = String.format(
|
forkAndSpecializePramsStr = String.format(
|
||||||
"Zygote#forkAndSpecialize(%d, %d, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s)",
|
"Zygote#forkAndSpecialize(%d, %d, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s)",
|
||||||
uid, gid, Arrays.toString(gids), debugFlags, Arrays.toString(rlimits),
|
uid, gid, Arrays.toString(gids), debugFlags, Arrays.toString(rlimits),
|
||||||
|
|
@ -60,12 +65,17 @@ public class Main implements KeepAll {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void forkAndSpecializePost(int pid, String appDataDir, String niceName) {
|
public static void forkAndSpecializePost(int pid, String appDataDir, String niceName) {
|
||||||
|
if (isBlackListedProcess(Process.myUid())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final EdxpImpl edxp = getEdxpImpl();
|
final EdxpImpl edxp = getEdxpImpl();
|
||||||
if (edxp == null || !edxp.isInitialized()) {
|
if (edxp == null || !edxp.isInitialized()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
Utils.logD(forkAndSpecializePramsStr + " = " + Process.myPid());
|
if (logEnabled) {
|
||||||
|
Utils.logI(forkAndSpecializePramsStr + " = " + Process.myPid());
|
||||||
|
}
|
||||||
if (ConfigManager.isBlackWhiteListEnabled()) {
|
if (ConfigManager.isBlackWhiteListEnabled()) {
|
||||||
edxp.getBlackWhiteListProxy().forkAndSpecializePost(pid, appDataDir, niceName);
|
edxp.getBlackWhiteListProxy().forkAndSpecializePost(pid, appDataDir, niceName);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -83,7 +93,7 @@ public class Main implements KeepAll {
|
||||||
if (edxp == null || !edxp.isInitialized()) {
|
if (edxp == null || !edxp.isInitialized()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (BuildConfig.DEBUG) {
|
if (logEnabled) {
|
||||||
forkSystemServerPramsStr = String.format("Zygote#forkSystemServer(%d, %d, %s, %d, %s, %d, %d)",
|
forkSystemServerPramsStr = String.format("Zygote#forkSystemServer(%d, %d, %s, %d, %s, %d, %d)",
|
||||||
uid, gid, Arrays.toString(gids), debugFlags, Arrays.toString(rlimits),
|
uid, gid, Arrays.toString(gids), debugFlags, Arrays.toString(rlimits),
|
||||||
permittedCapabilities, effectiveCapabilities);
|
permittedCapabilities, effectiveCapabilities);
|
||||||
|
|
@ -103,7 +113,9 @@ public class Main implements KeepAll {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
Utils.logD(forkSystemServerPramsStr + " = " + Process.myPid());
|
if (logEnabled) {
|
||||||
|
Utils.logI(forkSystemServerPramsStr + " = " + Process.myPid());
|
||||||
|
}
|
||||||
if (ConfigManager.isBlackWhiteListEnabled()) {
|
if (ConfigManager.isBlackWhiteListEnabled()) {
|
||||||
edxp.getBlackWhiteListProxy().forkSystemServerPost(pid);
|
edxp.getBlackWhiteListProxy().forkSystemServerPost(pid);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -145,4 +157,9 @@ public class Main implements KeepAll {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isBlackListedProcess(int uid) {
|
||||||
|
return ProcessHelper.isIsolated(uid)
|
||||||
|
|| ProcessHelper.isRELROUpdater(uid)
|
||||||
|
|| ProcessHelper.isWebViewZygote(uid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.elderdrivers.riru.edxp.framework;
|
||||||
|
|
||||||
|
import de.robv.android.xposed.XposedHelpers;
|
||||||
|
|
||||||
|
public class ProcessHelper {
|
||||||
|
|
||||||
|
static {
|
||||||
|
// WEBVIEW_ZYGOTE_UID differ among versions
|
||||||
|
WEBVIEW_ZYGOTE_UID = XposedHelpers.getStaticIntField(android.os.Process.class, "WEBVIEW_ZYGOTE_UID");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the UID/GID for the shared RELRO file updater process.
|
||||||
|
*/
|
||||||
|
public static final int SHARED_RELRO_UID = 1037;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the UID/GID for the WebView zygote process.
|
||||||
|
*/
|
||||||
|
public static final int WEBVIEW_ZYGOTE_UID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* First uid used for fully isolated sandboxed processes (with no permissions of their own)
|
||||||
|
*/
|
||||||
|
public static final int FIRST_ISOLATED_UID = 99000;
|
||||||
|
/**
|
||||||
|
* Last uid used for fully isolated sandboxed processes (with no permissions of their own)
|
||||||
|
*/
|
||||||
|
public static final int LAST_ISOLATED_UID = 99999;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Range of uids allocated for a user.
|
||||||
|
*/
|
||||||
|
public static final int PER_USER_RANGE = 100000;
|
||||||
|
|
||||||
|
public static int getAppId(int uid) {
|
||||||
|
return uid % PER_USER_RANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isRELROUpdater(int uid) {
|
||||||
|
return getAppId(uid) == SHARED_RELRO_UID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isWebViewZygote(int uid) {
|
||||||
|
return getAppId(uid) == WEBVIEW_ZYGOTE_UID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isIsolated(int uid) {
|
||||||
|
uid = getAppId(uid);
|
||||||
|
return uid >= FIRST_ISOLATED_UID && uid <= LAST_ISOLATED_UID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,7 @@ package com.elderdrivers.riru.edxp.util;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
|
|
||||||
import com.elderdrivers.riru.edxp.BuildConfig;
|
import com.elderdrivers.riru.edxp.common.BuildConfig;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ package com.elderdrivers.riru.edxp.util;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.elderdrivers.riru.edxp.BuildConfig;
|
import com.elderdrivers.riru.edxp.common.BuildConfig;
|
||||||
|
|
||||||
import de.robv.android.xposed.XposedHelpers;
|
import de.robv.android.xposed.XposedHelpers;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@ import org.gradle.internal.os.OperatingSystem
|
||||||
|
|
||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
version "v0.4.4.2_alpha"
|
version "v0.4.4.3_alpha"
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
versionCode = "4420"
|
versionCode = "4430"
|
||||||
module_name = "EdXposed"
|
module_name = "EdXposed"
|
||||||
jar_dest_dir = "${projectDir}/template_override/system/framework/"
|
jar_dest_dir = "${projectDir}/template_override/system/framework/"
|
||||||
is_windows = OperatingSystem.current().isWindows()
|
is_windows = OperatingSystem.current().isWindows()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#!/system/bin/sh
|
#!/system/bin/sh
|
||||||
|
|
||||||
EDXP_VERSION="0.4.4.2_alpha (4420)"
|
EDXP_VERSION="0.4.4.3_alpha (4430)"
|
||||||
ANDROID_SDK=`getprop ro.build.version.sdk`
|
ANDROID_SDK=`getprop ro.build.version.sdk`
|
||||||
BUILD_DESC=`getprop ro.build.description`
|
BUILD_DESC=`getprop ro.build.description`
|
||||||
PRODUCT=`getprop ro.build.product`
|
PRODUCT=`getprop ro.build.product`
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ package com.elderdrivers.riru.edxp.sandhook.dexmaker;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.elderdrivers.riru.edxp.BuildConfig;
|
import com.elderdrivers.riru.edxp.sandhook.BuildConfig;
|
||||||
|
|
||||||
public class DexLog {
|
public class DexLog {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ package com.elderdrivers.riru.edxp.yahfa.dexmaker;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.elderdrivers.riru.edxp.BuildConfig;
|
import com.elderdrivers.riru.edxp.yahfa.BuildConfig;
|
||||||
|
|
||||||
public class DexLog {
|
public class DexLog {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1 @@
|
||||||
<manifest package="com.elderdrivers.riru.edxp"
|
<manifest package="com.elderdrivers.riru.edxp.bridge" />
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"/>
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue