2

I have a target.java:

static void main(){
    int a = 0;

    a++;
    a++;
    return 0;
}

I want to use soot to insert a command so that target.java can output the following sentence "a is = 2" (I do not need the same code format as followed):

static void main(){
    int a = 0;

    a++;
    a++;
    System.out.println("a is = " + a + "\n");
    return 0;
}

Anyone knows how to do it?
I know some things about soot is that I should make an expression first then I should find the last position of main method then I convert the expression into a statement finally I should add the statement into the byte code.

InvokeExpr reportExpr = Jimple.v().newStaticInvokeExpr(//something here);
Stmt reportStmt = Jimple.v().newInvokeStmt(reportExpr);
units.insertBefore(reportStmt, stmt);

What should I put inside the newStaticInvokeExpr()?

sflee
  • 1,485
  • 4
  • 26
  • 50

0 Answers0