Skip to content

Commit

Permalink
Fix load native library
Browse files Browse the repository at this point in the history
  • Loading branch information
shatyuka committed Mar 19, 2021
1 parent dfaf7be commit 9557d24
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/src/main/java/com/shatyuka/zhiliao/MainHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class MainHook implements IXposedHookLoadPackage, IXposedHookZygoteInit {
private native void initNative();

private static boolean is64Bit(ClassLoader classLoader) {
if (android.os.Build.VERSION.SDK_INT >= 23) {
return android.os.Process.is64Bit();
}
try {
String path = (String)ClassLoader.class.getDeclaredMethod("findLibrary", String.class).invoke(classLoader, "art");
if (path != null) {
Expand All @@ -35,8 +38,16 @@ public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) {
if (modulePackage.equals(lpparam.packageName)) {
XposedHelpers.findAndHookMethod("com.shatyuka.zhiliao.MySettingsFragment", lpparam.classLoader, "isModuleActive", XC_MethodReplacement.returnConstant(true));
} else if (hookPackage.equals(lpparam.packageName)) {
System.load(modulePath.substring(0, modulePath.lastIndexOf('/')) + (is64Bit(lpparam.classLoader) ? "/lib/arm64/libzhiliao.so" : "/lib/arm/libzhiliao.so"));
initNative();
try {
System.loadLibrary("zhiliao");
initNative();
} catch (Throwable ignored) {
try { // Let's try again
System.load(modulePath.substring(0, modulePath.lastIndexOf('/')) + (is64Bit(lpparam.classLoader) ? "/lib/arm64/libzhiliao.so" : "/lib/arm/libzhiliao.so"));
initNative();
} catch (Throwable ignored2) {
}
}

XposedBridge.hookAllConstructors(XposedHelpers.findClass("com.tencent.tinker.loader.app.TinkerApplication", lpparam.classLoader), new XC_MethodHook() {
@Override
Expand Down

0 comments on commit 9557d24

Please sign in to comment.