WindySha / Xpatch

This is a tool to repackage apk file, then the apk can load any xposed modules installed in the device. It is another way to hook an app without root device.
Apache License 2.0
2.56k stars 393 forks source link

关于XposedModuleLoader的loadModule问题 #86

Open makeloveandroid opened 3 years ago

makeloveandroid commented 3 years ago

问题 我看加载插件使用DeclassLoader

ClassLoader mcl =
    new DexClassLoader(moduleApkPath, moduleOdexDir, moduleLibPath, appClassLoader);

这里有个问题,如果插件和宿主中存在相同的类(都用了相同点库),这时候就会出现问题。
我看Xposed源码

ClassLoader mcl = new PathClassLoader(apk, XposedBridge.BOOTCLASSLOADER);

我尝试改成。

  ClassLoader mcl =
      new DexClassLoader(moduleApkPath, moduleOdexDir, moduleLibPath, ClassLoader.getSystemClassLoader());

或者

        ClassLoader mcl =
            new DexClassLoader(moduleApkPath, moduleOdexDir, moduleLibPath, appClassLoader.getParent());

这样应该能解决这个问题,但是奇怪的是

Class<?> moduleClass = mcl.loadClass(moduleClassName);

既然 找不到这个类了?不应该啊 moduleClassName 不应该在插件里面吗?

大佬知道啥原因吗?

makeloveandroid commented 3 years ago

我知道为啥了,因为 插件的 moduleClassName 中实现的 IXposedHookLoadPackage 没有打包在插件中。而是在宿主中。

所以必须要使用 appClassLoader

但是就有了 如果插件和宿主中存在相同的类(都用了相同点库),这时候就会出现问题了。