GithubHelp home page GithubHelp logo

aerostun / dlhook Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 15 KB

Linux extension to dlfcn, for hooking functions from DSOs.

License: Apache License 2.0

CMake 4.56% C++ 80.40% C 15.05%
dlfcn hook linux

dlhook's Introduction

dlhook

An extension to the dlfcn.h family, for attaching hooks to functions from DSOs.

Requires C++14 to build, but the interface is C compatible.

Supported platforms:

  • Linux amd64 (manually tested), aarch64 (untested yet)
  • QNX aarch64 (untested yet)

Synopsis:

// Hook by symbol

/// Hooks the PLT entry of @a symbol with @a hook in @a handle.
///
/// @param handle result of a successful call to dlopen(),
///               or @a nullptr for the running executable.
/// @param symbol which symbol to hook in the PLT of @a handle.
/// @param hook replacement entry for @a symbol.
/// @return the original address found in the PLT
/// @note if an error occurs, the program will be aborted
void* dlhook_sym(void* handle, const char* symbol, void* hook);

/// Hooks the PLT entries of @a symbol with @a hook in all currently loaded objects.
///
/// @param symbol which symbol to hook in the PLT of @a handle.
/// @param hook replacement entry for @a symbol.
/// @note if an error occurs, it will be safely ignored.
void dlhook_sym_all(const char* symbol, void* hook);

// Hook by address

/// Replaces all PLT entries pointing to @a original by @a hook in @a handle
///
/// @param handle result of a successful call to dlopen(),
///               or @a nullptr for the running executable.
/// @param original address to replace.
/// @param hook replacement address.
/// @note if an error occurs, the program will be aborted.
void dlhook_addr(void* handle, void* original, void* hook);

/// Replaces all PLT entries pointing to @a original by @a hook in all currently loaded objects.
///
/// @param original address to replace.
/// @param hook replacement address.
/// @note if an error occurs, the program will be aborted.
void dlhook_addr_all(void* original, void* hook);

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.