Coder Social home page Coder Social logo

artandhook's Introduction

因为工作需要Hook java中的方法,一开始用的epic,但是稳定性不太好,手动JIT编译有时会失败,导致闪退,并且9.0上hook貌似不管用。

于是就基于一些已有的native hook方案,做了一些改进和完善,并适配了9.0。

该方案只能hook java函数,如果hook c函数,请看gotHook

不过正如epic的作者说的那样,这种方案不支持Hook系统的一些函数。因为这种方案的有一个前提就是方法调用必须是先拿到ArtMethod,再去取entrypoint然后跳转实现调用。但是很多情况下,系统知道你要调用的这个方法的entrypoint是什么,直接写死在汇编代码里,这样方法调用的时候就不会有取ArtMethod这个动作,从而不会去拿被替换的entrypoint,导致Hook失效。不过对我来说已经够用了。

dependencies {
    implementation 'com.yanggs:arthook:0.2.7'
}

JXposed.findAndHookMethod(MainActivity.class, "testFun", String.class,int.class,new MethodCallback() {
    @Override
    protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
        super.beforeHookedMethod(param);
        Logger.i("beforeHookedMethod:");
    }

    @Override
    protected void afterHookedMethod(MethodHookParam param) throws Throwable {
        super.afterHookedMethod(param);
        Logger.i("afterHookedMethod:");

    }
});     

artandhook's People

Contributors

fengjixuchui avatar shineygs avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.