syscall-intercept

Crates.iosyscall-intercept
lib.rssyscall-intercept
version0.1.0
sourcesrc
created_at2022-06-23 02:33:41.953992
updated_at2022-06-23 02:33:41.953992
descriptionUserspace syscall intercepting library.
homepagehttps://github.com/madsys-dev/syscall-intercept-rs
repositoryhttps://github.com/madsys-dev/syscall-intercept-rs
max_upload_size
id611602
size649,546
Runji Wang (wangrunji0408)

documentation

README

syscall-intercept-rs

Crate Docs CI

A Rust wrapper of pmem/syscall_intercept, a system call intercepting library on x86_64 Linux.

Usage

Install dependencies:

sudo apt install cmake libcapstone-dev

Add the following lines to your Cargo.toml:

[dependencies]
syscall-intercept = "0.1"

Define your syscall hook function:

use syscall_intercept::*;

extern "C" fn hook(
    num: isize,
    a0: isize,
    a1: isize,
    a2: isize,
    a3: isize,
    a4: isize,
    a5: isize,
    result: &mut isize,
) -> InterceptResult {
    ...
}

Enable or disable interception:

unsafe { set_hook_fn(hook) };
unsafe { unset_hook_fn() };

Issue syscall without being intercepted:

let ret = unsafe { syscall_no_intercept(libc::SYS_exit as _, 0) };

License

MIT License

Commit count: 8

cargo fmt