@Nonnull private BuilderInstruction22c newBuilderInstruction22c(@Nonnull Instruction22c instruction) { return new BuilderInstruction22c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB(), convertReference(instruction.getReference())); }
@Override public Op create(MethodLocation location, TIntObjectMap<MethodLocation> addressToLocation, VirtualMachine vm) { MethodLocation child = Utils.getNextLocation(location, addressToLocation); Instruction22c instr = (Instruction22c) location.getInstruction(); int destRegister = instr.getRegisterA(); int instanceRegister = instr.getRegisterB(); FieldReference reference = (FieldReference) instr.getReference(); String fieldDescriptor = ReferenceUtil.getFieldDescriptor(reference); return new IGetOp(location, child, destRegister, instanceRegister, fieldDescriptor, vm); }
@Override public Op create(MethodLocation location, TIntObjectMap<MethodLocation> addressToLocation, VirtualMachine vm) { MethodLocation child = Utils.getNextLocation(location, addressToLocation); Instruction22c instr = (Instruction22c) location.getInstruction(); int valueRegister = instr.getRegisterA(); int instanceRegister = instr.getRegisterB(); FieldReference reference = (FieldReference) instr.getReference(); String fieldDescriptor = ReferenceUtil.getFieldDescriptor(reference); return new IPutOp(location, child, valueRegister, instanceRegister, fieldDescriptor, vm); }
@Override public Op create(MethodLocation location, TIntObjectMap<MethodLocation> addressToLocation, VirtualMachine vm) { MethodLocation child = Utils.getNextLocation(location, addressToLocation); Instruction22c instr = (Instruction22c) location.getInstruction(); int destRegister = instr.getRegisterA(); int arg1Register = instr.getRegisterB(); TypeReference typeReference = (TypeReference) instr.getReference(); VirtualType referenceType = vm.getClassManager().getVirtualType(typeReference); return new InstanceOfOp(location, child, destRegister, arg1Register, referenceType, vm); }
@Before public void setUp() { vm = mock(VirtualMachine.class); ectx = mock(ExecutionContext.class); mState = mock(MethodState.class); when(ectx.getMethodState()).thenReturn(mState); node = mock(ExecutionNode.class); itemB = mock(HeapItem.class); when(mState.readRegister(REGISTER_B)).thenReturn(itemB); setItem = ArgumentCaptor.forClass(HeapItem.class); location = mock(MethodLocation.class); instruction = mock(BuilderInstruction.class, withSettings().extraInterfaces(Instruction22c.class)); when(location.getInstruction()).thenReturn(instruction); when(location.getCodeAddress()).thenReturn(ADDRESS); when(instruction.getLocation()).thenReturn(location); when(instruction.getCodeUnits()).thenReturn(0); when(((Instruction22c) instruction).getRegisterA()).thenReturn(REGISTER_A); when(((Instruction22c) instruction).getRegisterB()).thenReturn(REGISTER_B); FieldReference fieldRef = new ImmutableFieldReference("Lsome/class;", "someMethod", "I"); when(((Instruction22c) instruction).getReference()).thenReturn(fieldRef); addressToLocation = new TIntObjectHashMap<MethodLocation>(); addressToLocation.put(ADDRESS, location); opFactory = new IGetOpFactory(); }
@Override public NewArrayOp create(MethodLocation location, TIntObjectMap<MethodLocation> addressToLocation, VirtualMachine vm) { MethodLocation child = Utils.getNextLocation(location, addressToLocation); Instruction22c instr = (Instruction22c) location.getInstruction(); int destRegister = instr.getRegisterA(); int sizeRegister = instr.getRegisterB(); String arrayType = ReferenceUtil.getReferenceString(instr.getReference()); return new NewArrayOp(location, child, destRegister, sizeRegister, arrayType, vm.getClassLoader()); }
@Before public void setUp() { vm = mock(VirtualMachine.class); ectx = mock(ExecutionContext.class); mState = mock(MethodState.class); when(ectx.getMethodState()).thenReturn(mState); node = mock(ExecutionNode.class); itemA = mock(HeapItem.class); when(mState.readRegister(REGISTER_A)).thenReturn(itemA); itemB = mock(HeapItem.class); when(mState.readRegister(REGISTER_B)).thenReturn(itemB); setItem = ArgumentCaptor.forClass(HeapItem.class); location = mock(MethodLocation.class); when(location.getCodeAddress()).thenReturn(ADDRESS); instruction = mock(BuilderInstruction.class, withSettings().extraInterfaces(Instruction22c.class)); when(location.getInstruction()).thenReturn(instruction); when(instruction.getLocation()).thenReturn(location); when(instruction.getCodeUnits()).thenReturn(0); when(((Instruction22c) instruction).getRegisterA()).thenReturn(REGISTER_A); when(((Instruction22c) instruction).getRegisterB()).thenReturn(REGISTER_B); FieldReference fieldRef = new ImmutableFieldReference("Lsome/class;", "someMethod", "I"); when(((Instruction22c) instruction).getReference()).thenReturn(fieldRef); addressToLocation = new TIntObjectHashMap<MethodLocation>(); addressToLocation.put(ADDRESS, location); opFactory = new IPutOpFactory(); }
@Override public void jimplify(DexBody body) { if (!(instruction instanceof Instruction22c)) { throw new IllegalArgumentException("Expected Instruction22c but got: " + instruction.getClass()); } Instruction22c newArray = (Instruction22c) instruction; int dest = newArray.getRegisterA(); Value size = body.getRegisterLocal(newArray.getRegisterB()); Type t = DexType.toSoot((TypeReference) newArray.getReference()); // NewArrayExpr needs the ElementType as it increases the array dimension by 1 Type arrayType = ((ArrayType) t).getElementType(); NewArrayExpr newArrayExpr = Jimple.v().newNewArrayExpr(arrayType, size); Local l = body.getRegisterLocal(dest); AssignStmt assign = Jimple.v().newAssignStmt(l, newArrayExpr); setUnit(assign); addTags(assign); body.add(assign); if (IDalvikTyper.ENABLE_DVKTYPER) { DalvikTyper.v().setType(newArrayExpr.getSizeBox(), IntType.v(), true); DalvikTyper.v().setType(assign.getLeftOpBox(), newArrayExpr.getType(), false); } }
AnalyzedInstruction branchInstruction = analyzedInstructions.get(nextAddress); int narrowingRegister = ((Instruction22c)prevAnalyzedInstruction.instruction).getRegisterB(); RegisterType originalType = analyzedInstruction.getPreInstructionRegisterType(narrowingRegister);
@Override public void jimplify(DexBody body) { Instruction22c i = (Instruction22c) instruction; int dest = i.getRegisterA(); int source = i.getRegisterB(); Type t = DexType.toSoot((TypeReference) (i.getReference())); InstanceOfExpr e = Jimple.v().newInstanceOfExpr(body.getRegisterLocal(source), t); AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), e); setUnit(assign); addTags(assign); body.add(assign); if (IDalvikTyper.ENABLE_DVKTYPER) { // DalvikTyper.v().? } }
@Nonnull private BuilderInstruction22c newBuilderInstruction22c(@Nonnull Instruction22c instruction) { return new BuilderInstruction22c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB(), instruction.getReference()); }
@Nonnull private BuilderInstruction22c newBuilderInstruction22c(@Nonnull Instruction22c instruction) { return new BuilderInstruction22c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB(), instruction.getReference()); }
@Nonnull private BuilderInstruction22c newBuilderInstruction22c(@Nonnull Instruction22c instruction) { return new BuilderInstruction22c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB(), instruction.getReference()); }
@Nonnull private BuilderInstruction22c newBuilderInstruction22c(@Nonnull Instruction22c instruction) { return new BuilderInstruction22c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB(), convertReference(instruction.getReference())); }
public static ImmutableInstruction22c of(Instruction22c instruction) { if (instruction instanceof ImmutableInstruction22c) { return (ImmutableInstruction22c)instruction; } return new ImmutableInstruction22c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB(), instruction.getReference()); }
public static ImmutableInstruction22c of(Instruction22c instruction) { if (instruction instanceof ImmutableInstruction22c) { return (ImmutableInstruction22c)instruction; } return new ImmutableInstruction22c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB(), instruction.getReference()); }
public void write(@Nonnull Instruction22c instruction) { try { writer.write(instruction.getOpcode().value); writer.write(packNibbles(instruction.getRegisterA(), instruction.getRegisterB())); writer.writeUshort(getReferenceIndex(instruction)); } catch (IOException ex) { throw new RuntimeException(ex); } }
public static ImmutableInstruction22c of(Instruction22c instruction) { if (instruction instanceof ImmutableInstruction22c) { return (ImmutableInstruction22c)instruction; } return new ImmutableInstruction22c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB(), instruction.getReference()); }
public void write(@Nonnull Instruction22c instruction) { try { writer.write(getOpcodeValue(instruction.getOpcode())); writer.write(packNibbles(instruction.getRegisterA(), instruction.getRegisterB())); writer.writeUshort(getReferenceIndex(instruction)); } catch (IOException ex) { throw new RuntimeException(ex); } }
public void write(@Nonnull Instruction22c instruction) { try { writer.write(getOpcodeValue(instruction.getOpcode())); writer.write(packNibbles(instruction.getRegisterA(), instruction.getRegisterB())); writer.writeUshort(getReferenceIndex(instruction)); } catch (IOException ex) { throw new RuntimeException(ex); } }