Nuke EdxpConfig
This commit is contained in:
parent
5129050a66
commit
9f6740c7da
|
|
@ -7,18 +7,10 @@
|
|||
|
||||
namespace edxp {
|
||||
|
||||
static jboolean ConfigManager_isBlackWhiteListEnabled(JNI_START) {
|
||||
return (jboolean) ConfigManager::GetInstance()->IsBlackWhiteListEnabled();
|
||||
}
|
||||
|
||||
static jboolean ConfigManager_isResourcesHookEnabled(JNI_START) {
|
||||
return (jboolean) ConfigManager::GetInstance()->IsResourcesHookEnabled();
|
||||
}
|
||||
|
||||
static jboolean ConfigManager_isDeoptBootImageEnabled(JNI_START) {
|
||||
return (jboolean) ConfigManager::GetInstance()->IsDeoptBootImageEnabled();
|
||||
}
|
||||
|
||||
static jboolean ConfigManager_isNoModuleLogEnabled(JNI_START) {
|
||||
return (jboolean) ConfigManager::GetInstance()->IsNoModuleLogEnabled();
|
||||
}
|
||||
|
|
@ -76,9 +68,7 @@ namespace edxp {
|
|||
}
|
||||
|
||||
static JNINativeMethod gMethods[] = {
|
||||
NATIVE_METHOD(ConfigManager, isBlackWhiteListEnabled, "()Z"),
|
||||
NATIVE_METHOD(ConfigManager, isResourcesHookEnabled, "()Z"),
|
||||
NATIVE_METHOD(ConfigManager, isDeoptBootImageEnabled, "()Z"),
|
||||
NATIVE_METHOD(ConfigManager, isNoModuleLogEnabled, "()Z"),
|
||||
NATIVE_METHOD(ConfigManager, getInstallerPackageName, "()Ljava/lang/String;"),
|
||||
NATIVE_METHOD(ConfigManager, getLibSandHookName, "()Ljava/lang/String;"),
|
||||
|
|
|
|||
|
|
@ -46,12 +46,6 @@ namespace edxp {
|
|||
return edxp::isHooked(getArtMethod(env, member));
|
||||
}
|
||||
|
||||
static void
|
||||
Yahfa_makeInitializedClassesVisiblyInitialized(JNI_START, jlong thread, jboolean wait) {
|
||||
art::ClassLinker::Current()->MakeInitializedClassesVisiblyInitialized(
|
||||
reinterpret_cast<void *>(thread), wait);
|
||||
}
|
||||
|
||||
static JNINativeMethod gMethods[] = {
|
||||
NATIVE_METHOD(Yahfa, init, "(I)V"),
|
||||
NATIVE_METHOD(Yahfa, findMethodNative,
|
||||
|
|
@ -61,7 +55,6 @@ namespace edxp {
|
|||
NATIVE_METHOD(Yahfa, setMethodNonCompilable, "(Ljava/lang/reflect/Member;)V"),
|
||||
NATIVE_METHOD(Yahfa, recordHooked, "(Ljava/lang/reflect/Member;)V"),
|
||||
NATIVE_METHOD(Yahfa, isHooked, "(Ljava/lang/reflect/Member;)Z"),
|
||||
NATIVE_METHOD(Yahfa, makeInitializedClassesVisiblyInitialized, "(JZ)V"),
|
||||
};
|
||||
|
||||
void RegisterEdxpYahfa(JNIEnv *env) {
|
||||
|
|
|
|||
|
|
@ -1,44 +0,0 @@
|
|||
package com.elderdrivers.riru.edxp.config;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
public class BaseEdxpConfig implements EdxpConfig {
|
||||
|
||||
@Override
|
||||
public String getConfigPath(String suffix) {
|
||||
return ConfigManager.getConfigPath(suffix != null ? suffix : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataPathPrefix() {
|
||||
return ConfigManager.getDataPathPrefix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInstallerPackageName() {
|
||||
return ConfigManager.getInstallerPackageName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLibSandHookName() {
|
||||
return ConfigManager.getLibSandHookName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResourcesHookEnabled() {
|
||||
return ConfigManager.isResourcesHookEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNoModuleLogEnabled() {
|
||||
return ConfigManager.isNoModuleLogEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlackWhiteListMode() {
|
||||
return ConfigManager.isBlackWhiteListEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModulesList() { return ConfigManager.getModulesList(); }
|
||||
}
|
||||
|
|
@ -1,40 +1,15 @@
|
|||
package com.elderdrivers.riru.edxp.config;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import de.robv.android.xposed.SELinuxHelper;
|
||||
|
||||
public class ConfigManager {
|
||||
|
||||
public static String appDataDir = "";
|
||||
public static String niceName = "";
|
||||
public static String appProcessName = "";
|
||||
|
||||
private static final HashMap<String, Boolean> compatModeCache = new HashMap<>();
|
||||
|
||||
public static boolean shouldUseCompatMode(String packageName) {
|
||||
Boolean result;
|
||||
if (compatModeCache.containsKey(packageName)
|
||||
&& (result = compatModeCache.get(packageName)) != null) {
|
||||
return result;
|
||||
}
|
||||
result = isFileExists(getConfigPath("compatlist/" + packageName));
|
||||
compatModeCache.put(packageName, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean isFileExists(String path) {
|
||||
return SELinuxHelper.getAppDataFileService().checkFileExists(path);
|
||||
}
|
||||
|
||||
public static native boolean isBlackWhiteListEnabled();
|
||||
|
||||
public static native boolean isNoModuleLogEnabled();
|
||||
|
||||
public static native boolean isResourcesHookEnabled();
|
||||
|
||||
public static native boolean isDeoptBootImageEnabled();
|
||||
|
||||
public static native String getInstallerPackageName();
|
||||
|
||||
public static native String getLibSandHookName();
|
||||
|
|
|
|||
|
|
@ -4,16 +4,8 @@ import com.elderdrivers.riru.edxp.hook.HookProvider;
|
|||
|
||||
public class EdXpConfigGlobal {
|
||||
|
||||
public static volatile EdxpConfig sConfig;
|
||||
public static volatile HookProvider sHookProvider;
|
||||
|
||||
public static EdxpConfig getConfig() {
|
||||
if (sConfig == null) {
|
||||
throw new IllegalArgumentException("sConfig should not be null.");
|
||||
}
|
||||
return sConfig;
|
||||
}
|
||||
|
||||
public static HookProvider getHookProvider() {
|
||||
if (sHookProvider == null) {
|
||||
throw new IllegalArgumentException("sHookProvider should not be null.");
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
package com.elderdrivers.riru.edxp.config;
|
||||
|
||||
public interface EdxpConfig {
|
||||
|
||||
String getConfigPath(String suffix);
|
||||
|
||||
String getDataPathPrefix();
|
||||
|
||||
String getInstallerPackageName();
|
||||
|
||||
String getLibSandHookName();
|
||||
|
||||
boolean isNoModuleLogEnabled();
|
||||
|
||||
boolean isResourcesHookEnabled();
|
||||
|
||||
boolean isBlackWhiteListMode();
|
||||
|
||||
String getModulesList();
|
||||
}
|
||||
|
|
@ -17,6 +17,4 @@ public class Yahfa {
|
|||
public static native void recordHooked(Member member);
|
||||
|
||||
public static native boolean isHooked(Member member);
|
||||
|
||||
public static native void makeInitializedClassesVisiblyInitialized(long thread, boolean wait);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.elderdrivers.riru.edxp.core.yahfa;
|
|||
|
||||
import com.elderdrivers.riru.edxp.art.Heap;
|
||||
import com.elderdrivers.riru.edxp.core.Yahfa;
|
||||
import com.elderdrivers.riru.edxp.util.ClassUtils;
|
||||
import com.elderdrivers.riru.edxp.util.Utils;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
|
@ -14,8 +13,6 @@ import java.util.Arrays;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import de.robv.android.xposed.XposedHelpers;
|
||||
|
||||
public class HookMain {
|
||||
|
||||
private static final Set<String> hookItemWhiteList = new HashSet<String>();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.elderdrivers.riru.edxp.deopt;
|
|||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.elderdrivers.riru.edxp.config.ConfigManager;
|
||||
import com.elderdrivers.riru.edxp.config.EdXpConfigGlobal;
|
||||
import com.elderdrivers.riru.edxp.util.Utils;
|
||||
|
||||
|
|
@ -41,7 +42,7 @@ public class PrebuiltMethodsDeopter {
|
|||
// todo check if has been done before
|
||||
deoptMethods(KEY_BOOT_IMAGE, null);
|
||||
if (!TextUtils.isEmpty(Utils.getSysProp("ro.miui.ui.version.code"))
|
||||
&& EdXpConfigGlobal.getConfig().isResourcesHookEnabled()) {
|
||||
&& ConfigManager.isResourcesHookEnabled()) {
|
||||
//deopt these only for MIUI with resources hook enabled
|
||||
deoptMethods(KEY_BOOT_IMAGE_MIUI_RES, null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
package com.elderdrivers.riru.edxp.sandhook.config;
|
||||
|
||||
import com.elderdrivers.riru.edxp.config.BaseEdxpConfig;
|
||||
|
||||
public class SandHookEdxpConfig extends BaseEdxpConfig {
|
||||
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ package com.elderdrivers.riru.edxp.sandhook.core;
|
|||
|
||||
import com.elderdrivers.riru.edxp.config.EdXpConfigGlobal;
|
||||
import com.elderdrivers.riru.edxp.proxy.BaseRouter;
|
||||
import com.elderdrivers.riru.edxp.sandhook.config.SandHookEdxpConfig;
|
||||
import com.elderdrivers.riru.edxp.sandhook.config.SandHookProvider;
|
||||
import com.elderdrivers.riru.edxp.sandhook.entry.AppBootstrapHookInfo;
|
||||
import com.elderdrivers.riru.edxp.sandhook.entry.SysBootstrapHookInfo;
|
||||
|
|
@ -51,7 +50,6 @@ public class SandHookRouter extends BaseRouter {
|
|||
}
|
||||
|
||||
public void injectConfig() {
|
||||
EdXpConfigGlobal.sConfig = new SandHookEdxpConfig();
|
||||
EdXpConfigGlobal.sHookProvider = new SandHookProvider();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
package com.elderdrivers.riru.edxp.yahfa.config;
|
||||
|
||||
import com.elderdrivers.riru.edxp.config.BaseEdxpConfig;
|
||||
|
||||
public class YahfaEdxpConfig extends BaseEdxpConfig {
|
||||
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ package com.elderdrivers.riru.edxp.yahfa.core;
|
|||
|
||||
import com.elderdrivers.riru.edxp.config.EdXpConfigGlobal;
|
||||
import com.elderdrivers.riru.edxp.proxy.BaseRouter;
|
||||
import com.elderdrivers.riru.edxp.yahfa.config.YahfaEdxpConfig;
|
||||
import com.elderdrivers.riru.edxp.yahfa.config.YahfaHookProvider;
|
||||
import com.elderdrivers.riru.edxp.yahfa.dexmaker.DynamicBridge;
|
||||
|
||||
|
|
@ -18,7 +17,6 @@ public class YahfaRouter extends BaseRouter {
|
|||
}
|
||||
|
||||
public void injectConfig() {
|
||||
EdXpConfigGlobal.sConfig = new YahfaEdxpConfig();
|
||||
EdXpConfigGlobal.sHookProvider = new YahfaHookProvider();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ package com.elderdrivers.riru.edxp.yahfa.dexmaker;
|
|||
import android.annotation.TargetApi;
|
||||
import android.os.Build;
|
||||
|
||||
import com.elderdrivers.riru.edxp.BuildConfig;
|
||||
import com.elderdrivers.riru.edxp.config.ConfigManager;
|
||||
import com.elderdrivers.riru.edxp.core.Yahfa;
|
||||
import com.elderdrivers.riru.edxp.core.yahfa.HookMain;
|
||||
import com.elderdrivers.riru.edxp.util.ProxyClassLoader;
|
||||
import com.elderdrivers.riru.edxp.BuildConfig;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
|
@ -30,7 +30,6 @@ import external.com.android.dx.Label;
|
|||
import external.com.android.dx.Local;
|
||||
import external.com.android.dx.MethodId;
|
||||
import external.com.android.dx.TypeId;
|
||||
import pxb.android.arsc.Config;
|
||||
|
||||
import static com.elderdrivers.riru.edxp.yahfa.dexmaker.DexMakerUtils.autoBoxIfNecessary;
|
||||
import static com.elderdrivers.riru.edxp.yahfa.dexmaker.DexMakerUtils.autoUnboxIfNecessary;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import external.com.android.dx.Local;
|
|||
import external.com.android.dx.MethodId;
|
||||
import external.com.android.dx.TypeId;
|
||||
|
||||
import static com.swift.sandhook.xposedcompat.utils.DexMakerUtils.MD5;
|
||||
import static com.swift.sandhook.xposedcompat.utils.DexMakerUtils.autoBoxIfNecessary;
|
||||
import static com.swift.sandhook.xposedcompat.utils.DexMakerUtils.autoUnboxIfNecessary;
|
||||
import static com.swift.sandhook.xposedcompat.utils.DexMakerUtils.canCache;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import external.com.android.dx.Local;
|
|||
import external.com.android.dx.MethodId;
|
||||
import external.com.android.dx.TypeId;
|
||||
|
||||
import static com.swift.sandhook.xposedcompat.utils.DexMakerUtils.MD5;
|
||||
import static com.swift.sandhook.xposedcompat.utils.DexMakerUtils.autoBoxIfNecessary;
|
||||
import static com.swift.sandhook.xposedcompat.utils.DexMakerUtils.autoUnboxIfNecessary;
|
||||
import static com.swift.sandhook.xposedcompat.utils.DexMakerUtils.canCache;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.swift.sandhook.xposedcompat.methodgen;
|
|||
import android.os.Build;
|
||||
import android.os.Process;
|
||||
import android.os.Trace;
|
||||
import android.util.Log;
|
||||
|
||||
import com.elderdrivers.riru.edxp.config.ConfigManager;
|
||||
import com.elderdrivers.riru.edxp.core.Yahfa;
|
||||
|
|
@ -25,7 +24,6 @@ import java.lang.reflect.Method;
|
|||
import java.lang.reflect.Modifier;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import de.robv.android.xposed.XposedBridge;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,13 @@
|
|||
package de.robv.android.xposed;
|
||||
|
||||
import android.os.SELinux;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import de.robv.android.xposed.services.BaseService;
|
||||
import de.robv.android.xposed.services.BinderService;
|
||||
import de.robv.android.xposed.services.DirectAccessService;
|
||||
import de.robv.android.xposed.services.ZygoteService;
|
||||
|
||||
/**
|
||||
* A helper to work with (or without) SELinux, abstracting much of its big complexity.
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.content.res.TypedArray;
|
|||
import android.util.Log;
|
||||
|
||||
import com.elderdrivers.riru.edxp.BuildConfig;
|
||||
import com.elderdrivers.riru.edxp.config.ConfigManager;
|
||||
import com.elderdrivers.riru.edxp.config.EdXpConfigGlobal;
|
||||
|
||||
import java.lang.reflect.AccessibleObject;
|
||||
|
|
@ -158,7 +159,7 @@ public final class XposedBridge {
|
|||
* @param text The log message.
|
||||
*/
|
||||
public synchronized static void log(String text) {
|
||||
if (EdXpConfigGlobal.getConfig().isNoModuleLogEnabled()) {
|
||||
if (ConfigManager.isNoModuleLogEnabled()) {
|
||||
return;
|
||||
}
|
||||
Log.i(TAG, text);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import android.util.ArraySet;
|
|||
import android.util.Log;
|
||||
|
||||
import com.android.internal.os.ZygoteInit;
|
||||
import com.elderdrivers.riru.edxp.config.ConfigManager;
|
||||
import com.elderdrivers.riru.edxp.config.EdXpConfigGlobal;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
|
@ -41,9 +42,7 @@ import de.robv.android.xposed.callbacks.XC_InitPackageResources;
|
|||
import de.robv.android.xposed.callbacks.XC_InitZygote;
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage;
|
||||
import de.robv.android.xposed.callbacks.XCallback;
|
||||
import de.robv.android.xposed.services.BaseService;
|
||||
|
||||
import static de.robv.android.xposed.XposedBridge.clearAllCallbacks;
|
||||
import static de.robv.android.xposed.XposedBridge.hookAllConstructors;
|
||||
import static de.robv.android.xposed.XposedBridge.hookAllMethods;
|
||||
import static de.robv.android.xposed.XposedBridge.sInitPackageResourcesCallbacks;
|
||||
|
|
@ -97,7 +96,7 @@ public final class XposedInit {
|
|||
|
||||
@ApiSensitive(Level.MIDDLE)
|
||||
private static void hookResources() throws Throwable {
|
||||
if (!EdXpConfigGlobal.getConfig().isResourcesHookEnabled() || disableResources) {
|
||||
if (!ConfigManager.isResourcesHookEnabled() || disableResources) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -328,7 +327,7 @@ public final class XposedInit {
|
|||
topClassLoader = parent;
|
||||
}
|
||||
|
||||
String moduleList = EdXpConfigGlobal.getConfig().getModulesList();
|
||||
String moduleList = ConfigManager.getModulesList();
|
||||
InputStream stream = new ByteArrayInputStream(moduleList.getBytes());
|
||||
BufferedReader apks = new BufferedReader(new InputStreamReader(stream));
|
||||
ArraySet<String> newLoadedApk = new ArraySet<>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue