[Soot-list] How to add extra control statement on certain statements?

Jihao Liu nudt.liujihao at gmail.com
Sun Jan 14 19:28:21 EST 2018


 Hello, everyone.
          These days, I have been trying to add extra condition statements
into Android apps by Soot. However, I encountered some problems.
           Here is the example.
           long[] res = getNaturalEvnCtxs();
           long time = res[0];
           long seconds = res[1];
           if (time == 0 && time  > seconds)    //The original condition
  {
                   // add my if() statement {
                    boolean flag=fun1();
    if(flag){
                    System.exit(0);
                    }
                  // }  my condition statement
   }
          smsManager.sendTextMessage("223456", null, imei, null, null);

          To further control the execution of   "System.exit(0);", I want
to add another condition statement controlling it.

           My code is as follows:

          Unit unit = oldif; // original condition statement, namely  if
(time == 0 && time  > seconds)              IfStmt tt=(IfStmt) unit;
           List<Type> parameter=new ArrayList<Type>();
           List<Unit> beforegenerated = new ArrayList<Unit>();
   parameter.add(RefType.v("java.lang.String"));
   SootMethod fun = sootClass.getMethod("fun1",
parameter);
   StaticInvokeExpr test = Jimple.v().newStaticInvokeExpr(
fun.makeRef(), StringConstant.v(s11));
   Local beforestr=generateNewLocal(body,BooleanType.v());
   Unit astmt1 = Jimple.v().newAssignStmt(beforestr, test);    //generate
flag local
           beforegenerated.add(astmt1);

           EqExpr test=Jimple.v().newEqExpr(beforestr, IntConstant.v(0));
   IfStmt newifstmt = Jimple.v().newIfStmt(test,ttt.getTarget());
   beforegenerated.add(newifstmt);
   body.getUnits().insertAfter(beforegenerated,tt.getTarget());


           However, I failed to add the condition. Does anyone know the
questions about my code? I appreciate any suggestions or code?
            Thanks a lot.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20180114/235cd516/attachment.html>


More information about the Soot-list mailing list