private Object[] read_encoded_array(ByteBuffer in) { int size = readULeb128i(in); Object[] constant = new Object[size]; for (int i = 0; i < size; i++) { constant[i] = readEncodedValue(in); } return constant; }
/** * Reads a string index. String indicies are offset by 1, and a 0 value in the stream (-1 as returned by this * method) means "null" * * @return index into file's string ids table, -1 means null */ private static int readStringIndex(ByteBuffer bs) { int offsetIndex = readULeb128i(bs); return offsetIndex - 1; }
@Override public int getDexVersion() { int max = DexConstants.DEX_035; for (DexFileReader r : readers) { int v = r.getDexVersion(); if (v > max) { max = v; } } return max; }
public static void doData(byte[] data, Path destdir) throws IOException { new DexFileReader(data).accept(new ASMifierFileV(destdir, null)); }
public static Dex2jar from(ByteBuffer in) throws IOException { return from(new DexFileReader(in)); }
/** * equals to {@link #accept(DexFileVisitor, int)} with 0 as config * * @param dv */ @Override public void accept(DexFileVisitor dv) { this.accept(dv, 0); }
void init() { Set<String> classes = new HashSet<>(); for (DexFileReader reader : readers) { List<String> classNames = reader.getClassNames(); for (int i = 0; i < classNames.size(); i++) { String className = classNames.get(i); if (classes.add(className)) { items.add(new Item(i, reader, className)); } } } }
@Override public void accept(DexFileVisitor dv) { accept(dv, 0); }
public DexFileReader(InputStream is) throws IOException { this(toByteArray(is)); }
String op(Op op) { return op.name(); }
static int uint(byte[] data, int offset) { return sint(data, offset); }
private String getType(int id) { if (id == -1) { return null; } return getString(typeIdIn.getInt(id * 4)); }
private Object[] read_encoded_array_item(int static_values_off) { encodedArrayItemIn.position(static_values_off); return read_encoded_array(encodedArrayItemIn); }
public MultiDexFileReader(Collection<DexFileReader> readers) { this.readers.addAll(readers); init(); }
private Object[] getCallSite(int b) { callSiteIdIn.position(b * 4); int call_site_off = callSiteIdIn.getInt(); return read_encoded_array_item(call_site_off); }
private String[] getTypeList(int offset) { if (offset == 0) { return new String[0]; } typeListIn.position(offset); int size = typeListIn.getInt(); String[] types = new String[size]; for (int i = 0; i < size; i++) { types[i] = getType(0xFFFF & typeListIn.getShort()); } return types; }
private void read_annotation_set_item(int offset, DexAnnotationAble daa) { // annotation_set_item ByteBuffer in = annotationSetItemIn; in.position(offset); int size = in.getInt(); for (int j = 0; j < size; j++) { int annotation_off = in.getInt(); read_annotation_item(annotation_off, daa); } }
public static Dex2jar from(InputStream in) throws IOException { return from(new DexFileReader(in)); }
@Override public void accept(DexFileVisitor dv, int classIdx, int config) { Item item = items.get(classIdx); item.reader.accept(dv, item.idx, config); }
@Override public void accept(DexFileVisitor dv, int config) { int size = items.size(); for (int i = 0; i < size; i++) { accept(dv, i, config); } }