Frida hook带handler的method

有些Class里面有Handler对象,就必须在 主线程里执行,否则报错

E/AndroidRuntime( 2434): java.lang.ExceptionInInitializerError
E/AndroidRuntime( 2434): at dalvik.system.NativeStart.run(Native Method)
E/AndroidRuntime( 2434): Caused by: java.lang.RuntimeException: Can’t create handler inside thread that has not called Looper.prepare()
E/AndroidRuntime( 2434): at android.os.Handler.(Handler.java:200)

Frida提供了这样的设施, 那就是 scheduleOnMainThread

send(Java.available); 

Java.perform(function () { 
    send(Java.androidVersion); 
    send(Java.isMainThread());

    Java.scheduleOnMainThread(function () { 
        send(Java.isMainThread());
        
        var Mgr = Java.use("me.app.im.Mgr");
        var MgrInstance = Mgr.a();
        var Region = MgrInstance.v();
        send(Region);       
    });
});
    原文作者:一个会写诗的程序员
    原文地址: https://www.jianshu.com/p/6218af4382bb
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