2

In Xposed, I'm trying to call a method getResult of AppCustomClass object passed as argument in hooked method.

protected void myMethod(XC_LoadPackage.LoadPackageParam loadPackageParam) {
    final Class<?> appCustomClass = XposedHelpers.findClass("com.app.customClass", loadPackageParam.classLoader);

    findAndHookMethod("com.app.aClass", loadPackageParam.classLoader, "aMethod", appCustomClass, new XC_MethodHook() {
        protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
          //How to call param.args[0].getResult()
      }
}
Racil Hilan
  • 24,690
  • 13
  • 50
  • 55

1 Answers1

3

you can use XposedHelpers.callMethod it has two variants

callMethod(Object obj, String methodName, Class[]<?> parameterTypes, Object... args)

and

callMethod(Object obj, String methodName, Object... args)

so you can do

XposedHelpers.callMethod(param.args[0],"getResult");

if it takes arguments do

XposedHelpers.callMethod(param.args[0],"getResult",arg1,arg2,arg3);

Note: the method is resolved with findMethodBestMatch. The exception thrown by this( "callMethod" ) method is XposedHelpers.InvocationTargetError which gives the exception thrown ( if any ) by the invoked method.

further reading: http://api.xposed.info/reference/de/robv/android/xposed/XposedHelpers.html#callMethod(java.lang.Object,%20java.lang.String,%20java.lang.Object...)

Suraj
  • 184
  • 1
  • 14