Search in sources :

Example 46 with JadxRuntimeException

use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.

the class BlockProcessor method computeBlockDF.

private static void computeBlockDF(MethodNode mth, BlockNode block) {
    if (block.getDomFrontier() != null) {
        return;
    }
    List<BlockNode> blocks = mth.getBasicBlocks();
    BitSet domFrontier = null;
    for (BlockNode s : block.getSuccessors()) {
        if (s.getIDom() != block) {
            if (domFrontier == null) {
                domFrontier = new BitSet(blocks.size());
            }
            domFrontier.set(s.getId());
        }
    }
    for (BlockNode c : block.getDominatesOn()) {
        BitSet frontier = c.getDomFrontier();
        if (frontier == null) {
            throw new JadxRuntimeException("Dominance frontier not calculated for dominated block: " + c + ", from: " + block);
        }
        for (int p = frontier.nextSetBit(0); p >= 0; p = frontier.nextSetBit(p + 1)) {
            if (blocks.get(p).getIDom() != block) {
                if (domFrontier == null) {
                    domFrontier = new BitSet(blocks.size());
                }
                domFrontier.set(p);
            }
        }
    }
    if (domFrontier == null || domFrontier.isEmpty()) {
        domFrontier = EMPTY;
    }
    block.setDomFrontier(domFrontier);
}
Also used : BlockNode(jadx.core.dex.nodes.BlockNode) BitSet(java.util.BitSet) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException)

Example 47 with JadxRuntimeException

use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.

the class BlockProcessor method calcImmediateDominators.

private static void calcImmediateDominators(MethodNode mth, List<BlockNode> basicBlocks, BlockNode entryBlock) {
    for (BlockNode block : basicBlocks) {
        if (block == entryBlock) {
            continue;
        }
        BlockNode idom;
        List<BlockNode> preds = block.getPredecessors();
        if (preds.size() == 1) {
            idom = preds.get(0);
        } else {
            BitSet bs = new BitSet(block.getDoms().length());
            bs.or(block.getDoms());
            for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) {
                BlockNode dom = basicBlocks.get(i);
                bs.andNot(dom.getDoms());
            }
            if (bs.cardinality() != 1) {
                throw new JadxRuntimeException("Can't find immediate dominator for block " + block + " in " + bs + " preds:" + preds);
            }
            idom = basicBlocks.get(bs.nextSetBit(0));
        }
        block.setIDom(idom);
        idom.addDominatesOn(block);
    }
}
Also used : BlockNode(jadx.core.dex.nodes.BlockNode) BitSet(java.util.BitSet) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException)

Example 48 with JadxRuntimeException

use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.

the class FontUtils method loadByStr.

public static Font loadByStr(String fontDesc) {
    String[] parts = fontDesc.split("/");
    if (parts.length != 3) {
        throw new JadxRuntimeException("Unsupported font description format: " + fontDesc);
    }
    String name = parts[0];
    int style = parseFontStyle(parts[1]);
    int size = Integer.parseInt(parts[2]);
    StyleContext sc = StyleContext.getDefaultStyleContext();
    Font font = sc.getFont(name, style, size);
    if (font == null) {
        throw new JadxRuntimeException("Font not found: " + fontDesc);
    }
    return font;
}
Also used : JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) StyleContext(javax.swing.text.StyleContext) Font(java.awt.Font)

Example 49 with JadxRuntimeException

use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.

the class UiUtils method openSvgIcon.

public static FlatSVGIcon openSvgIcon(String name) {
    String iconPath = "icons/" + name + ".svg";
    FlatSVGIcon icon = new FlatSVGIcon(iconPath);
    boolean found;
    try {
        found = icon.hasFound();
    } catch (Exception e) {
        throw new JadxRuntimeException("Failed to load icon: " + iconPath, e);
    }
    if (!found) {
        throw new JadxRuntimeException("Icon not found: " + iconPath);
    }
    return icon;
}
Also used : FlatSVGIcon(com.formdev.flatlaf.extras.FlatSVGIcon) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException)

Example 50 with JadxRuntimeException

use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.

the class UiUtils method openIcon.

public static ImageIcon openIcon(String name) {
    String iconPath = "/icons-16/" + name + ".png";
    URL resource = UiUtils.class.getResource(iconPath);
    if (resource == null) {
        throw new JadxRuntimeException("Icon not found: " + iconPath);
    }
    return new ImageIcon(resource);
}
Also used : ImageIcon(javax.swing.ImageIcon) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) URL(java.net.URL)

Aggregations

JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)115 BlockNode (jadx.core.dex.nodes.BlockNode)25 ArrayList (java.util.ArrayList)25 InsnNode (jadx.core.dex.nodes.InsnNode)24 ArgType (jadx.core.dex.instructions.args.ArgType)20 RegisterArg (jadx.core.dex.instructions.args.RegisterArg)17 BitSet (java.util.BitSet)11 ClassNode (jadx.core.dex.nodes.ClassNode)10 MethodNode (jadx.core.dex.nodes.MethodNode)9 InsnArg (jadx.core.dex.instructions.args.InsnArg)8 SSAVar (jadx.core.dex.instructions.args.SSAVar)8 IOException (java.io.IOException)8 List (java.util.List)8 File (java.io.File)7 IRegion (jadx.core.dex.nodes.IRegion)6 Path (java.nio.file.Path)6 IndexInsnNode (jadx.core.dex.instructions.IndexInsnNode)5 PhiInsn (jadx.core.dex.instructions.PhiInsn)5 LiteralArg (jadx.core.dex.instructions.args.LiteralArg)5 FieldNode (jadx.core.dex.nodes.FieldNode)5