Hpmason / retour-rs

A cross-platform detour library written in Rust
Other
99 stars 18 forks source link

Hooking issue on Windows #11

Closed vars1ty closed 1 year ago

vars1ty commented 1 year ago

Whenever I try and hook into a function from Windows, it returns an error as seen in the picture. image

However, if I try and hook it through wine on Linux, it works just fine. I've checked if the parameters, addresses etc are all correct, and they are.

Hpmason commented 1 year ago

It's hard to tell the issue from just this error message.

How are you determining the address? (by symbol name or offset) What's the function signature of the function you're trying to hook? And does it use a different calling convention than the normal C ABI? (If it's from C++, you may need to specify it as extern "win64")

I'm actually working on a project that had a similar error, and come to find out that I was injecting the dll before the library I was trying to hook was loaded. I don't know about your case, but is it possible you're running into a similar issue?

vars1ty commented 1 year ago

I managed to fix it, I forgot to use the base-address + offset and instead relied on a hard-coded address that wasn't found on Windows xd. Thanks for your help though!