Java Code Examples for org.jf.dexlib2.dexbacked.DexBackedDexFile#readSmallUint()

The following examples show how to use org.jf.dexlib2.dexbacked.DexBackedDexFile#readSmallUint() . 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: AnnotationsDirectory.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static List<Set<? extends DexBackedAnnotation>> getParameterAnnotations(
        @Nonnull final DexBackedDexFile dexFile, final int annotationSetListOffset) {
    if (annotationSetListOffset > 0) {
        final int size = dexFile.readSmallUint(annotationSetListOffset);

        return new FixedSizeList<Set<? extends DexBackedAnnotation>>() {
            @Nonnull
            @Override
            public Set<? extends DexBackedAnnotation> readItem(int index) {
                int annotationSetOffset = dexFile.readSmallUint(annotationSetListOffset + 4 + index * 4);
                return getAnnotations(dexFile, annotationSetOffset);
            }

            @Override public int size() { return size; }
        };
    }
    return ImmutableList.of();
}
 
Example 2
Source File: ProtoIdItem.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static String asString(@Nonnull DexBackedDexFile dexFile, int protoIndex) {
    int offset = dexFile.getProtoIdItemOffset(protoIndex);

    StringBuilder sb = new StringBuilder();
    sb.append("(");

    int parametersOffset = dexFile.readSmallUint(offset + PARAMETERS_OFFSET);
    sb.append(TypeListItem.asString(dexFile, parametersOffset));
    sb.append(")");

    int returnTypeIndex = dexFile.readSmallUint(offset + RETURN_TYPE_OFFSET);
    String returnType = dexFile.getType(returnTypeIndex);
    sb.append(returnType);

    return sb.toString();
}
 
Example 3
Source File: TypeListItem.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static String asString(@Nonnull DexBackedDexFile dexFile, int typeListOffset) {
    if (typeListOffset == 0) {
        return "";
    }

    StringBuilder sb = new StringBuilder();

    int size = dexFile.readSmallUint(typeListOffset);
    for (int i=0; i<size; i++) {
        int typeIndex = dexFile.readUshort(typeListOffset + 4 + i*2);
        String type = dexFile.getType(typeIndex);
        sb.append(type);
    }
    return sb.toString();
}
 
Example 4
Source File: ProtoIdItem.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static String asString(@Nonnull DexBackedDexFile dexFile, int protoIndex) {
    int offset = dexFile.getProtoIdItemOffset(protoIndex);

    StringBuilder sb = new StringBuilder();
    sb.append("(");

    int parametersOffset = dexFile.readSmallUint(offset + PARAMETERS_OFFSET);
    sb.append(TypeListItem.asString(dexFile, parametersOffset));
    sb.append(")");

    int returnTypeIndex = dexFile.readSmallUint(offset + RETURN_TYPE_OFFSET);
    String returnType = dexFile.getType(returnTypeIndex);
    sb.append(returnType);

    return sb.toString();
}
 
Example 5
Source File: AnnotationsDirectory.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static Set<? extends DexBackedAnnotation> getAnnotations(@Nonnull final DexBackedDexFile dexFile,
                                                                 final int annotationSetOffset) {
    if (annotationSetOffset != 0) {
        final int size = dexFile.readSmallUint(annotationSetOffset);
        return new FixedSizeSet<DexBackedAnnotation>() {
            @Nonnull
            @Override
            public DexBackedAnnotation readItem(int index) {
                int annotationOffset = dexFile.readSmallUint(annotationSetOffset + 4 + (4*index));
                return new DexBackedAnnotation(dexFile, annotationOffset);
            }

            @Override public int size() { return size; }
        };
    }

    return ImmutableSet.of();
}
 
Example 6
Source File: TypeListItem.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static String asString(@Nonnull DexBackedDexFile dexFile, int typeListOffset) {
    if (typeListOffset == 0) {
        return "";
    }

    StringBuilder sb = new StringBuilder();

    int size = dexFile.readSmallUint(typeListOffset);
    for (int i=0; i<size; i++) {
        int typeIndex = dexFile.readUshort(typeListOffset + 4 + i*2);
        String type = dexFile.getType(typeIndex);
        sb.append(type);
    }
    return sb.toString();
}
 
