I have an android application into which I load a library and at some point I read a file. This is the code that is being used in the app.
FILE *fp = fopen(file_name, "r");
if (fp == NULL) {
return res;
}
Now I am attempting using Frida to hook that fopen
in order to force it to return null but I do not seem to be able to find out how.
The library that is included in the application is called libnative-lib.so
and my attempt in hooking fopen
includes the following code for frida
Module.enumerateExports("libnative-lib.so", {
onMatch: function(e) {
if(e.type == 'function') {
if(e.name == "fopen") {
console.log("Function recognized by name");
Interceptor.attach(e.address, {
onEnter: function(args) {
console.log("Interceptor attached onEnter...");
},
onLeave: function(retval){
console.log("Interceptor attached onLeave...");
}
});
}
}
},
onComplete: function() {}
});