Giter Site home page Giter Site logo

Comments (2)

caikelun avatar caikelun commented on September 15, 2024 1

你好~

可以改成这样试试:

int unity_new_open(const char *path, int flags, mode_t modes) {
    BYTEHOOK_STACK_SCOPE();
    VERBOSE("unity_new_open() path=%s", path);

    int result = BYTEHOOK_CALL_PREV(unity_new_open, path, flags, modes);
    VERBOSE("unity_new_open() ret=%d", result);

    return result;
}

可变参数分两种情况:

  1. 可变部分的参数个数上限已知:比如 open(具体可以看下 aosp 中 open 的实现)。这种情况可以按照最大的参数个数情况来定义 proxy 函数。
  2. 可变部分的参数个数上限未知:比如 snprintf。这种情况一般都会有对应的 va_list 类型的函数,比如 vsnprintf,因此可以在 proxy 函数中提取 va_list 然后调用 vsnprintf

另外,PLT 方式 hook open一共需要 hook 三处:open__open_real__open_2。供参考。

from bhook.

tyrionchen avatar tyrionchen commented on September 15, 2024 1

你好~

可以改成这样试试:

int unity_new_open(const char *path, int flags, mode_t modes) {
    BYTEHOOK_STACK_SCOPE();
    VERBOSE("unity_new_open() path=%s", path);

    int result = BYTEHOOK_CALL_PREV(unity_new_open, path, flags, modes);
    VERBOSE("unity_new_open() ret=%d", result);

    return result;
}

可变参数分两种情况:

  1. 可变部分的参数个数上限已知:比如 open(具体可以看下 aosp 中 open 的实现)。这种情况可以按照最大的参数个数情况来定义 proxy 函数。
  2. 可变部分的参数个数上限未知:比如 snprintf。这种情况一般都会有对应的 va_list 类型的函数,比如 vsnprintf,因此可以在 proxy 函数中提取 va_list 然后调用 vsnprintf

另外,PLT 方式 hook open一共需要 hook 三处:open__open_real__open_2。供参考。

感谢解答!
修改后确实就不崩了

from bhook.

Related Issues (20)

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.