frida / frida-gum

Cross-platform instrumentation and introspection library written in C
https://frida.re
Other
753 stars 245 forks source link

Added fast interceptor implementation for x86/64 #685

Closed WorksButNotTested closed 1 year ago

WorksButNotTested commented 2 years ago

I've only implemented for x86_64 as that's all I need right now, but the back-end changes are actually pretty minimal, so wouldn't be tricky to add to other architectures at all. On other architectures, fast Interceptor replacements just fall back to the standard implementation.

I've not added any support for the gumjs bindings yet as again, I don't need right them now (and I had real trouble getting the HEAD to link properly with V8). But can't see it being too tricky. However, it might mean returning the NativePointer for the trampoline to the original function from the interceptor API (as fast interceptors don't support re-entrancy, so calling the original function from inside a hook will just result in an infinite loop). You'd probably want to change Interceptor.replace to do likewise for consistency.

I guess if you were using gumjs, you'd probably want to implement your hook using CModule as otherwise you add back in a lot of overhead anyways.

WorksButNotTested commented 1 year ago

It's no worries. Appreciate you were busy with the new release. Hopefully I've got the changes sorted.

WorksButNotTested commented 1 year ago

Awesome. Thanks for wrapping that up!