private InsnNode fillArray(DecodedInstruction insn) { DecodedInstruction payload = insnArr[insn.getTarget()]; return new FillArrayNode(insn.getA(), (FillArrayDataPayloadDecodedInstruction) payload); }
private int getMoveResultRegister(DecodedInstruction[] insnArr, int offset) { int nextOffset = getNextInsnOffset(insnArr, offset); if (nextOffset >= 0) { DecodedInstruction next = insnArr[nextOffset]; int opc = next.getOpcode(); if (opc == Opcodes.MOVE_RESULT || opc == Opcodes.MOVE_RESULT_WIDE || opc == Opcodes.MOVE_RESULT_OBJECT) { return next.getA(); } } return -1; }
public static int getArg(DecodedInstruction insn, int arg) { switch (arg) { case 0: return insn.getA(); case 1: return insn.getB(); case 2: return insn.getC(); case 3: return insn.getD(); case 4: return insn.getE(); default: throw new JadxRuntimeException("Wrong argument number: " + arg); } }
public InvokeNode(MethodInfo mth, DecodedInstruction insn, InvokeType type, boolean isRange, int resReg) { super(InsnType.INVOKE, mth.getArgsCount() + (type != InvokeType.STATIC ? 1 : 0)); this.mth = mth; this.type = type; if (resReg >= 0) { setResult(InsnArg.reg(resReg, mth.getReturnType())); } int k = isRange ? insn.getA() : 0; if (type != InvokeType.STATIC) { int r = isRange ? k : InsnUtils.getArg(insn, k); addReg(r, mth.getDeclClass().getType()); k++; } for (ArgType arg : mth.getArgumentsTypes()) { addReg(isRange ? k : InsnUtils.getArg(insn, k), arg); k += arg.getRegCount(); } }
private InsnNode filledNewArray(DecodedInstruction insn, int offset, boolean isRange) { int resReg = getMoveResultRegister(insnArr, offset); ArgType arrType = dex.getType(insn.getIndex()); ArgType elType = arrType.getArrayElement(); boolean typeImmutable = elType.isPrimitive(); int regsCount = insn.getRegisterCount(); InsnArg[] regs = new InsnArg[regsCount]; if (isRange) { int r = insn.getA(); for (int i = 0; i < regsCount; i++) { regs[i] = InsnArg.reg(r, elType, typeImmutable); r++; } } else { for (int i = 0; i < regsCount; i++) { int regNum = InsnUtils.getArg(insn, i); regs[i] = InsnArg.reg(regNum, elType, typeImmutable); } } InsnNode node = new FilledNewArrayNode(elType, regs.length); node.setResult(resReg == -1 ? null : InsnArg.reg(resReg, arrType)); for (InsnArg arg : regs) { node.addArg(arg); } return node; }
/** * Gets the A register number, as a code unit. This will throw if the * value is out of the range of an unsigned code unit. */ public final short getAUnit() { int a = getA(); if ((a & ~0xffff) != 0) { throw new DexException("Register A out of range: " + Hex.u8(a)); } return (short) a; }
/** * Gets the A register number, as a nibble. This will throw if the * value is out of the range of an unsigned nibble. */ public final short getANibble() { int a = getA(); if ((a & ~0xf) != 0) { throw new DexException("Register A out of range: " + Hex.u8(a)); } return (short) a; }
@Override public void encode(DecodedInstruction insn, CodeOutput out) { out.write( codeUnit(insn.getOpcodeUnit(), makeByte(insn.getA(), insn.getB()))); } },
@Override public void encode(DecodedInstruction insn, CodeOutput out) { // See above. int opcode = insn.getOpcode(); int shift = (opcode == Opcodes.CONST_HIGH16) ? 16 : 48; short literal = (short) (insn.getLiteral() >> shift); out.write(codeUnit(opcode, insn.getA()), literal); } },
@Override public void encode(DecodedInstruction insn, CodeOutput out) { int index = insn.getIndex(); out.write( codeUnit(insn.getOpcode(), insn.getA()), unit0(index), unit1(index)); } },
@Override public void encode(DecodedInstruction insn, CodeOutput out) { out.write( codeUnit(insn.getOpcodeUnit(), makeByte(insn.getA(), insn.getLiteralNibble()))); } },
@Override public void encode(DecodedInstruction insn, CodeOutput out) { int index = insn.getIndex(); out.write( codeUnit(insn.getOpcode(), insn.getA()), unit0(index), unit1(index)); } },
@Override public void encode(DecodedInstruction insn, CodeOutput out) { out.write( codeUnit(insn.getOpcodeUnit(), makeByte(insn.getA(), insn.getB()))); } },
@Override public void encode(DecodedInstruction insn, CodeOutput out) { out.write( codeUnit(insn.getOpcodeUnit(), makeByte(insn.getA(), insn.getLiteralNibble()))); } },
@Override public void encode(DecodedInstruction insn, CodeOutput out) { short relativeTarget = insn.getTargetUnit(out.cursor()); out.write(codeUnit(insn.getOpcode(), insn.getA()), relativeTarget); } },
@Override public void encode(DecodedInstruction insn, CodeOutput out) { out.write( codeUnit(insn.getOpcode(), makeByte(insn.getA(), insn.getB())), insn.getIndexUnit()); } },
@Override public void encode(DecodedInstruction insn, CodeOutput out) { out.write( codeUnit(insn.getOpcode(), insn.getA()), codeUnit(insn.getB(), insn.getC())); } },
@Override public void encode(DecodedInstruction insn, CodeOutput out) { int relativeTarget = insn.getTarget(out.cursor()); out.write( codeUnit(insn.getOpcode(), insn.getA()), unit0(relativeTarget), unit1(relativeTarget)); } },
@Override public void encode(DecodedInstruction insn, CodeOutput out) { short relativeTarget = insn.getTargetUnit(out.cursor()); out.write( codeUnit(insn.getOpcode(), makeByte(insn.getA(), insn.getB())), relativeTarget); } },
@Override public void encode(DecodedInstruction insn, CodeOutput out) { short relativeTarget = insn.getTargetUnit(out.cursor()); out.write( codeUnit(insn.getOpcode(), makeByte(insn.getA(), insn.getB())), relativeTarget); } },