EzXHelper icon indicating copy to clipboard operation
EzXHelper copied to clipboard

Can EzXHelper or Xposed be used to call the superclass version of a hooked method?

Open DavidBerdik opened this issue 1 year ago • 6 comments

I have a scenario in which I want to hook a method in a class that is extended from another class. Under certain conditions, I want to override the hooked method in the extended class and have it instead execute the original method. Basically I want to do the Xposed/EzXHelper equivalent of calling super.myHookedMethod(). Is there a way to do this?

I tried using XposedHelpers.callMethod(XposedHelpers.getSurroundingThis(param.thisObject), "myHookedMethod") and XposedHelpers.callMethod(param.thisObject, "super.myHookedMethod") but neither has worked. Is there any way to achieve this?

DavidBerdik avatar Sep 20 '22 02:09 DavidBerdik

XposedBridge#invokeOriginalMethod (Member method, Object thisObject, Object[] args)

keta1 avatar Sep 20 '22 03:09 keta1

Doesn't this just call the method of the class you're in?

https://api.xposed.info/reference/de/robv/android/xposed/XposedBridge.html#invokeOriginalMethod(java.lang.reflect.Member,%20java.lang.Object,%20java.lang.Object[])

DavidBerdik avatar Sep 20 '22 03:09 DavidBerdik

Are you looking for java.lang.invoke.MethodHandle? it can call obj.super.method()

teble avatar Sep 20 '22 04:09 teble

For invoking a super method (aka. invoke-super), you can use JNIEnv::CallNonvirtual<Type>Method. Note that MethodHandle is added in API 26.

cinit avatar Sep 20 '22 04:09 cinit

@teble I'm honestly not sure if java.lang.invoke.MethodHandle is what I'm looking for, but it kind of sounds like it might be based on what I'm reading. Can I use callMethod() with obj.super then?

DavidBerdik avatar Sep 20 '22 04:09 DavidBerdik

@cinit I'm not sure I understand this.

DavidBerdik avatar Sep 20 '22 04:09 DavidBerdik