Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Library:plthook

From ReverseEngineering.wiki
Library
Platforms Linux, Android, BSDs, macOS, Windows
License BSD-2-Clause
Website https://github.com/kubo/plthook
On this wiki Facts · Code · Notes · Topics

plthook (BSD-2-Clause, archived) is a small C library that hooks calls from one ELF, Mach-O or PE module by replacing its PLT/GOT (or IAT) entries.

API (plthook.h): plthook_open(&p, filename), plthook_open_by_handle, plthook_open_by_address, plthook_enum(p, &pos, &name, &addr), plthook_replace(p, funcname, funcaddr, &oldfunc), plthook_close, plthook_error. Implementations: plthook_elf.c (927 lines), plthook_osx.c, plthook_win32.c.

How the ELF version works: it locates the module's link map, reads DT_JMPREL (and the DT_RELA/DT_REL table for GLOB_DAT) and treats JUMP_SLOT and GLOB_DAT relocations as hookable slots for x86, x86-64, ARM and AArch64. plthook_replace matches the name (optionally followed by @version), mprotects the page read-write if needed, stores the old pointer and writes the new one, then restores the protection. Only calls issued by the opened module are redirected. The README notes the repository is archived and points to forks (metacall's fork named best at archive time).

See Technique:Function hooking/Unix and mobile, Format:ELF (Executable and Linkable Format)/Relocations and PLT. Windows IAT equivalent: Technique:Function hooking.

Code & repositories

  • https://github.com/kubo/plthook
  • https://github.com/kubo/plthook @ 24c69df003310fb91f9c2950b5a659ff70e9dfb9 · license: BSD-2-Clause (declared by the contributor; GitHub's detector did not recognize a license file)
    plthook: GOT/PLT/IAT entry replacement (plthook_elf.c, plthook_osx.c).
    Tested on: source read, not run: source read, not run · checked 2026-10-18; archived; last activity 2025-10-05