org.jf.dexlib2.dexbacked.raw.ClassDefItem Java Examples

The following examples show how to use org.jf.dexlib2.dexbacked.raw.ClassDefItem. 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: DexBackedClassDef.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public Set<String> getInterfaces() {
    final int interfacesOffset = dexFile.readSmallUint(classDefOffset + ClassDefItem.INTERFACES_OFFSET);
    if (interfacesOffset > 0) {
        final int size = dexFile.readSmallUint(interfacesOffset);
        return new FixedSizeSet<String>() {
            @Nonnull
            @Override
            public String readItem(int index) {
                return dexFile.getType(dexFile.readUshort(interfacesOffset + 4 + (2*index)));
            }

            @Override public int size() { return size; }
        };
    }
    return ImmutableSet.of();
}
 
Example #2
Source File: DexBackedClassDef.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public Set<String> getInterfaces() {
    final int interfacesOffset = dexFile.readSmallUint(classDefOffset + ClassDefItem.INTERFACES_OFFSET);
    if (interfacesOffset > 0) {
        final int size = dexFile.readSmallUint(interfacesOffset);
        return new FixedSizeSet<String>() {
            @Nonnull
            @Override
            public String readItem(int index) {
                return dexFile.getType(dexFile.readUshort(interfacesOffset + 4 + (2*index)));
            }

            @Override public int size() { return size; }
        };
    }
    return ImmutableSet.of();
}
 
Example #3
Source File: DexBackedClassDef.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public Set<String> getInterfaces() {
    final int interfacesOffset = dexFile.readSmallUint(classDefOffset + ClassDefItem.INTERFACES_OFFSET);
    if (interfacesOffset > 0) {
        final int size = dexFile.readSmallUint(interfacesOffset);
        return new FixedSizeSet<String>() {
            @Nonnull
            @Override
            public String readItem(int index) {
                return dexFile.getType(dexFile.readUshort(interfacesOffset + 4 + (2*index)));
            }

            @Override public int size() { return size; }
        };
    }
    return ImmutableSet.of();
}
 
Example #4
Source File: DexBackedClassDef.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public Set<String> getInterfaces() {
    final int interfacesOffset = dexFile.readSmallUint(classDefOffset + ClassDefItem.INTERFACES_OFFSET);
    if (interfacesOffset > 0) {
        final int size = dexFile.readSmallUint(interfacesOffset);
        return new FixedSizeSet<String>() {
            @Nonnull
            @Override
            public String readItem(int index) {
                return dexFile.getType(dexFile.readUshort(interfacesOffset + 4 + (2*index)));
            }

            @Override public int size() { return size; }
        };
    }
    return ImmutableSet.of();
}
 
Example #5
Source File: DexBackedDexFile.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public int getClassDefItemOffset(int classIndex) {
	if(this.type == DexFileDataType.MEMORYTYPE){
		return classStartOffset + classIndex*ClassDefItem.ITEM_SIZE;
	}
    if (classIndex < 0 || classIndex >= classCount) {
        throw new InvalidItemIndex(classIndex, "Class index out of bounds: %d", classIndex);
    }
    return classStartOffset + classIndex*ClassDefItem.ITEM_SIZE;
}
 
Example #6
Source File: DexBackedClassDef.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
private AnnotationsDirectory getAnnotationsDirectory() {
    if (annotationsDirectory == null) {
        int annotationsDirectoryOffset = dexFile.readSmallUint(classDefOffset + ClassDefItem.ANNOTATIONS_OFFSET);
        annotationsDirectory = AnnotationsDirectory.newOrEmpty(dexFile, annotationsDirectoryOffset);
    }
    return annotationsDirectory;
}
 
Example #7
Source File: DexBackedClassDef.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public DexBackedClassDef(@Nonnull DexBackedDexFile dexFile,
                         int classDefOffset) {
    this.dexFile = dexFile;
    this.classDefOffset = classDefOffset;

    try{
       int classDataOffset = dexFile.readSmallUint(classDefOffset + ClassDefItem.CLASS_DATA_OFFSET);
       //Logger.log("the classDataOffset ="+classDataOffset);
       if (classDataOffset == 0) {
           staticFieldsOffset = -1;
           staticFieldCount = 0;
           instanceFieldCount = 0;
           directMethodCount = 0;
           virtualMethodCount = 0;
       } else {
           DexReader reader = dexFile.readerAt(classDataOffset);
           staticFieldCount = reader.readSmallUleb128();
           instanceFieldCount = reader.readSmallUleb128();
           directMethodCount = reader.readSmallUleb128();
           virtualMethodCount = reader.readSmallUleb128();
           staticFieldsOffset = reader.getOffset(); 
       }
    }catch(Exception e){
    	e.printStackTrace();
    	this.isValid = false;
    }


}
 
