DexFile dexFile = new DexBackedDexFile(org.jf.dexlib2.Opcodes.forApi(20), dex.getBytes()); boolean isCurrentDexHasChangedClass = false; for (org.jf.dexlib2.iface.ClassDef classDef : dexFile.getClasses()) { if (descOfChangedClassesInCurrDex.contains(classDef.getType())) { isCurrentDexHasChangedClass = true; for (org.jf.dexlib2.iface.ClassDef classDef : dexFile.getClasses()) { if (!descOfChangedClassesInCurrDex.contains(classDef.getType())) { continue;
public void addFile(@Nonnull DexFile dexFile) { classes.addAll(dexFile.getClasses()); if (files == null) { files = new ArrayList<>(); } files.add(dexFile); }
public void reset() { if (additionalDexFiles != null) { for (DexFile dexFile : additionalDexFiles) { for (ClassDef classDef : dexFile.getClasses()) { availableClasses.remove(classDef.getType()); } } additionalDexFiles.clear(); } loadedClasses = CacheBuilder.newBuilder().build(classLoader); }
public DexClassProvider(DexFile dexFile) { this.dexFile = dexFile; for (ClassDef classDef: dexFile.getClasses()) { classMap.put(classDef.getType(), classDef); } }
private static void reDexFile(@Nonnull DexFile dexFile) { for (ClassDef classDef : dexFile.getClasses()) { classes.add(reDexClass(classDef)); } }
public static ImmutableDexFile of(DexFile dexFile) { if (dexFile instanceof ImmutableDexFile) { return (ImmutableDexFile)dexFile; } return new ImmutableDexFile(dexFile.getClasses()); }
public DexClassProvider(DexFile dexFile) { this.dexFile = dexFile; for (ClassDef classDef: dexFile.getClasses()) { classMap.put(classDef.getType(), classDef); } }
public DexReader(List<File>files) throws IOException { for (File file:files){ DexFile dexFile =DexFileFactory.loadDexFile(file,19,true); classDefs.addAll(dexFile.getClasses()); } }
public DexReader(File file) throws IOException { if (file.exists()){ org.jf.dexlib2.iface.DexFile dexFile = DexFileFactory.loadDexFile(file,19,true); this.classDefs = dexFile.getClasses(); } } public DexReader(List<File>files) throws IOException {
@Override @Nonnull public Set<? extends ClassDef> getClasses() { return RewriterUtils.rewriteSet(getClassDefRewriter(), dexFile.getClasses()); }
public static ImmutableDexFile of(DexFile dexFile) { if (dexFile instanceof ImmutableDexFile) { return (ImmutableDexFile)dexFile; } return new ImmutableDexFile(dexFile.getOpcodes(), dexFile.getClasses()); }
public static ImmutableDexFile of(DexFile dexFile) { if (dexFile instanceof ImmutableDexFile) { return (ImmutableDexFile)dexFile; } return new ImmutableDexFile(dexFile.getOpcodes(), dexFile.getClasses()); }
public static void writeTo(@Nonnull String path, @Nonnull org.jf.dexlib2.iface.DexFile input) throws IOException { DexPool dexPool = makeDexPool(); for (ClassDef classDef: input.getClasses()) { ((ClassPool)dexPool.classSection).intern(classDef); } dexPool.writeTo(new FileDataStore(new File(path))); }
public static void writeTo(@Nonnull String path, @Nonnull org.jf.dexlib2.iface.DexFile input) throws IOException { DexPool dexPool = new DexPool(input.getOpcodes()); for (ClassDef classDef: input.getClasses()) { dexPool.internClass(classDef); } dexPool.writeTo(new FileDataStore(new File(path))); }
public static void writeTo(@Nonnull String path, @Nonnull org.jf.dexlib2.iface.DexFile input) throws IOException { DexPool dexPool = new DexPool(input.getOpcodes()); for (ClassDef classDef: input.getClasses()) { dexPool.internClass(classDef); } dexPool.writeTo(new FileDataStore(new File(path))); }
public static void writeTo(@Nonnull DexDataStore dataStore, @Nonnull org.jf.dexlib2.iface.DexFile input) throws IOException { DexPool dexPool = new DexPool(input.getOpcodes()); for (ClassDef classDef: input.getClasses()) { dexPool.internClass(classDef); } dexPool.writeTo(dataStore); }
public static void writeTo(@Nonnull DexDataStore dataStore, @Nonnull org.jf.dexlib2.iface.DexFile input) throws IOException { DexPool dexPool = new DexPool(input.getOpcodes()); for (ClassDef classDef: input.getClasses()) { dexPool.internClass(classDef); } dexPool.writeTo(dataStore); }
private void verifyDexFile(DexFile dexFile) { Assert.assertEquals(1, dexFile.getClasses().size()); ClassDef cls = Lists.newArrayList(dexFile.getClasses()).get(0); Assert.assertEquals("Lcls1;", cls.getType()); Assert.assertEquals(1, Lists.newArrayList(cls.getMethods()).size()); Method method = Iterators.getNext(cls.getMethods().iterator(), null); Assert.assertEquals("method1", method.getName()); Assert.assertEquals(1, Lists.newArrayList(method.getImplementation().getInstructions()).size()); Instruction instruction = Lists.newArrayList(method.getImplementation().getInstructions().iterator()).get(0); Assert.assertEquals(Opcode.INVOKE_CUSTOM, instruction.getOpcode()); Assert.assertTrue(((Instruction35c) instruction).getReference() instanceof CallSiteReference); } }
@Test public void testOldOrder() { DexFile dexFile = getInputDexFile("FieldGapOrder", new BaksmaliOptions()); Assert.assertEquals(3, dexFile.getClasses().size()); ClassPath classPath = new ClassPath(Lists.newArrayList(new DexClassProvider(dexFile)), false, 66); ClassProto classProto = (ClassProto)classPath.getClass("LGapOrder;"); Assert.assertEquals("r1", classProto.getFieldByOffset(12).getName()); Assert.assertEquals("r2", classProto.getFieldByOffset(16).getName()); Assert.assertEquals("d", classProto.getFieldByOffset(24).getName()); Assert.assertEquals("s", classProto.getFieldByOffset(36).getName()); Assert.assertEquals("i", classProto.getFieldByOffset(32).getName()); }
@Test public void testNewOrder() { DexFile dexFile = getInputDexFile("FieldGapOrder", new BaksmaliOptions()); Assert.assertEquals(3, dexFile.getClasses().size()); ClassPath classPath = new ClassPath(Lists.newArrayList(new DexClassProvider(dexFile)), false, 67); ClassProto classProto = (ClassProto)classPath.getClass("LGapOrder;"); Assert.assertEquals("s", classProto.getFieldByOffset(10).getName()); Assert.assertEquals("r1", classProto.getFieldByOffset(12).getName()); Assert.assertEquals("r2", classProto.getFieldByOffset(16).getName()); Assert.assertEquals("i", classProto.getFieldByOffset(20).getName()); Assert.assertEquals("d", classProto.getFieldByOffset(24).getName()); } }