org.jf.dexlib2.builder.BuilderInstruction Java Examples
The following examples show how to use
org.jf.dexlib2.builder.BuilderInstruction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StmtVisitor.java From JAADAS with GNU General Public License v3.0 | 6 votes |
public List<BuilderInstruction> getRealInsns(LabelAssigner labelAssigner) { List<BuilderInstruction> finalInsns = new ArrayList<BuilderInstruction>(); for (Insn i : insns) { if (i instanceof AddressInsn) { continue; // skip non-insns } BuilderInstruction realInsn = i.getRealInsn(labelAssigner); finalInsns.add(realInsn); if (insnStmtMap.containsKey(i)) { // get tags instructionInsnMap.put(realInsn, i); } if (insnRegisterMap.containsKey(i)) { instructionRegisterMap.put(realInsn, insnRegisterMap.get(i)); } if (i instanceof SwitchPayload) instructionPayloadMap.put(realInsn, (SwitchPayload) i); } return finalInsns; }
Example #2
Source File: PatchMethodTool.java From atlas with Apache License 2.0 | 5 votes |
private static MethodImplementation modifyMethodTpatch(@Nonnull MethodImplementation implementation, Method method) { MutableMethodImplementation mutableImplementation = new MutableMethodImplementation(implementation); System.out.println(mutableImplementation.getRegisterCount()); List<BuilderInstruction> instructions = mutableImplementation.getInstructions(); boolean isModified = false; for (int i = 0; i < instructions.size(); i++) { isModified = false; if (instructions.get(i).getOpcode() == Opcode.INVOKE_DIRECT) { if (!isModified) { mutableImplementation.addInstruction(i++, new BuilderInstruction21c(Opcode.CONST_STRING, 0, new ImmutableStringReference("tpatch:" + method.getDefiningClass().replace("/", ".")))); mutableImplementation.addInstruction(i++, new BuilderInstruction35c(Opcode.INVOKE_STATIC, 1, 0, 0, 0, 0, 0, new ImmutableMethodReference("Landroid/util/Log;", "e", Lists.newArrayList("Ljava/lang/String;", "Ljava/lang/String;"), "I"))); isModified = true; break; } } // mutableImplementation.addInstruction(instructions.get(i)); } return mutableImplementation; }
Example #3
Source File: PatchMethodTool.java From atlas with Apache License 2.0 | 5 votes |
private static MethodImplementation modifyMethodAndFix(@Nonnull MethodImplementation implementation, Method method) { MutableMethodImplementation mutableImplementation = new MutableMethodImplementation(implementation); System.out.println(mutableImplementation.getRegisterCount()); List<BuilderInstruction> instructions = mutableImplementation.getInstructions(); mutableImplementation.addInstruction(0, new BuilderInstruction21c(Opcode.CONST_STRING, 0, new ImmutableStringReference("AndFix:" + method.getDefiningClass().replace("/", ".")))); mutableImplementation.addInstruction(1, new BuilderInstruction35c(Opcode.INVOKE_STATIC, 1, 0, 0, 0, 0, 0, new ImmutableMethodReference("Landroid/util/Log;", "e", Lists.newArrayList("Ljava/lang/String;", "Ljava/lang/String;"), "I"))); return mutableImplementation; }
Example #4
Source File: DexPrinter.java From JAADAS with GNU General Public License v3.0 | 5 votes |
private int getDistanceBetween(List<BuilderInstruction> instructions, int i, int j) { if (i == j) return 0; int dist = 0; for (int idx = Math.min(i, j); idx < Math.max(i, j); idx++) { BuilderInstruction bi = instructions.get(idx); dist += (bi.getFormat().size / 2); } return dist; }
Example #5
Source File: AbstractInsn.java From JAADAS with GNU General Public License v3.0 | 5 votes |
@Override public BuilderInstruction getRealInsn(LabelAssigner assigner) { if (hasIncompatibleRegs()) { throw new RuntimeException("the instruction still has incompatible registers: " + getIncompatibleRegs()); } return getRealInsn0(assigner); }
Example #6
Source File: SparseSwitchPayload.java From JAADAS with GNU General Public License v3.0 | 5 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { List<SwitchLabelElement> elements = new ArrayList<SwitchLabelElement>(); for (int i = 0; i < keys.length; i++) elements.add(new SwitchLabelElement(keys[i], assigner.getOrCreateLabel((Stmt) targets.get(i)))); return new BuilderSparseSwitchPayload(elements); }
Example #7
Source File: PackedSwitchPayload.java From JAADAS with GNU General Public License v3.0 | 5 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { List<Label> elements = new ArrayList<Label>(); for (int i = 0; i < targets.size(); i++) elements.add(assigner.getOrCreateLabel((Stmt) targets.get(i))); return new BuilderPackedSwitchPayload(firstKey, elements); }
Example #8
Source File: Insn35c.java From JAADAS with GNU General Public License v3.0 | 5 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { int[] realRegNumbers = getRealRegNumbers(); byte regDNumber = (byte) realRegNumbers[REG_D_IDX]; byte regENumber = (byte) realRegNumbers[REG_E_IDX]; byte regFNumber = (byte) realRegNumbers[REG_F_IDX]; byte regGNumber = (byte) realRegNumbers[REG_G_IDX]; byte regANumber = (byte) realRegNumbers[REG_A_IDX]; return new BuilderInstruction35c(opc, regCount, regDNumber, regENumber, regFNumber, regGNumber, regANumber, referencedItem); }
Example #9
Source File: Insn23x.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction23x(opc, (short) getRegA().getNumber(), (short) getRegB().getNumber(), (short) getRegC().getNumber()); }
Example #10
Source File: Insn30t.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction30t(opc, assigner.getOrCreateLabel(target)); }
Example #11
Source File: Insn22x.java From JAADAS with GNU General Public License v3.0 | 4 votes |
protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction22x(opc, (short) getRegA().getNumber(), getRegB().getNumber()); }
Example #12
Source File: Insn22c.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction22c(opc, getRegA().getNumber(), getRegB().getNumber(), referencedItem); }
Example #13
Source File: Insn32x.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction32x(opc, getRegA().getNumber(), getRegB().getNumber()); }
Example #14
Source File: Insn31t.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction31t(opc, (short) getRegA().getNumber(), assigner.getOrCreateLabel(payload)); }
Example #15
Source File: Insn10t.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { if (target == null) throw new RuntimeException("Cannot jump to a NULL target"); return new BuilderInstruction10t(opc, assigner.getOrCreateLabel(target)); }
Example #16
Source File: Insn10x.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction10x(opc); }
Example #17
Source File: Insn21s.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction21s(opc, (short) getRegA().getNumber(), getLitB()); }
Example #18
Source File: Insn31i.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction31i(opc, (short) getRegA().getNumber(), getLitB()); }
Example #19
Source File: Insn22s.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction22s(opc, (byte) getRegA().getNumber(), (byte) getRegB().getNumber(), getLitC()); }
Example #20
Source File: Insn22b.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction22b(opc, (short) getRegA().getNumber(), (short) getRegB().getNumber(), getLitC()); }
Example #21
Source File: Insn11n.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction11n(opc, (byte) getRegA().getNumber(), getLitB()); }
Example #22
Source File: Insn21c.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction21c(opc, (short) getRegA().getNumber(), referencedItem); }
Example #23
Source File: Insn20t.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction20t(opc, assigner.getOrCreateLabel(target)); }
Example #24
Source File: Insn22t.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction22t(opc, (byte) getRegA().getNumber(), (byte) getRegB().getNumber(), assigner.getOrCreateLabel(target)); }
Example #25
Source File: Insn51l.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction51l(opc, (short) getRegA().getNumber(), getLitB()); }
Example #26
Source File: Insn3rc.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { Register startReg = regs.get(0); return new BuilderInstruction3rc(opc, startReg.getNumber(), regCount, referencedItem); }
Example #27
Source File: Insn12x.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction12x(opc, (byte) getRegA().getNumber(), (byte) getRegB().getNumber()); }
Example #28
Source File: Insn21t.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction21t(opc, (short) getRegA().getNumber(), assigner.getOrCreateLabel(target)); }
Example #29
Source File: Insn11x.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction11x(opc, (short) getRegA().getNumber()); }
Example #30
Source File: AddressInsn.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return null; }