Skip to content

Commit

Permalink
Adjusted CallRemover: when call in an assignment is removed, replace …
Browse files Browse the repository at this point in the history
…result by null
  • Loading branch information
palant committed Aug 27, 2021
1 parent 552fbb6 commit 6049a74
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/info/palant/apkInstrumentation/CallRemover.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import soot.Body;
import soot.BodyTransformer;
import soot.SootMethod;
import soot.jimple.AssignStmt;
import soot.jimple.NullConstant;

public class CallRemover extends BodyTransformer
{
Expand Down Expand Up @@ -40,7 +42,15 @@ protected void internalTransform(Body body, String phaseName, Map<String, String

body.getUnits().removeIf(unit -> {
SootMethod method = UnitParser.getInvocationMethod(unit);
return method != null && this.methodConfig.get(method) != null;
if (method != null && this.methodConfig.get(method) != null)
{
AssignStmt assignment = UnitParser.getAssignment(unit);
if (assignment != null)
assignment.setRightOp(NullConstant.v());
else
return true;
}
return false;
});

body.validate();
Expand Down

0 comments on commit 6049a74

Please sign in to comment.