Java Code Examples for org.jf.dexlib2.dexbacked.raw.OdexHeaderItem#getDexOffset()
The following examples show how to use
org.jf.dexlib2.dexbacked.raw.OdexHeaderItem#getDexOffset() .
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: DexBackedOdexFile.java From ZjDroid with Apache License 2.0 | 5 votes |
public static DexBackedOdexFile fromInputStream(@Nonnull Opcodes opcodes, @Nonnull InputStream is) throws IOException { if (!is.markSupported()) { throw new IllegalArgumentException("InputStream must support mark"); } is.mark(8); byte[] partialHeader = new byte[8]; try { ByteStreams.readFully(is, partialHeader); } catch (EOFException ex) { throw new NotADexFile("File is too short"); } finally { is.reset(); } verifyMagic(partialHeader); is.reset(); byte[] odexBuf = new byte[OdexHeaderItem.ITEM_SIZE]; ByteStreams.readFully(is, odexBuf); int dexOffset = OdexHeaderItem.getDexOffset(odexBuf); if (dexOffset > OdexHeaderItem.ITEM_SIZE) { ByteStreams.skipFully(is, dexOffset - OdexHeaderItem.ITEM_SIZE); } byte[] dexBuf = ByteStreams.toByteArray(is); return new DexBackedOdexFile(opcodes, odexBuf, dexBuf); }
Example 2
Source File: DexBackedOdexFile.java From zjdroid with Apache License 2.0 | 5 votes |
public static DexBackedOdexFile fromInputStream(@Nonnull Opcodes opcodes, @Nonnull InputStream is) throws IOException { if (!is.markSupported()) { throw new IllegalArgumentException("InputStream must support mark"); } is.mark(8); byte[] partialHeader = new byte[8]; try { ByteStreams.readFully(is, partialHeader); } catch (EOFException ex) { throw new NotADexFile("File is too short"); } finally { is.reset(); } verifyMagic(partialHeader); is.reset(); byte[] odexBuf = new byte[OdexHeaderItem.ITEM_SIZE]; ByteStreams.readFully(is, odexBuf); int dexOffset = OdexHeaderItem.getDexOffset(odexBuf); if (dexOffset > OdexHeaderItem.ITEM_SIZE) { ByteStreams.skipFully(is, dexOffset - OdexHeaderItem.ITEM_SIZE); } byte[] dexBuf = ByteStreams.toByteArray(is); return new DexBackedOdexFile(opcodes, odexBuf, dexBuf); }
Example 3
Source File: DexBackedOdexFile.java From HeyGirl with Apache License 2.0 | 5 votes |
public static DexBackedOdexFile fromInputStream(@Nonnull Opcodes opcodes, @Nonnull InputStream is) throws IOException { if (!is.markSupported()) { throw new IllegalArgumentException("InputStream must support mark"); } is.mark(8); byte[] partialHeader = new byte[8]; try { ByteStreams.readFully(is, partialHeader); } catch (EOFException ex) { throw new NotADexFile("File is too short"); } finally { is.reset(); } verifyMagic(partialHeader); is.reset(); byte[] odexBuf = new byte[OdexHeaderItem.ITEM_SIZE]; ByteStreams.readFully(is, odexBuf); int dexOffset = OdexHeaderItem.getDexOffset(odexBuf); if (dexOffset > OdexHeaderItem.ITEM_SIZE) { ByteStreams.skipFully(is, dexOffset - OdexHeaderItem.ITEM_SIZE); } byte[] dexBuf = ByteStreams.toByteArray(is); return new DexBackedOdexFile(opcodes, odexBuf, dexBuf); }
Example 4
Source File: DexBackedOdexFile.java From ZjDroid with Apache License 2.0 | 5 votes |
public static DexBackedOdexFile fromInputStream(@Nonnull Opcodes opcodes, @Nonnull InputStream is) throws IOException { if (!is.markSupported()) { throw new IllegalArgumentException("InputStream must support mark"); } is.mark(8); byte[] partialHeader = new byte[8]; try { ByteStreams.readFully(is, partialHeader); } catch (EOFException ex) { throw new NotADexFile("File is too short"); } finally { is.reset(); } verifyMagic(partialHeader); is.reset(); byte[] odexBuf = new byte[OdexHeaderItem.ITEM_SIZE]; ByteStreams.readFully(is, odexBuf); int dexOffset = OdexHeaderItem.getDexOffset(odexBuf); if (dexOffset > OdexHeaderItem.ITEM_SIZE) { ByteStreams.skipFully(is, dexOffset - OdexHeaderItem.ITEM_SIZE); } byte[] dexBuf = ByteStreams.toByteArray(is); return new DexBackedOdexFile(opcodes, odexBuf, dexBuf); }
Example 5
Source File: DexBackedOdexFile.java From ZjDroid with Apache License 2.0 | 4 votes |
public List<String> getDependencies() { if (this.getReader() == null) { final int dexOffset = OdexHeaderItem.getDexOffset(odexBuf); final int dependencyOffset = OdexHeaderItem .getDependenciesOffset(odexBuf) - dexOffset; BaseDexBuffer buf = new BaseDexBuffer(this.buf); int dependencyCount = buf.readInt(dependencyOffset + DEPENDENCY_COUNT_OFFSET); return new VariableSizeList<String>(this, dependencyOffset + DEPENDENCY_START_OFFSET, dependencyCount) { @Override protected String readNextItem(@Nonnull DexReader reader, int index) { int length = reader.readInt(); int offset = reader.getOffset(); reader.moveRelative(length + 20); try { return new String(DexBackedOdexFile.this.buf, offset, length - 1, "US-ASCII"); } catch (UnsupportedEncodingException ex) { throw new RuntimeException(ex); } } }; } else { File file = new File("/system/framework/"); File[] filelist = file.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { // TODO Auto-generated method stub if(pathname.getAbsolutePath().endsWith(".jar")) return true; else return false; } }); List<String> list = new ArrayList<String>(filelist.length); for(int i = 0; i<filelist.length; i++){ list.add(filelist[i].getAbsolutePath()); } return list; } }
Example 6
Source File: DexBackedOdexFile.java From zjdroid with Apache License 2.0 | 4 votes |
public List<String> getDependencies() { if (this.getReader() == null) { final int dexOffset = OdexHeaderItem.getDexOffset(odexBuf); final int dependencyOffset = OdexHeaderItem .getDependenciesOffset(odexBuf) - dexOffset; BaseDexBuffer buf = new BaseDexBuffer(this.buf); int dependencyCount = buf.readInt(dependencyOffset + DEPENDENCY_COUNT_OFFSET); return new VariableSizeList<String>(this, dependencyOffset + DEPENDENCY_START_OFFSET, dependencyCount) { @Override protected String readNextItem(@Nonnull DexReader reader, int index) { int length = reader.readInt(); int offset = reader.getOffset(); reader.moveRelative(length + 20); try { return new String(DexBackedOdexFile.this.buf, offset, length - 1, "US-ASCII"); } catch (UnsupportedEncodingException ex) { throw new RuntimeException(ex); } } }; } else { File file = new File("/system/framework/"); File[] filelist = file.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { // TODO Auto-generated method stub if(pathname.getAbsolutePath().endsWith(".jar")) return true; else return false; } }); List<String> list = new ArrayList<String>(filelist.length); for(int i = 0; i<filelist.length; i++){ list.add(filelist[i].getAbsolutePath()); } return list; } }
Example 7
Source File: DexBackedOdexFile.java From HeyGirl with Apache License 2.0 | 4 votes |
public List<String> getDependencies() { if (this.getReader() == null) { final int dexOffset = OdexHeaderItem.getDexOffset(odexBuf); final int dependencyOffset = OdexHeaderItem .getDependenciesOffset(odexBuf) - dexOffset; BaseDexBuffer buf = new BaseDexBuffer(this.buf); int dependencyCount = buf.readInt(dependencyOffset + DEPENDENCY_COUNT_OFFSET); return new VariableSizeList<String>(this, dependencyOffset + DEPENDENCY_START_OFFSET, dependencyCount) { @Override protected String readNextItem(@Nonnull DexReader reader, int index) { int length = reader.readInt(); int offset = reader.getOffset(); reader.moveRelative(length + 20); try { return new String(DexBackedOdexFile.this.buf, offset, length - 1, "US-ASCII"); } catch (UnsupportedEncodingException ex) { throw new RuntimeException(ex); } } }; } else { File file = new File("/system/framework/"); File[] filelist = file.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { // TODO Auto-generated method stub if(pathname.getAbsolutePath().endsWith(".jar")) return true; else return false; } }); List<String> list = new ArrayList<String>(filelist.length); for(int i = 0; i<filelist.length; i++){ list.add(filelist[i].getAbsolutePath()); } return list; } }
Example 8
Source File: DexBackedOdexFile.java From ZjDroid with Apache License 2.0 | 4 votes |
public List<String> getDependencies() { if (this.getReader() == null) { final int dexOffset = OdexHeaderItem.getDexOffset(odexBuf); final int dependencyOffset = OdexHeaderItem .getDependenciesOffset(odexBuf) - dexOffset; BaseDexBuffer buf = new BaseDexBuffer(this.buf); int dependencyCount = buf.readInt(dependencyOffset + DEPENDENCY_COUNT_OFFSET); return new VariableSizeList<String>(this, dependencyOffset + DEPENDENCY_START_OFFSET, dependencyCount) { @Override protected String readNextItem(@Nonnull DexReader reader, int index) { int length = reader.readInt(); int offset = reader.getOffset(); reader.moveRelative(length + 20); try { return new String(DexBackedOdexFile.this.buf, offset, length - 1, "US-ASCII"); } catch (UnsupportedEncodingException ex) { throw new RuntimeException(ex); } } }; } else { File file = new File("/system/framework/"); File[] filelist = file.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { // TODO Auto-generated method stub if(pathname.getAbsolutePath().endsWith(".jar")) return true; else return false; } }); List<String> list = new ArrayList<String>(filelist.length); for(int i = 0; i<filelist.length; i++){ list.add(filelist[i].getAbsolutePath()); } return list; } }