You can compile your crate as a shared object library by setting the crate-type to
crate-type = ["cdylib"]
When it gets compiled, you should then get a
target/release/libfoo.so if compiling with optimisations).
From there you'll need to set
LD_PRELOAD, and make sure your library exports (see the
#[no_mangle] attribute) the desired functions.
See the reference and edition guide for more. You may also want to look at The Reference's FFI Chapter for tips on writing FFI code in Rust, if you've never done this before.