oatFile = OatFile.fromInputStream(inputStream, new FilenameVdexProvider(file)); } catch (NotAnOatFileException ex) { if (oatFile.isSupportedVersion() == OatFile.UNSUPPORTED) { throw new UnsupportedOatVersionException(oatFile); List<OatDexFile> oatDexFiles = oatFile.getDexFiles();
public UnsupportedOatVersionException(@Nonnull OatFile oatFile) { super("Unsupported oat version: %d", oatFile.getOatVersion()); this.oatFile = oatFile; } }
oatFile = OatFile.fromInputStream(inputStream, new FilenameVdexProvider(file)); } catch (NotAnOatFileException ex) { if (oatFile.isSupportedVersion() == OatFile.UNSUPPORTED) { throw new UnsupportedOatVersionException(oatFile);
OatFile oatFile = OatFile.fromInputStream(inputStream); for (String entry: oatFile.getBootClassPath()) { System.out.println(entry);
@Override public DexEntry next() { int filenameLength = readSmallUint(offset); offset += 4; int dexOffset = readSmallUint(offset); offset += 4; if (getOatVersion() >= 87 && vdexProvider != null && vdexProvider.getVdex() != null) { buf = vdexProvider.getVdex(); } else { if (getOatVersion() >= 75) { offset += 4; // offset to class offsets table if (getOatVersion() >= 73) { offset += 4; // lookup table offset if (getOatVersion() >= 131) { offset += 4; // dex sections layout offset if (getOatVersion() >= 127) { offset += 4; // method bss mapping offset if (getOatVersion() < 75) { int classCount = readSmallUint(dexOffset + HeaderItem.CLASS_COUNT_OFFSET); offset += 4 * classCount;
private static List<String> bootClassPathForOat(@Nonnull OatDexFile dexFile) { List<String> bcp = dexFile.getContainer().getBootClassPath(); if(bcp.isEmpty()) { return Lists.newArrayList("boot.oat"); } else { return replaceElementsSuffix(bcp, ".art", ".oat"); } }
@Nonnull private StringTable getSectionNameStringTable() { int index = readUshort(50); if (index == 0) { throw new InvalidOatFileException("There is no section name string table"); } try { return new StringTable(getSections().get(index)); } catch (IndexOutOfBoundsException ex) { throw new InvalidOatFileException("The section index for the section name string table is invalid"); } }
public static OatFile fromInputStream(@Nonnull InputStream is) throws IOException { return fromInputStream(is, null); }
public static OatFile fromInputStream(@Nonnull InputStream is, @Nullable VdexProvider vdexProvider) throws IOException { if (!is.markSupported()) { throw new IllegalArgumentException("InputStream must support mark"); } is.mark(4); byte[] partialHeader = new byte[4]; try { ByteStreams.readFully(is, partialHeader); } catch (EOFException ex) { throw new NotAnOatFileException(); } finally { is.reset(); } verifyMagic(partialHeader); is.reset(); byte[] buf = ByteStreams.toByteArray(is); return new OatFile(buf, vdexProvider); }
verifyMagic(buf); SymbolTable symbolTable = getSymbolTable(); for (Symbol symbol: symbolTable.getSymbols()) { if (symbol.getName().equals("oatdata")) {
public int getType() { return readInt(offset + 4); } public abstract long getAddress();
public long getValue() { return readLong(offset + 8); } public int getSize() { return readLongAsSmallUint(offset + 16); }
@Nonnull private SymbolTable getSymbolTable() { for (SectionHeader header: getSections()) { if (header.getType() == SectionHeader.TYPE_DYNAMIC_SYMBOL_TABLE) { return new SymbolTable(header); } } throw new InvalidOatFileException("Oat file has no symbol table"); }
OatFile oatFile = OatFile.fromInputStream(inputStream); for (String entry: oatFile.getBootClassPath()) { System.out.println(entry);
oatFile = OatFile.fromInputStream(inputStream, new FilenameVdexProvider(file)); } catch (NotAnOatFileException ex) { if (oatFile.isSupportedVersion() == OatFile.UNSUPPORTED) { throw new UnsupportedOatVersionException(oatFile);
@Override public DexEntry next() { int filenameLength = readSmallUint(offset); offset += 4; int dexOffset = readSmallUint(offset); offset += 4; if (getOatVersion() >= 87 && vdexProvider != null && vdexProvider.getVdex() != null) { buf = vdexProvider.getVdex(); } else { if (getOatVersion() >= 75) { offset += 4; // offset to class offsets table if (getOatVersion() >= 73) { offset += 4; // lookup table offset if (getOatVersion() >= 131) { offset += 4; // dex sections layout offset if (getOatVersion() >= 127) { offset += 4; // method bss mapping offset if (getOatVersion() < 75) { int classCount = readSmallUint(dexOffset + HeaderItem.CLASS_COUNT_OFFSET); offset += 4 * classCount;
private static List<String> bootClassPathForOat(@Nonnull OatDexFile dexFile) { List<String> bcp = dexFile.getContainer().getBootClassPath(); if(bcp.isEmpty()) { return Lists.newArrayList("boot.oat"); } else { return replaceElementsSuffix(bcp, ".art", ".oat"); } }
@Nonnull private StringTable getSectionNameStringTable() { int index = readUshort(50); if (index == 0) { throw new InvalidOatFileException("There is no section name string table"); } try { return new StringTable(getSections().get(index)); } catch (IndexOutOfBoundsException ex) { throw new InvalidOatFileException("The section index for the section name string table is invalid"); } }
public static OatFile fromInputStream(@Nonnull InputStream is) throws IOException { return fromInputStream(is, null); }
public static OatFile fromInputStream(@Nonnull InputStream is, @Nullable VdexProvider vdexProvider) throws IOException { if (!is.markSupported()) { throw new IllegalArgumentException("InputStream must support mark"); } is.mark(4); byte[] partialHeader = new byte[4]; try { ByteStreams.readFully(is, partialHeader); } catch (EOFException ex) { throw new NotAnOatFileException(); } finally { is.reset(); } verifyMagic(partialHeader); is.reset(); byte[] buf = ByteStreams.toByteArray(is); return new OatFile(buf, vdexProvider); }