[core] Fix DexFile name
This commit is contained in:
parent
96c80493c8
commit
a70e2595bd
|
|
@ -36,7 +36,6 @@ import org.lsposed.lspd.deopt.PrebuiltMethodsDeopter;
|
||||||
import org.lsposed.lspd.hooker.CrashDumpHooker;
|
import org.lsposed.lspd.hooker.CrashDumpHooker;
|
||||||
import org.lsposed.lspd.hooker.HandleBindAppHooker;
|
import org.lsposed.lspd.hooker.HandleBindAppHooker;
|
||||||
import org.lsposed.lspd.hooker.LoadedApkCstrHooker;
|
import org.lsposed.lspd.hooker.LoadedApkCstrHooker;
|
||||||
import org.lsposed.lspd.hooker.StartBootstrapServicesHooker;
|
|
||||||
import org.lsposed.lspd.hooker.SystemMainHooker;
|
import org.lsposed.lspd.hooker.SystemMainHooker;
|
||||||
import org.lsposed.lspd.service.ServiceManager;
|
import org.lsposed.lspd.service.ServiceManager;
|
||||||
import org.lsposed.lspd.util.ModuleLogger;
|
import org.lsposed.lspd.util.ModuleLogger;
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,11 @@ public final class LspModuleClassLoader extends ByteBufferDexClassLoader {
|
||||||
String apk) {
|
String apk) {
|
||||||
super(dexBuffers, parent);
|
super(dexBuffers, parent);
|
||||||
this.apk = apk;
|
this.apk = apk;
|
||||||
|
try {
|
||||||
|
fixDexName(apk);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Utils.logE("fix name", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.Q)
|
@RequiresApi(Build.VERSION_CODES.Q)
|
||||||
|
|
@ -57,6 +62,11 @@ public final class LspModuleClassLoader extends ByteBufferDexClassLoader {
|
||||||
super(dexBuffers, librarySearchPath, parent);
|
super(dexBuffers, librarySearchPath, parent);
|
||||||
initNativeLibraryDirs(librarySearchPath);
|
initNativeLibraryDirs(librarySearchPath);
|
||||||
this.apk = apk;
|
this.apk = apk;
|
||||||
|
try {
|
||||||
|
fixDexName(apk);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Utils.logE("fix name", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initNativeLibraryDirs(String librarySearchPath) {
|
private void initNativeLibraryDirs(String librarySearchPath) {
|
||||||
|
|
@ -158,8 +168,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)};
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,32 @@
|
||||||
package hidden;
|
package hidden;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
import dalvik.system.BaseDexClassLoader;
|
import dalvik.system.BaseDexClassLoader;
|
||||||
|
|
||||||
public class ByteBufferDexClassLoader extends BaseDexClassLoader {
|
public class ByteBufferDexClassLoader extends BaseDexClassLoader {
|
||||||
|
static Field pathListField = null;
|
||||||
|
static Field dexElementsField = null;
|
||||||
|
static Field dexFileField = null;
|
||||||
|
static Field nameField = null;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
pathListField = BaseDexClassLoader.class.getDeclaredField("pathList");
|
||||||
|
pathListField.setAccessible(true);
|
||||||
|
dexElementsField = pathListField.getType().getDeclaredField("dexElements");
|
||||||
|
dexElementsField.setAccessible(true);
|
||||||
|
var elementType = dexElementsField.getType().getComponentType();
|
||||||
|
dexFileField = elementType.getDeclaredField("dexFile");
|
||||||
|
dexFileField.setAccessible(true);
|
||||||
|
nameField = dexFileField.getType().getDeclaredField("mFileName");
|
||||||
|
nameField.setAccessible(true);
|
||||||
|
} catch (Throwable ignored) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ByteBufferDexClassLoader(ByteBuffer[] dexFiles, ClassLoader parent) {
|
public ByteBufferDexClassLoader(ByteBuffer[] dexFiles, ClassLoader parent) {
|
||||||
super(dexFiles, parent);
|
super(dexFiles, parent);
|
||||||
}
|
}
|
||||||
|
|
@ -13,6 +35,10 @@ public class ByteBufferDexClassLoader extends BaseDexClassLoader {
|
||||||
super(dexFiles, librarySearchPath, parent);
|
super(dexFiles, librarySearchPath, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void fixDexName(String name) throws IllegalAccessException {
|
||||||
|
nameField.set(dexFileField.get(((Object[]) dexElementsField.get(pathListField.get(this)))[0]), name);
|
||||||
|
}
|
||||||
|
|
||||||
public String getLdLibraryPath() {
|
public String getLdLibraryPath() {
|
||||||
return super.getLdLibraryPath();
|
return super.getLdLibraryPath();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import java.io.File;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
public class BaseDexClassLoader extends ClassLoader {
|
public class BaseDexClassLoader extends ClassLoader {
|
||||||
|
private Object pathList;
|
||||||
public BaseDexClassLoader(String dexPath, File optimizedDirectory, String librarySearchPath, ClassLoader parent) {
|
public BaseDexClassLoader(String dexPath, File optimizedDirectory, String librarySearchPath, ClassLoader parent) {
|
||||||
throw new RuntimeException("Stub!");
|
throw new RuntimeException("Stub!");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue