i hooked the native function dlopen in libc.so,and i want to use it.i find i need to new a nativefunction and set the arguments type like this:
but the console gives me an error that :
invalid argument value at /[5] what should i do ? can someone help me ?
You can use Module.load
https://frida.re/docs/javascript-api/#module-load
If you want to inject a module instead of another module you can do something like this
Interceptor.attach(Module.findExportByName(null, "dlopen"), {
onEnter: function(args) {
if ( args[0].readUtf8String().includes(excludeModuleName) ) {
Module.load('/data/local/tmp/custom.so');
// now we need to fail the original dlopen
// we can do something like this.. or replace the return value..
// maybe later i'll edit with a better solution ;)
args[0].writeUtf8String('...');
}
}
});
To answer your question in comment
how do i start my function in the so injected by frida?is there some methods?
Module.load('/data/local/tmp/a');
var func_ptr = Module.findExportByName('a', 'function_name');
// wrap with NativeFunction(pointer, return_value, [list_of_arguments])
// lets assume your function gets a string and an int
// function_name(string a1, int a2)
var f = new NativeFunction(func_ptr, 'pointer', ['pointer', 'int']);
// invoking the fuction
f(Memory.allocUtf8String("abcd"), 3);