diff --git a/app/build.gradle b/app/build.gradle index f32ab9d..82530a1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,7 +4,7 @@ plugins { } def defVersion = 'v.1.1.0' -int defVersionCode = 2024121200 +int defVersionCode = 2024121301 group = 'com.github.HChenX' version = defVersion diff --git a/app/src/main/java/com/hchen/hooktool/BaseHC.java b/app/src/main/java/com/hchen/hooktool/BaseHC.java index 0199314..504724b 100644 --- a/app/src/main/java/com/hchen/hooktool/BaseHC.java +++ b/app/src/main/java/com/hchen/hooktool/BaseHC.java @@ -40,7 +40,7 @@ */ public abstract class BaseHC extends CoreTool { public String TAG = getClass().getSimpleName(); // 快捷获取类的简单名称作为 TAG, 为了效果建议配置相应的混淆规则。 - private final ChainTool mChainTool = new ChainTool(); + private static final ChainTool mChainTool = new ChainTool(); public static XC_LoadPackage.LoadPackageParam lpparam; // onZygote 状态下为 null。 public static ClassLoader classLoader; @@ -110,27 +110,27 @@ public static void chain(Class clazz, ChainTool chain) { ChainTool.chain(clazz, chain); } - final public ChainTool.ChainHook method(String name, Object... params) { + public static ChainTool.ChainHook method(String name, Object... params) { return mChainTool.method(name, params); } - final public ChainTool.ChainHook methodIfExist(String name, Object... params) { + public static ChainTool.ChainHook methodIfExist(String name, Object... params) { return mChainTool.methodIfExist(name, params); } - final public ChainTool.ChainHook anyMethod(String name) { + public static ChainTool.ChainHook anyMethod(String name) { return mChainTool.anyMethod(name); } - final public ChainTool.ChainHook constructor(Object... params) { + public static ChainTool.ChainHook constructor(Object... params) { return mChainTool.constructor(params); } - final public ChainTool.ChainHook constructorIfExist(Object... params) { + public static ChainTool.ChainHook constructorIfExist(Object... params) { return mChainTool.constructorIfExist(params); } - final public ChainTool.ChainHook anyConstructor() { + public static ChainTool.ChainHook anyConstructor() { return mChainTool.anyConstructor(); } diff --git a/app/src/main/java/com/hchen/hooktool/tool/ChainTool.java b/app/src/main/java/com/hchen/hooktool/tool/ChainTool.java index 48514d3..09f2039 100644 --- a/app/src/main/java/com/hchen/hooktool/tool/ChainTool.java +++ b/app/src/main/java/com/hchen/hooktool/tool/ChainTool.java @@ -120,12 +120,15 @@ public ChainHook anyConstructor() { // 各种奇奇怪怪的添加 >.< private void doFind(Class clazz) { - if (clazz == null) return; + if (clazz == null) { + cacheDataList.clear(); + return; + } if (cacheDataList.isEmpty()) { logW(getTag(), "cache data list is empty, can't find or hook anything!" + getStackTrace()); - cacheDataList.clear(); return; } + ArrayList members = new ArrayList<>(); for (ChainData cacheData : cacheDataList) { String UUID = cacheData.mType + "#" + clazz.getName() + "#" + cacheData.mName + "#" + Arrays.toString(cacheData.mParams); diff --git a/app/src/main/java/com/hchen/hooktool/tool/PrefsTool.java b/app/src/main/java/com/hchen/hooktool/tool/PrefsTool.java index 5f54d21..6856de3 100644 --- a/app/src/main/java/com/hchen/hooktool/tool/PrefsTool.java +++ b/app/src/main/java/com/hchen/hooktool/tool/PrefsTool.java @@ -139,7 +139,7 @@ private static SharedPreferences currentSp(Context context, String prefsName) { throw new RuntimeException(HCData.getInitTag() + "[" + getTag() + "][E]: Context is null, can't create sprefs!" + getStackTrace()); } - if (sPrefs.get(context + prefsName) == null) { + if (sPrefs.get(context.getPackageName() + prefsName) == null) { SharedPreferences s; try { s = context.getSharedPreferences(prefsName, Context.MODE_WORLD_READABLE); @@ -147,7 +147,7 @@ private static SharedPreferences currentSp(Context context, String prefsName) { s = context.getSharedPreferences(prefsName, Context.MODE_PRIVATE); AndroidLog.logW(getTag(), "Maybe can't use xSharedPreferences!" + getStackTrace()); } - sPrefs.put(context + prefsName, s); + sPrefs.put(context.getPackageName() + prefsName, s); return s; } else { return sPrefs.get(prefsName);