Search in sources :

Example 6 with DataReader

use of jadx.plugins.input.java.data.DataReader in project jadx by skylot.

the class LookupSwitchDecoder method read.

private static void read(CodeDecodeState state, boolean skip) {
    DataReader reader = state.reader();
    JavaInsnData insn = state.insn();
    int dataOffset = reader.getOffset();
    int insnOffset = insn.getOffset();
    reader.skip(3 - insnOffset % 4);
    int defTarget = insnOffset + reader.readS4();
    int pairs = reader.readS4();
    if (skip) {
        reader.skip(pairs * 8);
    } else {
        state.pop(0);
        int[] keys = new int[pairs];
        int[] targets = new int[pairs];
        for (int i = 0; i < pairs; i++) {
            keys[i] = reader.readS4();
            int target = insnOffset + reader.readS4();
            targets[i] = target;
            state.registerJump(target);
        }
        insn.setTarget(defTarget);
        state.registerJump(defTarget);
        insn.setPayload(new SwitchPayload(pairs, keys, targets));
    }
    insn.setPayloadSize(reader.getOffset() - dataOffset);
}
Also used : DataReader(jadx.plugins.input.java.data.DataReader) SwitchPayload(jadx.api.plugins.input.insns.custom.impl.SwitchPayload) JavaInsnData(jadx.plugins.input.java.data.code.JavaInsnData)

Example 7 with DataReader

use of jadx.plugins.input.java.data.DataReader in project jadx by skylot.

the class WideDecoder method skip.

@Override
public void skip(CodeDecodeState state) {
    DataReader reader = state.reader();
    JavaInsnData insn = state.insn();
    int opcode = reader.readU1();
    if (opcode == IINC) {
        reader.skip(4);
        insn.setPayloadSize(5);
    } else {
        reader.skip(2);
        insn.setPayloadSize(3);
    }
}
Also used : DataReader(jadx.plugins.input.java.data.DataReader) JavaInsnData(jadx.plugins.input.java.data.code.JavaInsnData)

Aggregations

DataReader (jadx.plugins.input.java.data.DataReader)7 JavaInsnData (jadx.plugins.input.java.data.code.JavaInsnData)6 SwitchPayload (jadx.api.plugins.input.insns.custom.impl.SwitchPayload)2 JavaClassParseException (jadx.plugins.input.java.utils.JavaClassParseException)2 ICallSite (jadx.api.plugins.input.data.ICallSite)1 IMethodProto (jadx.api.plugins.input.data.IMethodProto)1 IMethodRef (jadx.api.plugins.input.data.IMethodRef)1 ConstPoolReader (jadx.plugins.input.java.data.ConstPoolReader)1 ConstantType (jadx.plugins.input.java.data.ConstantType)1