org.jf.dexlib2.iface.instruction.formats.PackedSwitchPayload Java Examples

The following examples show how to use org.jf.dexlib2.iface.instruction.formats.PackedSwitchPayload. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InstructionMethodItemFactory.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
public static InstructionMethodItem makeInstructionFormatMethodItem(
        MethodDefinition methodDef, int codeAddress, Instruction instruction) {

    if (instruction instanceof OffsetInstruction) {
        return new OffsetInstructionFormatMethodItem(methodDef.classDef.options, methodDef, codeAddress,
                (OffsetInstruction)instruction);
    }

    if (instruction instanceof UnresolvedOdexInstruction) {
        return new UnresolvedOdexInstructionMethodItem(methodDef, codeAddress,
                (UnresolvedOdexInstruction)instruction);
    }

    switch (instruction.getOpcode().format) {
        case ArrayPayload:
            return new ArrayDataMethodItem(methodDef, codeAddress, (ArrayPayload)instruction);
        case PackedSwitchPayload:
            return new PackedSwitchMethodItem(methodDef, codeAddress, (PackedSwitchPayload)instruction);
        case SparseSwitchPayload:
            return new SparseSwitchMethodItem(methodDef, codeAddress, (SparseSwitchPayload)instruction);
        default:
            return new InstructionMethodItem<Instruction>(methodDef, codeAddress, instruction);
    }
}
 
Example #2
Source File: InstructionMethodItemFactory.java    From atlas with Apache License 2.0 6 votes vote down vote up
public static InstructionMethodItem makeInstructionFormatMethodItem(
        MethodDefinition methodDef, int codeAddress, Instruction instruction) {

    if (instruction instanceof OffsetInstruction) {
        return new OffsetInstructionFormatMethodItem(methodDef.classDef.options, methodDef, codeAddress,
                (OffsetInstruction)instruction);
    }

    if (instruction instanceof UnresolvedOdexInstruction) {
        return new UnresolvedOdexInstructionMethodItem(methodDef, codeAddress,
                (UnresolvedOdexInstruction)instruction);
    }

    switch (instruction.getOpcode().format) {
        case ArrayPayload:
            return new ArrayDataMethodItem(methodDef, codeAddress, (ArrayPayload)instruction);
        case PackedSwitchPayload:
            return new PackedSwitchMethodItem(methodDef, codeAddress, (PackedSwitchPayload)instruction);
        case SparseSwitchPayload:
            return new SparseSwitchMethodItem(methodDef, codeAddress, (SparseSwitchPayload)instruction);
        default:
            return new InstructionMethodItem<Instruction>(methodDef, codeAddress, instruction);
    }
}
 
Example #3
Source File: InstructionMethodItemFactory.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
public static InstructionMethodItem makeInstructionFormatMethodItem(
        MethodDefinition methodDef, int codeAddress, Instruction instruction) {

    if (instruction instanceof OffsetInstruction) {
        return new OffsetInstructionFormatMethodItem(methodDef.classDef.options, methodDef, codeAddress,
                (OffsetInstruction)instruction);
    }

    if (instruction instanceof UnresolvedOdexInstruction) {
        return new UnresolvedOdexInstructionMethodItem(methodDef, codeAddress,
                (UnresolvedOdexInstruction)instruction);
    }

    switch (instruction.getOpcode().format) {
        case ArrayPayload:
            return new ArrayDataMethodItem(methodDef, codeAddress, (ArrayPayload)instruction);
        case PackedSwitchPayload:
            return new PackedSwitchMethodItem(methodDef, codeAddress, (PackedSwitchPayload)instruction);
        case SparseSwitchPayload:
            return new SparseSwitchMethodItem(methodDef, codeAddress, (SparseSwitchPayload)instruction);
        default:
            return new InstructionMethodItem<Instruction>(methodDef, codeAddress, instruction);
    }
}
 
Example #4
Source File: PackedSwitchInstruction.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
protected Stmt switchStatement(DexBody body, Instruction targetData, Local key) {
     PackedSwitchPayload i = (PackedSwitchPayload) targetData;
     List<? extends SwitchElement> seList = i.getSwitchElements();

     // the default target always follows the switch statement
     int defaultTargetAddress = codeAddress + instruction.getCodeUnits();
     Unit defaultTarget = body.instructionAtAddress(defaultTargetAddress).getUnit();

     List<IntConstant> lookupValues = new ArrayList<IntConstant>();
     List<Unit> targets = new ArrayList<Unit>();
     for(SwitchElement se: seList) {
       lookupValues.add(IntConstant.v(se.getKey()));
       int offset = se.getOffset();
       targets.add(body.instructionAtAddress(codeAddress + offset).getUnit());
     }
     switchStmt = Jimple.v().newLookupSwitchStmt(key, lookupValues, targets, defaultTarget);
     setUnit(switchStmt);
     
     if (IDalvikTyper.ENABLE_DVKTYPER) {
Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ switchStmt);
         DalvikTyper.v().setType(switchStmt.getKeyBox(), IntType.v(), true);
     }
     
     return switchStmt;
 }
 
