Search in sources :

Example 86 with JadxRuntimeException

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

the class DepthRegionTraversal method traverseIncludingExcHandlers.

public static void traverseIncludingExcHandlers(MethodNode mth, IRegionIterativeVisitor visitor) {
    boolean repeat;
    int k = 0;
    int limit = ITERATIVE_LIMIT_MULTIPLIER * mth.getBasicBlocks().size();
    do {
        repeat = traverseIterativeStepInternal(mth, visitor, mth.getRegion());
        if (!repeat) {
            for (ExceptionHandler h : mth.getExceptionHandlers()) {
                repeat = traverseIterativeStepInternal(mth, visitor, h.getHandlerRegion());
                if (repeat) {
                    break;
                }
            }
        }
        if (k++ > limit) {
            throw new JadxRuntimeException("Iterative traversal limit reached: " + "limit: " + limit + ", visitor: " + visitor.getClass().getName() + ", blocks count: " + mth.getBasicBlocks().size());
        }
    } while (repeat);
}
Also used : ExceptionHandler(jadx.core.dex.trycatch.ExceptionHandler) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException)

Example 87 with JadxRuntimeException

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

the class QuarkManager method installQuark.

private void installQuark() {
    List<String> cmd = new ArrayList<>();
    cmd.add(getCommand("pip3"));
    cmd.add("install");
    cmd.add("quark-engine");
    cmd.add("--upgrade");
    try {
        runCommand(cmd);
    } catch (Exception e) {
        throw new JadxRuntimeException("Failed to install quark-engine", e);
    }
}
Also used : ArrayList(java.util.ArrayList) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException)

Example 88 with JadxRuntimeException

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

the class QuarkManager method updateQuarkRules.

private void updateQuarkRules() {
    List<String> cmd = new ArrayList<>();
    cmd.add(getCommand("freshquark"));
    try {
        runCommand(cmd);
    } catch (Exception e) {
        throw new JadxRuntimeException("Failed to update quark rules", e);
    }
}
Also used : ArrayList(java.util.ArrayList) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException)

Example 89 with JadxRuntimeException

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

the class QuarkManager method createVirtualEnv.

private void createVirtualEnv() {
    if (Files.exists(getVenvPath("activate"))) {
        return;
    }
    File directory = QUARK_DIR_PATH.toFile();
    if (!directory.isDirectory()) {
        if (!directory.mkdirs()) {
            throw new JadxRuntimeException("Failed create directory: " + directory);
        }
    }
    List<String> cmd = new ArrayList<>();
    if (SystemInfo.IS_WINDOWS) {
        cmd.add("python");
        cmd.add("-m");
        cmd.add("venv");
    } else {
        cmd.add("virtualenv");
    }
    cmd.add(VENV_PATH.toString());
    try {
        runCommand(cmd);
    } catch (Exception e) {
        throw new JadxRuntimeException("Failed to create virtual environment", e);
    }
}
Also used : ArrayList(java.util.ArrayList) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) File(java.io.File) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException)

Example 90 with JadxRuntimeException

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

the class JadxDecompiler method convertNode.

@Nullable
JavaNode convertNode(Object obj) {
    if (obj instanceof VarRef) {
        VarRef varRef = (VarRef) obj;
        MethodNode mthNode = varRef.getMth();
        JavaMethod mth = getJavaMethodByNode(mthNode);
        if (mth == null) {
            return null;
        }
        return new JavaVariable(mth, varRef);
    }
    if (!(obj instanceof LineAttrNode)) {
        return null;
    }
    LineAttrNode node = (LineAttrNode) obj;
    if (node.contains(AFlag.DONT_GENERATE)) {
        return null;
    }
    if (obj instanceof ClassNode) {
        return convertClassNode((ClassNode) obj);
    }
    if (obj instanceof MethodNode) {
        return getJavaMethodByNode(((MethodNode) obj));
    }
    if (obj instanceof FieldNode) {
        return getJavaFieldByNode((FieldNode) obj);
    }
    throw new JadxRuntimeException("Unexpected node type: " + obj);
}
Also used : VarRef(jadx.api.data.annotations.VarRef) ClassNode(jadx.core.dex.nodes.ClassNode) LineAttrNode(jadx.core.dex.attributes.nodes.LineAttrNode) MethodNode(jadx.core.dex.nodes.MethodNode) FieldNode(jadx.core.dex.nodes.FieldNode) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) Nullable(org.jetbrains.annotations.Nullable)

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