xposed 如何主动调用java层类中的方
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xposed 如何主动调用java层类中的方相关的知识,希望对你有一定的参考价值。
final Class <?> test = XposedHelpers.findClass("com.debug.xposed.xposedtest.test", lpparam.classLoader);final Class <?> testndk = XposedHelpers.findClass("com.debug.xposed.xposedtest.testndk", lpparam.classLoader);
findAndHookMethod("com.debug.xposed.xposedtest.MainActivity", lpparam.classLoader, "testbtn", View.class, new XC_MethodHook()
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable
XposedBridge.log("Hook之前");
//getSign
@Override
//函数执行后
protected void afterHookedMethod(MethodHookParam param) throws Throwable
XposedBridge.log("Hook之后");
try
String str1 = (String) XposedHelpers.callMethod(param.thisObject, "test1");
Log.i("debug","mainactivity test1 return "+str1);
String str2 = (String) XposedHelpers.callMethod(param.thisObject, "test2","xposed input main test2");
Log.i("debug","mainactivity test2 return "+str2);
Object testObject = test.newInstance();
String str3 = (String) XposedHelpers.callMethod(testObject,"test1");
Log.i("debug","test test1 return= "+str3);
String str4 = (String) XposedHelpers.callMethod(testObject, "test2", "hello ", "txmg");
Log.i("debug","test test2 return= "+str4);
Object testndkobject = testndk.newInstance();
Method myteststr = XposedHelpers.findMethodBestMatch(testndkobject.getClass(), "teststr");
String str5 = (String) myteststr.invoke(testndkobject);
Log.i("debug","ndk teststr return= "+str5);
Method mytest = XposedHelpers.findMethodBestMatch(testndkobject.getClass(), "mytest"," gggg");
String str6 = (String) mytest.invoke(testndkobject,"mytest input test ");
Log.i("debug","ndk mytest return= "+str6);
catch (Exception e)
e.printStackTrace();
参考技术A XposedHelpers.callMethod
XposedHelpers.callStaticMethod
以上是关于xposed 如何主动调用java层类中的方的主要内容,如果未能解决你的问题,请参考以下文章