darfink / detour-rs

A cross-platform detour library written in Rust
Other
406 stars 75 forks source link

How to set c function pointer to detour function. #18

Closed edsky closed 4 years ago

edsky commented 4 years ago

Test.set_detour(|val| val - 5); to Test.set_detour(c function pointer);?

darfink commented 4 years ago

Hi @edsky, I do not know whether you ever solved your problem or not, but for the sake of completeness I'll answer. I'd say your question is more related to the semantics of Rust rather than this library.

The most obvious alternative would be to merely forward the arguments of the closure to the C function:

Test.set_detour(|arg1, arg2| c_function(arg1, arg2));