@Nonnull private BuilderInstruction35c newBuilderInstruction35c(@Nonnull Instruction35c instruction) { return new BuilderInstruction35c( instruction.getOpcode(), instruction.getRegisterCount(), instruction.getRegisterC(), instruction.getRegisterD(), instruction.getRegisterE(), instruction.getRegisterF(), instruction.getRegisterG(), convertReference(instruction.getReference())); }
void peepStringInit() { List<Integer> peepAddresses = addresses.stream().filter(this::canPeepStringInit).collect(Collectors.toList()); if (0 == peepAddresses.size()) { return; } madeChanges = true; peepCount += peepAddresses.size(); Collections.sort(peepAddresses, Collections.reverseOrder()); for (int address : peepAddresses) { BuilderInstruction original = manipulator.getInstruction(address); Instruction35c instr = (Instruction35c) original; int instanceRegister = instr.getRegisterC(); HeapItem item = manipulator.getRegisterConsensus(address, instanceRegister); BuilderInstruction replacement = ConstantBuilder.buildConstant(item.getValue(), item.getUnboxedType(), instanceRegister, manipulator.getDexBuilder()); if (log.isDebugEnabled()) { log.debug("Peeping string init @{} {}", address, manipulator.getOp(address)); } manipulator.replaceInstruction(address, replacement); } }
private static int[] buildRegisters35c(Instruction35c instruction) { int registerCount = instruction.getRegisterCount(); int[] registers = new int[registerCount]; switch (registerCount) { case 5: registers[4] = instruction.getRegisterG(); case 4: registers[3] = instruction.getRegisterF(); case 3: registers[2] = instruction.getRegisterE(); case 2: registers[1] = instruction.getRegisterD(); case 1: registers[0] = instruction.getRegisterC(); break; } return registers; }
/** * Check if register is referenced by this instruction. * */ private boolean isRegisterUsed(int register) { Instruction35c i = (Instruction35c) instruction; return register == i.getRegisterD() || register == i.getRegisterE() || register == i.getRegisterF() || register == i.getRegisterG() || register == i.getRegisterC(); }
private void analyzeInvokeDirectEmpty(@Nonnull AnalyzedInstruction analyzedInstruction, boolean analyzeResult) { Instruction35c instruction = (Instruction35c)analyzedInstruction.instruction; Instruction35c deodexedInstruction = new ImmutableInstruction35c(Opcode.INVOKE_DIRECT, instruction.getRegisterCount(), instruction.getRegisterC(), instruction.getRegisterD(), instruction.getRegisterE(), instruction.getRegisterF(), instruction.getRegisterG(), instruction.getReference()); analyzedInstruction.setDeodexedInstruction(deodexedInstruction); if (analyzeResult) { analyzeInstruction(analyzedInstruction); } }
boolean canPeepStringInit(int address) { BuilderInstruction original = manipulator.getInstruction(address); if (original.getOpcode() != Opcode.INVOKE_DIRECT) { return false; } Instruction35c instr = (Instruction35c) original; MethodReference methodReference = (MethodReference) instr.getReference(); String methodDescriptor = ReferenceUtil.getMethodDescriptor(methodReference); if (!methodDescriptor.startsWith("Ljava/lang/String;-><init>(")) { return false; } int instanceRegister = instr.getRegisterC(); HeapItem item = manipulator.getRegisterConsensus(address, instanceRegister); if (!(item.getValue() instanceof String)) { return false; } return true; }
private boolean analyzeInvokeVirtual(@Nonnull AnalyzedInstruction analyzedInstruction, boolean isRange) { MethodReference targetMethod; if (!normalizeVirtualMethods) { return true; } if (isRange) { Instruction3rc instruction = (Instruction3rc)analyzedInstruction.instruction; targetMethod = (MethodReference)instruction.getReference(); } else { Instruction35c instruction = (Instruction35c)analyzedInstruction.instruction; targetMethod = (MethodReference)instruction.getReference(); } MethodReference replacementMethod = normalizeMethodReference(targetMethod); if (replacementMethod == null || replacementMethod.equals(targetMethod)) { return true; } Instruction deodexedInstruction; if (isRange) { Instruction3rc instruction = (Instruction3rc)analyzedInstruction.instruction; deodexedInstruction = new ImmutableInstruction3rc(instruction.getOpcode(), instruction.getStartRegister(), instruction.getRegisterCount(), replacementMethod); } else { Instruction35c instruction = (Instruction35c)analyzedInstruction.instruction; deodexedInstruction = new ImmutableInstruction35c(instruction.getOpcode(), instruction.getRegisterCount(), instruction.getRegisterC(), instruction.getRegisterD(), instruction.getRegisterE(), instruction.getRegisterF(), instruction.getRegisterG(), replacementMethod); } analyzedInstruction.setDeodexedInstruction(deodexedInstruction); return true; }
when(instruction.getLocation()).thenReturn(location); when(instruction.getCodeUnits()).thenReturn(0); when(((Instruction35c) instruction).getRegisterC()).thenReturn(REGISTER_C); when(((Instruction35c) instruction).getRegisterD()).thenReturn(REGISTER_D); when(((Instruction35c) instruction).getRegisterE()).thenReturn(REGISTER_E);
int[] regs = { filledNewArrayInstr.getRegisterC(), filledNewArrayInstr.getRegisterD(), filledNewArrayInstr.getRegisterE(), filledNewArrayInstr.getRegisterF(), filledNewArrayInstr.getRegisterG(), };
dimensionRegisters[1] = instr.getRegisterD(); case 1: dimensionRegisters[0] = instr.getRegisterC(); break; default:
@Nonnull private BuilderInstruction35c newBuilderInstruction35c(@Nonnull Instruction35c instruction) { return new BuilderInstruction35c( instruction.getOpcode(), instruction.getRegisterCount(), instruction.getRegisterC(), instruction.getRegisterD(), instruction.getRegisterE(), instruction.getRegisterF(), instruction.getRegisterG(), instruction.getReference()); }
public int getRegisterC() { return instruction.getRegisterC(); }
@Nonnull private BuilderInstruction35c newBuilderInstruction35c(@Nonnull Instruction35c instruction) { return new BuilderInstruction35c( instruction.getOpcode(), instruction.getRegisterCount(), instruction.getRegisterC(), instruction.getRegisterD(), instruction.getRegisterE(), instruction.getRegisterF(), instruction.getRegisterG(), instruction.getReference()); }
@Nonnull private BuilderInstruction35c newBuilderInstruction35c(@Nonnull Instruction35c instruction) { return new BuilderInstruction35c( instruction.getOpcode(), instruction.getRegisterCount(), instruction.getRegisterC(), instruction.getRegisterD(), instruction.getRegisterE(), instruction.getRegisterF(), instruction.getRegisterG(), instruction.getReference()); }
@Nonnull private BuilderInstruction35c newBuilderInstruction35c(@Nonnull Instruction35c instruction) { return new BuilderInstruction35c( instruction.getOpcode(), instruction.getRegisterCount(), instruction.getRegisterC(), instruction.getRegisterD(), instruction.getRegisterE(), instruction.getRegisterF(), instruction.getRegisterG(), convertReference(instruction.getReference())); }
private void analyzeInvokeDirectEmpty(@Nonnull AnalyzedInstruction analyzedInstruction, boolean analyzeResult) { Instruction35c instruction = (Instruction35c)analyzedInstruction.instruction; Instruction35c deodexedInstruction = new ImmutableInstruction35c(Opcode.INVOKE_DIRECT, instruction.getRegisterCount(), instruction.getRegisterC(), instruction.getRegisterD(), instruction.getRegisterE(), instruction.getRegisterF(), instruction.getRegisterG(), instruction.getReference()); analyzedInstruction.setDeodexedInstruction(deodexedInstruction); if (analyzeResult) { analyzeInstruction(analyzedInstruction); } }
private void analyzeInvokeDirectEmpty(@Nonnull AnalyzedInstruction analyzedInstruction, boolean analyzeResult) { Instruction35c instruction = (Instruction35c)analyzedInstruction.instruction; Instruction35c deodexedInstruction = new ImmutableInstruction35c(Opcode.INVOKE_DIRECT, instruction.getRegisterCount(), instruction.getRegisterC(), instruction.getRegisterD(), instruction.getRegisterE(), instruction.getRegisterF(), instruction.getRegisterG(), instruction.getReference()); analyzedInstruction.setDeodexedInstruction(deodexedInstruction); if (analyzeResult) { analyzeInstruction(analyzedInstruction); } }
public void write(@Nonnull Instruction35c instruction) { try { writer.write(instruction.getOpcode().value); writer.write(packNibbles(instruction.getRegisterG(), instruction.getRegisterCount())); writer.writeUshort(getReferenceIndex(instruction)); writer.write(packNibbles(instruction.getRegisterC(), instruction.getRegisterD())); writer.write(packNibbles(instruction.getRegisterE(), instruction.getRegisterF())); } catch (IOException ex) { throw new RuntimeException(ex); } }
public void write(@Nonnull Instruction35c instruction) { try { writer.write(getOpcodeValue(instruction.getOpcode())); writer.write(packNibbles(instruction.getRegisterG(), instruction.getRegisterCount())); writer.writeUshort(getReferenceIndex(instruction)); writer.write(packNibbles(instruction.getRegisterC(), instruction.getRegisterD())); writer.write(packNibbles(instruction.getRegisterE(), instruction.getRegisterF())); } catch (IOException ex) { throw new RuntimeException(ex); } }
public void write(@Nonnull Instruction35c instruction) { try { writer.write(getOpcodeValue(instruction.getOpcode())); writer.write(packNibbles(instruction.getRegisterG(), instruction.getRegisterCount())); writer.writeUshort(getReferenceIndex(instruction)); writer.write(packNibbles(instruction.getRegisterC(), instruction.getRegisterD())); writer.write(packNibbles(instruction.getRegisterE(), instruction.getRegisterF())); } catch (IOException ex) { throw new RuntimeException(ex); } }