[Soot-list] Obtaining the JimpleLocal from a ValueBox

Andrew Santosa santosa_1999 at yahoo.com
Wed Sep 30 04:06:15 EDT 2015


Given invkExpr of type InvokeExprBox is the invocation expression of the special invocation statement,
we can obtain the list of use boxes within the expression in the following way:
List<ValueBox> boxesList = invkExpr.getValue().getUseBoxes();
One of the boxes in boxesList should be the local that you want.
Best,
Andrew
 


     On Wednesday, 30 September 2015, 10:38, Jason Ott <jott002 at ucr.edu> wrote:
   

 I have the following Jimple:
 public boolean getFlashlightEnabled()    {        com.android.server.lights.LightsService$1 r0;        int i0;        java.io.FileInputStream $r1, r3; // I'm interested in this        java.lang.Exception $r2;        boolean $z0;        r0 := @this: com.android.server.lights.LightsService$1;     label1:        $r1 = new java.io.FileInputStream;        specialinvoke $r1.<java.io.FileInputStream: void <init>(java.lang.String)>("/sys/class/leds/spotlight/brightness");  // But my interest in $r1 and r3 are predicated upon this        r3 = $r1;        i0 = virtualinvoke r3.<java.io.FileInputStream: int read()>();        virtualinvoke r3.<java.io.FileInputStream: void close()>();        if i0 == 48 goto label2;        $z0 = 1;        goto label3;     label2:        $z0 = 0;     label3:        return $z0;     label4:        $r2 := @caughtexception;        return 0;        catch java.lang.Exception from label1 to label3 with label4;    }
You can see that I am interested in the variable that, in some way or another, uses the "/sys/class/leds/spotlight/brightness" string.  Thus, I am interested in the variable $r1.  But I don't know that I'm interested in $r1 until I see that $r1 is using the string that I am interested.
Now I know that $r1 is a local, more specifically a LinkedRValueBox.  I know that the string, "/sys/class/..." is an ImmediateBox, which is leveraged in an InvokeExprBox (specialinvoke $r1...).  What I cannot seem to manage to figure out is how to derive the Local $r1 variable from either the InvokeExprBox or the ImmediateBox.  Neither of them have any formal link to $r1 (a Local) other than by parsing the string representation of them and then going through the Locals looking for what you want.
So my question is: Is there a way to get the Local from the InvokeExprBox or the ImmediateBox in this case, or the general case?  I can only get ValueBoxes from anything which is of ValueBox, as defined by the ValueBox interface.
Thanks.
_______________________________________________
Soot-list mailing list
Soot-list at CS.McGill.CA
https://mailman.CS.McGill.CA/mailman/listinfo/soot-list


  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20150930/3055fbaf/attachment.html 


More information about the Soot-list mailing list