Example 7
Source File: ProtoIdItem.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static String asString(@Nonnull DexBackedDexFile dexFile, int protoIndex) {
    int offset = dexFile.getProtoIdItemOffset(protoIndex);

    StringBuilder sb = new StringBuilder();
    sb.append("(");

    int parametersOffset = dexFile.readSmallUint(offset + PARAMETERS_OFFSET);
    sb.append(TypeListItem.asString(dexFile, parametersOffset));
    sb.append(")");

    int returnTypeIndex = dexFile.readSmallUint(offset + RETURN_TYPE_OFFSET);
    String returnType = dexFile.getType(returnTypeIndex);
    sb.append(returnType);

    return sb.toString();
}
 
Example 8
Source File: TypeListItem.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static String asString(@Nonnull DexBackedDexFile dexFile, int typeListOffset) {
    if (typeListOffset == 0) {
        return "";
    }

    StringBuilder sb = new StringBuilder();

    int size = dexFile.readSmallUint(typeListOffset);
    for (int i=0; i<size; i++) {
        int typeIndex = dexFile.readUshort(typeListOffset + 4 + i*2);
        String type = dexFile.getType(typeIndex);
        sb.append(type);
    }
    return sb.toString();
}
 
Example 9
Source File: AnnotationsDirectory.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static List<Set<? extends DexBackedAnnotation>> getParameterAnnotations(
        @Nonnull final DexBackedDexFile dexFile, final int annotationSetListOffset) {
    if (annotationSetListOffset > 0) {
        final int size = dexFile.readSmallUint(annotationSetListOffset);

        return new FixedSizeList<Set<? extends DexBackedAnnotation>>() {
            @Nonnull
            @Override
            public Set<? extends DexBackedAnnotation> readItem(int index) {
                int annotationSetOffset = dexFile.readSmallUint(annotationSetListOffset + 4 + index * 4);
                return getAnnotations(dexFile, annotationSetOffset);
            }

            @Override public int size() { return size; }
        };
    }
    return ImmutableList.of();
}
 
Example 10
Source File: FieldIdItem.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static String asString(@Nonnull DexBackedDexFile dexFile, int fieldIndex) {
    int fieldOffset = dexFile.getFieldIdItemOffset(fieldIndex);
    int classIndex = dexFile.readUshort(fieldOffset + CLASS_OFFSET);
    String classType = dexFile.getType(classIndex);

    int typeIndex = dexFile.readUshort(fieldOffset + TYPE_OFFSET);
    String fieldType = dexFile.getType(typeIndex);

    int nameIndex = dexFile.readSmallUint(fieldOffset + NAME_OFFSET);
    String fieldName = dexFile.getString(nameIndex);

    return String.format("%s->%s:%s", classType, fieldName, fieldType);
}
 
Example 11
Source File: DexBackedArrayPayload.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public DexBackedArrayPayload(@Nonnull DexBackedDexFile dexFile,
                             int instructionStart) {
    super(dexFile, OPCODE, instructionStart);

    elementWidth = dexFile.readUshort(instructionStart + ELEMENT_WIDTH_OFFSET);
    elementCount = dexFile.readSmallUint(instructionStart + ELEMENT_COUNT_OFFSET);
}
 
Example 12
Source File: DexBackedArrayPayload.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public DexBackedArrayPayload(@Nonnull DexBackedDexFile dexFile,
                             int instructionStart) {
    super(dexFile, OPCODE, instructionStart);

    elementWidth = dexFile.readUshort(instructionStart + ELEMENT_WIDTH_OFFSET);
    elementCount = dexFile.readSmallUint(instructionStart + ELEMENT_COUNT_OFFSET);
}
 
Example 13
Source File: MethodIdItem.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static String asString(@Nonnull DexBackedDexFile dexFile, int methodIndex) {
    int methodOffset = dexFile.getMethodIdItemOffset(methodIndex);
    int classIndex = dexFile.readUshort(methodOffset + CLASS_OFFSET);
    String classType = dexFile.getType(classIndex);

    int protoIndex = dexFile.readUshort(methodOffset + PROTO_OFFSET);
    String protoString = ProtoIdItem.asString(dexFile, protoIndex);

    int nameIndex = dexFile.readSmallUint(methodOffset + NAME_OFFSET);
    String methodName = dexFile.getString(nameIndex);

    return String.format("%s->%s%s", classType, methodName, protoString);
}
 
