Search in sources :

Example 36 with BlockNode

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

the class BlockExceptionHandler method process.

public static boolean process(MethodNode mth) {
    if (mth.isNoExceptionHandlers()) {
        return false;
    }
    BlockProcessor.updateCleanSuccessors(mth);
    BlockProcessor.computeDominanceFrontier(mth);
    processCatchAttr(mth);
    initExcHandlers(mth);
    List<TryCatchBlockAttr> tryBlocks = prepareTryBlocks(mth);
    connectExcHandlers(mth, tryBlocks);
    mth.addAttr(AType.TRY_BLOCKS_LIST, tryBlocks);
    mth.getBasicBlocks().forEach(BlockNode::updateCleanSuccessors);
    for (ExceptionHandler eh : mth.getExceptionHandlers()) {
        removeMonitorExitFromExcHandler(mth, eh);
    }
    BlockProcessor.removeMarkedBlocks(mth);
    return true;
}
Also used : BlockNode(jadx.core.dex.nodes.BlockNode) ExceptionHandler(jadx.core.dex.trycatch.ExceptionHandler) TryCatchBlockAttr(jadx.core.dex.trycatch.TryCatchBlockAttr)

Example 37 with BlockNode

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

the class ConstInlineVisitor method process.

public static void process(MethodNode mth) {
    List<InsnNode> toRemove = new ArrayList<>();
    for (BlockNode block : mth.getBasicBlocks()) {
        toRemove.clear();
        for (InsnNode insn : block.getInstructions()) {
            checkInsn(mth, insn, toRemove);
        }
        InsnRemover.removeAllAndUnbind(mth, block, toRemove);
    }
}
Also used : BlockNode(jadx.core.dex.nodes.BlockNode) IndexInsnNode(jadx.core.dex.instructions.IndexInsnNode) InsnNode(jadx.core.dex.nodes.InsnNode) ArrayList(java.util.ArrayList)

Example 38 with BlockNode

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

the class DeboxingVisitor method visit.

@Override
public void visit(MethodNode mth) throws JadxException {
    if (mth.isNoCode()) {
        return;
    }
    boolean replaced = false;
    for (BlockNode blockNode : mth.getBasicBlocks()) {
        List<InsnNode> insnList = blockNode.getInstructions();
        int count = insnList.size();
        for (int i = 0; i < count; i++) {
            InsnNode insnNode = insnList.get(i);
            if (insnNode.getType() == InsnType.INVOKE) {
                InsnNode replaceInsn = checkForReplace(((InvokeNode) insnNode));
                if (replaceInsn != null) {
                    BlockUtils.replaceInsn(mth, blockNode, i, replaceInsn);
                    replaced = true;
                }
            }
        }
    }
    if (replaced) {
        ConstInlineVisitor.process(mth);
    }
}
Also used : BlockNode(jadx.core.dex.nodes.BlockNode) InsnNode(jadx.core.dex.nodes.InsnNode) InvokeNode(jadx.core.dex.instructions.InvokeNode)

Example 39 with BlockNode

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

the class ExtractFieldInit method collectFieldsInit.

private static List<FieldInitInfo> collectFieldsInit(ClassNode cls, MethodNode mth, InsnType putType) {
    List<FieldInitInfo> fieldsInit = new ArrayList<>();
    Set<BlockNode> singlePathBlocks = new HashSet<>();
    BlockUtils.visitSinglePath(mth.getEnterBlock(), singlePathBlocks::add);
    for (BlockNode block : mth.getBasicBlocks()) {
        for (InsnNode insn : block.getInstructions()) {
            if (insn.getType() == putType) {
                IndexInsnNode putInsn = (IndexInsnNode) insn;
                FieldInfo field = (FieldInfo) putInsn.getIndex();
                if (field.getDeclClass().equals(cls.getClassInfo())) {
                    FieldNode fn = cls.searchField(field);
                    if (fn != null) {
                        boolean singlePath = singlePathBlocks.contains(block);
                        fieldsInit.add(new FieldInitInfo(fn, putInsn, singlePath));
                    }
                }
            }
        }
    }
    return fieldsInit;
}
Also used : BlockNode(jadx.core.dex.nodes.BlockNode) IndexInsnNode(jadx.core.dex.instructions.IndexInsnNode) InsnNode(jadx.core.dex.nodes.InsnNode) FieldNode(jadx.core.dex.nodes.FieldNode) ArrayList(java.util.ArrayList) IndexInsnNode(jadx.core.dex.instructions.IndexInsnNode) FieldInfo(jadx.core.dex.info.FieldInfo) HashSet(java.util.HashSet)

Example 40 with BlockNode

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

the class MoveInlineVisitor method moveInline.

public static void moveInline(MethodNode mth) {
    InsnRemover remover = new InsnRemover(mth);
    for (BlockNode block : mth.getBasicBlocks()) {
        remover.setBlock(block);
        for (InsnNode insn : block.getInstructions()) {
            if (insn.getType() != InsnType.MOVE) {
                continue;
            }
            if (processMove(mth, insn)) {
                remover.addAndUnbind(insn);
            }
        }
        remover.perform();
    }
}
Also used : BlockNode(jadx.core.dex.nodes.BlockNode) InsnNode(jadx.core.dex.nodes.InsnNode) InsnRemover(jadx.core.utils.InsnRemover)

Aggregations

BlockNode (jadx.core.dex.nodes.BlockNode)220 InsnNode (jadx.core.dex.nodes.InsnNode)91 RegisterArg (jadx.core.dex.instructions.args.RegisterArg)43 ArrayList (java.util.ArrayList)41 BitSet (java.util.BitSet)31 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)29 InsnArg (jadx.core.dex.instructions.args.InsnArg)25 IndexInsnNode (jadx.core.dex.instructions.IndexInsnNode)21 ExceptionHandler (jadx.core.dex.trycatch.ExceptionHandler)19 PhiInsn (jadx.core.dex.instructions.PhiInsn)14 SSAVar (jadx.core.dex.instructions.args.SSAVar)14 Nullable (org.jetbrains.annotations.Nullable)14 LoopInfo (jadx.core.dex.attributes.nodes.LoopInfo)13 IRegion (jadx.core.dex.nodes.IRegion)13 HashSet (java.util.HashSet)13 MethodNode (jadx.core.dex.nodes.MethodNode)12 Region (jadx.core.dex.regions.Region)12 LoopRegion (jadx.core.dex.regions.loops.LoopRegion)12 InsnType (jadx.core.dex.instructions.InsnType)11 SynchronizedRegion (jadx.core.dex.regions.SynchronizedRegion)11