Skip to content

Commit

Permalink
Improve test to nest two Interceptor hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmacete committed Apr 8, 2024
1 parent 947bb39 commit 7f8d23f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tests/test-host-session.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2140,11 +2140,11 @@ namespace Frida.HostSessionTest {
meth.implementation = ObjC.implement(meth, function (handle, selector, url) {
return origImpl(handle, selector, NULL);
});
Interceptor.attach(Module.getExportByName(null, "abort"), function () {
Interceptor.attach(Module.getExportByName(null, 'abort'), function () {
send('abort');
Thread.sleep(1);
});
Interceptor.attach(Module.getExportByName(null, "__exit"), function (args) {
Interceptor.attach(Module.getExportByName(null, '__exit'), function (args) {
send(`exit(${args[0].toUInt32()})`);
Thread.sleep(1);
});
Expand Down Expand Up @@ -2193,17 +2193,24 @@ namespace Frida.HostSessionTest {

var session = yield device.attach (process.id);
var script = yield session.create_script ("""
const meth = ObjC.classes.NSBundle['- initWithURL:'];
const { NSBundle } = ObjC.classes;
const meth = NSBundle['+ bundleWithURL:'];
const methInner = NSBundle['- initWithURL:'];
Interceptor.attach(meth.implementation, {
onEnter(args) {
args[2] = NULL;
}
});
Interceptor.attach(Module.getExportByName(null, "abort"), function () {
Interceptor.attach(methInner.implementation, {
onEnter(args) {
args[2] = NULL;
}
});
Interceptor.attach(Module.getExportByName(null, 'abort'), function () {
send('abort');
Thread.sleep(1);
});
Interceptor.attach(Module.getExportByName(null, "__exit"), function (args) {
Interceptor.attach(Module.getExportByName(null, '__exit'), function (args) {
send(`exit(${args[0].toUInt32()})`);
Thread.sleep(1);
});
Expand Down

0 comments on commit 7f8d23f

Please sign in to comment.