Crochet

This crate is a simple runtime hooking library based on detour and heavily inspired by skyline-rs (by heavily inspired I mean "I copied a lot from their awesome project so go check it out").

Installation

toml [dependencies] crochet = "0.1"

Usage

```rust use winapi::ctypes::cint; use winapi::shared::minwindef::{BOOL, DWORD, HINSTANCE, LPVOID, TRUE, UINT}; use winapi::shared::windef::HWND; use winapi::um::winnt::{DLLPROCESSATTACH, DLLPROCESS_DETACH, LPCWSTR};

[no_mangle]

[allow(nonsnakecase, unused_variables)]

extern "system" fn DllMain(dllmodule: HINSTANCE, callreason: DWORD, reserved: LPVOID) -> BOOL { match callreason { DLLPROCESSATTACH => { crochet::enable!(messageboxwhook).expect("Could not enable messageboxw hook") } DLLPROCESSDETACH => { crochet::disable!(messageboxw_hook).expect("Could not disable messageboxw hook") } _ => {} }

TRUE

}

[crochet::hook(compile_check, "user32.dll", "MessageBoxW")]

fn messageboxwhook(hwnd: HWND, _text: LPCWSTR, caption: LPCWSTR, utype: UINT) -> cint { let text = "Tu as fait mouche, Mouche !\0" .encodeutf16() .collect::>();

call_original!(hwnd, text.as_ptr(), caption, u_type)

} ```

License

MIT