diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/base/dexkit/DexKit.java b/app/src/main/java/com/sevtinge/hyperceiler/module/base/dexkit/DexKit.java index f4595b9b7a..b392461e60 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/base/dexkit/DexKit.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/base/dexkit/DexKit.java @@ -42,21 +42,23 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.lang.reflect.Type; import java.nio.file.FileVisitResult; import java.nio.file.FileVisitor; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; +import java.util.stream.Collectors; import de.robv.android.xposed.callbacks.XC_LoadPackage; public class DexKit { public boolean isInit = false; - private final String version = "2"; + // 更新版本可触发全部缓存重建 + private final String version = "2.1"; private static final String TYPE_METHOD = "METHOD"; private static final String TYPE_CLASS = "CLASS"; private static final String TYPE_FIELD = "FIELD"; @@ -100,21 +102,35 @@ private void init() { isInit = true; } + @NotNull + public static DexKitBridge getDexKitBridge() { + if (privateDexKitBridge == null) { + if (dexKit == null) { + throw new RuntimeException("InitDexKit is null!!"); + } else { + // new DexKitCache(dexKit.loadPackageParam).create(); + dexKit.init(); + } + } + return privateDexKitBridge; + } + /** * 检查当前软件版本是否发生变化。 */ private void versionCheck() { - String versionName = Helpers.getPackageVersionName(loadPackageParam); - int versionCode = Helpers.getPackageVersionCode(loadPackageParam); + String versionName = Helpers.getPackageVersionName(loadPackageParam), + versionCode = Integer.toString(Helpers.getPackageVersionCode(loadPackageParam)); // String dexFile = dir + callTAG; - String nameFile = getFile("versionName"); - String codeFile = getFile("versionCode"); - String dexkitVersion = getFile("cacheVersion"); + String nameFile = getFile("versionName"), + codeFile = getFile("versionCode"), + dexkitVersion = getFile("cacheVersion"); + if (!FileUtils.mkdirs(dexPath)) { isMkdir = false; XposedLogUtils.logE(callTAG, "failed to create mkdirs: " + dexPath + " cant use dexkit cache!!"); - } else isMkdir = true; - if (isMkdir) { + } else { + isMkdir = true; if (!FileUtils.touch(dexkitVersion)) XposedLogUtils.logE(callTAG, "failed to create file: " + dexkitVersion); String deVer = FileUtils.read(dexkitVersion); @@ -126,18 +142,18 @@ private void versionCheck() { XposedLogUtils.logE(callTAG, "failed to create file: " + nameFile); if (!FileUtils.touch(codeFile)) XposedLogUtils.logE(callTAG, "failed to create file: " + codeFile); - String verName = FileUtils.read(nameFile); - String codeName = FileUtils.read(codeFile); + String verName = FileUtils.read(nameFile), + codeName = FileUtils.read(codeFile); if (verName != null && codeName != null) { - if ("null".equals(versionName) && versionCode == -1) return; + if ("null".equals(versionName) && versionCode.equals("-1")) return; if (verName.isEmpty() || codeName.isEmpty()) { FileUtils.write(nameFile, versionName); - FileUtils.write(codeFile, Integer.toString(versionCode)); - } else if (!(verName.equals(versionName)) || (!codeName.equals(Integer.toString(versionCode)))) { + FileUtils.write(codeFile, versionCode); + } else if (!(verName.equals(versionName)) || (!codeName.equals(versionCode))) { // FileUtils.write(dexFile, new JSONArray().toString()); clearCache(dexPath); FileUtils.write(nameFile, versionName); - FileUtils.write(codeName, String.valueOf(versionCode)); + FileUtils.write(codeName, versionCode); } } } @@ -175,81 +191,31 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOEx return FileVisitResult.CONTINUE; } }); - } - @NotNull - public static DexKitBridge getDexKitBridge() { - if (privateDexKitBridge == null) { - if (dexKit == null) { - throw new RuntimeException("InitDexKit is null!!"); - } else { - // new DexKitCache(dexKit.loadPackageParam).create(); - dexKit.init(); - } - } - return privateDexKitBridge; - } - - /** - * 不检查缓存,每次执行搜索。 - */ - @Nullable - public static BaseDataList useDexKitIfNoCache(String[] tags, IDexKitData iDexKitData) { - return useDexKitIfNoCache(tags, false, iDexKitData); - } - - /** - * 当结果被缓存时返回 null,否则执行搜索。 - */ @Nullable - public static BaseDataList useDexKitIfNoCache(String[] tags, boolean noCache, IDexKitData iDexKitData) { - if (noCache) iDexKitData.dexkit(getDexKitBridge()); + public static BaseDataList useDexkitIfNoCache(String[] tags, IDexKitData iDexKitData) { callTAG = getCallName(Thread.currentThread().getStackTrace()); - String dexFile = getFile(callTAG); - ArrayList data = getCacheMapOrReadFile(dexFile); - // XposedLogUtils.logE(callTAG, "data: " + data); - // 非常不严谨,按你需求改吧。 - boolean have = false; - for (String tag : tags) { - if (isAdded(tag, data)) { - have = true; - break; - } - } - if (!have) { + if (getCacheMapOrReadFile(getFile(callTAG)).stream() + .noneMatch(data -> Arrays.stream(tags) + .anyMatch(t -> t.equals(data.tag)))) { return iDexKitData.dexkit(getDexKitBridge()); } return null; } - /** - * 不写入缓存,直接返回 baseDataList 内结果。 - */ - public static DexKit createCache(String tag, List baseDataList, ClassLoader classLoader) { - return createCache(tag, false, baseDataList, classLoader); - } - - /** - * 创建缓存,创建成功后将返回缓存内结果。 - */ - public static DexKit createCache(String tag, boolean noCache, List baseDataList, ClassLoader classLoader) { - dexKit.elementList = getDexKitBridge(tag, noCache, null, null, toElementList(baseDataList, classLoader)); - return dexKit; - } - /** * 获取一个结果的时候使用,并且设置 debug 模式,可以使结果不被写入缓存。 */ public static AnnotatedElement getDexKitBridge(String tag, boolean noCache, IDexKit iDexKit) { - return getDexKitBridge(tag, noCache, iDexKit, null, null).get(0); + return getDexKitBridge(tag, noCache, iDexKit, null).get(0); } /** * 获取一个结果的时候使用。 */ public static AnnotatedElement getDexKitBridge(String tag, IDexKit iDexKit) { - return getDexKitBridge(tag, false, iDexKit, null, null).get(0); + return getDexKitBridge(tag, false, iDexKit, null).get(0); } /** @@ -262,7 +228,7 @@ public static AnnotatedElement getDexKitBridge(String tag, IDexKit iDexKit) { * 使用 */ public static DexKit getDexKitBridgeList(String tag, boolean noCache, IDexKitList iDexKitList) { - dexKit.elementList = getDexKitBridge(tag, noCache, null, iDexKitList, null); + dexKit.elementList = getDexKitBridge(tag, noCache, null, iDexKitList); return dexKit; } @@ -276,53 +242,39 @@ public static DexKit getDexKitBridgeList(String tag, boolean noCache, IDexKitLis * 使用 */ public static DexKit getDexKitBridgeList(String tag, IDexKitList iDexKitList) { - dexKit.elementList = getDexKitBridge(tag, false, null, iDexKitList, null); + dexKit.elementList = getDexKitBridge(tag, false, null, iDexKitList); return dexKit; } // 主体代码 private static List getDexKitBridge(@NotNull String tag, boolean noCache, IDexKit iDexKit, - IDexKitList iDexKitList, List list) { - String callName = getCallName(Thread.currentThread().getStackTrace()); - callTAG = callName; + IDexKitList iDexKitList) { + callTAG = getCallName(Thread.currentThread().getStackTrace()); DexKitBridge dexKitBridge = getDexKitBridge(); - String dexFile = getFile(callName); - // XposedLogUtils.logE(callTAG, "path: " + dexPath + " file: " + dexFile + " cll: " + stackTrace[2].getClassName()); - ClassLoader classLoader = dexKit.loadPackageParam.classLoader; - if (noCache) { - return getElements(iDexKit, iDexKitList, dexKitBridge); - } - if (!isMkdir) { - return getElements(iDexKit, iDexKitList, dexKitBridge); - } + String dexFile = getFile(callTAG); + if (noCache) + return getElement(dexKitBridge, iDexKit, iDexKitList); + if (!isMkdir) + return getElement(dexKitBridge, iDexKit, iDexKitList); if (!touchIfNeed(dexFile)) - return getElements(iDexKit, iDexKitList, dexKitBridge); - return run(tag, iDexKit, iDexKitList, dexFile, dexKitBridge, classLoader, list); + return getElement(dexKitBridge, iDexKit, iDexKitList); + return run(tag, dexFile, dexKitBridge, dexKit.loadPackageParam.classLoader, iDexKit, iDexKitList); } // 执行缓存或读取 - private static List run(@NonNull String tag, IDexKit iDexKit, IDexKitList iDexKitList, - String dexFile, DexKitBridge dexKitBridge, ClassLoader classLoader, List list) { + private static List run(@NonNull String tag, String dexFile, DexKitBridge dexKitBridge, + ClassLoader classLoader, IDexKit iDexKit, IDexKitList iDexKitList) { ArrayList cacheData = getCacheMapOrReadFile(dexFile); - boolean isAdded = isAdded(tag, cacheData); - if (!isAdded) { - return getElementsAndWriteCache(tag, iDexKit, iDexKitList, dexKitBridge, cacheData, dexFile, list); - } else { - return getFileCache(tag, iDexKit, iDexKitList, cacheData, dexKitBridge, classLoader, list); - } + if (!haveCache(tag, cacheData)) + return getElementAndWriteCache(tag, iDexKit, iDexKitList, dexKitBridge, cacheData, dexFile); + else + return getFileCache(tag, classLoader, cacheData); } // 获取结果并写入缓存 - private static List getElementsAndWriteCache(String tag, IDexKit iDexKit, IDexKitList iDexKitList, - DexKitBridge dexKitBridge, ArrayList dadaList, String dexFile, - List list) { - ArrayList elements; - if (iDexKit != null || iDexKitList != null) { - elements = new ArrayList<>(getElements(iDexKit, iDexKitList, dexKitBridge)); - } else { - elements = new ArrayList<>(list); - } - // if (dadaList.isEmpty()) return elements; + private static List getElementAndWriteCache(String tag, IDexKit iDexKit, IDexKitList iDexKitList, + DexKitBridge dexKitBridge, ArrayList dadaList, String dexFile) { + ArrayList elements = new ArrayList<>(getElement(dexKitBridge, iDexKit, iDexKitList)); dadaList.addAll(createJsonList(tag, elements)); FileUtils.write(dexFile, gson.toJson(dadaList)); cacheMap.put(dexFile, dadaList); @@ -335,108 +287,66 @@ private static ArrayList createJsonList(String tag, ArrayList(); for (AnnotatedElement element : elements) { if (element instanceof Method method) { - String methodName = method.getName(); - String clName = method.getDeclaringClass().getName(); - Class[] param = method.getParameterTypes(); - ArrayList paramList = new ArrayList<>(); - for (Class p : param) { - paramList.add(p.getName()); - } - DexKitData data = new DexKitData(tag, TYPE_METHOD, clName, methodName, paramList, DexKitData.EMPTY); - jsonList.add(data); + jsonList.add(new DexKitData(tag, TYPE_METHOD, method.getDeclaringClass().getName(), + method.getName(), Arrays.stream(method.getParameterTypes()) + .map(Class::getName) + .collect(Collectors.toCollection(ArrayList::new)) + , DexKitData.EMPTY)); } else if (element instanceof Field field) { - String fieldName = field.getName(); - String clName = field.getDeclaringClass().getName(); - DexKitData data = new DexKitData(tag, TYPE_FIELD, clName, DexKitData.EMPTY, - DexKitData.EMPTYLIST, fieldName); - jsonList.add(data); + jsonList.add(new DexKitData(tag, TYPE_FIELD, field.getDeclaringClass().getName(), DexKitData.EMPTY, + DexKitData.EMPTYLIST, field.getName())); } else if (element instanceof Constructor constructor) { - String clzName = constructor.getName(); - Class[] param = constructor.getParameterTypes(); - ArrayList paramList = new ArrayList<>(); - for (Class p : param) { - paramList.add(p.getName()); - } - DexKitData data = new DexKitData(tag, TYPE_CONSTRUCTOR, clzName, - DexKitData.EMPTY, paramList, DexKitData.EMPTY); - jsonList.add(data); + jsonList.add(new DexKitData(tag, TYPE_CONSTRUCTOR, constructor.getName(), + DexKitData.EMPTY, Arrays.stream(constructor.getParameterTypes()) + .map(Class::getName) + .collect(Collectors.toCollection(ArrayList::new)) + , DexKitData.EMPTY)); } else if (element instanceof Class c) { - String clzName = c.getName(); - DexKitData data = new DexKitData(tag, TYPE_CLASS, clzName, - DexKitData.EMPTY, DexKitData.EMPTYLIST, DexKitData.EMPTY); - jsonList.add(data); + jsonList.add(new DexKitData(tag, TYPE_CLASS, c.getName(), + DexKitData.EMPTY, DexKitData.EMPTYLIST, DexKitData.EMPTY)); } } return jsonList; } // 读取缓存 - private static List getFileCache(String tag, IDexKit iDexKit, IDexKitList iDexKitList, - ArrayList dadaList, DexKitBridge dexKitBridge, ClassLoader classLoader, - List list) { + private static List getFileCache(String tag, ClassLoader classLoader, ArrayList dadaList) { ArrayList getElement = new ArrayList<>(); for (DexKitData data : dadaList) { if (!tag.equals(data.tag)) { continue; } String type = data.type; - switch (type) { - case TYPE_CLASS -> { - String clzName = data.clazz; - getElement.add(getClass(clzName, classLoader)); - } - case TYPE_METHOD -> { - String clzName = data.clazz; - String method = data.method; - ArrayList paramList = data.param; - Class clz = getClass(clzName, classLoader); - Class[] paramArray = stringToClassArray(paramList, classLoader); - try { - Method getMethod = clz.getDeclaredMethod(method, paramArray); - getElement.add(getMethod); - } catch (NoSuchMethodException e) { - throwRuntime(e.toString()); + try { + switch (type) { + case TYPE_CLASS -> { + getElement.add(getClass(data.clazz, classLoader)); } - } - case TYPE_FIELD, TYPE_FILED -> { - String clzName = data.clazz; - String field = data.field; - Class clz = getClass(clzName, classLoader); - try { - Field getField = clz.getDeclaredField(field); - getElement.add(getField); - } catch (NoSuchFieldException e) { - throwRuntime(e.toString()); + case TYPE_METHOD -> { + getElement.add(getClass(data.clazz, classLoader).getDeclaredMethod(data.method, + stringToClassArray(data.param, classLoader))); } - } - case TYPE_CONSTRUCTOR -> { - String clzName = data.clazz; - ArrayList paramList = data.param; - Class clz = getClass(clzName, classLoader); - Class[] paramArray = stringToClassArray(paramList, classLoader); - try { - Constructor constructor = clz.getConstructor(paramArray); - getElement.add(constructor); - } catch (NoSuchMethodException e) { - throwRuntime(e.toString()); + case TYPE_FIELD, TYPE_FILED -> { + getElement.add(getClass(data.clazz, classLoader).getDeclaredField(data.field)); + } + case TYPE_CONSTRUCTOR -> { + getElement.add(getClass(data.clazz, classLoader).getConstructor( + stringToClassArray(data.param, classLoader))); } } + } catch (NoSuchFieldException | NoSuchMethodException e) { + throwRuntime(e.toString()); } } - if (getElement.isEmpty()) { - if (iDexKit != null || iDexKitList != null) - return getElements(iDexKit, iDexKitList, dexKitBridge); - else return list; - } return getElement; } private static ArrayList getCacheMapOrReadFile(String dexFile) { ArrayList cacheData = cacheMap.get(dexFile); if (cacheData == null) { - Type type = new TypeToken>() { - }.getType(); - ArrayList dataList = gson.fromJson(FileUtils.read(dexFile), type); + ArrayList dataList = gson.fromJson(FileUtils.read(dexFile), + new TypeToken>() { + }.getType()); cacheMap.put(dexFile, dataList); cacheData = dataList; } @@ -448,15 +358,14 @@ private static boolean touchIfNeed(String dexFile) { if (!Boolean.TRUE.equals(isTouch)) { if (!FileUtils.exists(dexFile)) { if (FileUtils.touch(dexFile)) { - if (FileUtils.write(dexFile, new JSONArray().toString())) - touchMap.put(dexFile, true); - else touchMap.put(dexFile, true); + FileUtils.write(dexFile, new JSONArray().toString()); + touchMap.put(dexFile, true); } else { XposedLogUtils.logE(callTAG, "failed to create file!"); touchMap.put(dexFile, false); return false; } - } + } else touchMap.put(dexFile, true); } return true; } @@ -489,20 +398,16 @@ public static boolean removeData(@NotNull String tag) { } private static String getCallName(StackTraceElement[] stackTrace) { - for (StackTraceElement stackTraceElement : stackTrace) { - String callName = stackTraceElement.getClassName(); - if (callName.contains("com.sevtinge.hyperceiler.module.hook.")) { - String last = callName.substring(callName.lastIndexOf('.') + 1); - if (last.contains("$")) { - continue; - } - return last; - } - } - throw new RuntimeException("Invalid call stack"); + String call = Arrays.stream(stackTrace).map(StackTraceElement::getClassName) + .filter(name -> name.contains("com.sevtinge.hyperceiler.module.hook.")) + .map(name -> name.substring(name.lastIndexOf('.') + 1)) + .filter(find -> !find.contains("$")) + .findFirst() + .orElse(null); + if (call == null) throwRuntime("Invalid call stack"); + return call; } - @NotNull private static Class getClass(@Nullable String name, ClassLoader classLoader) { if (name == null) throwRuntime("str is null, cant get class!!"); @@ -549,46 +454,34 @@ private static Class getClass(@Nullable String name, ClassLoader classLoader) } private static void throwRuntime(String msg) { - throw new RuntimeException("failed: " + msg); + throw new RuntimeException("[HyperCeiler][E][" + callTAG + "]: " + msg); } // 字符串获取为类列表 private static Class[] stringToClassArray(ArrayList arrayList, ClassLoader classLoader) { if (arrayList.isEmpty()) return new Class[]{}; if (arrayList.get(0).isEmpty()) return new Class[]{}; - ArrayList> classes = new ArrayList<>(); - for (String s : arrayList) { - classes.add(getClass(s, classLoader)); - } - return classes.toArray(new Class[classes.size()]); + return arrayList.stream().map(s -> getClass(s, classLoader)).toArray(Class[]::new); } // 是否已经存在缓存中 - private static boolean isAdded(String tag, ArrayList dadaList) { - for (DexKitData data : dadaList) { - String mTag = data.tag; - if (tag.equals(mTag)) { - return true; - } - } - return false; + private static boolean haveCache(String tag, ArrayList dadaList) { + return dadaList.stream().anyMatch(data -> tag.equals(data.tag)); } // 获取接口结果 - private static List getElements(IDexKit iDexKit, IDexKitList iDexKitList, DexKitBridge dexKitBridge) { + private static List getElement(DexKitBridge dexKitBridge, IDexKit iDexKit, IDexKitList iDexKitList) { ArrayList memberList = new ArrayList<>(); - if (iDexKit != null) { - try { + try { + if (iDexKit != null) { memberList.add(iDexKit.dexkit(dexKitBridge)); - } catch (ReflectiveOperationException e) { - throwRuntime(e.toString()); - } - } else if (iDexKitList != null) { - try { - memberList.addAll(iDexKitList.dexkit(dexKitBridge)); - } catch (ReflectiveOperationException e) { - throwRuntime(e.toString()); + } else if (iDexKitList != null) { + List list = iDexKitList.dexkit(dexKitBridge); + if (list == null) return memberList; + memberList.addAll(list); } + } catch (ReflectiveOperationException e) { + throwRuntime(e.toString()); } return memberList; } @@ -596,28 +489,20 @@ private static List getElements(IDexKit iDexKit, IDexKitList i /** * 将 BaseDataList 转为 ArrayList 时使用,调用 IDexKitList 接口会用到。 */ - public static List toElementList(List baseDataList, ClassLoader classLoader) { + public static List toElementList(List baseDataList) { if (baseDataList == null) return new ArrayList<>(); ArrayList elements = new ArrayList<>(baseDataList.size()); for (Object baseData : baseDataList) { - if (baseData instanceof MethodData) { - try { - elements.add(((MethodData) baseData).getMethodInstance(classLoader)); - } catch (NoSuchMethodException e) { - XposedLogUtils.logE(callTAG, e.toString()); - } - } else if (baseData instanceof FieldData) { - try { - elements.add(((FieldData) baseData).getFieldInstance(classLoader)); - } catch (NoSuchFieldException e) { - XposedLogUtils.logE(callTAG, e.toString()); - } - } else if (baseData instanceof ClassData) { - try { - elements.add(((ClassData) baseData).getInstance(classLoader)); - } catch (ClassNotFoundException e) { - XposedLogUtils.logE(callTAG, e.toString()); + try { + if (baseData instanceof MethodData) { + elements.add(((MethodData) baseData).getMethodInstance(dexKit.loadPackageParam.classLoader)); + } else if (baseData instanceof FieldData) { + elements.add(((FieldData) baseData).getFieldInstance(dexKit.loadPackageParam.classLoader)); + } else if (baseData instanceof ClassData) { + elements.add(((ClassData) baseData).getInstance(dexKit.loadPackageParam.classLoader)); } + } catch (NoSuchMethodException | NoSuchFieldException | ClassNotFoundException e) { + XposedLogUtils.logE(callTAG, e.toString()); } } return elements; @@ -627,22 +512,18 @@ public static List toElementList(List baseDataList, ClassLo * 转为方法列表 */ public List toMethodList() { - ArrayList methods = new ArrayList<>(elementList.size()); - for (AnnotatedElement element : elementList) { - methods.add((Method) element); - } + ArrayList list = elementList.stream().map(element -> (Method) element) + .collect(Collectors.toCollection(ArrayList::new)); elementList.clear(); - return methods; + return list; } /** * 转为字段列表 */ public List toFieldList() { - ArrayList fields = new ArrayList<>(elementList.size()); - for (AnnotatedElement element : elementList) { - fields.add((Field) element); - } + ArrayList fields = elementList.stream().map(elementList -> (Field) elementList) + .collect(Collectors.toCollection(ArrayList::new)); elementList.clear(); return fields; } @@ -651,10 +532,8 @@ public List toFieldList() { * 转为构造函数列表 */ public List> toConstructorList() { - ArrayList> constructors = new ArrayList<>(elementList.size()); - for (AnnotatedElement element : elementList) { - constructors.add((Constructor) element); - } + ArrayList> constructors = elementList.stream().map(elementList -> (Constructor) elementList) + .collect(Collectors.toCollection(ArrayList::new)); elementList.clear(); return constructors; } @@ -663,10 +542,8 @@ public List> toConstructorList() { * 转为类列表 */ public List> toClassList() { - ArrayList> classes = new ArrayList<>(elementList.size()); - for (AnnotatedElement element : elementList) { - classes.add((Class) element); - } + ArrayList> classes = elementList.stream().map(elementList -> (Class) elementList) + .collect(Collectors.toCollection(ArrayList::new)); elementList.clear(); return classes; } diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/base/dexkit/DexKitTool.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/base/dexkit/DexKitTool.kt index f85a4e8e23..5703e57c0e 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/base/dexkit/DexKitTool.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/base/dexkit/DexKitTool.kt @@ -31,24 +31,32 @@ object DexKitTool { * 将 ClassData 列表快捷转为 List * 使用时在查找后调用 .toElementList(EzXHelper.safeClassLoader) 即可 */ - fun ClassDataList.toElementList(classLoader: ClassLoader): List { - return DexKit.toElementList(this, classLoader) + fun ClassDataList.toElementList(): List { + return DexKit.toElementList(this) } /** * 将 MethodData 列表快捷转为 List * 使用时在查找后调用 .toElementList(EzXHelper.safeClassLoader) 即可 */ - fun MethodDataList.toElementList(classLoader: ClassLoader): List { - return DexKit.toElementList(this, classLoader) + fun MethodDataList.toElementList(): List { + return DexKit.toElementList(this) } /** * 将 FieldData 列表快捷转为 List * 使用时在查找后调用 .toElementList(EzXHelper.safeClassLoader) 即可 */ - fun FieldDataList.toElementList(classLoader: ClassLoader): List { - return DexKit.toElementList(this, classLoader) + fun FieldDataList.toElementList(): List { + return DexKit.toElementList(this) + } + + fun List<*>.toElementList(): List { + return DexKit.toElementList(this) + } + + fun BaseDataList<*>.toElementList(): List { + return DexKit.toElementList(this) } /** diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/camera/CustomWatermark.java b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/camera/CustomWatermark.java index 3e9112d8a8..39c9570f1a 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/camera/CustomWatermark.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/camera/CustomWatermark.java @@ -52,7 +52,7 @@ public List dexkit(DexKitBridge bridge) throws ReflectiveOpera ) ) ); - return DexKit.toElementList(methodData, lpparam.classLoader); + return DexKit.toElementList(methodData); } }).toMethodList(); for (Method method : methods) { diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/UnlockCustomPhotoFrames.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/UnlockCustomPhotoFrames.kt index 7a79dc7c58..b7e6e9282d 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/UnlockCustomPhotoFrames.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/UnlockCustomPhotoFrames.kt @@ -18,7 +18,6 @@ */ package com.sevtinge.hyperceiler.module.hook.mediaeditor -import com.github.kyuubiran.ezxhelper.* import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook import com.sevtinge.hyperceiler.module.base.* import com.sevtinge.hyperceiler.module.base.dexkit.* @@ -38,7 +37,7 @@ object UnlockCustomPhotoFrames : BaseHook() { private val isPOCO by lazy { frames == 3 } private val publicA by lazy { - DexKit.useDexKitIfNoCache(arrayOf("PA", "PC")) { bridge -> + DexKit.useDexkitIfNoCache(arrayOf("PC", "PA")) { bridge -> bridge.findMethod { matcher { // 真是妹想到啊,1.5 和 1.6 版本还以为不会套回去了 @@ -67,19 +66,28 @@ object UnlockCustomPhotoFrames : BaseHook() { modifiers = Modifier.STATIC or Modifier.FINAL } } - }.toElementList(EzXHelper.classLoader) + }.toElementList() }.toMethodList() } override fun init() { // 为了减少查询次数,这玩意写得好懵圈.png - val publicC = DexKit.createCache("PC", publicA?.toMethodDataList()?.filter { methodData -> - methodData.usingFields.any { - it.field.typeName == "boolean" // 1.6.3.5 通过此条件应该只会返回 b() 方法 - } - }, lpparam.classLoader).toMethodList().toSet() + // val publicC = DexKit.getDexKitBridge("PC", publicA?.toMethodDataList()?.filter { methodData -> + // methodData.usingFields.any { + // it.field.typeName == "boolean" // 1.6.3.5 通过此条件应该只会返回 b() 方法 + // } + // }, lpparam.classLoader).toMethodList().toSet() + val publicC = DexKit.getDexKitBridgeList("PC") { _ -> + publicA?.toMethodDataList()?.filter { methodData -> + methodData.usingFields.any { + it.field.typeName == "boolean" // 1.6.3.5 通过此条件应该只会返回 b() 方法 + } + }?.toElementList() + }.toMethodList() val actions = listOf<(Method) -> Unit>(::xiaomi, ::poco, ::redmi, ::other) - val orderedPublicA = DexKit.createCache("PA", publicA, lpparam.classLoader).toMethodList() + val orderedPublicA = DexKit.getDexKitBridgeList("PA") { _ -> + publicA?.toElementList() + }.toMethodList() val differentItems = orderedPublicA.subtract(publicC) var index = 0 diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/UnlockLeicaFilter.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/UnlockLeicaFilter.kt index bbdd5d1b1b..ba83c875eb 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/UnlockLeicaFilter.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/UnlockLeicaFilter.kt @@ -42,7 +42,7 @@ object UnlockLeicaFilter : BaseHook() { returnType = "boolean" paramCount = 0 } - }.toElementList(classLoader) + }.toElementList() }.toMethodList() } private val leicaNew by lazy { diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/UnlockMinimumCropLimit.java b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/UnlockMinimumCropLimit.java index 881f438925..63e3d467c2 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/UnlockMinimumCropLimit.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/UnlockMinimumCropLimit.java @@ -44,7 +44,7 @@ public List dexkit(DexKitBridge bridge) throws ReflectiveOpera .usingNumbers(0.5f, 200) ) ); - return DexKit.toElementList(methodData, lpparam.classLoader); + return DexKit.toElementList(methodData); } }).toMethodList(); for (Method method : methods) { diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mishare/NoAutoTurnOff.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mishare/NoAutoTurnOff.kt index c4586e5ebf..f648d6f927 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mishare/NoAutoTurnOff.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mishare/NoAutoTurnOff.kt @@ -80,7 +80,7 @@ object NoAutoTurnOff : BaseHook() { paramTypes = listOf("android.content.Context", "java.lang.String") paramCount = 2 } - }.toElementList(safeClassLoader) + }.toElementList() }.toMethodList() } diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mms/DisableAd.java b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mms/DisableAd.java index 343e95536c..ea667d8f08 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mms/DisableAd.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mms/DisableAd.java @@ -22,14 +22,11 @@ import com.sevtinge.hyperceiler.module.base.BaseHook; import com.sevtinge.hyperceiler.module.base.dexkit.DexKit; -import com.sevtinge.hyperceiler.module.base.dexkit.IDexKit; import com.sevtinge.hyperceiler.module.base.dexkit.IDexKitList; import org.luckypray.dexkit.DexKitBridge; import org.luckypray.dexkit.query.FindMethod; -import org.luckypray.dexkit.query.matchers.ClassMatcher; import org.luckypray.dexkit.query.matchers.MethodMatcher; -import org.luckypray.dexkit.result.MethodData; import org.luckypray.dexkit.result.MethodDataList; import java.lang.reflect.AnnotatedElement; @@ -57,7 +54,7 @@ public List dexkit(DexKitBridge bridge) throws ReflectiveOpera .name("setHideButton") ) ); - return DexKit.toElementList(methodData, lpparam.classLoader); + return DexKit.toElementList(methodData); } }).toMethodList(); for (Method method2 : methods) { diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/packageinstaller/AllAsSystemApp.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/packageinstaller/AllAsSystemApp.kt index 860bc820c0..5ebe058617 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/packageinstaller/AllAsSystemApp.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/packageinstaller/AllAsSystemApp.kt @@ -19,7 +19,6 @@ package com.sevtinge.hyperceiler.module.hook.packageinstaller import android.content.pm.* -import com.github.kyuubiran.ezxhelper.EzXHelper.safeClassLoader import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHooks import com.sevtinge.hyperceiler.module.base.* import com.sevtinge.hyperceiler.module.base.dexkit.* @@ -33,7 +32,7 @@ object AllAsSystemApp : BaseHook() { paramTypes = listOf("android.content.pm.ApplicationInfo") returnType = "boolean" } - }.toElementList(safeClassLoader) + }.toElementList() }.toMethodList() } diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/packageinstaller/DisableAppInfoUpload.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/packageinstaller/DisableAppInfoUpload.kt index 75af14d17a..dc611366eb 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/packageinstaller/DisableAppInfoUpload.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/packageinstaller/DisableAppInfoUpload.kt @@ -19,7 +19,6 @@ package com.sevtinge.hyperceiler.module.hook.packageinstaller import android.content.* -import com.github.kyuubiran.ezxhelper.* import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook import com.sevtinge.hyperceiler.* import com.sevtinge.hyperceiler.module.base.* @@ -60,7 +59,7 @@ object DisableAppInfoUpload : BaseHook() { returnType(Void::class.javaPrimitiveType as Class<*>) modifiers(AccessFlagsMatcher.create(Modifier.STATIC)) } - }.toElementList(EzXHelper.safeClassLoader) + }.toElementList() }.toMethodList() if (avlUploadInvokerList.isEmpty()) { @@ -94,7 +93,7 @@ object DisableAppInfoUpload : BaseHook() { returnType(Object::class.java) usingStrings("device_type", "packageName", "installationMode", "apk_bit") } - }.toElementList(EzXHelper.safeClassLoader) + }.toElementList() }.toMethodList() if (interceptCheckInvokerList.isEmpty()) { @@ -127,7 +126,7 @@ object DisableAppInfoUpload : BaseHook() { null ) } - }.toElementList(EzXHelper.safeClassLoader) + }.toElementList() }.toMethodList() if (infoLayoutInvokerList.isEmpty()) { diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/packageinstaller/InstallRiskDisable.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/packageinstaller/InstallRiskDisable.kt index 81abfe1859..1374be7d88 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/packageinstaller/InstallRiskDisable.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/packageinstaller/InstallRiskDisable.kt @@ -18,7 +18,6 @@ */ package com.sevtinge.hyperceiler.module.hook.packageinstaller -import com.github.kyuubiran.ezxhelper.* import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHooks import com.sevtinge.hyperceiler.module.base.* import com.sevtinge.hyperceiler.module.base.dexkit.* @@ -41,7 +40,7 @@ object InstallRiskDisable : BaseHook() { addUsingString("android.provider.MiuiSettings\$Ad", StringMatchType.Equals) returnType = "boolean" } - }.toElementList(EzXHelper.safeClassLoader) + }.toElementList() }.toMethodList().createHooks { returnConstant(false) } diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/personalassistant/BlurPersonalAssistant.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/personalassistant/BlurPersonalAssistant.kt index 61a2460611..db7f08c633 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/personalassistant/BlurPersonalAssistant.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/personalassistant/BlurPersonalAssistant.kt @@ -20,7 +20,6 @@ package com.sevtinge.hyperceiler.module.hook.personalassistant import android.graphics.drawable.* import android.view.* -import com.github.kyuubiran.ezxhelper.* import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createAfterHook import com.sevtinge.hyperceiler.module.base.* import com.sevtinge.hyperceiler.module.base.dexkit.* @@ -45,7 +44,7 @@ object BlurPersonalAssistant : BaseHook() { matcher { addUsingStringsEquals("ScrollStateManager") } - }.toElementList(EzXHelper.safeClassLoader) + }.toElementList() }.toMethodList().forEach { methodData -> methodData.createAfterHook { val scrollX = it.args[0] as Float diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/screenrecorder/UnlockMoreVolumeFromNew.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/screenrecorder/UnlockMoreVolumeFromNew.kt index 81ba1b79d3..ca39bba9af 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/screenrecorder/UnlockMoreVolumeFromNew.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/screenrecorder/UnlockMoreVolumeFromNew.kt @@ -44,7 +44,7 @@ object UnlockMoreVolumeFromNew : BaseHook() { declaredClass(getClass) type = "boolean" } - }.toElementList(safeClassLoader) + }.toElementList() }.toFieldList() findAndHookConstructor(getClass, object : MethodHook() { diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/screenshot/UnlockMinimumCropLimit.java b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/screenshot/UnlockMinimumCropLimit.java index 52e174cb31..dd998285f0 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/screenshot/UnlockMinimumCropLimit.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/screenshot/UnlockMinimumCropLimit.java @@ -44,7 +44,7 @@ public List dexkit(DexKitBridge bridge) throws ReflectiveOpera .usingNumbers(0.5f, 200) ) ); - return DexKit.toElementList(methodData, lpparam.classLoader); + return DexKit.toElementList(methodData); } }).toMethodList(); for (Method method : methods) { diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/battery/BatteryHealth.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/battery/BatteryHealth.kt index 6b864bbdb3..868d390246 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/battery/BatteryHealth.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/battery/BatteryHealth.kt @@ -23,6 +23,7 @@ import com.github.kyuubiran.ezxhelper.* import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createAfterHook import com.sevtinge.hyperceiler.module.base.* import com.sevtinge.hyperceiler.module.base.dexkit.* +import com.sevtinge.hyperceiler.module.base.dexkit.DexKitTool.toElementList import com.sevtinge.hyperceiler.module.base.dexkit.DexKitTool.toMethod import com.sevtinge.hyperceiler.utils.* import de.robv.android.xposed.* @@ -41,7 +42,7 @@ object BatteryHealth : BaseHook() { } private val cc by lazy { - DexKit.useDexKitIfNoCache(arrayOf("SecurityBatteryHealthClass")) { + DexKit.useDexkitIfNoCache(arrayOf("SecurityBatteryHealthClass")) { it.findClass { searchPackages("com.miui.powercenter.nightcharge") findFirst = true @@ -77,7 +78,9 @@ object BatteryHealth : BaseHook() { } ) - val nameClass = DexKit.createCache("SecurityBatteryHealthClass", cc, lpparam.classLoader).toClassList().first().name + val nameClass = DexKit.getDexKitBridgeList("SecurityBatteryHealthClass") { _ -> + cc?.toElementList() + }.toClassList().first().name findAndHookMethod( nameClass, "handleMessage", diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/battery/ScreenUsedTime.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/battery/ScreenUsedTime.kt index e1aefdd7c4..09488eec5b 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/battery/ScreenUsedTime.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/battery/ScreenUsedTime.kt @@ -47,7 +47,7 @@ object ScreenUsedTime : BaseHook() { returnType = "boolean" paramCount = 0 } - }.toElementList(safeClassLoader) + }.toElementList() }.toMethodList() } diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/battery/UnlockSmartCharge.java b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/battery/UnlockSmartCharge.java index 2b805a2a92..258112f86c 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/battery/UnlockSmartCharge.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/battery/UnlockSmartCharge.java @@ -20,27 +20,19 @@ import static com.sevtinge.hyperceiler.module.base.tool.HookTool.MethodHook.returnConstant; -import android.util.SparseArray; - import com.sevtinge.hyperceiler.module.base.BaseHook; import com.sevtinge.hyperceiler.module.base.dexkit.DexKit; -import com.sevtinge.hyperceiler.module.base.dexkit.IDexKit; import com.sevtinge.hyperceiler.module.base.dexkit.IDexKitList; import org.luckypray.dexkit.DexKitBridge; import org.luckypray.dexkit.query.FindMethod; -import org.luckypray.dexkit.query.matchers.AnnotationMatcher; -import org.luckypray.dexkit.query.matchers.AnnotationsMatcher; import org.luckypray.dexkit.query.matchers.MethodMatcher; -import org.luckypray.dexkit.result.MethodData; import org.luckypray.dexkit.result.MethodDataList; import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Method; import java.util.List; -import de.robv.android.xposed.XC_MethodHook; - public class UnlockSmartCharge extends BaseHook { @Override public void init() throws NoSuchMethodException { @@ -52,7 +44,7 @@ public List dexkit(DexKitBridge bridge) throws ReflectiveOpera .usingStrings("persist.vendor.smartchg") ) ); - return DexKit.toElementList(methodData, lpparam.classLoader); + return DexKit.toElementList(methodData); } }).toMethodList(); for (Method method : methods) { diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/beauty/BeautyLightAuto.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/beauty/BeautyLightAuto.kt index 471dac8921..b5ee398e95 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/beauty/BeautyLightAuto.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/beauty/BeautyLightAuto.kt @@ -45,7 +45,7 @@ object BeautyLightAuto : BaseHook() { addUsingStringsEquals("taoyao") returnType = "boolean" } - }.toElementList(EzXHelper.classLoader) + }.toElementList() }.toMethodList() } diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/beauty/BeautyPrivacy.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/beauty/BeautyPrivacy.kt index d10289b3a9..19d9005849 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/beauty/BeautyPrivacy.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/beauty/BeautyPrivacy.kt @@ -55,7 +55,7 @@ object BeautyPrivacy : BaseHook() { paramTypes = listOf(R0.parameterTypes[0].name) } } - }.toElementList(EzXHelper.classLoader) + }.toElementList() }.toMethodList() } diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/lab/LabUtilsClass.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/lab/LabUtilsClass.kt index dcbac18ce3..fb9cf7e53c 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/lab/LabUtilsClass.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/lab/LabUtilsClass.kt @@ -18,7 +18,6 @@ */ package com.sevtinge.hyperceiler.module.hook.securitycenter.lab -import com.github.kyuubiran.ezxhelper.* import com.sevtinge.hyperceiler.module.base.dexkit.* import com.sevtinge.hyperceiler.module.base.dexkit.DexKitTool.addUsingStringsEquals import com.sevtinge.hyperceiler.module.base.dexkit.DexKitTool.toElementList @@ -30,7 +29,7 @@ object LabUtilsClass { matcher { addUsingStringsEquals("mi_lab_ai_clipboard_enable", "mi_lab_blur_location_enable") } - }.toElementList(EzXHelper.classLoader) + }.toElementList() }.toClassList() } } diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/other/BypassSimLockMiAccountAuth.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/other/BypassSimLockMiAccountAuth.kt index f9660a4aa1..2f4a602b05 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/other/BypassSimLockMiAccountAuth.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/other/BypassSimLockMiAccountAuth.kt @@ -18,7 +18,6 @@ */ package com.sevtinge.hyperceiler.module.hook.securitycenter.other -import com.github.kyuubiran.ezxhelper.* import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook import com.sevtinge.hyperceiler.module.base.* import com.sevtinge.hyperceiler.module.base.dexkit.* @@ -40,7 +39,7 @@ object BypassSimLockMiAccountAuth : BaseHook() { paramTypes("android.content.Context") returnType = "boolean" } - }.toElementList(EzXHelper.classLoader) + }.toElementList() }.toMethodList() } diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/other/FuckRiskPkg.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/other/FuckRiskPkg.kt index c17917c2cf..4e34174a31 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/other/FuckRiskPkg.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/other/FuckRiskPkg.kt @@ -18,7 +18,6 @@ */ package com.sevtinge.hyperceiler.module.hook.securitycenter.other -import com.github.kyuubiran.ezxhelper.* import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHooks import com.sevtinge.hyperceiler.module.base.* import com.sevtinge.hyperceiler.module.base.dexkit.* @@ -34,7 +33,7 @@ object FuckRiskPkg : BaseHook() { "riskPkgList", "key_virus_pkg_list", "show_virus_notification" ) } - }.toElementList(EzXHelper.classLoader) + }.toElementList() }.toMethodList() } diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/sidebar/video/UnlockVideoSomeFunc.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/sidebar/video/UnlockVideoSomeFunc.kt index 31078c96fe..6cf919030c 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/sidebar/video/UnlockVideoSomeFunc.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/securitycenter/sidebar/video/UnlockVideoSomeFunc.kt @@ -23,6 +23,7 @@ import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder import com.sevtinge.hyperceiler.module.base.* import com.sevtinge.hyperceiler.module.base.dexkit.* +import com.sevtinge.hyperceiler.module.base.dexkit.DexKitTool.toElementList import com.sevtinge.hyperceiler.module.base.dexkit.DexKitTool.toMethod import com.sevtinge.hyperceiler.module.base.dexkit.DexKitTool.toMethodDataList import org.luckypray.dexkit.query.enums.* @@ -30,7 +31,7 @@ import java.lang.reflect.* object UnlockVideoSomeFunc : BaseHook() { private val findFrc by lazy { - DexKit.useDexKitIfNoCache(arrayOf( "findFrcA", "findFrcB")) { + DexKit.useDexkitIfNoCache(arrayOf("findFrcA", "findFrcB")) { it.findMethod { matcher { declaredClass { @@ -69,12 +70,16 @@ object UnlockVideoSomeFunc : BaseHook() { } override fun init() { - val orderedB = DexKit.createCache("findFrcB", findFrc?.toMethodDataList()?.filter { methodData -> - methodData.usingFields.any { - it.field.typeName == "java.util.List" - } - }, classLoader).toMethodList().toSet() - val orderedA = DexKit.createCache("findFrcA", findFrc?.toMethodDataList(), classLoader).toMethodList().toSet() + val orderedB = DexKit.getDexKitBridgeList("findFrcB") { _ -> + findFrc?.toMethodDataList()?.filter { methodData -> + methodData.usingFields.any { + it.field.typeName == "java.util.List" + } + }?.toElementList() + }.toMethodList() + val orderedA = DexKit.getDexKitBridgeList("findFrcA") { _ -> + findFrc?.toElementList() + }.toMethodList() val differentItems = orderedA.subtract(orderedB) if (memc) { diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/updater/DeviceModify.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/updater/DeviceModify.kt index e227bcedab..390c05bc3f 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/updater/DeviceModify.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/updater/DeviceModify.kt @@ -18,7 +18,6 @@ */ package com.sevtinge.hyperceiler.module.hook.updater -import com.github.kyuubiran.ezxhelper.* import com.sevtinge.hyperceiler.module.base.* import com.sevtinge.hyperceiler.module.base.dexkit.* import com.sevtinge.hyperceiler.module.base.dexkit.DexKitTool.addUsingStringsEquals @@ -56,7 +55,7 @@ object DeviceModify : BaseHook() { matcher { addUsingStringsEquals("android.os.SystemProperties", "get", "get e") } - }.toElementList(EzXHelper.safeClassLoader) + }.toElementList() }.toMethodList().forEach { method -> method.hookBeforeMethod { if (it.args[0] == "ro.product.mod_device") it.result = deviceName diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/updater/VersionCodeNew.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/updater/VersionCodeNew.kt index a39555078d..1447455761 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/updater/VersionCodeNew.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/updater/VersionCodeNew.kt @@ -46,7 +46,7 @@ object VersionCodeNew : BaseHook() { matcher { addUsingStringsEquals("ro.mi.os.version.incremental") } - }.toElementList(EzXHelper.safeClassLoader) + }.toElementList() }.toMethodList() } private val mOSCode by lazy { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ce83deb17c..acb7534ef7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] agp = "8.4.2" -hooktool = "v.0.8.9" +hooktool = "v.0.9.0" kotlinAndroid = "2.0.0" lsparanoid = "0.6.0" #lspluginResopt = "1.6"