fix loader's loader
This commit is contained in:
parent
ab1a213161
commit
bc84cd5add
|
|
@ -38,8 +38,8 @@ android {
|
|||
dependsOn("assemble$buildType")
|
||||
def dexFilePath = "$buildDir/intermediates/dex/${variantLowered}/mergeDex${buildType}/classes.dex"
|
||||
from dexFilePath
|
||||
rename "(.*).dex", "classes-${version_name}.dex"
|
||||
into "$rootProject.projectDir/out/list-dex"
|
||||
rename "(.*).dex", "lsploader.dex"
|
||||
into "$rootProject.projectDir/out/list-assets"
|
||||
}
|
||||
|
||||
task "copySo$buildType"(type: Copy) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package org.lsposed.lspatch.loader;
|
|||
import static android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE;
|
||||
import static org.lsposed.lspatch.loader.LSPLoader.initAndLoadModules;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
|
|
@ -30,6 +31,7 @@ import de.robv.android.xposed.XposedInit;
|
|||
/**
|
||||
* Created by Windysha
|
||||
*/
|
||||
@SuppressLint("UnsafeDynamicallyLoadedCode")
|
||||
public class LSPApplication extends Application {
|
||||
private static final String ORIGINAL_APPLICATION_NAME_ASSET_PATH = "original_application_name.ini";
|
||||
private static final String ORIGINAL_SIGNATURE_ASSET_PATH = "original_signature_info.ini";
|
||||
|
|
@ -62,15 +64,15 @@ public class LSPApplication extends Application {
|
|||
XLog.d(TAG, "skip isolated process");
|
||||
}
|
||||
else {
|
||||
System.loadLibrary("lspd");
|
||||
YahfaHooker.init();
|
||||
XposedInit.startsSystemServer = false;
|
||||
|
||||
context = XpatchUtils.createAppContext();
|
||||
if (context == null) {
|
||||
XLog.e(TAG, "create context err");
|
||||
}
|
||||
else {
|
||||
System.load(context.getApplicationInfo().nativeLibraryDir + "/liblspd.so");
|
||||
YahfaHooker.init();
|
||||
XposedInit.startsSystemServer = false;
|
||||
|
||||
originalApplicationName = FileUtils.readTextFromAssets(context, ORIGINAL_APPLICATION_NAME_ASSET_PATH);
|
||||
originalSignature = FileUtils.readTextFromAssets(context, ORIGINAL_SIGNATURE_ASSET_PATH);
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class LSPLoader {
|
|||
ClassLoader mcl = new DelegateLastClassLoader(moduleApkPath, nativePath.toString(), initLoader);
|
||||
|
||||
try {
|
||||
if (mcl.loadClass(XposedBridge.class.getName()).getClassLoader() != appClassLoader) {
|
||||
if (mcl.loadClass(XposedBridge.class.getName()).getClassLoader() != initLoader) {
|
||||
Log.e(TAG, "Cannot load module:");
|
||||
Log.e(TAG, "The Xposed API classes are compiled into the module's APK.");
|
||||
Log.e(TAG, "This may cause strange issues and must be fixed by the module developer.");
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ android {
|
|||
versionName "1.0"
|
||||
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
multiDexEnabled false
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
|
@ -39,14 +40,7 @@ android {
|
|||
into "$rootProject.projectDir/out/list-dex"
|
||||
}
|
||||
|
||||
task "copySo$buildType"(type: Copy) {
|
||||
dependsOn("assemble$buildType")
|
||||
from "$buildDir/intermediates/merged_native_libs/${variantLowered}/out/lib"
|
||||
into "$rootProject.projectDir/out/list-so"
|
||||
}
|
||||
|
||||
task "copy$buildType"() {
|
||||
dependsOn("copySo$buildType")
|
||||
dependsOn("copyDex$buildType")
|
||||
|
||||
doLast {
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ import java.nio.ByteBuffer;
|
|||
|
||||
import dalvik.system.InMemoryDexClassLoader;
|
||||
|
||||
public class LSPApplicationSub extends Application {
|
||||
final static String TAG = LSPApplicationSub.class.getSimpleName();
|
||||
public class LSPApplicationStub extends Application {
|
||||
final static String TAG = LSPApplicationStub.class.getSimpleName();
|
||||
|
||||
static Object realLSPApplication = null;
|
||||
|
||||
|
|
@ -37,8 +37,18 @@ public class LSPApplicationSub extends Application {
|
|||
buffer.write(data, 0, nRead);
|
||||
}
|
||||
|
||||
InMemoryDexClassLoader inMemoryDexClassLoader = new InMemoryDexClassLoader(ByteBuffer.wrap(buffer.toByteArray()), LSPApplicationSub.class.getClassLoader());
|
||||
Class<?> lspa = inMemoryDexClassLoader.loadClass("org.lsposed.lspatch.appstub.LSPApplication");
|
||||
buffer.flush();
|
||||
buffer.close();
|
||||
|
||||
// loader can load it's own so from app native library dir
|
||||
String libraryDir = context.getApplicationInfo().nativeLibraryDir;
|
||||
|
||||
Log.d(TAG, "LSPApplicationStub cl: " + LSPApplicationStub.class.getClassLoader());
|
||||
Log.d(TAG, "NativePath : " + libraryDir);
|
||||
|
||||
InMemoryDexClassLoader loaderClassLoader = new InMemoryDexClassLoader(ByteBuffer.wrap(buffer.toByteArray()),
|
||||
LSPApplicationStub.class.getClassLoader());
|
||||
Class<?> lspa = loaderClassLoader.loadClass("org.lsposed.lspatch.loader.LSPApplication");
|
||||
realLSPApplication = lspa.newInstance();
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
|
@ -53,7 +63,7 @@ public class LSPApplicationSub extends Application {
|
|||
|
||||
if (realLSPApplication != null) {
|
||||
try {
|
||||
realLSPApplication.getClass().getMethod("attachBaseContext", Context.class).invoke(realLSPApplication, base);
|
||||
realLSPApplication.getClass().getDeclaredMethod("attachBaseContext", Context.class).invoke(realLSPApplication, base);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException("wtf", e);
|
||||
|
|
@ -54,6 +54,7 @@ task clean(type: Delete) {
|
|||
tasks.register("build$variant") {
|
||||
description("Build LSPatch with $variant")
|
||||
dependsOn tasks.getByPath(":app:copy$variant")
|
||||
dependsOn tasks.getByPath(":appstub:copy$variant")
|
||||
dependsOn tasks.getByPath(":patch:build")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public class LSPatch extends BaseCommand {
|
|||
private boolean forceOverwrite = false;
|
||||
|
||||
@Opt(opt = "p", longOpt = "proxyname", description = "Special proxy app name with full dot path", argName = "name")
|
||||
private String proxyName = "org.lsposed.lspatch.loader.LSPApplication";
|
||||
private String proxyName = "org.lsposed.lspatch.appstub.LSPApplicationStub";
|
||||
|
||||
@Opt(opt = "d", longOpt = "debuggable", description = "Set 1 to make the app debuggable = true, " +
|
||||
"set 0 to make the app debuggable = false", argName = "0 or 1")
|
||||
|
|
|
|||
Loading…
Reference in New Issue