Search in sources :

Example 21 with InsnNode

use of jadx.core.dex.nodes.InsnNode in project jadx by skylot.

the class TryCatchBlock method removeWholeBlock.

private void removeWholeBlock(MethodNode mth) {
    // self destruction
    for (Iterator<ExceptionHandler> it = handlers.iterator(); it.hasNext(); ) {
        ExceptionHandler h = it.next();
        unbindHandler(h);
        it.remove();
    }
    for (InsnNode insn : insns) {
        insn.removeAttr(attr);
    }
    insns.clear();
    if (mth.getBasicBlocks() != null) {
        for (BlockNode block : mth.getBasicBlocks()) {
            block.removeAttr(attr);
        }
    }
}
Also used : BlockNode(jadx.core.dex.nodes.BlockNode) InsnNode(jadx.core.dex.nodes.InsnNode)

Example 22 with InsnNode

use of jadx.core.dex.nodes.InsnNode in project jadx by skylot.

the class CodeShrinker method simplifyMoveInsns.

private static void simplifyMoveInsns(BlockNode block) {
    List<InsnNode> insns = block.getInstructions();
    int size = insns.size();
    for (int i = 0; i < size; i++) {
        InsnNode insn = insns.get(i);
        if (insn.getType() == InsnType.MOVE) {
            // replace 'move' with wrapped insn
            InsnArg arg = insn.getArg(0);
            if (arg.isInsnWrap()) {
                InsnNode wrapInsn = ((InsnWrapArg) arg).getWrapInsn();
                wrapInsn.setResult(insn.getResult());
                wrapInsn.copyAttributesFrom(insn);
                wrapInsn.setOffset(insn.getOffset());
                wrapInsn.remove(AFlag.WRAPPED);
                block.getInstructions().set(i, wrapInsn);
            }
        }
    }
}
Also used : InsnNode(jadx.core.dex.nodes.InsnNode) InsnArg(jadx.core.dex.instructions.args.InsnArg) InsnWrapArg(jadx.core.dex.instructions.args.InsnWrapArg)

Example 23 with InsnNode

use of jadx.core.dex.nodes.InsnNode in project jadx by skylot.

the class InsnArg method wrapInstruction.

public InsnArg wrapInstruction(InsnNode insn) {
    InsnNode parent = parentInsn;
    if (parent == null) {
        return null;
    }
    if (parent == insn) {
        LOG.debug("Can't wrap instruction info itself: {}", insn);
        return null;
    }
    int i = getArgIndex(parent, this);
    if (i == -1) {
        return null;
    }
    insn.add(AFlag.WRAPPED);
    InsnArg arg = wrapArg(insn);
    parent.setArg(i, arg);
    return arg;
}
Also used : InsnNode(jadx.core.dex.nodes.InsnNode)

Example 24 with InsnNode

use of jadx.core.dex.nodes.InsnNode in project jadx by skylot.

the class InsnDecoder method process.

public InsnNode[] process() throws DecodeException {
    InsnNode[] instructions = new InsnNode[insnArr.length];
    for (int i = 0; i < insnArr.length; i++) {
        DecodedInstruction rawInsn = insnArr[i];
        if (rawInsn != null) {
            InsnNode insn = decode(rawInsn, i);
            if (insn != null) {
                insn.setOffset(i);
            }
            instructions[i] = insn;
        } else {
            instructions[i] = null;
        }
    }
    insnArr = null;
    return instructions;
}
Also used : InsnNode(jadx.core.dex.nodes.InsnNode) DecodedInstruction(com.android.dx.io.instructions.DecodedInstruction) FillArrayDataPayloadDecodedInstruction(com.android.dx.io.instructions.FillArrayDataPayloadDecodedInstruction) SparseSwitchPayloadDecodedInstruction(com.android.dx.io.instructions.SparseSwitchPayloadDecodedInstruction) PackedSwitchPayloadDecodedInstruction(com.android.dx.io.instructions.PackedSwitchPayloadDecodedInstruction)

Example 25 with InsnNode

use of jadx.core.dex.nodes.InsnNode in project jadx by skylot.

the class InsnDecoder method arrayPut.

private InsnNode arrayPut(DecodedInstruction insn, ArgType argType) {
    InsnNode inode = new InsnNode(InsnType.APUT, 3);
    inode.addArg(InsnArg.reg(insn, 1, ArgType.unknown(PrimitiveType.ARRAY)));
    inode.addArg(InsnArg.reg(insn, 2, ArgType.INT));
    inode.addArg(InsnArg.reg(insn, 0, argType));
    return inode;
}
Also used : InsnNode(jadx.core.dex.nodes.InsnNode)

Aggregations

InsnNode (jadx.core.dex.nodes.InsnNode)123 BlockNode (jadx.core.dex.nodes.BlockNode)41 RegisterArg (jadx.core.dex.instructions.args.RegisterArg)39 IndexInsnNode (jadx.core.dex.instructions.IndexInsnNode)35 InsnArg (jadx.core.dex.instructions.args.InsnArg)32 InsnWrapArg (jadx.core.dex.instructions.args.InsnWrapArg)19 SSAVar (jadx.core.dex.instructions.args.SSAVar)16 ArrayList (java.util.ArrayList)14 ArgType (jadx.core.dex.instructions.args.ArgType)11 PhiInsn (jadx.core.dex.instructions.PhiInsn)10 FieldNode (jadx.core.dex.nodes.FieldNode)10 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)8 LiteralArg (jadx.core.dex.instructions.args.LiteralArg)7 ClassNode (jadx.core.dex.nodes.ClassNode)7 MethodNode (jadx.core.dex.nodes.MethodNode)7 FieldInfo (jadx.core.dex.info.FieldInfo)6 ArithNode (jadx.core.dex.instructions.ArithNode)6 ConstructorInsn (jadx.core.dex.instructions.mods.ConstructorInsn)6 InsnType (jadx.core.dex.instructions.InsnType)5 IContainer (jadx.core.dex.nodes.IContainer)5