LSPosed / LSPlant

A hook framework for Android Runtime (ART)
https://lsposed.org/LSPlant/
GNU Lesser General Public License v3.0
814 stars 203 forks source link

如何hook一个无返回值带参数的函数,并修改函数参数呢? #95

Closed anjiuzhe closed 2 months ago

anjiuzhe commented 2 months ago

你好,假设有一个函数为void test(LTest t),需求是替换或修改函数的参数LTest t,在LSPlant没有找到相关的示例,请问用LSPlant可以实现这个需求吗?谢谢。

yujincheng08 commented 2 months ago

可以

anjiuzhe commented 2 months ago

@yujincheng08 你好,我在LSPlant的项目中测试hook webview的setWebViewClient方法,想替换其中WebViewClient,但是两种实现方式都没有成功,请问需要怎么做呢?下面是关键代码:

image image
yujincheng08 commented 2 months ago

替换之后得调用 backup,从你的代码完全看不到

anjiuzhe commented 2 months ago

@yujincheng08 感谢大佬指点,代码目前这样可以了。

image

但是调用backup的话,如果是对象方法,需要传入实际的对象,目前因为是测试,可以直接用变量保存,如果这个对象没法直接获取到,如何通过LSPlant来获取呢?

yujincheng08 commented 2 months ago

args[0] 就是啊

anjiuzhe commented 2 months ago

谢谢大佬,这回懂了。