frida hook overloads
同时hook多个重载的函数
function hookOverloads(className, func,check_index=0,check_text="",trace=false) {
var toHook;
Java.perform(()=>{
toHook = Java.use(className)[func];
var overloads = toHook.overloads;
var overloadCount = overloads.length;
for (var i = 0; i < overloadCount; i++) {
toHook.overloads[i].implementation = function () {
let check_arg=arguments[check_index]
if(check_arg.indexOf(check_text)>-1){
if(trace){
printStack();
}
console.log("========")
let s = ""
let l = Array.from(arguments)
for(let l_i=0;l_i<l.length;l_i++){
s+="args"+[l_i]+": "+l[l_i]+", ";
}
console.log(className+"."+func+" is Call: Args "+s);
console.log("========")
}
var retval = this[func].apply(this, arguments);
return retval;
}
}
})
}