No description
Find a file
2025-05-14 23:59:18 +07:00
.github Create FUNDING.yml 2021-10-01 07:39:15 +07:00
docs add docs 2019-09-26 08:58:01 +07:00
src remove distorm3 from dependencies 2025-05-14 23:56:56 +07:00
tests updat test3 2023-05-23 10:44:04 +07:00
.gitmodules compile funchook direclty, get rid of static linked libraries 2021-09-04 19:12:29 +07:00
funchook.nimble Update funchook.nimble 2025-05-14 23:59:18 +07:00
LICENSE add LICENSE 2019-09-26 18:27:08 +07:00
README.md Fix check list 2023-05-22 14:56:36 +03:30

funchook.nim

Build Status (github) made-with-python

funchook wrapper for Nim

This wrapper compiles funchook with diStorm3 disassembler.

Suports both x64 and x86-64 on:

  • Linux
  • Windows
  • MacOS (not tested yet)

Installation

nimble install funchook

Usage

import funchook

proc my_add(a, b: int): int =
  ## original proc to be hooked
  a + b

var add_func = my_add

proc hook_add(a, b: int): int =
  ## proc to replace my_add
  echo add_func(a, b) # call original proc with trampoline
  a * b

var h = initHook()

if h == nil:
  quit("Error: create funchook failed")

if h.prepare(addr add_func, hook_add) != SUCCESS:
  quit("Error: " & h.errorMessage())

assert my_add(4, 5) == 9, "pre-hook"

if h.install(0) != SUCCESS:
  quit("Error: " & h.errorMessage())

assert my_add(4, 5) == 20, "post-hook"