Arrays
Explanation of the way to work with arrays in Frida
**** NOTE: BLOG MOVED TO https://cmrodriguez.me/ ****
Arrays are transformed in Frida from Javascript to Java transparently, so there is no special consideration, as shown in the following examples:
var intArray = [1, 2, 3];
console.log(ArrayType.sumArray(intArray));This example shows a transformation from a javascript Array to a Java array.
ArrayType.sumArray.overload("[I").implementation = function (arrayList) {
var total = 0;
for (var i = 0; i < arrayList.length; i++) {
total += arrayList[i];
}
console.log("Entra en arrayInt sumArray: " + total);
return total;
}This method receives an array in Java. When the Frida user writes the reimplementation function, they will receive a Javascript Array.
The forEach structure (used in Javascript) to iterate on an array does not work.
Whenever the following code is called:
var total = 0.0;
arrayList.forEach(function (element) { total += element; });the frida server generates an error:
Working with array of Objects is like working with native types, with the exception that a position in the Array can be null, so it must be taken in consideration when the script is being developed, as in the following example:
Last updated
Was this helpful?