Example #5
Source File: InstructionMethodItemFactory.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
public static InstructionMethodItem makeInstructionFormatMethodItem(
        MethodDefinition methodDef, int codeAddress, Instruction instruction) {

    if (instruction instanceof OffsetInstruction) {
        return new OffsetInstructionFormatMethodItem(methodDef.classDef.options, methodDef, codeAddress,
                (OffsetInstruction)instruction);
    }

    if (instruction instanceof UnresolvedOdexInstruction) {
        return new UnresolvedOdexInstructionMethodItem(methodDef, codeAddress,
                (UnresolvedOdexInstruction)instruction);
    }

    switch (instruction.getOpcode().format) {
        case ArrayPayload:
            return new ArrayDataMethodItem(methodDef, codeAddress, (ArrayPayload)instruction);
        case PackedSwitchPayload:
            return new PackedSwitchMethodItem(methodDef, codeAddress, (PackedSwitchPayload)instruction);
        case SparseSwitchPayload:
            return new SparseSwitchMethodItem(methodDef, codeAddress, (SparseSwitchPayload)instruction);
        default:
            return new InstructionMethodItem<Instruction>(methodDef, codeAddress, instruction);
    }
}
 
Example #6
Source File: InstructionMethodItemFactory.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
public static InstructionMethodItem makeInstructionFormatMethodItem(
        MethodDefinition methodDef, int codeAddress, Instruction instruction) {

    if (instruction instanceof OffsetInstruction) {
        return new OffsetInstructionFormatMethodItem(methodDef.classDef.options, methodDef, codeAddress,
                (OffsetInstruction)instruction);
    }

    if (instruction instanceof UnresolvedOdexInstruction) {
        return new UnresolvedOdexInstructionMethodItem(methodDef, codeAddress,
                (UnresolvedOdexInstruction)instruction);
    }

    switch (instruction.getOpcode().format) {
        case ArrayPayload:
            return new ArrayDataMethodItem(methodDef, codeAddress, (ArrayPayload)instruction);
        case PackedSwitchPayload:
            return new PackedSwitchMethodItem(methodDef, codeAddress, (PackedSwitchPayload)instruction);
        case SparseSwitchPayload:
            return new SparseSwitchMethodItem(methodDef, codeAddress, (SparseSwitchPayload)instruction);
        default:
            return new InstructionMethodItem<Instruction>(methodDef, codeAddress, instruction);
    }
}
 
Example #7
Source File: ImmutablePackedSwitchPayload.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static ImmutablePackedSwitchPayload of(PackedSwitchPayload instruction) {
    if (instruction instanceof ImmutablePackedSwitchPayload) {
        return (ImmutablePackedSwitchPayload)instruction;
    }
    return new ImmutablePackedSwitchPayload(
            instruction.getSwitchElements());
}
 
Example #8
Source File: ImmutablePackedSwitchPayload.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static ImmutablePackedSwitchPayload of(PackedSwitchPayload instruction) {
    if (instruction instanceof ImmutablePackedSwitchPayload) {
        return (ImmutablePackedSwitchPayload)instruction;
    }
    return new ImmutablePackedSwitchPayload(
            instruction.getSwitchElements());
}
 
Example #9
Source File: ImmutablePackedSwitchPayload.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static ImmutablePackedSwitchPayload of(PackedSwitchPayload instruction) {
    if (instruction instanceof ImmutablePackedSwitchPayload) {
        return (ImmutablePackedSwitchPayload)instruction;
    }
    return new ImmutablePackedSwitchPayload(
            instruction.getSwitchElements());
}
 
Example #10
Source File: ImmutablePackedSwitchPayload.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static ImmutablePackedSwitchPayload of(PackedSwitchPayload instruction) {
    if (instruction instanceof ImmutablePackedSwitchPayload) {
        return (ImmutablePackedSwitchPayload)instruction;
    }
    return new ImmutablePackedSwitchPayload(
            instruction.getSwitchElements());
}