Hpmason / retour-utils

Other
4 stars 2 forks source link

Macro for hooking impl blocks #7

Open Hpmason opened 1 year ago

Hpmason commented 1 year ago

When hooking libraries with C++ code, it can be helpful to organize hooks inside an impl block, which can make use of Self

struct FfiType;

#[hook_impl("Foo.dll")]
impl FfiType {
    #[hook(extern "C" BarHook, offset = 0xDEAD)]
    fn bar(this: *mut Self) {}
    #[hook(extern "C" CtorHook, offset = 0xBEEF)]
    fn new() -> *mut Self {}
}