Skip to main content
added 1 character in body
Source Link
alx
  • 13
  • 3

Let's assume we have a such code snippet:

public class Test {
  public void testArrayValue() {
    Object[] objects = new Object[1];
    fillObject(objects);
    Log.d("test", (String)objects[0]);
  }
  public void fillObject(Object[] objects) {
    objects[0] = new String("fillObject str");
  }
}

How to hook the fillObject method to change the value of the first element in array passed to method?

Java.perform(function () {
    var clazz = Java.use("com.some.package.Test");
    clazz.fillObject.overload('[Ljava.lang.Object;').implementation = function(var_0) {
        
      // this won't work :( assigning a string value to var0[0]var_0[0] 
      // does not pass it outside the hooked code
      // 
      var stringClass = Java.use("java.lang.String");
      var stringInstance = stringClass.$new("Hello World");
      var_0[0] = stringInstance
    };
});

The output of running hooked code will be "fillObject str", and not "Hello World"

Let's assume we have a such code snippet:

public class Test {
  public void testArrayValue() {
    Object[] objects = new Object[1];
    fillObject(objects);
    Log.d("test", (String)objects[0]);
  }
  public void fillObject(Object[] objects) {
    objects[0] = new String("fillObject str");
  }
}

How to hook the fillObject method to change the value of the first element in array passed to method?

Java.perform(function () {
    var clazz = Java.use("com.some.package.Test");
    clazz.fillObject.overload('[Ljava.lang.Object;').implementation = function(var_0) {
        
      // this won't work :( assigning a string value to var0[0] 
      // does not pass it outside the hooked code
      // 
      var stringClass = Java.use("java.lang.String");
      var stringInstance = stringClass.$new("Hello World");
      var_0[0] = stringInstance
    };
});

The output of running hooked code will be "fillObject str", and not "Hello World"

Let's assume we have a such code snippet:

public class Test {
  public void testArrayValue() {
    Object[] objects = new Object[1];
    fillObject(objects);
    Log.d("test", (String)objects[0]);
  }
  public void fillObject(Object[] objects) {
    objects[0] = new String("fillObject str");
  }
}

How to hook the fillObject method to change the value of the first element in array passed to method?

Java.perform(function () {
    var clazz = Java.use("com.some.package.Test");
    clazz.fillObject.overload('[Ljava.lang.Object;').implementation = function(var_0) {
        
      // this won't work :( assigning a string value to var_0[0] 
      // does not pass it outside the hooked code
      // 
      var stringClass = Java.use("java.lang.String");
      var stringInstance = stringClass.$new("Hello World");
      var_0[0] = stringInstance
    };
});

The output of running hooked code will be "fillObject str", and not "Hello World"

added 99 characters in body
Source Link
alx
  • 13
  • 3

Let's assume we have a such code snippet:

public class Test {
  public void testArrayValue() {
    Object[] objects = new Object[1];
    fillObject(objects);
    Log.d("test", (String)objects[0]);
  }
  public void fillObject(Object[] objects) {
    objects[0] = new String("fillObject str");
  }
}

How to hook the fillObject method to change the value of the first element in array passed to method?

Java.perform(function () {
    var clazz = Java.use("com.some.package.Test");
    clazz.fillObject.overload('[Ljava.lang.Object;').implementation = function(var_0) {
        
      // this won't work :( assigning a string value to var0[0] 
      // does not pass it outside the hooked code
      // 
      var stringClass = Java.use("java.lang.String");
      var stringInstance = stringClass.$new("Hello World");
      var_0[0] = stringInstance
    };
});
 

The output of running hooked code will be "fillObject str", and not "Hello World"

Let's assume we have a such code snippet:

public class Test {
  public void testArrayValue() {
    Object[] objects = new Object[1];
    fillObject(objects);
    Log.d("test", (String)objects[0]);
  }
  public void fillObject(Object[] objects) {
    objects[0] = new String("fillObject str");
  }
}

How to hook the fillObject method to change the value of the first element in array passed to method?

Java.perform(function () {
    var clazz = Java.use("com.some.package.Test");
    clazz.fillObject.overload('[Ljava.lang.Object;').implementation = function(var_0) {
        
      // this won't work :(
      var stringClass = Java.use("java.lang.String");
      var stringInstance = stringClass.$new("Hello World");
      var_0[0] = stringInstance
    };
});
 

Let's assume we have a such code snippet:

public class Test {
  public void testArrayValue() {
    Object[] objects = new Object[1];
    fillObject(objects);
    Log.d("test", (String)objects[0]);
  }
  public void fillObject(Object[] objects) {
    objects[0] = new String("fillObject str");
  }
}

How to hook the fillObject method to change the value of the first element in array passed to method?

Java.perform(function () {
    var clazz = Java.use("com.some.package.Test");
    clazz.fillObject.overload('[Ljava.lang.Object;').implementation = function(var_0) {
        
      // this won't work :( assigning a string value to var0[0] 
      // does not pass it outside the hooked code
      // 
      var stringClass = Java.use("java.lang.String");
      var stringInstance = stringClass.$new("Hello World");
      var_0[0] = stringInstance
    };
});

The output of running hooked code will be "fillObject str", and not "Hello World"

edited body
Source Link
alx
  • 13
  • 3

Let's assume we have a such code snippet:

public class Test {
  public void testArrayValue() {
    Object[] objects = new Object[1];
    fillObject(objects);
    Log.d("test", (String)objects[0]);
  }
  public void fillObject(Object[] objects) {
    objects[0] = new String("fillObject str");
  }
}

How to hook the fillObject method to updatechange the value of the first element in array passed to method?

Java.perform(function () {
    var clazz = Java.use("com.some.package.Test");
    clazz.fillObject.overload('[Ljava.lang.Object;').implementation = function(var_0) {
        
      // this won't work :(
      var stringClass = Java.use("java.lang.String");
      var stringInstance = stringClass.$new("Hello World");
      var_0[0] = stringInstance
    };
});

Let's assume we have a such code snippet:

public class Test {
  public void testArrayValue() {
    Object[] objects = new Object[1];
    fillObject(objects);
    Log.d("test", (String)objects[0]);
  }
  public void fillObject(Object[] objects) {
    objects[0] = new String("fillObject str");
  }
}

How to hook the fillObject method to update the value of the first element in array passed to method?

Java.perform(function () {
    var clazz = Java.use("com.some.package.Test");
    clazz.fillObject.overload('[Ljava.lang.Object;').implementation = function(var_0) {
        
      // this won't work :(
      var stringClass = Java.use("java.lang.String");
      var stringInstance = stringClass.$new("Hello World");
      var_0[0] = stringInstance
    };
});

Let's assume we have a such code snippet:

public class Test {
  public void testArrayValue() {
    Object[] objects = new Object[1];
    fillObject(objects);
    Log.d("test", (String)objects[0]);
  }
  public void fillObject(Object[] objects) {
    objects[0] = new String("fillObject str");
  }
}

How to hook the fillObject method to change the value of the first element in array passed to method?

Java.perform(function () {
    var clazz = Java.use("com.some.package.Test");
    clazz.fillObject.overload('[Ljava.lang.Object;').implementation = function(var_0) {
        
      // this won't work :(
      var stringClass = Java.use("java.lang.String");
      var stringInstance = stringClass.$new("Hello World");
      var_0[0] = stringInstance
    };
});

edited title
Link
alx
  • 13
  • 3
Loading
deleted 3 characters in body
Source Link
alx
  • 13
  • 3
Loading
Source Link
alx
  • 13
  • 3
Loading