本文整理汇总了Java中org.jf.dexlib2.dexbacked.raw.HeaderItem类的典型用法代码示例。如果您正苦于以下问题:Java HeaderItem类的具体用法?Java HeaderItem怎么用?Java HeaderItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HeaderItem类属于org.jf.dexlib2.dexbacked.raw包,在下文中一共展示了HeaderItem类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: DexBackedDexFile
import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入依赖的package包/类
private DexBackedDexFile(Opcodes opcodes, @Nonnull byte[] buf, int offset, boolean verifyMagic) {
super(buf);
this.type = DexFileDataType.FILETYPE;
this.opcodes = opcodes;
if (verifyMagic) {
verifyMagicAndByteOrder(buf, offset);
}
stringCount = readSmallUint(HeaderItem.STRING_COUNT_OFFSET);
stringStartOffset = readSmallUint(HeaderItem.STRING_START_OFFSET);
typeCount = readSmallUint(HeaderItem.TYPE_COUNT_OFFSET);
typeStartOffset = readSmallUint(HeaderItem.TYPE_START_OFFSET);
protoCount = readSmallUint(HeaderItem.PROTO_COUNT_OFFSET);
protoStartOffset = readSmallUint(HeaderItem.PROTO_START_OFFSET);
fieldCount = readSmallUint(HeaderItem.FIELD_COUNT_OFFSET);
fieldStartOffset = readSmallUint(HeaderItem.FIELD_START_OFFSET);
methodCount = readSmallUint(HeaderItem.METHOD_COUNT_OFFSET);
methodStartOffset = readSmallUint(HeaderItem.METHOD_START_OFFSET);
classCount = readSmallUint(HeaderItem.CLASS_COUNT_OFFSET);
classStartOffset = readSmallUint(HeaderItem.CLASS_START_OFFSET);
}
开发者ID:Miracle963,项目名称:zjdroid,代码行数:23,代码来源:DexBackedDexFile.java
示例2: verifyMagicAndByteOrder
import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入依赖的package包/类
private static void verifyMagicAndByteOrder(@Nonnull byte[] buf, int offset) {
if (!HeaderItem.verifyMagic(buf, offset)) {
StringBuilder sb = new StringBuilder("Invalid magic value:");
for (int i=0; i<8; i++) {
sb.append(String.format(" %02x", buf[i]));
}
throw new NotADexFile(sb.toString());
}
int endian = HeaderItem.getEndian(buf, offset);
if (endian == HeaderItem.BIG_ENDIAN_TAG) {
throw new ExceptionWithContext("Big endian dex files are not currently supported");
}
if (endian != HeaderItem.LITTLE_ENDIAN_TAG) {
throw new ExceptionWithContext("Invalid endian tag: 0x%x", endian);
}
}
开发者ID:Miracle963,项目名称:zjdroid,代码行数:19,代码来源:DexBackedDexFile.java
示例3: verifyDexHeader
import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入依赖的package包/类
/**
* Verifies that the dex header is valid and a supported version
*
* @param buf A byte array containing at least the first 44 bytes of a dex file
* @param offset The offset within the array to the dex header
* @throws NotADexFile If the file is not a dex file
* @throws InvalidFile If the header appears to be a dex file, but is not valid for some reason
* @throws UnsupportedFile If the dex header is valid, but uses unsupported functionality
*/
public static void verifyDexHeader( byte[] buf, int offset) {
int dexVersion = HeaderItem.getVersion(buf, offset);
if (dexVersion == -1) {
StringBuilder sb = new StringBuilder("Not a valid dex magic value:");
for (int i=0; i<8; i++) {
sb.append(String.format(" %02x", buf[i]));
}
throw new NotADexFile(sb.toString());
}
if (!HeaderItem.isSupportedDexVersion(dexVersion)) {
throw new UnsupportedFile(String.format("Dex version %03d is not supported", dexVersion));
}
int endian = HeaderItem.getEndian(buf, offset);
if (endian == HeaderItem.BIG_ENDIAN_TAG) {
throw new UnsupportedFile("Big endian dex files are not supported");
}
if (endian != HeaderItem.LITTLE_ENDIAN_TAG) {
throw new InvalidFile(String.format("Invalid endian tag: 0x%x", endian));
}
}
开发者ID:AndreJCL,项目名称:JCL,代码行数:33,代码来源:DexUtil.java
示例4: DexBackedDexFile
import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入依赖的package包/类
private DexBackedDexFile(@Nonnull Opcodes opcodes, @Nonnull byte[] buf, int offset, boolean verifyMagic) {
super(buf, offset);
this.opcodes = opcodes;
if (verifyMagic) {
verifyMagicAndByteOrder(buf, offset);
}
stringCount = readSmallUint(HeaderItem.STRING_COUNT_OFFSET);
stringStartOffset = readSmallUint(HeaderItem.STRING_START_OFFSET);
typeCount = readSmallUint(HeaderItem.TYPE_COUNT_OFFSET);
typeStartOffset = readSmallUint(HeaderItem.TYPE_START_OFFSET);
protoCount = readSmallUint(HeaderItem.PROTO_COUNT_OFFSET);
protoStartOffset = readSmallUint(HeaderItem.PROTO_START_OFFSET);
fieldCount = readSmallUint(HeaderItem.FIELD_COUNT_OFFSET);
fieldStartOffset = readSmallUint(HeaderItem.FIELD_START_OFFSET);
methodCount = readSmallUint(HeaderItem.METHOD_COUNT_OFFSET);
methodStartOffset = readSmallUint(HeaderItem.METHOD_START_OFFSET);
classCount = readSmallUint(HeaderItem.CLASS_COUNT_OFFSET);
classStartOffset = readSmallUint(HeaderItem.CLASS_START_OFFSET);
}
开发者ID:johnlee175,项目名称:dex,代码行数:23,代码来源:DexBackedDexFile.java
示例5: updateSignature
import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入依赖的package包/类
private void updateSignature(@Nonnull DexDataStore dataStore) throws IOException {
MessageDigest md;
try {
md = MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException ex) {
throw new RuntimeException(ex);
}
byte[] buffer = new byte[4 * 1024];
InputStream input = dataStore.readAt(HeaderItem.SIGNATURE_DATA_START_OFFSET);
int bytesRead = input.read(buffer);
while (bytesRead >= 0) {
md.update(buffer, 0, bytesRead);
bytesRead = input.read(buffer);
}
byte[] signature = md.digest();
if (signature.length != HeaderItem.SIGNATURE_SIZE) {
throw new RuntimeException("unexpected digest write: " + signature.length + " bytes");
}
// write signature
OutputStream output = dataStore.outputAt(HeaderItem.SIGNATURE_OFFSET);
output.write(signature);
output.close();
}
开发者ID:niranjan94,项目名称:show-java,代码行数:27,代码来源:DexWriter.java
示例6: updateChecksum
import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入依赖的package包/类
private void updateChecksum(@Nonnull DexDataStore dataStore) throws IOException {
Adler32 a32 = new Adler32();
byte[] buffer = new byte[4 * 1024];
InputStream input = dataStore.readAt(HeaderItem.CHECKSUM_DATA_START_OFFSET);
int bytesRead = input.read(buffer);
while (bytesRead >= 0) {
a32.update(buffer, 0, bytesRead);
bytesRead = input.read(buffer);
}
// write checksum, utilizing logic in DexWriter to write the integer value properly
OutputStream output = dataStore.outputAt(HeaderItem.CHECKSUM_OFFSET);
DexDataWriter.writeInt(output, (int) a32.getValue());
output.close();
}
开发者ID:niranjan94,项目名称:show-java,代码行数:17,代码来源:DexWriter.java
示例7: DexBackedDexFile
import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入依赖的package包/类
private DexBackedDexFile(Opcodes opcodes, @Nonnull byte[] buf, int offset, boolean verifyMagic) {
super(buf);
this.opcodes = opcodes;
if (verifyMagic) {
verifyMagicAndByteOrder(buf, offset);
}
stringCount = readSmallUint(HeaderItem.STRING_COUNT_OFFSET);
stringStartOffset = readSmallUint(HeaderItem.STRING_START_OFFSET);
typeCount = readSmallUint(HeaderItem.TYPE_COUNT_OFFSET);
typeStartOffset = readSmallUint(HeaderItem.TYPE_START_OFFSET);
protoCount = readSmallUint(HeaderItem.PROTO_COUNT_OFFSET);
protoStartOffset = readSmallUint(HeaderItem.PROTO_START_OFFSET);
fieldCount = readSmallUint(HeaderItem.FIELD_COUNT_OFFSET);
fieldStartOffset = readSmallUint(HeaderItem.FIELD_START_OFFSET);
methodCount = readSmallUint(HeaderItem.METHOD_COUNT_OFFSET);
methodStartOffset = readSmallUint(HeaderItem.METHOD_START_OFFSET);
classCount = readSmallUint(HeaderItem.CLASS_COUNT_OFFSET);
classStartOffset = readSmallUint(HeaderItem.CLASS_START_OFFSET);
}
开发者ID:niranjan94,项目名称:show-java,代码行数:23,代码来源:DexBackedDexFile.java
示例8: verifyMagicAndByteOrder
import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入依赖的package包/类
private static void verifyMagicAndByteOrder(@Nonnull byte[] buf, int offset) {
if (!HeaderItem.verifyMagic(buf, offset)) {
StringBuilder sb = new StringBuilder("Invalid magic value:");
for (int i = 0; i < 8; i++) {
sb.append(String.format(" %02x", buf[i]));
}
throw new NotADexFile(sb.toString());
}
int endian = HeaderItem.getEndian(buf, offset);
if (endian == HeaderItem.BIG_ENDIAN_TAG) {
throw new ExceptionWithContext("Big endian dex files are not currently supported");
}
if (endian != HeaderItem.LITTLE_ENDIAN_TAG) {
throw new ExceptionWithContext("Invalid endian tag: 0x%x", endian);
}
}
开发者ID:niranjan94,项目名称:show-java,代码行数:19,代码来源:DexBackedDexFile.java
示例9: readRawDexFile
import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入依赖的package包/类
public static DexBackedDexFile readRawDexFile(byte[] buf, int offset, Opcodes opcodes) throws IOException {
DexUtil.verifyDexHeader(buf, offset);
if (opcodes == null) {
int dexVersion = HeaderItem.getVersion(buf, offset);
opcodes = OpcodeUtils.getOpcodesFromDexVersion(dexVersion);
};
return new DexBackedDexFile(opcodes, buf, 0);
}
开发者ID:DexPatcher,项目名称:multidexlib2,代码行数:9,代码来源:RawDexIO.java
示例10: next
import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入依赖的package包/类
@Override public DexEntry next() {
int filenameLength = readSmallUint(offset);
offset += 4;
// TODO: what is the correct character encoding?
String filename = new String(buf, offset, filenameLength, Charset.forName("US-ASCII"));
offset += filenameLength;
offset += 4; // checksum
int dexOffset = readSmallUint(offset) + oatHeader.headerOffset;
offset += 4;
if (getOatVersion() >= 75) {
offset += 4; // offset to class offsets table
}
if (getOatVersion() >= 73) {
offset += 4; // lookup table offset
}
if (getOatVersion() < 75) {
// prior to 75, the class offsets are included here directly
int classCount = readSmallUint(dexOffset + HeaderItem.CLASS_COUNT_OFFSET);
offset += 4 * classCount;
}
index++;
return new DexEntry(filename, dexOffset);
}
开发者ID:AndreJCL,项目名称:JCL,代码行数:31,代码来源:OatFile.java
示例11: getDataSectionOffset
import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入依赖的package包/类
private int getDataSectionOffset() {
return HeaderItem.ITEM_SIZE +
stringSection.getItems().size() * StringIdItem.ITEM_SIZE +
typeSection.getItems().size() * TypeIdItem.ITEM_SIZE +
protoSection.getItems().size() * ProtoIdItem.ITEM_SIZE +
fieldSection.getItems().size() * FieldIdItem.ITEM_SIZE +
methodSection.getItems().size() * MethodIdItem.ITEM_SIZE +
classSection.getItems().size() * ClassDefItem.ITEM_SIZE;
}
开发者ID:niranjan94,项目名称:show-java,代码行数:10,代码来源:DexWriter.java
示例12: writeTo
import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入依赖的package包/类
public void writeTo(@Nonnull DexDataStore dest,
@Nonnull DeferredOutputStreamFactory tempFactory) throws IOException {
try {
int dataSectionOffset = getDataSectionOffset();
DexDataWriter headerWriter = outputAt(dest, 0);
DexDataWriter indexWriter = outputAt(dest, HeaderItem.ITEM_SIZE);
DexDataWriter offsetWriter = outputAt(dest, dataSectionOffset);
try {
writeStrings(indexWriter, offsetWriter);
writeTypes(indexWriter);
writeTypeLists(offsetWriter);
writeProtos(indexWriter);
writeFields(indexWriter);
writeMethods(indexWriter);
writeEncodedArrays(offsetWriter);
writeAnnotations(offsetWriter);
writeAnnotationSets(offsetWriter);
writeAnnotationSetRefs(offsetWriter);
writeAnnotationDirectories(offsetWriter);
writeDebugAndCodeItems(offsetWriter, tempFactory.makeDeferredOutputStream());
writeClasses(indexWriter, offsetWriter);
writeMapItem(offsetWriter);
writeHeader(headerWriter, dataSectionOffset, offsetWriter.getPosition());
} finally {
headerWriter.close();
indexWriter.close();
offsetWriter.close();
}
updateSignature(dest);
updateChecksum(dest);
} finally {
dest.close();
}
}
开发者ID:niranjan94,项目名称:show-java,代码行数:35,代码来源:DexWriter.java
示例13: writeHeader
import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入依赖的package包/类
private void writeHeader(@Nonnull DexDataWriter writer, int dataOffset, int fileSize) throws IOException {
// always write the 035 version, there's no reason to use the 036 version for now
writer.write(HeaderItem.MAGIC_VALUES[0]);
// checksum placeholder
writer.writeInt(0);
// signature placeholder
writer.write(new byte[20]);
writer.writeInt(fileSize);
writer.writeInt(HeaderItem.ITEM_SIZE);
writer.writeInt(HeaderItem.LITTLE_ENDIAN_TAG);
// link
writer.writeInt(0);
writer.writeInt(0);
// map
writer.writeInt(mapSectionOffset);
// index sections
writeSectionInfo(writer, stringSection.getItems().size(), stringIndexSectionOffset);
writeSectionInfo(writer, typeSection.getItems().size(), typeSectionOffset);
writeSectionInfo(writer, protoSection.getItems().size(), protoSectionOffset);
writeSectionInfo(writer, fieldSection.getItems().size(), fieldSectionOffset);
writeSectionInfo(writer, methodSection.getItems().size(), methodSectionOffset);
writeSectionInfo(writer, classSection.getItems().size(), classIndexSectionOffset);
// data section
writer.writeInt(fileSize - dataOffset);
writer.writeInt(dataOffset);
}
开发者ID:niranjan94,项目名称:show-java,代码行数:35,代码来源:DexWriter.java
示例14: getHighestDexVersionFromApiLevel
import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入依赖的package包/类
public static int getHighestDexVersionFromApiLevel(int apiLevel) {
return HeaderItem.getVersion(HeaderItem.getMagicForApi(apiLevel), 0);
}
开发者ID:DexPatcher,项目名称:multidexlib2,代码行数:4,代码来源:DexVersionMap.java
示例15: getDexFiles
import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入依赖的package包/类
@Nonnull
public List<OatDexFile> getDexFiles() {
return new AbstractForwardSequentialList<OatDexFile>() {
@Override public int size() {
return oatHeader.getDexFileCount();
}
@Nonnull @Override public Iterator<OatDexFile> iterator() {
return new Iterator<OatDexFile>() {
int index = 0;
int offset = oatHeader.getDexListStart();
@Override public boolean hasNext() {
return index < size();
}
@Override public OatDexFile next() {
int filenameLength = readSmallUint(offset);
offset += 4;
// TODO: what is the correct character encoding?
String filename = new String(buf, offset, filenameLength, Charset.forName("US-ASCII"));
offset += filenameLength;
offset += 4; // checksum
int dexOffset = readSmallUint(offset) + oatHeader.offset;
offset += 4;
int classCount = readSmallUint(dexOffset + HeaderItem.CLASS_COUNT_OFFSET);
offset += 4 * classCount;
index++;
return new OatDexFile(dexOffset, filename);
}
@Override public void remove() {
throw new UnsupportedOperationException();
}
};
}
};
}
开发者ID:johnlee175,项目名称:dex,代码行数:45,代码来源:OatFile.java
示例16: DexAnnotator
import org.jf.dexlib2.dexbacked.raw.HeaderItem; //导入依赖的package包/类
public DexAnnotator(@Nonnull RawDexFile dexFile, int width) {
super(width);
this.dexFile = dexFile;
for (MapItem mapItem : dexFile.getMapItems()) {
switch (mapItem.getType()) {
case ItemType.HEADER_ITEM:
annotators.put(mapItem.getType(), HeaderItem.makeAnnotator(this, mapItem));
break;
case ItemType.STRING_ID_ITEM:
annotators.put(mapItem.getType(), StringIdItem.makeAnnotator(this, mapItem));
break;
case ItemType.TYPE_ID_ITEM:
annotators.put(mapItem.getType(), TypeIdItem.makeAnnotator(this, mapItem));
break;
case ItemType.PROTO_ID_ITEM:
annotators.put(mapItem.getType(), ProtoIdItem.makeAnnotator(this, mapItem));
break;
case ItemType.FIELD_ID_ITEM:
annotators.put(mapItem.getType(), FieldIdItem.makeAnnotator(this, mapItem));
break;
case ItemType.METHOD_ID_ITEM:
annotators.put(mapItem.getType(), MethodIdItem.makeAnnotator(this, mapItem));
break;
case ItemType.CLASS_DEF_ITEM:
annotators.put(mapItem.getType(), ClassDefItem.makeAnnotator(this, mapItem));
break;
case ItemType.MAP_LIST:
annotators.put(mapItem.getType(), MapItem.makeAnnotator(this, mapItem));
break;
case ItemType.TYPE_LIST:
annotators.put(mapItem.getType(), TypeListItem.makeAnnotator(this, mapItem));
break;
case ItemType.ANNOTATION_SET_REF_LIST:
annotators.put(mapItem.getType(), AnnotationSetRefList.makeAnnotator(this, mapItem));
break;
case ItemType.ANNOTATION_SET_ITEM:
annotators.put(mapItem.getType(), AnnotationSetItem.makeAnnotator(this, mapItem));
break;
case ItemType.CLASS_DATA_ITEM:
annotators.put(mapItem.getType(), ClassDataItem.makeAnnotator(this, mapItem));
break;
case ItemType.CODE_ITEM:
annotators.put(mapItem.getType(), CodeItem.makeAnnotator(this, mapItem));
break;
case ItemType.STRING_DATA_ITEM:
annotators.put(mapItem.getType(), StringDataItem.makeAnnotator(this, mapItem));
break;
case ItemType.DEBUG_INFO_ITEM:
annotators.put(mapItem.getType(), DebugInfoItem.makeAnnotator(this, mapItem));
break;
case ItemType.ANNOTATION_ITEM:
annotators.put(mapItem.getType(), AnnotationItem.makeAnnotator(this, mapItem));
break;
case ItemType.ENCODED_ARRAY_ITEM:
annotators.put(mapItem.getType(), EncodedArrayItem.makeAnnotator(this, mapItem));
break;
case ItemType.ANNOTATION_DIRECTORY_ITEM:
annotators.put(mapItem.getType(), AnnotationDirectoryItem.makeAnnotator(this, mapItem));
break;
default:
throw new RuntimeException(String.format("Unrecognized item type: 0x%x", mapItem.getType()));
}
}
}
开发者ID:niranjan94,项目名称:show-java,代码行数:67,代码来源:DexAnnotator.java
注:本文中的org.jf.dexlib2.dexbacked.raw.HeaderItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论