From b5c157b3a7098add1fcb64794913e9da21ba5330 Mon Sep 17 00:00:00 2001 From: wangkaixun <904028997@qq.com> Date: Sat, 25 Jul 2020 09:29:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0InitProvider=E7=B1=BB?= =?UTF-8?q?=E5=92=8C=E6=B7=BB=E5=8A=A0PathClassLoader=E5=AE=9E=E7=8E=B0=20?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E9=80=9A=E8=BF=87=E4=BF=AE=E6=94=B9AndroidMa?= =?UTF-8?q?nifest=E6=B3=A8=E5=86=8Cprovider,=E6=B3=A8=E5=86=8Capplication?= =?UTF-8?q?=EF=BC=8C=E8=BF=9B=E8=A1=8C=E4=BD=8E=E4=BE=B5=E5=85=A5=E5=BC=8F?= =?UTF-8?q?=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 3 +- exposed-core/build.gradle | 11 ---- .../java/me/weishu/exposed/ExposedBridge.java | 32 ++++++++++++ .../java/me/weishu/exposed/InitProvider.java | 52 +++++++++++++++++++ gradle/wrapper/gradle-wrapper.properties | 4 +- 5 files changed, 88 insertions(+), 14 deletions(-) create mode 100644 exposed-core/src/main/java/me/weishu/exposed/InitProvider.java diff --git a/build.gradle b/build.gradle index b5984a7..a16e54d 100644 --- a/build.gradle +++ b/build.gradle @@ -5,9 +5,10 @@ buildscript { repositories { maven { url 'https://maven.google.com' } jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.3' + classpath 'com.android.tools.build:gradle:4.0.0' classpath 'com.novoda:bintray-release:0.3.4' // NOTE: Do not place your application dependencies here; they belong diff --git a/exposed-core/build.gradle b/exposed-core/build.gradle index 1c2cb35..4898855 100644 --- a/exposed-core/build.gradle +++ b/exposed-core/build.gradle @@ -32,14 +32,3 @@ dependencies { group = 'me.weishu.exposed' version = '0.8.0' - -apply plugin: 'com.novoda.bintray-release' - -publish { - userOrg = 'twsxtd' - groupId = "${project.group}" - artifactId = "${project.name}" - publishVersion = "${project.version}" - desc = 'Xposed Wrapper in non-root environment' - website = 'https://github.com/android-hacker/exposed' -} \ No newline at end of file diff --git a/exposed-core/src/main/java/me/weishu/exposed/ExposedBridge.java b/exposed-core/src/main/java/me/weishu/exposed/ExposedBridge.java index 3407363..7e706cb 100644 --- a/exposed-core/src/main/java/me/weishu/exposed/ExposedBridge.java +++ b/exposed-core/src/main/java/me/weishu/exposed/ExposedBridge.java @@ -42,6 +42,7 @@ import java.util.Set; import dalvik.system.DexClassLoader; +import dalvik.system.PathClassLoader; import de.robv.android.xposed.DexposedBridge; import de.robv.android.xposed.ExposedHelper; import de.robv.android.xposed.IXposedHookInitPackageResources; @@ -284,6 +285,37 @@ public static ModuleLoadResult loadModule(final String moduleApkPath, String mod return ModuleLoadResult.FAILED; } + public static void loadModule(Context context) { + String dexPacName = "com.debby.spellbook"; + try { + ClassLoader originClassLoader = context.getClassLoader(); + ApplicationInfo info = context.getPackageManager().getApplicationInfo(dexPacName, 0); + ClassLoader appClassLoaderWithXposed = getAppClassLoaderWithXposed(originClassLoader); + ClassLoader mcl = new PathClassLoader(info.sourceDir, getXposedClassLoader(ExposedBridge.class.getClassLoader())); + Class moduleClass = mcl.loadClass("com.debby.spellbook.WechatHook"); + final Object moduleInstance = moduleClass.newInstance(); + + if (moduleInstance instanceof IXposedHookLoadPackage) { + IXposedHookLoadPackage.Wrapper wrapper = new IXposedHookLoadPackage.Wrapper((IXposedHookLoadPackage) moduleInstance); + XposedBridge.CopyOnWriteSortedSet xc_loadPackageCopyOnWriteSortedSet = new XposedBridge.CopyOnWriteSortedSet<>(); + xc_loadPackageCopyOnWriteSortedSet.add(wrapper); + XC_LoadPackage.LoadPackageParam lpparam = new XC_LoadPackage.LoadPackageParam(xc_loadPackageCopyOnWriteSortedSet); + ApplicationInfo currentApplicationInfo = context.getApplicationInfo(); + + lpparam.packageName = currentApplicationInfo.packageName; + lpparam.processName = currentApplicationInfo.processName; + lpparam.classLoader = appClassLoaderWithXposed; + lpparam.appInfo = currentApplicationInfo; + lpparam.isFirstApplication = true; + XC_LoadPackage.callAll(lpparam); + } + } catch (Throwable t) { + Log.e("InitProvider", t.getMessage()); + log(t); + } + } + + private static boolean ignoreHooks(Member member) { if (member == null) { return false; diff --git a/exposed-core/src/main/java/me/weishu/exposed/InitProvider.java b/exposed-core/src/main/java/me/weishu/exposed/InitProvider.java new file mode 100644 index 0000000..64baa70 --- /dev/null +++ b/exposed-core/src/main/java/me/weishu/exposed/InitProvider.java @@ -0,0 +1,52 @@ +package me.weishu.exposed; + +import android.content.ContentProvider; +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; +import android.net.Uri; +import android.util.Log; + +/** + * Create by wakfu on 2020/7/14 + */ +public class InitProvider extends ContentProvider { + + @Override + public boolean onCreate() { + Log.e("InitProvider", "onCreate"); + Context context = getContext(); + if (context != null) { + ExposedBridge.initOnce(context, context.getApplicationInfo(), context.getClassLoader()); + ExposedBridge.loadModule(context); + } else { + Log.e("InitProvider", "onCreateFail"); + } + return false; + } + + @Override + public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { + return null; + } + + @Override + public String getType(Uri uri) { + return null; + } + + @Override + public Uri insert(Uri uri, ContentValues values) { + return null; + } + + @Override + public int delete(Uri uri, String selection, String[] selectionArgs) { + return 0; + } + + @Override + public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { + return 0; + } +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5c27162..ea1476f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Nov 30 19:01:20 CST 2017 +#Sat Jul 25 09:21:35 CST 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip From 101ef57de7d8de20c3aceeb0856133855c88268d Mon Sep 17 00:00:00 2001 From: wangkaixun <904028997@qq.com> Date: Sat, 25 Jul 2020 09:36:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8C=85=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/me/weishu/exposed/ExposedBridge.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exposed-core/src/main/java/me/weishu/exposed/ExposedBridge.java b/exposed-core/src/main/java/me/weishu/exposed/ExposedBridge.java index 7e706cb..ef18990 100644 --- a/exposed-core/src/main/java/me/weishu/exposed/ExposedBridge.java +++ b/exposed-core/src/main/java/me/weishu/exposed/ExposedBridge.java @@ -286,13 +286,13 @@ public static ModuleLoadResult loadModule(final String moduleApkPath, String mod } public static void loadModule(Context context) { - String dexPacName = "com.debby.spellbook"; + String dexPacName = "com.debby.xposetest"; try { ClassLoader originClassLoader = context.getClassLoader(); ApplicationInfo info = context.getPackageManager().getApplicationInfo(dexPacName, 0); ClassLoader appClassLoaderWithXposed = getAppClassLoaderWithXposed(originClassLoader); ClassLoader mcl = new PathClassLoader(info.sourceDir, getXposedClassLoader(ExposedBridge.class.getClassLoader())); - Class moduleClass = mcl.loadClass("com.debby.spellbook.WechatHook"); + Class moduleClass = mcl.loadClass("com.debby.xposetest.HookLogic"); final Object moduleInstance = moduleClass.newInstance(); if (moduleInstance instanceof IXposedHookLoadPackage) {