Search in sources :

Example 1 with CatchData

use of jadx.api.plugins.input.data.impl.CatchData in project jadx by skylot.

the class JavaCodeReader method convertSingleCatches.

private static CatchData convertSingleCatches(List<JavaSingleCatch> list) {
    int allHandler = -1;
    for (JavaSingleCatch singleCatch : list) {
        if (singleCatch.getType() == null) {
            allHandler = singleCatch.getHandler();
            list.remove(singleCatch);
            break;
        }
    }
    int len = list.size();
    int[] handlers = new int[len];
    String[] types = new String[len];
    for (int i = 0; i < len; i++) {
        JavaSingleCatch singleCatch = list.get(i);
        handlers[i] = singleCatch.getHandler();
        types[i] = singleCatch.getType();
    }
    return new CatchData(handlers, types, allHandler);
}
Also used : CatchData(jadx.api.plugins.input.data.impl.CatchData) JavaSingleCatch(jadx.plugins.input.java.data.code.trycatch.JavaSingleCatch)

Example 2 with CatchData

use of jadx.api.plugins.input.data.impl.CatchData in project jadx by skylot.

the class DexCodeReader method getCatchHandlers.

private Map<Integer, ICatch> getCatchHandlers(int offset, SectionReader ext) {
    in.pos(offset);
    int byteOffsetStart = in.getAbsPos();
    int size = in.readUleb128();
    Map<Integer, ICatch> map = new HashMap<>(size);
    for (int i = 0; i < size; i++) {
        int byteIndex = in.getAbsPos() - byteOffsetStart;
        int sizeAndType = in.readSleb128();
        int handlersLen = Math.abs(sizeAndType);
        int[] addr = new int[handlersLen];
        String[] types = new String[handlersLen];
        for (int h = 0; h < handlersLen; h++) {
            types[h] = ext.getType(in.readUleb128());
            addr[h] = in.readUleb128();
        }
        int catchAllAddr;
        if (sizeAndType <= 0) {
            catchAllAddr = in.readUleb128();
        } else {
            catchAllAddr = -1;
        }
        map.put(byteIndex, new CatchData(addr, types, catchAllAddr));
    }
    return map;
}
Also used : CatchData(jadx.api.plugins.input.data.impl.CatchData) HashMap(java.util.HashMap) ICatch(jadx.api.plugins.input.data.ICatch)

Aggregations

CatchData (jadx.api.plugins.input.data.impl.CatchData)2 ICatch (jadx.api.plugins.input.data.ICatch)1 JavaSingleCatch (jadx.plugins.input.java.data.code.trycatch.JavaSingleCatch)1 HashMap (java.util.HashMap)1