the first interceptor to 0x121f works without any problem
the native callback has been called successfully
the second interceptor to mtNativeCallback is NOT called. (???)
1 & 2 is good but 3 makes no sense because it should work.
Workaround
After investigating a lot with Frida, the following workaround works:
use a setImmediate to put the mtNativeFunction() call to the next event loop
Interceptor.attach(
sidecarModuleBaseAddress.add(0x121f),
{
- onEnter: args => mtNativeFunction(args[0])
+ onEnter: args => {
+ * Huan(202107):
+ * 1. We MUST use `setImmediate()` for calling `mtNativeFunction(arg0),
+ * or the hook to mtNativeCallback will not be triggered. (???)
+ * 2. `args` MUST be saved to arg0 so that it can be access in the `setImmediate`
+ */
+ const arg0 = args[0]
+ setImmediate(() => mtNativeFunction(arg0))
}
}
)
This week I ran into an issue that the
onEnter
has not been triggered with theInterceptor.attach()
.The following is the source code. It's quite straightforward:
NativeCallback
(mtNativeCallback
) then create aNativeFunction
(mtNativeFunction
) to call it.Interceptor.attach()
to address0x121f
, and invokemtNativeFunction
in itsonEnter
callback.Interceptor.attach()
to ptrmtNativeCallback
, and print SUCCEDD when it was invoked.However, the above code does not work:
0x121f
works without any problemmtNativeCallback
is NOT called. (???)1 & 2 is good but 3 makes no sense because it should work.
Workaround
After investigating a lot with Frida, the following workaround works:
setImmediate
to put themtNativeFunction()
call to the next event loopLink to frida#1774, Need to be investigated.