DexLabel getLabel(String name) { DexLabel dexLabel = labelMap.get(name); if (dexLabel == null) { dexLabel = new DexLabel(); labelMap.put(name, dexLabel); } return dexLabel; }
private static void order(Map<Integer, DexLabel> labelsMap, int offset) { if (!labelsMap.containsKey(offset)) { labelsMap.put(offset, new DexLabel(offset)); } }
@Override public void visitFillArrayDataStmt(Op op, int ra, Object array) { DexLabel dx = new DexLabel(); dx.displayName = "L" + nextLabelNumber++; usedLabel.add(dx); out.s("%s %s, %s", op.displayName, reg(ra), xLabel(dx)); appendLast.add(new AbstractMap.SimpleEntry<DexLabel, Object>(dx, array)); }
@Override public Object visitFprologue(SmaliParser.FprologueContext ctx) { if (dexDebugVisitor != null) { DexLabel dexLabel = new DexLabel(); scv.visitLabel(dexLabel); dexDebugVisitor.visitPrologue(dexLabel); } return null; }
@Override public Object visitFepiogue(SmaliParser.FepiogueContext ctx) { if (dexDebugVisitor != null) { DexLabel dexLabel = new DexLabel(); scv.visitLabel(dexLabel); dexDebugVisitor.visitEpiogue(dexLabel); } return null; } };
@Override public Object visitFrestart(SmaliParser.FrestartContext ctx) { if (dexDebugVisitor != null) { DexLabel dexLabel = new DexLabel(); scv.visitLabel(dexLabel); int reg = m.pareReg(ctx.r.getText()); dexDebugVisitor.visitRestartLocal(reg, dexLabel); } return null; }
@Override public Object visitFend(SmaliParser.FendContext ctx) { if (dexDebugVisitor != null) { DexLabel dexLabel = new DexLabel(); scv.visitLabel(dexLabel); int reg = m.pareReg(ctx.r.getText()); dexDebugVisitor.visitEndLocal(reg, dexLabel); } return null; }
@Override public Object visitFline(SmaliParser.FlineContext ctx) { if (dexDebugVisitor != null) { DexLabel dexLabel = new DexLabel(); scv.visitLabel(dexLabel); dexDebugVisitor.visitLineNumber(Utils.parseInt(ctx.line.getText()), dexLabel); } return null; }
@Override public void visitPackedSwitchStmt(Op op, int ra, int first_case, DexLabel[] labels) { DexLabel dx = new DexLabel(); dx.displayName = "L" + nextLabelNumber++; usedLabel.add(dx); out.s(op.displayName + " " + reg(ra) + ", " + xLabel(dx)); appendLast.add(new AbstractMap.SimpleEntry<DexLabel, Object>(dx, new PackedSwitchStmt(first_case, labels))); }
@Override public void visitSparseSwitchStmt(Op op, int ra, int[] cases, DexLabel[] labels) { DexLabel dx = new DexLabel(); dx.displayName = "L" + nextLabelNumber++; usedLabel.add(dx); out.s(op.displayName + " " + reg(ra) + ", " + xLabel(dx)); appendLast.add(new AbstractMap.SimpleEntry<DexLabel, Object>(dx, new SparseSwitchStmt(cases, labels))); }
DexLabel n = needChange.get(index); if (n == null) { n = new DexLabel(); needChange.put(index, n); DexLabelStmtNode dexStmtNode = new DexLabelStmtNode(n);
@Override public Object visitFlocal(SmaliParser.FlocalContext ctx) { if (dexDebugVisitor != null) { DexLabel dexLabel = new DexLabel(); scv.visitLabel(dexLabel); int reg = m.pareReg(ctx.r.getText()); String name; String type; if (ctx.v1 != null) { Field fld = parseFieldAndUnescape("Lt;", ctx.v1.getText()); name = fld.getName(); type = fld.getType(); } else if (ctx.v2 != null) { String txt = ctx.v2.getText(); int i = findString(txt, 1, txt.length(), '\"'); name = unescapeStr(txt.substring(0, i + 1)); type = unEscapeId(txt.substring(i + 2)); } else { if (ctx.name2 != null) { name = unescapeStr(ctx.name2.getText()); } else { name = unEscapeId(ctx.name1.getText()); } type = unEscapeId(ctx.type.getText()); } String sig = ctx.sig == null ? null : unescapeStr(ctx.sig.getText()); dexDebugVisitor.visitStartLocal(reg, dexLabel, name, type, sig); } return null; }
DexLabel label = strMap.get(key); if (label == null) { label = new DexLabel(); strMap.put(key, label);
public static void a(DexClassVisitor cv) { DexMethodVisitor mv = cv.visitMethod(ACC_PUBLIC | ACC_STATIC, new Method("La;", "b", new String[] {}, "V")); DexCodeVisitor code = mv.visitCode(); code.visitRegister(2); DexLabel L0 = new DexLabel(); DexLabel L1 = new DexLabel(); DexLabel L2 = new DexLabel(); code.visitTryCatch(L0, L1, new DexLabel[] { L2 }, new String[] { "Lsome/Exception;" }); code.visitLabel(L0); code.visitConstStmt(CONST_STRING, 0, "abc"); code.visitLabel(L1); code.visitMethodStmt(INVOKE_VIRTUAL, new int[] { 0 }, new Method("Ljava/lang/String;", "toString", new String[] {}, "Ljava/lang/String;")); code.visitStmt0R(RETURN_VOID); code.visitLabel(L2); code.visitStmt1R(MOVE_EXCEPTION, 1); code.visitMethodStmt(INVOKE_VIRTUAL, new int[] { 1 }, new Method("Ljava/lang/String;", "toString", new String[] {}, "Ljava/lang/String;")); code.visitStmt0R(RETURN_VOID); code.visitEnd(); mv.visitEnd(); }
@Test public static void i63(DexClassVisitor cv) { DexMethodVisitor mv = cv.visitMethod(ACC_STATIC, new Method("La;", "b", new String[] {}, "V")); if (mv != null) { DexCodeVisitor code = mv.visitCode(); if (code != null) { code.visitRegister(1); DexLabel L1 = new DexLabel(); DexLabel L2 = new DexLabel(); code.visitLabel(L1); code.visitFieldStmt(Op.SGET, 0, -1, new Field("La;", "f", "J")); code.visitLabel(L2); code.visitStmt0R(Op.RETURN_VOID); code.visitEnd(); code.visitTryCatch(L1, L2, new DexLabel[] { L2 }, new String[] { "La;" }); } mv.visitEnd(); } } }
@Test public static void merge1(DexClassVisitor cv) {// obj = array DexMethodVisitor mv = cv.visitMethod(ACC_PUBLIC | ACC_STATIC, new Method("La;", "b", new String[] {}, "V")); DexCodeVisitor code = mv.visitCode(); DexLabel L0 = new DexLabel(); DexLabel L1 = new DexLabel(); code.visitRegister(3); code.visitConstStmt(CONST, 0, 0); code.visitJumpStmt(GOTO, -1, -1, L1); code.visitLabel(L0); code.visitStmt2R(ARRAY_LENGTH, 1, 0); code.visitConstStmt(CONST, 1, 0); code.visitStmt3R(AGET, 2, 0, 1); code.visitStmt0R(RETURN_VOID); code.visitLabel(L1); code.visitConstStmt(CONST, 1, 1); code.visitTypeStmt(NEW_ARRAY, 0, 1, "[Ljava/security/cert/X509Certificate;"); code.visitJumpStmt(GOTO, -1, -1, L0); code.visitEnd(); mv.visitEnd(); } }
code.visitRegister(6); DexLabel L8 = new DexLabel(); DexLabel L9 = new DexLabel(); DexLabel L10 = new DexLabel(); DexLabel L0 = new DexLabel(); DexLabel L1 = new DexLabel(); DexLabel L2 = new DexLabel(); code.visitTryCatch(L0, L1, new DexLabel[] { L2 }, new String[] { "Lorg/json/JSONException;" }); DexLabel L3 = new DexLabel(); DexLabel L4 = new DexLabel(); code.visitTryCatch(L3, L4, new DexLabel[] { L2 }, new String[] { "Lorg/json/JSONException;" }); DexLabel L5 = new DexLabel(); DexLabel L6 = new DexLabel(); code.visitTryCatch(L5, L6, new DexLabel[] { L2 }, new String[] { "Lorg/json/JSONException;" });