Java Code Examples for org.jf.dexlib2.dexbacked.DexReader#moveRelative()

The following examples show how to use org.jf.dexlib2.dexbacked.DexReader#moveRelative() . 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: DexBackedInstruction.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static Instruction readFrom(@Nonnull DexReader reader) {
    int opcodeValue = reader.peekUbyte();

    if (opcodeValue == 0) {
        opcodeValue = reader.peekUshort();
    }

    Opcode opcode = reader.dexBuf.getOpcodes().getOpcodeByValue(opcodeValue);

    Instruction instruction = buildInstruction(reader.dexBuf, opcode, reader.getOffset());
    reader.moveRelative(instruction.getCodeUnits()*2);
    return instruction;
}
 
Example 2
Source File: DexBackedInstruction.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static Instruction readFrom(@Nonnull DexReader reader) {
    int opcodeValue = reader.peekUbyte();

    if (opcodeValue == 0) {
        opcodeValue = reader.peekUshort();
    }

    Opcode opcode = reader.dexBuf.getOpcodes().getOpcodeByValue(opcodeValue);

    Instruction instruction = buildInstruction(reader.dexBuf, opcode, reader.getOffset());
    reader.moveRelative(instruction.getCodeUnits()*2);
    return instruction;
}
 
Example 3
Source File: DexBackedInstruction.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static Instruction readFrom(@Nonnull DexReader reader) {
    int opcodeValue = reader.peekUbyte();

    if (opcodeValue == 0) {
        opcodeValue = reader.peekUshort();
    }

    Opcode opcode = reader.dexBuf.getOpcodes().getOpcodeByValue(opcodeValue);

    Instruction instruction = buildInstruction(reader.dexBuf, opcode, reader.getOffset());
    reader.moveRelative(instruction.getCodeUnits()*2);
    return instruction;
}
 
Example 4
Source File: DexBackedInstruction.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static Instruction readFrom(@Nonnull DexReader reader) {
    int opcodeValue = reader.peekUbyte();

    if (opcodeValue == 0) {
        opcodeValue = reader.peekUshort();
    }

    Opcode opcode = reader.dexBuf.getOpcodes().getOpcodeByValue(opcodeValue);

    Instruction instruction = buildInstruction(reader.dexBuf, opcode, reader.getOffset());
    reader.moveRelative(instruction.getCodeUnits()*2);
    return instruction;
}
 
Example 5
Source File: DexBackedEncodedValue.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
public static void skipFrom(@Nonnull DexReader reader) {
    int startOffset = reader.getOffset();

    try {
        int b = reader.readUbyte();
        int valueType = b & 0x1f;

        switch (valueType) {
            case ValueType.BYTE:
                reader.skipByte();
                break;
            case ValueType.SHORT:
            case ValueType.CHAR:
            case ValueType.INT:
            case ValueType.LONG:
            case ValueType.FLOAT:
            case ValueType.DOUBLE:
            case ValueType.STRING:
            case ValueType.TYPE:
            case ValueType.FIELD:
            case ValueType.METHOD:
            case ValueType.ENUM:
                int valueArg = b >>> 5;
                reader.moveRelative(valueArg+1);
                break;
            case ValueType.ARRAY:
                DexBackedArrayEncodedValue.skipFrom(reader);
                break;
            case ValueType.ANNOTATION:
                DexBackedAnnotationEncodedValue.skipFrom(reader);
                break;
            case ValueType.NULL:
            case ValueType.BOOLEAN:
                break;
            default:
                throw new ExceptionWithContext("Invalid encoded_value type: 0x%x", valueType);
        }
    } catch (Exception ex) {
        throw ExceptionWithContext.withContext(ex, "Error while skipping encoded value at offset 0x%x",
                startOffset);
    }
}
 
