[Soot-list] How to insert IfStmt before an existing stmt and How to modify a method definition?

Steven Arzt Steven.Arzt at cased.de
Wed Aug 6 10:39:09 EDT 2014


Hi Jin,

 

If you want to change the parameter list of an existing method, you can use SootMethod.setParameterTypes(). For changing the return type, there is SootMethod.setReturnType(). Note that you still need to use the callgraph to identify all call sites and change the corresponding invocations. Beware not to change methods that implement abstract supertype methods or interface methods since you’ll otherwise break the class.

 

Best regards,

  Steven

 

Von: soot-list-bounces at CS.McGill.CA [mailto:soot-list-bounces at CS.McGill.CA] Im Auftrag von Jin Li
Gesendet: Mittwoch, 6. August 2014 16:31
An: Steven Arzt
Cc: soot-list at CS.McGill.CA
Betreff: Re: [Soot-list] How to insert IfStmt before an existing stmt and How to modify a method definition?

 

Hi Steven,

Thanks for your tutorials. But my second question remains. 

If I want to modify the definition of an existing method, e.g. 

  before:   public void A(int, init)
  after:     public int  A(int,init,boolean,boolean)

I want to change the parameters and return values of a method. (add another parameter or change the type of the return value) 

Now I create a new method public int  B(int,init,boolean,boolean) , and replace all the original call to B.

How to change the original definition directly?

Best Regards,

Jin





 

2014-08-04 17:00 GMT+08:00 Steven Arzt <Steven.Arzt at cased.de>:

Hi Jin,

 

Have you looked into our Android instrumentation tutorial we gave at RV’2013 and CCS’2013? Most of the stuff we explain there also applies to normal Java programs. You can find the tutorial here: http://sseblog.ec-spride.de/tutorials/

 

Best regards,

  Steven

 

Von: soot-list-bounces at CS.McGill.CA [mailto:soot-list-bounces at CS.McGill.CA] Im Auftrag von Jin Li
Gesendet: Montag, 4. August 2014 04:40
An: soot-list at CS.McGill.CA
Betreff: [Soot-list] How to insert IfStmt before an existing stmt and How to modify a method definition?

 

Hi All,

I searched the soot tutorials, but I didn't find answers to my questions.

1, I want to insert IfStmt before an existing Stmt. e.g.:
  

  before: 
   

    virtualinvoke r6.<java.io.OutputStream: void write(byte[]),int,int>(r2,0,$i0);

after:

    if  local ==1 goto label 0;

    goto label1;

  label0: 

    staticinvoke ...

 label1:
    virtualinvoke r6.<java.io.OutputStream: void write(byte[]),int,int>(r2,0,$i0);

2, I want to modify a method definition. e.g.
   

  before:   public void A(int, init)

  after:     public int  A(int,init,boolean,boolean)

Any suggestions and code snippets are welcome! 

Thank you.  Looking forward your suggestions!

Best regards,

Jin

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20140806/5309ef7a/attachment-0001.html 


More information about the Soot-list mailing list