Commit b5dec3cb authored by swift_gan's avatar swift_gan

tweak loadModule

parent 60f3ddbc
...@@ -25,8 +25,8 @@ public class XposedCompat { ...@@ -25,8 +25,8 @@ public class XposedCompat {
private static ClassLoader sandHookXposedClassLoader; private static ClassLoader sandHookXposedClassLoader;
public static void loadModule(String apkPath, ClassLoader classLoader) { public static void loadModule(String modulePath, String moduleOdexDir, String moduleSoPath,ClassLoader classLoader) {
XposedInit.loadModule(apkPath, classLoader); XposedInit.loadModule(modulePath, moduleOdexDir, moduleSoPath, classLoader);
} }
......
...@@ -14,8 +14,8 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -14,8 +14,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import dalvik.system.DexClassLoader;
import dalvik.system.DexFile; import dalvik.system.DexFile;
import dalvik.system.PathClassLoader;
import de.robv.android.xposed.services.BaseService; import de.robv.android.xposed.services.BaseService;
import static de.robv.android.xposed.XposedHelpers.closeSilently; import static de.robv.android.xposed.XposedHelpers.closeSilently;
...@@ -102,7 +102,7 @@ public final class XposedInit { ...@@ -102,7 +102,7 @@ public final class XposedInit {
BufferedReader apks = new BufferedReader(new InputStreamReader(stream)); BufferedReader apks = new BufferedReader(new InputStreamReader(stream));
String apk; String apk;
while ((apk = apks.readLine()) != null) { while ((apk = apks.readLine()) != null) {
loadModule(apk, topClassLoader); loadModule(apk, null, null, topClassLoader);
} }
apks.close(); apks.close();
} }
...@@ -112,16 +112,16 @@ public final class XposedInit { ...@@ -112,16 +112,16 @@ public final class XposedInit {
* Load a module from an APK by calling the init(String) method for all classes defined * Load a module from an APK by calling the init(String) method for all classes defined
* in <code>assets/xposed_init</code>. * in <code>assets/xposed_init</code>.
*/ */
public static void loadModule(String apk, ClassLoader topClassLoader) { public static void loadModule(String modulePath, String moduleOdexDir, String moduleSoPath,ClassLoader topClassLoader) {
if (!new File(apk).exists()) { if (!new File(modulePath).exists()) {
Log.e(TAG, " File does not exist"); Log.e(TAG, " File does not exist");
return; return;
} }
DexFile dexFile; DexFile dexFile;
try { try {
dexFile = new DexFile(apk); dexFile = new DexFile(modulePath);
} catch (IOException e) { } catch (IOException e) {
Log.e(TAG, " Cannot load module", e); Log.e(TAG, " Cannot load module", e);
return; return;
...@@ -147,7 +147,7 @@ public final class XposedInit { ...@@ -147,7 +147,7 @@ public final class XposedInit {
ZipFile zipFile = null; ZipFile zipFile = null;
InputStream is; InputStream is;
try { try {
zipFile = new ZipFile(apk); zipFile = new ZipFile(modulePath);
ZipEntry zipEntry = zipFile.getEntry("assets/xposed_init"); ZipEntry zipEntry = zipFile.getEntry("assets/xposed_init");
if (zipEntry == null) { if (zipEntry == null) {
Log.e(TAG, " assets/xposed_init not found in the APK"); Log.e(TAG, " assets/xposed_init not found in the APK");
...@@ -161,7 +161,7 @@ public final class XposedInit { ...@@ -161,7 +161,7 @@ public final class XposedInit {
return; return;
} }
ClassLoader mcl = new PathClassLoader(apk, XposedInit.class.getClassLoader()); ClassLoader mcl = new DexClassLoader(modulePath, moduleOdexDir, moduleSoPath, topClassLoader);
BufferedReader moduleClassesReader = new BufferedReader(new InputStreamReader(is)); BufferedReader moduleClassesReader = new BufferedReader(new InputStreamReader(is));
try { try {
String moduleClassName; String moduleClassName;
...@@ -189,7 +189,7 @@ public final class XposedInit { ...@@ -189,7 +189,7 @@ public final class XposedInit {
//fake //fake
if (moduleInstance instanceof IXposedHookZygoteInit) { if (moduleInstance instanceof IXposedHookZygoteInit) {
IXposedHookZygoteInit.StartupParam param = new IXposedHookZygoteInit.StartupParam(); IXposedHookZygoteInit.StartupParam param = new IXposedHookZygoteInit.StartupParam();
param.modulePath = apk; param.modulePath = modulePath;
param.startsSystemServer = false; param.startsSystemServer = false;
((IXposedHookZygoteInit) moduleInstance).initZygote(param); ((IXposedHookZygoteInit) moduleInstance).initZygote(param);
} }
...@@ -219,7 +219,7 @@ public final class XposedInit { ...@@ -219,7 +219,7 @@ public final class XposedInit {
} }
} }
} catch (IOException e) { } catch (IOException e) {
Log.e(TAG, " Failed to load module from " + apk, e); Log.e(TAG, " Failed to load module from " + modulePath, e);
} finally { } finally {
closeSilently(is); closeSilently(is);
closeSilently(zipFile); closeSilently(zipFile);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment