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").
toml
[dependencies]
crochet = "0.2"
```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};
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
}
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)
} ```
MIT