正文
xposed获取context 的方法
小程序:扫一扫查出行
【扫一扫了解最新限行尾号】
复制小程序
【扫一扫了解最新限行尾号】
复制小程序
// 应用被加壳,采用这种方式加载类
try {
XposedHelpers.findAndHookMethod(Application.class, "attach", Context.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
context = (Context) param.args[0];
ClassLoader loader = context.getClassLoader(); // 获取题目和答案
try {
Class clazz = loader.loadClass("com.chongdingdahui.app.socket.MessageManager$7");
if (clazz != null){ XposedHelpers.findAndHookMethod(clazz, "call", Object[].class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
super.beforeHookedMethod(param);
Object[] obj = (Object[]) param.args[0];
String content = obj[0].toString();
Log.d(TAG, content);
question = Util.getQuestion(content);
answers = Util.getAnswer(content);
}
});
}
}catch (Exception e){
Log.e(TAG, "socket.MessageManager$7 clazz not found" + Log.getStackTraceString(e));
}
亲测可用