Example 14
Source File: FieldIdItem.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static String asString(@Nonnull DexBackedDexFile dexFile, int fieldIndex) {
    int fieldOffset = dexFile.getFieldIdItemOffset(fieldIndex);
    int classIndex = dexFile.readUshort(fieldOffset + CLASS_OFFSET);
    String classType = dexFile.getType(classIndex);

    int typeIndex = dexFile.readUshort(fieldOffset + TYPE_OFFSET);
    String fieldType = dexFile.getType(typeIndex);

    int nameIndex = dexFile.readSmallUint(fieldOffset + NAME_OFFSET);
    String fieldName = dexFile.getString(nameIndex);

    return String.format("%s->%s:%s", classType, fieldName, fieldType);
}
 
Example 15
Source File: FieldIdItem.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static String asString(@Nonnull DexBackedDexFile dexFile, int fieldIndex) {
    int fieldOffset = dexFile.getFieldIdItemOffset(fieldIndex);
    int classIndex = dexFile.readUshort(fieldOffset + CLASS_OFFSET);
    String classType = dexFile.getType(classIndex);

    int typeIndex = dexFile.readUshort(fieldOffset + TYPE_OFFSET);
    String fieldType = dexFile.getType(typeIndex);

    int nameIndex = dexFile.readSmallUint(fieldOffset + NAME_OFFSET);
    String fieldName = dexFile.getString(nameIndex);

    return String.format("%s->%s:%s", classType, fieldName, fieldType);
}
 
Example 16
Source File: FieldIdItem.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static String asString(@Nonnull DexBackedDexFile dexFile, int fieldIndex) {
    int fieldOffset = dexFile.getFieldIdItemOffset(fieldIndex);
    int classIndex = dexFile.readUshort(fieldOffset + CLASS_OFFSET);
    String classType = dexFile.getType(classIndex);

    int typeIndex = dexFile.readUshort(fieldOffset + TYPE_OFFSET);
    String fieldType = dexFile.getType(typeIndex);

    int nameIndex = dexFile.readSmallUint(fieldOffset + NAME_OFFSET);
    String fieldName = dexFile.getString(nameIndex);

    return String.format("%s->%s:%s", classType, fieldName, fieldType);
}
 
Example 17
Source File: MethodIdItem.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static String asString(@Nonnull DexBackedDexFile dexFile, int methodIndex) {
    int methodOffset = dexFile.getMethodIdItemOffset(methodIndex);
    int classIndex = dexFile.readUshort(methodOffset + CLASS_OFFSET);
    String classType = dexFile.getType(classIndex);

    int protoIndex = dexFile.readUshort(methodOffset + PROTO_OFFSET);
    String protoString = ProtoIdItem.asString(dexFile, protoIndex);

    int nameIndex = dexFile.readSmallUint(methodOffset + NAME_OFFSET);
    String methodName = dexFile.getString(nameIndex);

    return String.format("%s->%s%s", classType, methodName, protoString);
}
 
Example 18
Source File: ClassDefItem.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static String asString(@Nonnull DexBackedDexFile dexFile, int classIndex) {
    int offset = dexFile.getClassDefItemOffset(classIndex);
    int typeIndex = dexFile.readSmallUint(offset + CLASS_OFFSET);
    return dexFile.getType(typeIndex);
}
 
Example 19
Source File: ClassDefItem.java    From zjdroid with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static String asString(@Nonnull DexBackedDexFile dexFile, int classIndex) {
    int offset = dexFile.getClassDefItemOffset(classIndex);
    int typeIndex = dexFile.readSmallUint(offset + CLASS_OFFSET);
    return dexFile.getType(typeIndex);
}
 
Example 20
Source File: ClassDefItem.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static String asString(@Nonnull DexBackedDexFile dexFile, int classIndex) {
    int offset = dexFile.getClassDefItemOffset(classIndex);
    int typeIndex = dexFile.readSmallUint(offset + CLASS_OFFSET);
    return dexFile.getType(typeIndex);
}