GithubHelp home page GithubHelp logo

jevinskie / plthook Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kubo/plthook

0.0 3.0 2.0 27 KB

Hook function calls by replacing PLT(Procedure Linkage Table) entries.

C 97.96% Makefile 2.04%

plthook's Introduction

PLT Hook

What is plthook.

A utility library to hook library function calls issued by specified object files (executable and libraries).

Usage

If you have a library libfoo.so.1 and want to intercept a function call recv() without modifying the library, put plthook.c (or plthook_win32.c for Windows) and plthook.h in your source tree and add the following code.

static ssize_t my_recv(int sockfd, void *buf, size_t len, int flags)
{
    ssize_t rv;

    ... do your task: logging, etc. ...
    rv = recv(sockfd, buf, len, flags); /* call real recv(). */
    ... do your task: logging, check received data, etc. ...
    return rv;
}

int install_hook_function()
{
    plthook_t *plthook;

    if (plthook_open(&plthook, "libfoo.so.1") != 0) {
        printf("plthook_open error: %s\n", plthook_error());
        return -1;
    }
    if (plthook_replace(plthook, "recv", (void*)my_recv, NULL) != 0) {
        printf("plthook_replace error: %s\n", plthook_error());
        plthook_close(plthook);
        return -1;
    }
    plthook_close(plthook);
    return 0;
}

Supported Platforms

  • Linux i386 and x86_64 by plthook_elf.c
  • Windows 32-bit and x64 (MSVC, Mingw32 and Cygwin) by plthook_win32.c
  • OS X (tested on Mavericks) by plthook_osx.c
  • Solaris x86_64 by plthook_elf.c
  • FreeBSD i386 and x86_64 except i386 program on x86_64 OS by plthook_elf.c

License

2-clause BSD-style license.

plthook's People

Contributors

kubo avatar

Watchers

 avatar  avatar  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.