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..ef18990 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.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.xposetest.HookLogic"); + 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