use of soot.jimple.AssignStmt in project soot by Sable.
the class FilledNewArrayRangeInstruction method jimplify.
@Override
public void jimplify(DexBody body) {
if (!(instruction instanceof Instruction3rc))
throw new IllegalArgumentException("Expected Instruction3rc but got: " + instruction.getClass());
Instruction3rc filledNewArrayInstr = (Instruction3rc) instruction;
// NopStmt nopStmtBeginning = Jimple.v().newNopStmt();
// body.add(nopStmtBeginning);
int usedRegister = filledNewArrayInstr.getRegisterCount();
Type t = DexType.toSoot((TypeReference) filledNewArrayInstr.getReference());
// NewArrayExpr needs the ElementType as it increases the array dimension by 1
Type arrayType = ((ArrayType) t).getElementType();
NewArrayExpr arrayExpr = Jimple.v().newNewArrayExpr(arrayType, IntConstant.v(usedRegister));
Local arrayLocal = body.getStoreResultLocal();
AssignStmt assignStmt = Jimple.v().newAssignStmt(arrayLocal, arrayExpr);
body.add(assignStmt);
for (int i = 0; i < usedRegister; i++) {
ArrayRef arrayRef = Jimple.v().newArrayRef(arrayLocal, IntConstant.v(i));
AssignStmt assign = Jimple.v().newAssignStmt(arrayRef, body.getRegisterLocal(i + filledNewArrayInstr.getStartRegister()));
addTags(assign);
body.add(assign);
}
// NopStmt nopStmtEnd = Jimple.v().newNopStmt();
// body.add(nopStmtEnd);
// defineBlock(nopStmtBeginning,nopStmtEnd);
setUnit(assignStmt);
if (IDalvikTyper.ENABLE_DVKTYPER) {
// Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assignStmt);
DalvikTyper.v().setType(assignStmt.getLeftOpBox(), arrayExpr.getType(), false);
// DalvikTyper.v().addConstraint(assignStmt.getLeftOpBox(), assignStmt.getRightOpBox());
}
}
use of soot.jimple.AssignStmt in project soot by Sable.
the class IgetInstruction method jimplify.
@Override
public void jimplify(DexBody body) {
TwoRegisterInstruction i = (TwoRegisterInstruction) instruction;
int dest = i.getRegisterA();
int object = i.getRegisterB();
FieldReference f = (FieldReference) ((ReferenceInstruction) instruction).getReference();
final Jimple jimple = Jimple.v();
InstanceFieldRef r = jimple.newInstanceFieldRef(body.getRegisterLocal(object), getSootFieldRef(f));
AssignStmt assign = jimple.newAssignStmt(body.getRegisterLocal(dest), r);
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
DalvikTyper.v().setType(assign.getLeftOpBox(), r.getType(), false);
}
}
use of soot.jimple.AssignStmt in project soot by Sable.
the class FillArrayDataInstruction method jimplify.
@Override
public void jimplify(DexBody body) {
if (!(instruction instanceof Instruction31t))
throw new IllegalArgumentException("Expected Instruction31t but got: " + instruction.getClass());
Instruction31t fillArrayInstr = (Instruction31t) instruction;
int destRegister = fillArrayInstr.getRegisterA();
int offset = fillArrayInstr.getCodeOffset();
int targetAddress = codeAddress + offset;
Instruction referenceTable = body.instructionAtAddress(targetAddress).instruction;
if (!(referenceTable instanceof ArrayPayload)) {
throw new RuntimeException("Address " + targetAddress + "refers to an invalid PseudoInstruction.");
}
ArrayPayload arrayTable = (ArrayPayload) referenceTable;
// NopStmt nopStmtBeginning = Jimple.v().newNopStmt();
// body.add(nopStmtBeginning);
Local arrayReference = body.getRegisterLocal(destRegister);
List<Number> elements = arrayTable.getArrayElements();
int numElements = elements.size();
Stmt firstAssign = null;
for (int i = 0; i < numElements; i++) {
ArrayRef arrayRef = Jimple.v().newArrayRef(arrayReference, IntConstant.v(i));
NumericConstant element = getArrayElement(elements.get(i), body, destRegister);
if (// array was not defined -> element type can not be found (obfuscated bytecode?)
element == null)
break;
AssignStmt assign = Jimple.v().newAssignStmt(arrayRef, element);
addTags(assign);
body.add(assign);
if (i == 0) {
firstAssign = assign;
}
}
if (firstAssign == null) {
// if numElements == 0. Is it possible?
firstAssign = Jimple.v().newNopStmt();
body.add(firstAssign);
}
// NopStmt nopStmtEnd = Jimple.v().newNopStmt();
// body.add(nopStmtEnd);
// defineBlock(nopStmtBeginning, nopStmtEnd);
setUnit(firstAssign);
}
use of soot.jimple.AssignStmt in project soot by Sable.
the class MoveInstruction method jimplify.
@Override
public void jimplify(DexBody body) {
TwoRegisterInstruction i = (TwoRegisterInstruction) instruction;
int dest = i.getRegisterA();
int source = i.getRegisterB();
AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), body.getRegisterLocal(source));
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
DalvikTyper.v().addConstraint(assign.getLeftOpBox(), assign.getRightOpBox());
}
}
use of soot.jimple.AssignStmt in project soot by Sable.
the class SgetInstruction method jimplify.
@Override
public void jimplify(DexBody body) {
int dest = ((OneRegisterInstruction) instruction).getRegisterA();
FieldReference f = (FieldReference) ((ReferenceInstruction) instruction).getReference();
StaticFieldRef r = Jimple.v().newStaticFieldRef(getStaticSootFieldRef(f));
AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), r);
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
DalvikTyper.v().setType(assign.getLeftOpBox(), r.getType(), false);
}
}
Aggregations