In this post I’ll show how to access the this reference. In Java (and a lot of other languages as well) there is always a special variable called this that references the object which is running the method. In Frida, whenever someone is rewriting a method, he has access to the “this” parameter. Check the following script as an example:
BasicTypes.addTwoInts.implementation = function (var1,var2) {
console.log("the method is being called");
return this.addTwoInts(var1,var2);
}
In this case the “this” references the class BasicTypes. So by calling the “this.addTwoInts” we are calling the original implementation of the method, instead of reimplementing it. This feature is useful for many use cases as:
In all these cases the idea is not to change the workflow of the methods, just trace or debug the functionality.
Next: Arrays