org.jf.baksmali.Adaptors.MethodDefinition Java Examples

The following examples show how to use org.jf.baksmali.Adaptors.MethodDefinition. 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 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 #3
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 #4
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 #5
Source File: SmaliCodeUtils.java    From atlas with Apache License 2.0 5 votes vote down vote up
/**
 * 将方法的实现转换为smali代码
 *
 * @param dexBackedMethodImplementation
 * @param withLineNo                    是否包含行号
 * @return
 */
public static String methodImplementionToCode(DexBackedMethodImplementation dexBackedMethodImplementation, boolean withLineNo) {
    if (null == dexBackedMethodImplementation) {
        return null;
    }
    StringWriter stringWriter = new StringWriter();
    IndentingWriter writer = new IndentingWriter(stringWriter);
    MethodDefinition methodDefinition = new MethodDefinition(toClassDefinition(dexBackedMethodImplementation),
            dexBackedMethodImplementation.method,
            dexBackedMethodImplementation);
    try {
        methodDefinition.writeTo(writer);
    } catch (IOException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
    if (withLineNo) {
        return stringWriter.toString();
    } else {
        List<String> codes = Lists.newArrayList();
        String[] lines = StringUtils.split(stringWriter.toString(), "\n");
        for (String line : lines) {
            if (StringUtils.isNoneBlank(line) && !line.matches("\\s+\\.line\\s+[0-9]+$")) {
                codes.add(line);
            }
        }
        return StringUtils.join(codes, "\n");
    }

}
 
Example #6
Source File: OffsetInstructionFormatMethodItem.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public OffsetInstructionFormatMethodItem(@Nonnull baksmaliOptions options, @Nonnull MethodDefinition methodDef,
                                         int codeAddress, OffsetInstruction instruction) {
    super(methodDef, codeAddress, instruction);

    label = new LabelMethodItem(options, codeAddress + instruction.getCodeOffset(), getLabelPrefix());
    label = methodDef.getLabelCache().internLabel(label);
}
 
Example #7
Source File: OffsetInstructionFormatMethodItem.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public OffsetInstructionFormatMethodItem(@Nonnull baksmaliOptions options, @Nonnull MethodDefinition methodDef,
                                         int codeAddress, OffsetInstruction instruction) {
    super(methodDef, codeAddress, instruction);

    label = new LabelMethodItem(options, codeAddress + instruction.getCodeOffset(), getLabelPrefix());
    label = methodDef.getLabelCache().internLabel(label);
}
 
Example #8
Source File: OffsetInstructionFormatMethodItem.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public OffsetInstructionFormatMethodItem(@Nonnull baksmaliOptions options, @Nonnull MethodDefinition methodDef,
                                         int codeAddress, OffsetInstruction instruction) {
    super(methodDef, codeAddress, instruction);

    label = new LabelMethodItem(options, codeAddress + instruction.getCodeOffset(), getLabelPrefix());
    label = methodDef.getLabelCache().internLabel(label);
}
 
Example #9
Source File: OffsetInstructionFormatMethodItem.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public OffsetInstructionFormatMethodItem(@Nonnull baksmaliOptions options, @Nonnull MethodDefinition methodDef,
                                         int codeAddress, OffsetInstruction instruction) {
    super(methodDef, codeAddress, instruction);

    label = new LabelMethodItem(options, codeAddress + instruction.getCodeOffset(), getLabelPrefix());
    label = methodDef.getLabelCache().internLabel(label);
}
 
Example #10
Source File: ArrayDataMethodItem.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
public ArrayDataMethodItem(MethodDefinition methodDef, int codeAddress, ArrayPayload instruction) {
    super(methodDef, codeAddress, instruction);
}
 
Example #11
Source File: UnresolvedOdexInstructionMethodItem.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
public UnresolvedOdexInstructionMethodItem(@Nonnull MethodDefinition methodDef, int codeAddress,
                                           @Nonnull UnresolvedOdexInstruction instruction) {
    super(methodDef, codeAddress, instruction);
}
 
Example #12
Source File: UnresolvedOdexInstructionMethodItem.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
public UnresolvedOdexInstructionMethodItem(@Nonnull MethodDefinition methodDef, int codeAddress,
                                           @Nonnull UnresolvedOdexInstruction instruction) {
    super(methodDef, codeAddress, instruction);
}
 
Example #13
Source File: InstructionMethodItem.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
public InstructionMethodItem(@Nonnull MethodDefinition methodDef, int codeAddress, @Nonnull T instruction) {
    super(codeAddress);
    this.methodDef = methodDef;
    this.instruction = instruction;
}
 
Example #14
Source File: ArrayDataMethodItem.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
public ArrayDataMethodItem(MethodDefinition methodDef, int codeAddress, ArrayPayload instruction) {
    super(methodDef, codeAddress, instruction);
}
 
Example #15
Source File: InstructionMethodItem.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
public InstructionMethodItem(@Nonnull MethodDefinition methodDef, int codeAddress, @Nonnull T instruction) {
    super(codeAddress);
    this.methodDef = methodDef;
    this.instruction = instruction;
}
 
Example #16
Source File: UnresolvedOdexInstructionMethodItem.java    From HeyGirl with Apache License 2.0 4 votes vote down vote up
public UnresolvedOdexInstructionMethodItem(@Nonnull MethodDefinition methodDef, int codeAddress,
                                           @Nonnull UnresolvedOdexInstruction instruction) {
    super(methodDef, codeAddress, instruction);
}
 
Example #17
Source File: InstructionMethodItem.java    From HeyGirl with Apache License 2.0 4 votes vote down vote up
public InstructionMethodItem(@Nonnull MethodDefinition methodDef, int codeAddress, @Nonnull T instruction) {
    super(codeAddress);
    this.methodDef = methodDef;
    this.instruction = instruction;
}
 
Example #18
Source File: ArrayDataMethodItem.java    From HeyGirl with Apache License 2.0 4 votes vote down vote up
public ArrayDataMethodItem(MethodDefinition methodDef, int codeAddress, ArrayPayload instruction) {
    super(methodDef, codeAddress, instruction);
}
 
Example #19
Source File: UnresolvedOdexInstructionMethodItem.java    From zjdroid with Apache License 2.0 4 votes vote down vote up
public UnresolvedOdexInstructionMethodItem(@Nonnull MethodDefinition methodDef, int codeAddress,
                                           @Nonnull UnresolvedOdexInstruction instruction) {
    super(methodDef, codeAddress, instruction);
}
 
Example #20
Source File: InstructionMethodItem.java    From zjdroid with Apache License 2.0 4 votes vote down vote up
public InstructionMethodItem(@Nonnull MethodDefinition methodDef, int codeAddress, @Nonnull T instruction) {
    super(codeAddress);
    this.methodDef = methodDef;
    this.instruction = instruction;
}
 
Example #21
Source File: ArrayDataMethodItem.java    From zjdroid with Apache License 2.0 4 votes vote down vote up
public ArrayDataMethodItem(MethodDefinition methodDef, int codeAddress, ArrayPayload instruction) {
    super(methodDef, codeAddress, instruction);
}