From dbc9d3aa6161c23357c62ace7d7abf36551b5c87 Mon Sep 17 00:00:00 2001 From: Nullptr Date: Sun, 12 Sep 2021 21:07:29 +0800 Subject: [PATCH] Fix openat hook --- .../org/lsposed/lspatch/loader/LSPApplication.java | 14 ++++++++------ core | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/lsposed/lspatch/loader/LSPApplication.java b/app/src/main/java/org/lsposed/lspatch/loader/LSPApplication.java index 5bcd573..8fe65e1 100644 --- a/app/src/main/java/org/lsposed/lspatch/loader/LSPApplication.java +++ b/app/src/main/java/org/lsposed/lspatch/loader/LSPApplication.java @@ -45,6 +45,7 @@ import java.util.zip.ZipFile; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; +import de.robv.android.xposed.XposedInit; import hidden.HiddenApiBridge; /** @@ -103,6 +104,8 @@ public class LSPApplication extends ApplicationServiceClient { loadModules(context); Main.forkPostCommon(false, context.getDataDir().toString(), ActivityThread.currentProcessName()); doHook(context); + Log.i(TAG, "Start loading modules"); + XposedInit.loadModules(); // WARN: Since it uses `XResource`, the following class should not be initialized // before forkPostCommon is invoke. Otherwise, you will get failure of XResources LSPLoader.initModules(context); @@ -173,7 +176,7 @@ public class LSPApplication extends ApplicationServiceClient { String packageName = name.substring(0, name.length() - 4); String modulePath = context.getCacheDir() + "/lspatch/" + packageName + "/"; String cacheApkPath; - try (ZipFile sourceFile = new ZipFile(context.getApplicationInfo().sourceDir)) { + try (ZipFile sourceFile = new ZipFile(context.getPackageResourcePath())) { cacheApkPath = modulePath + sourceFile.getEntry("assets/modules/" + name).getCrc(); } @@ -190,7 +193,7 @@ public class LSPApplication extends ApplicationServiceClient { module.apkPath = cacheApkPath; module.packageName = packageName; module.file = loadModule(cacheApkPath); - if (module.file != null) module.file.hostApk = context.getApplicationInfo().sourceDir; + if (module.file != null) module.file.hostApk = context.getPackageResourcePath(); modules.add(module); } } catch (Throwable ignored) { @@ -280,11 +283,10 @@ public class LSPApplication extends ApplicationServiceClient { } if (bypassLv >= Constants.SIGBYPASS_LV_PM_OPENAT) { String cacheApkPath; - var aInfo = context.getApplicationInfo(); - try (ZipFile sourceFile = new ZipFile(aInfo.sourceDir)) { - cacheApkPath = aInfo.dataDir + "/cache/lspatch/origin/" + sourceFile.getEntry(ORIGINAL_APK_ASSET_PATH).getCrc(); + try (ZipFile sourceFile = new ZipFile(context.getPackageResourcePath())) { + cacheApkPath = context.getCacheDir() + "/lspatch/origin/" + sourceFile.getEntry(ORIGINAL_APK_ASSET_PATH).getCrc(); } - SigBypass.enableOpenatHook(context.getApplicationInfo().sourceDir, cacheApkPath); + SigBypass.enableOpenatHook(context.getPackageResourcePath(), cacheApkPath); } } diff --git a/core b/core index d76db3c..89eeddd 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit d76db3cb82d52c648aed4c8e798eb0385936589c +Subproject commit 89eedddbd94af1240c14e6172e98c19bd4c7cafa