Example #8
Source File: DexBackedDexFile.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public int getClassDefItemOffset(int classIndex) {
	if(this.type == DexFileDataType.MEMORYTYPE){
		return classStartOffset + classIndex*ClassDefItem.ITEM_SIZE;
	}
    if (classIndex < 0 || classIndex >= classCount) {
        throw new InvalidItemIndex(classIndex, "Class index out of bounds: %d", classIndex);
    }
    return classStartOffset + classIndex*ClassDefItem.ITEM_SIZE;
}
 
Example #9
Source File: DexBackedClassDef.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
private AnnotationsDirectory getAnnotationsDirectory() {
    if (annotationsDirectory == null) {
        int annotationsDirectoryOffset = dexFile.readSmallUint(classDefOffset + ClassDefItem.ANNOTATIONS_OFFSET);
        annotationsDirectory = AnnotationsDirectory.newOrEmpty(dexFile, annotationsDirectoryOffset);
    }
    return annotationsDirectory;
}
 
Example #10
Source File: DexBackedClassDef.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public DexBackedClassDef(@Nonnull DexBackedDexFile dexFile,
                         int classDefOffset) {
    this.dexFile = dexFile;
    this.classDefOffset = classDefOffset;

    try{
       int classDataOffset = dexFile.readSmallUint(classDefOffset + ClassDefItem.CLASS_DATA_OFFSET);
       //Logger.log("the classDataOffset ="+classDataOffset);
       if (classDataOffset == 0) {
           staticFieldsOffset = -1;
           staticFieldCount = 0;
           instanceFieldCount = 0;
           directMethodCount = 0;
           virtualMethodCount = 0;
       } else {
           DexReader reader = dexFile.readerAt(classDataOffset);
           staticFieldCount = reader.readSmallUleb128();
           instanceFieldCount = reader.readSmallUleb128();
           directMethodCount = reader.readSmallUleb128();
           virtualMethodCount = reader.readSmallUleb128();
           staticFieldsOffset = reader.getOffset(); 
       }
    }catch(Exception e){
    	e.printStackTrace();
    	this.isValid = false;
    }


}
 
Example #11
Source File: DexBackedDexFile.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public int getClassDefItemOffset(int classIndex) {
	if(this.type == DexFileDataType.MEMORYTYPE){
		return classStartOffset + classIndex*ClassDefItem.ITEM_SIZE;
	}
    if (classIndex < 0 || classIndex >= classCount) {
        throw new InvalidItemIndex(classIndex, "Class index out of bounds: %d", classIndex);
    }
    return classStartOffset + classIndex*ClassDefItem.ITEM_SIZE;
}
 
Example #12
Source File: DexBackedClassDef.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
private AnnotationsDirectory getAnnotationsDirectory() {
    if (annotationsDirectory == null) {
        int annotationsDirectoryOffset = dexFile.readSmallUint(classDefOffset + ClassDefItem.ANNOTATIONS_OFFSET);
        annotationsDirectory = AnnotationsDirectory.newOrEmpty(dexFile, annotationsDirectoryOffset);
    }
    return annotationsDirectory;
}
 
Example #13
Source File: DexBackedClassDef.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
private AnnotationsDirectory getAnnotationsDirectory() {
    if (annotationsDirectory == null) {
        int annotationsDirectoryOffset = dexFile.readSmallUint(classDefOffset + ClassDefItem.ANNOTATIONS_OFFSET);
        annotationsDirectory = AnnotationsDirectory.newOrEmpty(dexFile, annotationsDirectoryOffset);
    }
    return annotationsDirectory;
}
 
Example #14
Source File: DexBackedClassDef.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public DexBackedClassDef(@Nonnull DexBackedDexFile dexFile,
                         int classDefOffset) {
    this.dexFile = dexFile;
    this.classDefOffset = classDefOffset;

    try{
       int classDataOffset = dexFile.readSmallUint(classDefOffset + ClassDefItem.CLASS_DATA_OFFSET);
       //Logger.log("the classDataOffset ="+classDataOffset);
       if (classDataOffset == 0) {
           staticFieldsOffset = -1;
           staticFieldCount = 0;
           instanceFieldCount = 0;
           directMethodCount = 0;
           virtualMethodCount = 0;
       } else {
           DexReader reader = dexFile.readerAt(classDataOffset);
           staticFieldCount = reader.readSmallUleb128();
           instanceFieldCount = reader.readSmallUleb128();
           directMethodCount = reader.readSmallUleb128();
           virtualMethodCount = reader.readSmallUleb128();
           staticFieldsOffset = reader.getOffset(); 
       }
    }catch(Exception e){
    	e.printStackTrace();
    	this.isValid = false;
    }


}
 
