use of org.jf.dexlib2.iface.DexFile in project atlas by alibaba.
the class PatchFieldTool method addField.
public static void addField(String inFile, String outFile, DexBackedClassDef dexBackedClassDef, ImmutableField immutableField) throws IOException {
DexFile dexFile = readDexFile(inFile);
for (ClassDef classDef : dexFile.getClasses()) {
if (dexBackedClassDef != null && dexBackedClassDef.getType().equals(classDef.getType())) {
dexFile = addField(dexFile, classDef.getType(), immutableField);
} else if (dexBackedClassDef == null) {
dexFile = addField(dexFile, classDef.getType(), immutableField);
}
}
reDexFile(dexFile);
DexFileFactory.writeDexFile(outFile, new DexFile() {
@Nonnull
@Override
public Set<? extends ClassDef> getClasses() {
return new AbstractSet<ClassDef>() {
@Nonnull
@Override
public Iterator<ClassDef> iterator() {
return classes.iterator();
}
@Override
public int size() {
return classes.size();
}
};
}
});
}
use of org.jf.dexlib2.iface.DexFile in project atlas by alibaba.
the class PatchUtils method getBundleClassDef.
private static Map<String, ClassDef> getBundleClassDef(File file) throws IOException {
HashMap<String, ClassDef> classDefMap = new HashMap<String, ClassDef>();
File[] dexFiles = getDexFiles(file);
HashSet<ClassDef> classDefs = new HashSet<ClassDef>();
for (File dexFile : dexFiles) {
classDefs.addAll(DexFileFactory.loadDexFile(dexFile, 19, true).getClasses());
}
for (ClassDef classDef : classDefs) {
classDefMap.put(classDef.getType(), classDef);
}
return classDefMap;
}
use of org.jf.dexlib2.iface.DexFile in project Apktool by iBotPeaches.
the class SmaliDecoder method decode.
private void decode() throws AndrolibException {
try {
baksmaliOptions options = new baksmaliOptions();
// options
options.deodex = false;
options.outputDirectory = mOutDir.toString();
options.noParameterRegisters = false;
options.useLocalsDirective = true;
options.useSequentialLabels = true;
options.outputDebugInfo = mBakDeb;
options.addCodeOffsets = false;
options.jobs = -1;
options.noAccessorComments = false;
options.registerInfo = 0;
options.ignoreErrors = false;
options.inlineResolver = null;
options.checkPackagePrivateAccess = false;
// set jobs automatically
options.jobs = Runtime.getRuntime().availableProcessors();
if (options.jobs > 6) {
options.jobs = 6;
}
// create the dex
DexBackedDexFile dexFile = DexFileFactory.loadDexFile(mApkFile, mDexFile, mApi, false);
if (dexFile.isOdexFile()) {
throw new AndrolibException("Warning: You are disassembling an odex file without deodexing it.");
}
if (dexFile instanceof DexBackedOdexFile) {
options.inlineResolver = InlineMethodResolver.createInlineMethodResolver(((DexBackedOdexFile) dexFile).getOdexVersion());
}
baksmali.disassembleDexFile(dexFile, options);
} catch (IOException ex) {
throw new AndrolibException(ex);
}
}
use of org.jf.dexlib2.iface.DexFile in project android-classyshark by google.
the class StressTest method runAllClassesInDex.
public static void runAllClassesInDex(String jarCanonicalPath) throws Exception {
DexFile dexFile = DexlibLoader.loadDexFile(new File(jarCanonicalPath));
Set<? extends ClassDef> allClassesInDex = dexFile.getClasses();
for (ClassDef currentClass : allClassesInDex) {
String normType = DexlibAdapter.getClassStringFromDex(currentClass.getType());
Translator sourceGenerator = TranslatorFactory.createTranslator(normType, new File(jarCanonicalPath));
sourceGenerator.apply();
System.out.println(sourceGenerator.toString());
}
}
use of org.jf.dexlib2.iface.DexFile in project android-classyshark by google.
the class DexlibAdapter method getClassDefByName.
public static ClassDef getClassDefByName(String className, DexFile dexFile) throws Exception {
ClassDef result = null;
String dexName;
for (ClassDef currentClassDef : dexFile.getClasses()) {
dexName = currentClassDef.getType();
if (isMatchFromDex(className, dexName)) {
result = currentClassDef;
break;
}
}
return result;
}
Aggregations