Example 6
Source File: DexBackedEncodedValue.java    From zjdroid with Apache License 2.0 4 votes vote down vote up
public static void skipFrom(@Nonnull DexReader reader) {
    int startOffset = reader.getOffset();

    try {
        int b = reader.readUbyte();
        int valueType = b & 0x1f;

        switch (valueType) {
            case ValueType.BYTE:
                reader.skipByte();
                break;
            case ValueType.SHORT:
            case ValueType.CHAR:
            case ValueType.INT:
            case ValueType.LONG:
            case ValueType.FLOAT:
            case ValueType.DOUBLE:
            case ValueType.STRING:
            case ValueType.TYPE:
            case ValueType.FIELD:
            case ValueType.METHOD:
            case ValueType.ENUM:
                int valueArg = b >>> 5;
                reader.moveRelative(valueArg+1);
                break;
            case ValueType.ARRAY:
                DexBackedArrayEncodedValue.skipFrom(reader);
                break;
            case ValueType.ANNOTATION:
                DexBackedAnnotationEncodedValue.skipFrom(reader);
                break;
            case ValueType.NULL:
            case ValueType.BOOLEAN:
                break;
            default:
                throw new ExceptionWithContext("Invalid encoded_value type: 0x%x", valueType);
        }
    } catch (Exception ex) {
        throw ExceptionWithContext.withContext(ex, "Error while skipping encoded value at offset 0x%x",
                startOffset);
    }
}
 
Example 7
Source File: DexBackedEncodedValue.java    From HeyGirl with Apache License 2.0 4 votes vote down vote up
public static void skipFrom(@Nonnull DexReader reader) {
    int startOffset = reader.getOffset();

    try {
        int b = reader.readUbyte();
        int valueType = b & 0x1f;

        switch (valueType) {
            case ValueType.BYTE:
                reader.skipByte();
                break;
            case ValueType.SHORT:
            case ValueType.CHAR:
            case ValueType.INT:
            case ValueType.LONG:
            case ValueType.FLOAT:
            case ValueType.DOUBLE:
            case ValueType.STRING:
            case ValueType.TYPE:
            case ValueType.FIELD:
            case ValueType.METHOD:
            case ValueType.ENUM:
                int valueArg = b >>> 5;
                reader.moveRelative(valueArg+1);
                break;
            case ValueType.ARRAY:
                DexBackedArrayEncodedValue.skipFrom(reader);
                break;
            case ValueType.ANNOTATION:
                DexBackedAnnotationEncodedValue.skipFrom(reader);
                break;
            case ValueType.NULL:
            case ValueType.BOOLEAN:
                break;
            default:
                throw new ExceptionWithContext("Invalid encoded_value type: 0x%x", valueType);
        }
    } catch (Exception ex) {
        throw ExceptionWithContext.withContext(ex, "Error while skipping encoded value at offset 0x%x",
                startOffset);
    }
}
 
Example 8
Source File: DexBackedEncodedValue.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
public static void skipFrom(@Nonnull DexReader reader) {
    int startOffset = reader.getOffset();

    try {
        int b = reader.readUbyte();
        int valueType = b & 0x1f;

        switch (valueType) {
            case ValueType.BYTE:
                reader.skipByte();
                break;
            case ValueType.SHORT:
            case ValueType.CHAR:
            case ValueType.INT:
            case ValueType.LONG:
            case ValueType.FLOAT:
            case ValueType.DOUBLE:
            case ValueType.STRING:
            case ValueType.TYPE:
            case ValueType.FIELD:
            case ValueType.METHOD:
            case ValueType.ENUM:
                int valueArg = b >>> 5;
                reader.moveRelative(valueArg+1);
                break;
            case ValueType.ARRAY:
                DexBackedArrayEncodedValue.skipFrom(reader);
                break;
            case ValueType.ANNOTATION:
                DexBackedAnnotationEncodedValue.skipFrom(reader);
                break;
            case ValueType.NULL:
            case ValueType.BOOLEAN:
                break;
            default:
                throw new ExceptionWithContext("Invalid encoded_value type: 0x%x", valueType);
        }
    } catch (Exception ex) {
        throw ExceptionWithContext.withContext(ex, "Error while skipping encoded value at offset 0x%x",
                startOffset);
    }
}