Xposed: how to block a method call

I am using Xposed to execute some method (for now, just for teaching). I was able to connect the SendTextMessage method (android.telephony.SmsManager), I can do some things before and after the method call, so my question is: can I do something in the previous case because the original method will not be called?

Thank,

+3


source to share


3 answers


Use this somewhere in "before" to prevent calling the original method

param.setResult(null);

      



(In the "after" case, this only changes the result of the original method, because it has been executed yet)

+7


source


Instead of replacing, XC_MethodHook

you can use XC_MethodReplacement

instead XC_MethodHook

.



+2


source


There are comments in the source code that say the way to prevent the method from being called is to call MethodHookParam # setThrowable (Throwable) to prevent the function from being called. So take the paras that were passed in beforeHookedMethod and call param.setThrowable (Throwable t)

Note that Throwable is just a superclass for all errors and exceptions in Java, so you should just use Exception or Error as Throwable.

( https://github.com/rovo89/XposedBridge/blob/13c9918eb449a4b851740c5e380057d6f0d23bd5/src/de/robv/android/xposed/XC_MethodHook.java )

-1


source







All Articles