Search in sources :

Example 6 with JadxRuntimeException

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

the class MethodNode method checkInstructions.

public void checkInstructions() {
    List<RegisterArg> list = new ArrayList<RegisterArg>();
    for (InsnNode insnNode : instructions) {
        if (insnNode == null) {
            continue;
        }
        list.clear();
        RegisterArg resultArg = insnNode.getResult();
        if (resultArg != null) {
            list.add(resultArg);
        }
        insnNode.getRegisterArgs(list);
        int argsCount = list.size();
        for (int i = 0; i < argsCount; i++) {
            if (list.get(i).getRegNum() >= regsCount) {
                throw new JadxRuntimeException("Incorrect register number in instruction: " + insnNode + ", expected to be less than " + regsCount);
            }
        }
    }
}
Also used : RegisterArg(jadx.core.dex.instructions.args.RegisterArg) ArrayList(java.util.ArrayList) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException)

Example 7 with JadxRuntimeException

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

the class SignatureParser method consumeType.

public ArgType consumeType() {
    char ch = next();
    mark();
    switch(ch) {
        case 'L':
            ArgType obj = consumeObjectType(false);
            if (obj != null) {
                return obj;
            }
            break;
        case 'T':
            next();
            mark();
            if (forwardTo(';')) {
                return ArgType.genericType(slice());
            }
            break;
        case '[':
            return ArgType.array(consumeType());
        case STOP_CHAR:
            return null;
        default:
            // primitive type (one char)
            ArgType type = ArgType.parse(ch);
            if (type != null) {
                return type;
            }
            break;
    }
    throw new JadxRuntimeException("Can't parse type: " + debugString());
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException)

Example 8 with JadxRuntimeException

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

the class InsnGen method makeConstructor.

private void makeConstructor(ConstructorInsn insn, CodeWriter code) throws CodegenException {
    ClassNode cls = mth.dex().resolveClass(insn.getClassType());
    if (cls != null && cls.contains(AFlag.ANONYMOUS_CLASS) && !fallback) {
        inlineAnonymousConstr(code, cls, insn);
        return;
    }
    if (insn.isSelf()) {
        throw new JadxRuntimeException("Constructor 'self' invoke must be removed!");
    }
    if (insn.isSuper()) {
        code.add("super");
    } else if (insn.isThis()) {
        code.add("this");
    } else {
        code.add("new ");
        useClass(code, insn.getClassType());
    }
    MethodNode callMth = mth.dex().resolveMethod(insn.getCallMth());
    generateMethodArguments(code, insn, 0, callMth);
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) ConstClassNode(jadx.core.dex.instructions.ConstClassNode) MethodNode(jadx.core.dex.nodes.MethodNode) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException)

Example 9 with JadxRuntimeException

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

the class ClassNode method parseClassSignature.

private void parseClassSignature() {
    SignatureParser sp = SignatureParser.fromNode(this);
    if (sp == null) {
        return;
    }
    try {
        // parse class generic map
        genericMap = sp.consumeGenericMap();
        // parse super class signature
        superClass = sp.consumeType();
        // parse interfaces signatures
        for (int i = 0; i < interfaces.size(); i++) {
            ArgType type = sp.consumeType();
            if (type != null) {
                interfaces.set(i, type);
            } else {
                break;
            }
        }
    } catch (JadxRuntimeException e) {
        LOG.error("Class signature parse error: {}", this, e);
    }
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) SignatureParser(jadx.core.dex.nodes.parser.SignatureParser)

Example 10 with JadxRuntimeException

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

the class FillArrayNode method getLiteralArgs.

public List<LiteralArg> getLiteralArgs() {
    List<LiteralArg> list = new ArrayList<LiteralArg>(size);
    Object array = data;
    if (array instanceof int[]) {
        for (int b : (int[]) array) {
            list.add(InsnArg.lit(b, elemType));
        }
    } else if (array instanceof byte[]) {
        for (byte b : (byte[]) array) {
            list.add(InsnArg.lit(b, elemType));
        }
    } else if (array instanceof short[]) {
        for (short b : (short[]) array) {
            list.add(InsnArg.lit(b, elemType));
        }
    } else if (array instanceof long[]) {
        for (long b : (long[]) array) {
            list.add(InsnArg.lit(b, elemType));
        }
    } else {
        throw new JadxRuntimeException("Unknown type: " + data.getClass() + ", expected: " + elemType);
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) LiteralArg(jadx.core.dex.instructions.args.LiteralArg) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException)

Aggregations

JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)35 BlockNode (jadx.core.dex.nodes.BlockNode)14 InsnNode (jadx.core.dex.nodes.InsnNode)8 RegisterArg (jadx.core.dex.instructions.args.RegisterArg)6 ArrayList (java.util.ArrayList)6 ArgType (jadx.core.dex.instructions.args.ArgType)5 BitSet (java.util.BitSet)5 SSAVar (jadx.core.dex.instructions.args.SSAVar)4 PhiInsn (jadx.core.dex.instructions.PhiInsn)3 InsnArg (jadx.core.dex.instructions.args.InsnArg)3 ClassNode (jadx.core.dex.nodes.ClassNode)3 IContainer (jadx.core.dex.nodes.IContainer)3 IRegion (jadx.core.dex.nodes.IRegion)3 File (java.io.File)3 ZipEntry (java.util.zip.ZipEntry)3 LoopInfo (jadx.core.dex.attributes.nodes.LoopInfo)2 PhiListAttr (jadx.core.dex.attributes.nodes.PhiListAttr)2 LiteralArg (jadx.core.dex.instructions.args.LiteralArg)2 FieldNode (jadx.core.dex.nodes.FieldNode)2 IBlock (jadx.core.dex.nodes.IBlock)2