Example #15
Source File: DexBackedDexFile.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public int getClassDefItemOffset(int classIndex) {
	if(this.type == DexFileDataType.MEMORYTYPE){
		return classStartOffset + classIndex*ClassDefItem.ITEM_SIZE;
	}
    if (classIndex < 0 || classIndex >= classCount) {
        throw new InvalidItemIndex(classIndex, "Class index out of bounds: %d", classIndex);
    }
    return classStartOffset + classIndex*ClassDefItem.ITEM_SIZE;
}
 
Example #16
Source File: DexBackedClassDef.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public DexBackedClassDef(@Nonnull DexBackedDexFile dexFile,
                         int classDefOffset) {
    this.dexFile = dexFile;
    this.classDefOffset = classDefOffset;

    try{
       int classDataOffset = dexFile.readSmallUint(classDefOffset + ClassDefItem.CLASS_DATA_OFFSET);
       //Logger.log("the classDataOffset ="+classDataOffset);
       if (classDataOffset == 0) {
           staticFieldsOffset = -1;
           staticFieldCount = 0;
           instanceFieldCount = 0;
           directMethodCount = 0;
           virtualMethodCount = 0;
       } else {
           DexReader reader = dexFile.readerAt(classDataOffset);
           staticFieldCount = reader.readSmallUleb128();
           instanceFieldCount = reader.readSmallUleb128();
           directMethodCount = reader.readSmallUleb128();
           virtualMethodCount = reader.readSmallUleb128();
           staticFieldsOffset = reader.getOffset(); 
       }
    }catch(Exception e){
    	e.printStackTrace();
    	this.isValid = false;
    }


}
 
Example #17
Source File: DexBackedClassDef.java    From zjdroid with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public String getType() {
    return dexFile.getType(dexFile.readSmallUint(classDefOffset + ClassDefItem.CLASS_OFFSET));
}
 
Example #18
Source File: DexBackedClassDef.java    From zjdroid with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public String getSuperclass() {
    return dexFile.getOptionalType(dexFile.readOptionalUint(classDefOffset + ClassDefItem.SUPERCLASS_OFFSET));
}
 
Example #19
Source File: DexBackedClassDef.java    From HeyGirl with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public String getType() {
    return dexFile.getType(dexFile.readSmallUint(classDefOffset + ClassDefItem.CLASS_OFFSET));
}
 
Example #20
Source File: DexBackedClassDef.java    From HeyGirl with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public String getSuperclass() {
    return dexFile.getOptionalType(dexFile.readOptionalUint(classDefOffset + ClassDefItem.SUPERCLASS_OFFSET));
}
 
Example #21
Source File: DexBackedClassDef.java    From HeyGirl with Apache License 2.0 4 votes vote down vote up
@Override
public int getAccessFlags() {
    return dexFile.readSmallUint(classDefOffset + ClassDefItem.ACCESS_FLAGS_OFFSET);
}
 
Example #22
Source File: DexBackedClassDef.java    From HeyGirl with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public String getSourceFile() {
    return dexFile.getOptionalString(dexFile.readOptionalUint(classDefOffset + ClassDefItem.SOURCE_FILE_OFFSET));
}
 
Example #23
Source File: DexBackedClassDef.java    From zjdroid with Apache License 2.0 4 votes vote down vote up
@Override
public int getAccessFlags() {
    return dexFile.readSmallUint(classDefOffset + ClassDefItem.ACCESS_FLAGS_OFFSET);
}
 
Example #24
Source File: DexBackedClassDef.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public String getSourceFile() {
    return dexFile.getOptionalString(dexFile.readOptionalUint(classDefOffset + ClassDefItem.SOURCE_FILE_OFFSET));
}
 
Example #25
Source File: DexBackedClassDef.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Override
public int getAccessFlags() {
    return dexFile.readSmallUint(classDefOffset + ClassDefItem.ACCESS_FLAGS_OFFSET);
}
 
Example #26
Source File: DexBackedClassDef.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public String getSuperclass() {
    return dexFile.getOptionalType(dexFile.readOptionalUint(classDefOffset + ClassDefItem.SUPERCLASS_OFFSET));
}
 
Example #27
Source File: DexBackedClassDef.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public String getType() {
    return dexFile.getType(dexFile.readSmallUint(classDefOffset + ClassDefItem.CLASS_OFFSET));
}
 
Example #28
Source File: DexBackedClassDef.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public String getSuperclass() {
    return dexFile.getOptionalType(dexFile.readOptionalUint(classDefOffset + ClassDefItem.SUPERCLASS_OFFSET));
}
 
Example #29
Source File: DexBackedClassDef.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Override
public int getAccessFlags() {
    return dexFile.readSmallUint(classDefOffset + ClassDefItem.ACCESS_FLAGS_OFFSET);
}
 
Example #30
Source File: DexBackedClassDef.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public String getSourceFile() {
    return dexFile.getOptionalString(dexFile.readOptionalUint(classDefOffset + ClassDefItem.SOURCE_FILE_OFFSET));
}