本帖最后由 aqz236 于 2024-3-20 01:22 编辑
小骚 发表于 2024-3-20 01:11
使用Xposed框架的XposedHelpers.findClass试试
[Java] 纯文本查看 复制代码 package com.example.he;
import android.app.Application;
import android.content.Context;
import android.util.Log;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
public class Hook implements IXposedHookLoadPackage {
Context context;
String TAG = "lubenwei";
@Override
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
if (!lpparam.packageName.equals("com.milink.service"))
return;
Log.d(TAG + "_find", "FindAppStart");
// 多dex
XposedHelpers.findAndHookMethod(Application.class, "attach", Context.class,
new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
context = (Context) param.args[0];
ClassLoader classLoader = context.getClassLoader();
XposedHelpers.findAndHookMethod("com.android.server.display.LogicalDisplayMapper", classLoader, "updateLogicalDisplaysLocked",
new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Log.d(TAG + "[找到了]", "111");
}
});
}
});
// 动态加载
XposedHelpers.findAndHookMethod(ClassLoader.class, "loadClass", String.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Class clazz = (Class) param.getResult();
ClassLoader classLoader2 = clazz.getClassLoader();
Class<?> aClass = XposedHelpers.findClass("com.android.server.display.LogicalDisplayMapper", classLoader2);
Log.d(TAG + "[找到了]", aClass.getName());
}
});
// 测试反射
// try {
// Class<?> targetClass = Class.forName("com.android.server.display.LogicalDisplayMapper", true, lpparam.classLoader);
// Method targetMethod = null;
// for (Method method : targetClass.getDeclaredMethods()) {
// if (method.getName().equals("updateLogicalDisplaysLocked")) {
// targetMethod = method;
// break;
// }
// }
// if (targetMethod != null) {
// targetMethod.setAccessible(true);
// Log.d(TAG, "反射前");
// targetMethod.invoke(targetClass.newInstance());
// Log.d(TAG, "反射后");
// } else {
// Log.d(TAG, "未找到");
// }
// } catch (Exception e) {
// Log.e(TAG, "Error", e);
// }
}
}
这是全部的代码,findClass也是不行的,现在的情况就是反编译出来的文件找不到我要hook的类,要hook的类在service.jar中可以看到,但是hook不到。。。 |