#hook #detours #microsoft #bindings #imports #sleep #created

detours-rs

Microsoft Detours FFI bindings created with bindgen

2 unstable releases

0.2.0 Jun 25, 2023
0.1.0 Jun 25, 2023

#9 in #imports

MIT/Apache

2.5MB
65K SLoC

C++ 62K SLoC // 0.0% comments Assembly 1.5K SLoC // 0.0% comments Visual Studio Project 604 SLoC Rust 520 SLoC Visual Studio Solution 43 SLoC C# 36 SLoC // 0.1% comments

crates.io version

detours-rs

Microsoft Detours Rust library bindings.

This is raw FFI and doesn't provide a nice wrapper, only some windows-rs imports.

DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)Sleep, SleepHook);
DetourTransactionCommit();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
let c_fn_ptr = Sleep as unsafe extern "C" fn(_) -> _ as *mut std::ffi::c_void;
DetourAttach(
    c_fn_ptr as *mut *mut c_void,
    sleep_hook as fn(_) -> _ as *mut c_void,
);
DetourTransactionCommit();
let start = Instant::now();
Sleep(10_000u32);
let duration = start.elapsed();
assert!(duration.as_secs() < 10_000);

Dependencies

~129MB
~2M SLoC