https://github.com/cppcoffee/inl_hook
a linux kernel function inline hooking library
https://github.com/cppcoffee/inl_hook
Last synced: 10 months ago
JSON representation
a linux kernel function inline hooking library
- Host: GitHub
- URL: https://github.com/cppcoffee/inl_hook
- Owner: cppcoffee
- Created: 2017-08-20T02:08:05.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-19T03:21:59.000Z (over 8 years ago)
- Last Synced: 2025-04-12T23:53:00.108Z (about 1 year ago)
- Language: C
- Homepage:
- Size: 69.3 KB
- Stars: 30
- Watchers: 4
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### about inl_hook
**inl_hook** is a linux kernel function inline hooking library. it is very easy to use.
### example
in the hello_core.c
```c
static void (*tcp_set_state_fn)(struct sock *sk, int state);
static void my_tcp_set_state(struct sock *sk, int state);
static struct hook_ops hello_hooks[] = {
DECLARE_HOOK(&tcp_set_state_fn, my_tcp_set_state),
};
static void
my_tcp_set_state(struct sock *sk, int state)
{
// copy your origin code here, then write patch code.
// You can refer to hello_core.c
}
// hooking
ret = inl_sethook_ops(hello_hooks, ARRAY_SIZE(hello_hooks));
if (ret < 0) {
pr_err("inl_sethook_ops hello_hooks fail.\n");
goto exit;
}
// unhook
inl_unhook_ops(hello_hooks, ARRAY_SIZE(hello_hooks));
```
### thank
udis86: https://github.com/vmt/udis86
mhook: https://github.com/martona/mhook