@Nullable private Dex makeDexBuf(String entryName, InputStream inputStream) { try { return new Dex(inputStream); } catch (Exception e) { LOG.error("Failed to load file: {}, error: {}", entryName, e.getMessage(), e); return null; } }
private static Dex loadFromJar(File jarFile) throws DecodeException { JavaToDex j2d = new JavaToDex(); try { LOG.info("converting to dex: {} ...", jarFile.getName()); byte[] ba = j2d.convert(jarFile.getAbsolutePath()); if (ba.length == 0) { throw new JadxException("Empty dx output"); } return new Dex(ba); } catch (Exception e) { throw new DecodeException("java class to dex conversion error:\n " + e.getMessage(), e); } finally { if (j2d.isError()) { LOG.warn("dx message: {}", j2d.getDxErrors()); } } }
addDexFile(new Dex(file)); return;
public DexIndexPrinter(File file) throws IOException { this.dex = new Dex(file); this.tableOfContents = dex.getTableOfContents(); }
public DexIndexPrinter(File file) throws IOException { this.dex = new Dex(file); this.tableOfContents = dex.getTableOfContents(); }
public DexIndexPrinter(File file) throws IOException { this.dex = new Dex(file); this.tableOfContents = dex.getTableOfContents(); }
public static void main(String[] args) throws IOException { String dexFile = args[0]; String pattern = args[1]; Dex dex = new Dex(new File(dexFile)); int count = new Grep(dex, Pattern.compile(pattern), new PrintWriter(System.out)).grep(); System.exit((count > 0) ? 0 : 1); } }
public static void main(String[] args) throws IOException { String dexFile = args[0]; String pattern = args[1]; Dex dex = new Dex(new File(dexFile)); int count = new Grep(dex, Pattern.compile(pattern), new PrintWriter(System.out)).grep(); System.exit((count > 0) ? 0 : 1); } }
public static void main(String[] args) throws IOException { String dexFile = args[0]; String pattern = args[1]; Dex dex = new Dex(new File(dexFile)); int count = new Grep(dex, Pattern.compile(pattern), new PrintWriter(System.out)).grep(); System.exit((count > 0) ? 0 : 1); } }
public static void main(String[] args) throws IOException { String dexFile = args[0]; String declaredBy = args[1]; String memberName = args[2]; Dex dex = new Dex(new File(dexFile)); PrintWriter out = new PrintWriter(System.out); new FindUsages(dex, declaredBy, memberName, out).findUsages(); out.flush(); } }
public static void main(String[] args) throws IOException { String dexFile = args[0]; String declaredBy = args[1]; String memberName = args[2]; Dex dex = new Dex(new File(dexFile)); PrintWriter out = new PrintWriter(System.out); new FindUsages(dex, declaredBy, memberName, out).findUsages(); out.flush(); } }
public static void main(String[] args) throws IOException { String dexFile = args[0]; String declaredBy = args[1]; String memberName = args[2]; Dex dex = new Dex(new File(dexFile)); PrintWriter out = new PrintWriter(System.out); new FindUsages(dex, declaredBy, memberName, out).findUsages(); out.flush(); } }
/** * Creates a new dex from the contents of {@code bytes}. This API supports * both {@code .dex} and {@code .odex} input. Calling this constructor * transfers ownership of {@code bytes} to the returned Dex: it is an error * to access the buffer after calling this method. */ public static Dex create(ByteBuffer data) throws IOException { data.order(ByteOrder.LITTLE_ENDIAN); // if it's an .odex file, set position and limit to the .dex section if (data.get(0) == 'd' && data.get(1) == 'e' && data.get(2) == 'y' && data.get(3) == '\n') { data.position(8); int offset = data.getInt(); int length = data.getInt(); data.position(offset); data.limit(offset + length); data = data.slice(); } return new Dex(data); }
public static void main(String[] args) throws IOException { if (args.length < 2) { printUsage(); return; } Dex merged = new Dex(new File(args[1])); for (int i = 2; i < args.length; i++) { Dex toMerge = new Dex(new File(args[i])); merged = new DexMerger(merged, toMerge, CollisionPolicy.KEEP_FIRST).merge(); } merged.writeTo(new File(args[0])); }
/** * Merges the dex files in library jars. If multiple dex files define the * same type, this fails with an exception. */ private byte[] mergeLibraryDexBuffers(byte[] outArray) throws IOException { ArrayList<Dex> dexes = new ArrayList<Dex>(); if (outArray != null) { dexes.add(new Dex(outArray)); } for (byte[] libraryDex : libraryDexBuffers) { dexes.add(new Dex(libraryDex)); } if (dexes.isEmpty()) { return null; } Dex merged = new DexMerger(dexes.toArray(new Dex[dexes.size()]), CollisionPolicy.FAIL, context).merge(); return merged.getBytes(); }
/** * Merges the dex files in library jars. If multiple dex files define the * same type, this fails with an exception. */ private byte[] mergeLibraryDexBuffers(byte[] outArray) throws IOException { ArrayList<Dex> dexes = new ArrayList<Dex>(); if (outArray != null) { dexes.add(new Dex(outArray)); } for (byte[] libraryDex : libraryDexBuffers) { dexes.add(new Dex(libraryDex)); } if (dexes.isEmpty()) { return null; } DexMerger dexMerger = new DexMerger( dexes.toArray(new Dex[dexes.size()]), CollisionPolicy.FAIL, context); Dex merged = dexMerger.merge(); return merged.getBytes(); }
/** * Merges the dex files in library jars. If multiple dex files define the * same type, this fails with an exception. */ private static byte[] mergeLibraryDexBuffers(byte[] outArray) throws IOException { for (byte[] libraryDex : libraryDexBuffers) { if (outArray == null) { outArray = libraryDex; continue; } Dex a = new Dex(outArray); Dex b = new Dex(libraryDex); Dex ab = new DexMerger(a, b, CollisionPolicy.FAIL).merge(); outArray = ab.getBytes(); } return outArray; }
public static void main(String[] args) throws IOException { if (args.length < 2) { printUsage(); return; } Dex[] dexes = new Dex[args.length - 1]; for (int i = 1; i < args.length; i++) { dexes[i - 1] = new Dex(new File(args[i])); } Dex merged = new DexMerger(dexes, CollisionPolicy.KEEP_FIRST, new DxContext()).merge(); merged.writeTo(new File(args[0])); }
public static void main(String[] args) throws IOException { if (args.length < 2) { printUsage(); return; } Dex[] dexes = new Dex[args.length - 1]; for (int i = 1; i < args.length; i++) { dexes[i - 1] = new Dex(new File(args[i])); } Dex merged = new DexMerger(dexes, CollisionPolicy.KEEP_FIRST, new DxContext()).merge(); merged.writeTo(new File(args[0])); }
if (wastedByteCount > + compactWasteThreshold) { DexMerger compacter = new DexMerger( dexOut, new Dex(0), CollisionPolicy.FAIL, compactedSizes); result = compacter.mergeDexes(); System.out.printf("Result compacted from %.1fKiB to %.1fKiB to save %.1fKiB%n",