@Nonnull private BuilderInstruction21c newBuilderInstruction21c(@Nonnull Instruction21c instruction) { return new BuilderInstruction21c( instruction.getOpcode(), instruction.getRegisterA(), convertReference(instruction.getReference())); }
/** * Return the source register for this instruction. */ private int sourceRegister() { // I hate smali's API .. if (instruction instanceof Instruction23x) { return ((Instruction23x) instruction).getRegisterA(); } else if (instruction instanceof Instruction22c) { return ((Instruction22c) instruction).getRegisterA(); } else if (instruction instanceof Instruction21c) { return ((Instruction21c) instruction).getRegisterA(); } else { throw new RuntimeException("Instruction is not a instance, array or static op"); } }
@Override public Op create(MethodLocation location, TIntObjectMap<MethodLocation> addressToLocation, VirtualMachine vm) { MethodLocation child = Utils.getNextLocation(location, addressToLocation); Instruction21c instr = (Instruction21c) location.getInstruction(); int destRegister = instr.getRegisterA(); TypeReference typeRef = (TypeReference) instr.getReference(); String className = typeRef.getType(); VirtualClass virtualClass = vm.getClassManager().getVirtualClass(className); return new NewInstanceOp(location, child, destRegister, virtualClass, vm); }
@Override public Op create(MethodLocation location, TIntObjectMap<MethodLocation> addressToLocation, VirtualMachine vm) { MethodLocation child = Utils.getNextLocation(location, addressToLocation); Instruction21c instr = (Instruction21c) location.getInstruction(); int targetRegister = instr.getRegisterA(); TypeReference reference = (TypeReference) instr.getReference(); VirtualType referenceType = vm.getClassManager().getVirtualType(reference); return new CheckCastOp(location, child, targetRegister, referenceType, vm.getClassManager(), vm.getExceptionFactory()); }
@Override public void jimplify(DexBody body) { if (!(instruction instanceof Instruction21c)) { throw new IllegalArgumentException("Expected Instruction21c but got: " + instruction.getClass()); } Instruction21c checkCastInstr = (Instruction21c) instruction; Local castValue = body.getRegisterLocal(checkCastInstr.getRegisterA()); Type checkCastType = DexType.toSoot((TypeReference) checkCastInstr.getReference()); CastExpr castExpr = Jimple.v().newCastExpr(castValue, checkCastType); // generate "x = (Type) x" // splitter will take care of the rest AssignStmt assign = Jimple.v().newAssignStmt(castValue, castExpr); setUnit(assign); addTags(assign); body.add(assign); if (IDalvikTyper.ENABLE_DVKTYPER) { DalvikTyper.v().setType(assign.getLeftOpBox(), checkCastType, false); } }
@Override public Op create(MethodLocation location, TIntObjectMap<MethodLocation> addressToLocation, VirtualMachine vm) { MethodLocation child = Utils.getNextLocation(location, addressToLocation); Instruction21c instr = (Instruction21c) location.getInstruction(); int destRegister = instr.getRegisterA(); FieldReference fieldReference = (FieldReference) instr.getReference(); VirtualClass fieldClass = vm.getClassManager().getVirtualClass(fieldReference.getDefiningClass()); VirtualField actualField = fieldClass.getField(fieldReference.getName()); return new SGetOp(location, child, destRegister, fieldReference, actualField, vm); }
@Override public Op create(MethodLocation location, TIntObjectMap<MethodLocation> addressToLocation, VirtualMachine vm) { MethodLocation child = Utils.getNextLocation(location, addressToLocation); Instruction21c instr = (Instruction21c) location.getInstruction(); int destRegister = instr.getRegisterA(); FieldReference fieldReference = (FieldReference) instr.getReference(); VirtualClass fieldClass = vm.getClassManager().getVirtualClass(fieldReference.getDefiningClass()); VirtualField actualField = fieldClass.getField(fieldReference.getName()); return new SPutOp(location, child, destRegister, fieldReference, actualField, vm); }
@Override public void jimplify(DexBody body) { Instruction21c i = (Instruction21c) instruction; int dest = i.getRegisterA(); String className = dottedClassName(((TypeReference) (i.getReference())).toString()); RefType type = RefType.v(className); NewExpr n = Jimple.v().newNewExpr(type); AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), n); setUnit(assign); addTags(assign); body.add(assign); if (IDalvikTyper.ENABLE_DVKTYPER) { // DalvikTyper.v().captureAssign((JAssignStmt)assign, op); // TODO: ref. type may be null! DalvikTyper.v().setType(assign.getLeftOpBox(), type, false); } }
public int getRegisterA() { return instruction.getRegisterA(); } }
public int getRegisterA() { return instruction.getRegisterA(); } }
@Nonnull private BuilderInstruction21c newBuilderInstruction21c(@Nonnull Instruction21c instruction) { return new BuilderInstruction21c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getReference()); }
@Nonnull private BuilderInstruction21c newBuilderInstruction21c(@Nonnull Instruction21c instruction) { return new BuilderInstruction21c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getReference()); }
@Nonnull private BuilderInstruction21c newBuilderInstruction21c(@Nonnull Instruction21c instruction) { return new BuilderInstruction21c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getReference()); }
@Nonnull private BuilderInstruction21c newBuilderInstruction21c(@Nonnull Instruction21c instruction) { return new BuilderInstruction21c( instruction.getOpcode(), instruction.getRegisterA(), convertReference(instruction.getReference())); }
public void write(@Nonnull Instruction21c instruction) { try { writer.write(instruction.getOpcode().value); writer.write(instruction.getRegisterA()); writer.writeUshort(getReferenceIndex(instruction)); } catch (IOException ex) { throw new RuntimeException(ex); } }
public static ImmutableInstruction21c of(Instruction21c instruction) { if (instruction instanceof ImmutableInstruction21c) { return (ImmutableInstruction21c)instruction; } return new ImmutableInstruction21c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getReference()); }
public static ImmutableInstruction21c of(Instruction21c instruction) { if (instruction instanceof ImmutableInstruction21c) { return (ImmutableInstruction21c)instruction; } return new ImmutableInstruction21c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getReference()); }
public static ImmutableInstruction21c of(Instruction21c instruction) { if (instruction instanceof ImmutableInstruction21c) { return (ImmutableInstruction21c)instruction; } return new ImmutableInstruction21c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getReference()); }
public void write(@Nonnull Instruction21c instruction) { try { writer.write(getOpcodeValue(instruction.getOpcode())); writer.write(instruction.getRegisterA()); writer.writeUshort(getReferenceIndex(instruction)); } catch (IOException ex) { throw new RuntimeException(ex); } }
public void write(@Nonnull Instruction21c instruction) { try { writer.write(getOpcodeValue(instruction.getOpcode())); writer.write(instruction.getRegisterA()); writer.writeUshort(getReferenceIndex(instruction)); } catch (IOException ex) { throw new RuntimeException(ex); } }