From 59f890c5596d124d91a3f1765404084c4940d9de Mon Sep 17 00:00:00 2001 From: HChenX Date: Wed, 19 Jun 2024 12:48:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=97=A5=E5=BF=97=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20throws?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/inspectionProfiles/Project_Default.xml | 1 + README.md | 4 ++-- app/build.gradle | 19 ++----------------- .../java/com/hchen/hooktool/MainTest.java | 2 +- .../com/hchen/hooktool/callback/IAction.java | 4 ++-- .../com/hchen/hooktool/tool/ActionTool.java | 4 ++-- .../com/hchen/hooktool/tool/ExpandTool.java | 7 +++++-- .../com/hchen/hooktool/tool/ParamTool.java | 2 ++ gradle/libs.versions.toml | 2 -- 9 files changed, 17 insertions(+), 28 deletions(-) diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 817ad56..104c25d 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -4,5 +4,6 @@ + \ No newline at end of file diff --git a/README.md b/README.md index 90c8e46..db9d5fa 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ dependencyResolutionManagement { ```groovy dependencies { - implementation 'com.github.HChenX:HookTool:v.0.9.6.3' + implementation 'com.github.HChenX:HookTool:v.0.9.6.5' } ``` @@ -188,7 +188,7 @@ public class MainTest extends BaseHC { new IAction() { @Override - public void before(ParamTool param) { + public void before(ParamTool param) throws Throwable { // hook 方法所属的类 Class c = param.mClass; diff --git a/app/build.gradle b/app/build.gradle index d4aebbe..94069b8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,8 +3,8 @@ plugins { id 'maven-publish' } -def defVersion = 'v.0.9.6.3' -int defVersionCode = 2024061705 +def defVersion = 'v.0.9.6.5' +int defVersionCode = 2024061900 group = 'com.github.HChenX' version = defVersion @@ -19,10 +19,6 @@ android { // noinspection HighAppVersionCode versionCode defVersionCode versionName defVersion - // ndk { - // noinspection ChromeOsAbiSupport - // abiFilters 'arm64-v8a', 'armeabi-v7a' - // } } buildTypes { @@ -58,20 +54,9 @@ tasks.register('androidSourcesJar', Jar) { from android.sourceSets.main.java.srcDirs } -// getTasks().withType(JavaCompile) { -// options.compilerArgs += ['-Xplugin:Manifold'] -// } - dependencies { compileOnly libs.xposed implementation libs.annotation - // implementation libs.dexkit - // implementation libs.jetbrains.annotations - // compileOnly libs.systems.manifold.ext - // implementation libs.annotations - // implementation libs.androidx.annotation.jvm - // implementation libs.jetbrains.annotations - // implementation libs.manifold.ext.rt } afterEvaluate { diff --git a/app/src/main/java/com/hchen/hooktool/MainTest.java b/app/src/main/java/com/hchen/hooktool/MainTest.java index bb84a3b..edf604f 100644 --- a/app/src/main/java/com/hchen/hooktool/MainTest.java +++ b/app/src/main/java/com/hchen/hooktool/MainTest.java @@ -50,7 +50,7 @@ protected void beforeHookedMethod(MethodHookParam param) { new IAction() { @Override - public void before(ParamTool param) { + public void before(ParamTool param) throws Throwable { // hook 方法所属的类 Class c = param.mClass; diff --git a/app/src/main/java/com/hchen/hooktool/callback/IAction.java b/app/src/main/java/com/hchen/hooktool/callback/IAction.java index 3e5e5ec..c9b88ea 100644 --- a/app/src/main/java/com/hchen/hooktool/callback/IAction.java +++ b/app/src/main/java/com/hchen/hooktool/callback/IAction.java @@ -24,9 +24,9 @@ * Hook 动作接口 */ public interface IAction { - default void before(ParamTool param) { + default void before(ParamTool param) throws Throwable { } - default void after(ParamTool param) { + default void after(ParamTool param) throws Throwable { } } diff --git a/app/src/main/java/com/hchen/hooktool/tool/ActionTool.java b/app/src/main/java/com/hchen/hooktool/tool/ActionTool.java index a2bdd09..feeadb5 100644 --- a/app/src/main/java/com/hchen/hooktool/tool/ActionTool.java +++ b/app/src/main/java/com/hchen/hooktool/tool/ActionTool.java @@ -175,13 +175,13 @@ protected Action hookTool(Member member, IAction iAction) { ParamTool paramTool = new ParamTool(utils); return new Action(member, utils.getTAG()) { @Override - protected void before(MethodHookParam param) { + protected void before(MethodHookParam param) throws Throwable { paramTool.setParam(param); iAction.before(paramTool); } @Override - protected void after(MethodHookParam param) { + protected void after(MethodHookParam param) throws Throwable { paramTool.setParam(param); iAction.after(paramTool); } diff --git a/app/src/main/java/com/hchen/hooktool/tool/ExpandTool.java b/app/src/main/java/com/hchen/hooktool/tool/ExpandTool.java index 626557c..1b4e3a1 100644 --- a/app/src/main/java/com/hchen/hooktool/tool/ExpandTool.java +++ b/app/src/main/java/com/hchen/hooktool/tool/ExpandTool.java @@ -18,6 +18,7 @@ */ package com.hchen.hooktool.tool; +import static com.hchen.hooktool.log.XposedLog.logD; import static com.hchen.hooktool.log.XposedLog.logE; import static com.hchen.hooktool.log.XposedLog.logW; @@ -262,6 +263,7 @@ public void hook(Member member, IAction iAction) { } try { XposedBridge.hookMethod(member, utils.getActionTool().hookTool(member, iAction)); + logD(utils.getTAG(), "success hook: " + member); } catch (Throwable e) { logE(utils.getTAG(), "hook: [" + member + "], failed!", e); } @@ -273,6 +275,7 @@ public void hook(ArrayList members, IAction iAction) { try { XposedBridge.hookMethod((Member) o, utils.getActionTool().hookTool((Member) o, iAction)); + logD(utils.getTAG(), "success hook: " + o); } catch (Throwable e) { logE(utils.getTAG(), "hook: [" + o + "], failed!", e); } @@ -283,7 +286,7 @@ public void hook(ArrayList members, IAction iAction) { public IAction returnResult(final Object result) { return new IAction() { @Override - public void before(ParamTool param) { + public void before(ParamTool param) throws Throwable { param.setResult(result); } }; @@ -292,7 +295,7 @@ public void before(ParamTool param) { public IAction doNothing() { return new IAction() { @Override - public void before(ParamTool param) { + public void before(ParamTool param) throws Throwable { param.setResult(null); } }; diff --git a/app/src/main/java/com/hchen/hooktool/tool/ParamTool.java b/app/src/main/java/com/hchen/hooktool/tool/ParamTool.java index de2855d..f181467 100644 --- a/app/src/main/java/com/hchen/hooktool/tool/ParamTool.java +++ b/app/src/main/java/com/hchen/hooktool/tool/ParamTool.java @@ -32,6 +32,7 @@ public class ParamTool extends Arguments { public Class mClass; public Member mMember; + public Object[] mParam; public ParamTool(DataUtils utils) { super(utils); @@ -44,6 +45,7 @@ protected void setParam(XC_MethodHook.MethodHookParam param) { this.param = param; mClass = param.method.getDeclaringClass(); mMember = param.method; + mParam = param.args; } public T thisObject() { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c413763..e8344cf 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,11 +1,9 @@ [versions] agp = "8.5.0" -dexkit = "2.0.2" annotation = "1.8.0" xposed = "82" [libraries] -dexkit = { module = "org.luckypray:dexkit", version.ref = "dexkit" } annotation = { module = "androidx.annotation:annotation", version.ref = "annotation" } xposed = { group = "de.robv.android.xposed", name = "api", version.ref = "xposed" }