Fix set trusted (#1899)

This commit is contained in:
LoveSy 2022-04-28 11:56:59 +08:00 committed by GitHub
parent dbc350a75e
commit 7aa27b8386
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 12 deletions

View File

@ -53,6 +53,7 @@ public class Startup {
var hooker = new OpenDexFileHooker(); var hooker = new OpenDexFileHooker();
XposedBridge.hookAllMethods(DexFile.class, "openDexFile", hooker); XposedBridge.hookAllMethods(DexFile.class, "openDexFile", hooker);
XposedBridge.hookAllMethods(DexFile.class, "openInMemoryDexFile", hooker); XposedBridge.hookAllMethods(DexFile.class, "openInMemoryDexFile", hooker);
XposedBridge.hookAllMethods(DexFile.class, "openInMemoryDexFiles", hooker);
} }
XposedHelpers.findAndHookConstructor(LoadedApk.class, XposedHelpers.findAndHookConstructor(LoadedApk.class,
ActivityThread.class, ApplicationInfo.class, CompatibilityInfo.class, ActivityThread.class, ApplicationInfo.class, CompatibilityInfo.class,

View File

@ -26,7 +26,6 @@ import java.util.jar.JarFile;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import dalvik.system.DelegateLastClassLoader; import dalvik.system.DelegateLastClassLoader;
import dalvik.system.PathClassLoader;
import de.robv.android.xposed.XposedBridge; import de.robv.android.xposed.XposedBridge;
import hidden.ByteBufferDexClassLoader; import hidden.ByteBufferDexClassLoader;
@ -34,7 +33,7 @@ import hidden.ByteBufferDexClassLoader;
public final class LspModuleClassLoader extends ByteBufferDexClassLoader { public final class LspModuleClassLoader extends ByteBufferDexClassLoader {
private static final String zipSeparator = "!/"; private static final String zipSeparator = "!/";
private final String apk; private final String apk;
private final List<File> nativeLibraryDirs = new ArrayList<>(); private final File[] nativeLibraryDirs;
private static List<File> splitPaths(String searchPath) { private static List<File> splitPaths(String searchPath) {
var result = new ArrayList<File>(); var result = new ArrayList<File>();
@ -49,6 +48,7 @@ public final class LspModuleClassLoader extends ByteBufferDexClassLoader {
ClassLoader parent, ClassLoader parent,
String apk) { String apk) {
super(dexBuffers, parent); super(dexBuffers, parent);
nativeLibraryDirs = new File[0];
this.apk = apk; this.apk = apk;
} }
@ -58,13 +58,15 @@ public final class LspModuleClassLoader extends ByteBufferDexClassLoader {
ClassLoader parent, ClassLoader parent,
String apk) { String apk) {
super(dexBuffers, librarySearchPath, parent); super(dexBuffers, librarySearchPath, parent);
initNativeLibraryDirs(librarySearchPath); nativeLibraryDirs = initNativeLibraryDirs(librarySearchPath);
this.apk = apk; this.apk = apk;
} }
private void initNativeLibraryDirs(String librarySearchPath) { private File[] initNativeLibraryDirs(String librarySearchPath) {
nativeLibraryDirs.addAll(splitPaths(librarySearchPath)); var searchPaths = new ArrayList<File>();
nativeLibraryDirs.addAll(splitPaths(System.getProperty("java.library.path"))); searchPaths.addAll(splitPaths(librarySearchPath));
searchPaths.addAll(splitPaths(System.getProperty("java.library.path")));
return searchPaths.toArray(new File[0]);
} }
@Override @Override
@ -161,8 +163,7 @@ public final class LspModuleClassLoader extends ByteBufferDexClassLoader {
@Override @Override
public Enumeration<URL> getResources(String name) throws IOException { public Enumeration<URL> getResources(String name) throws IOException {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked") final var resources = (Enumeration<URL>[]) new Enumeration<?>[]{
final var resources = (Enumeration<URL>[]) new Enumeration<?>[]{
Object.class.getClassLoader().getResources(name), Object.class.getClassLoader().getResources(name),
findResources(name), findResources(name),
getParent() == null ? null : getParent().getResources(name)}; getParent() == null ? null : getParent().getResources(name)};
@ -174,14 +175,14 @@ public final class LspModuleClassLoader extends ByteBufferDexClassLoader {
public String toString() { public String toString() {
return "LspModuleClassLoader[" + return "LspModuleClassLoader[" +
"module=" + apk + "," + "module=" + apk + "," +
"nativeLibraryDirs=" + nativeLibraryDirs == null ? "null" : Arrays.toString(nativeLibraryDirs.toArray()) + "," + "nativeLibraryDirs=" + Arrays.toString(nativeLibraryDirs) + "," +
super.toString() + "]"; super.toString() + "]";
} }
public static ClassLoader loadApk(String apk, public static ClassLoader loadApk(String apk,
List<SharedMemory> dexes, List<SharedMemory> dexes,
String librarySearchPath, String librarySearchPath,
ClassLoader parent) { ClassLoader parent) {
var dexBuffers = dexes.stream().parallel().map(dex -> { var dexBuffers = dexes.stream().parallel().map(dex -> {
try { try {
return dex.mapReadOnly(); return dex.mapReadOnly();