1

I've this struct

public struct LatLng
{
    public double Latitude; // 0x0
    public double Longitude; // 0x8
}

I've this function

public LatLng get_Location()

How i can get latitude and longitude value in frida script

This is my code:

 Interceptor.attach(il2cpp.add(0x23CCCCC),{ 
    onEnter: function(args){            
    },
    onLeave: function(ret_val){             
        this.instance = ret_val;
        var pointer = this.instance.readPointer();
        var lat = pointer.add(0x0);
        console.log( "lat: "+lat.readDouble());
        var lng = pointer.add(0x8);
        console.log( "long: "+lng.readDouble());
    }
 });

Thanks!

Robert
  • 39,162
  • 17
  • 99
  • 152
  • Stackoverflow is a question & answer site. Unfortunately your post seems to miss a question so that makes it problem as I don't know what answer you expect. BTW your code looks good. I only don't understand the part where you use `this.instance` this seems unnecessary to me. – Robert Mar 22 '23 at 20:44
  • @Robert i want get Latitude and longitude but my code return wrong value, it not longitude or Latitude what i did wrong? – trongtd1988 Mar 23 '23 at 02:02
  • I think your main problem is that the function is defined as `public LatLng get_Location()` (return by value) but we both were thinking of `public LatLng* get_Location()` (return by reference). According by [this answer](https://stackoverflow.com/a/30272872/150978) it depends on the CPU architecture how such structs are returned (e.g. by using multiple registers). Not sure how frida handles such a return value. – Robert Mar 23 '23 at 08:07

0 Answers0