use of org.jf.dexlib2.dexbacked.DexBackedDexFile 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.dexbacked.DexBackedDexFile in project android by JetBrains.
the class DexParser method constructMethodRefTreeForDex.
@NotNull
static PackageTreeNode constructMethodRefTreeForDex(@NotNull DexBackedDexFile dexFile) {
PackageTreeNode root = new PackageTreeNode("", "root", PackageTreeNode.NodeType.PACKAGE, null);
Set<String> classesWithDefinition = dexFile.getClasses().stream().map(DexBackedClassDef::getType).collect(Collectors.toSet());
Multimap<String, MethodReference> methodsByClassName = getMethodsByClassName(dexFile);
for (String className : methodsByClassName.keySet()) {
Collection<MethodReference> methods = methodsByClassName.get(className);
for (MethodReference ref : methods) {
root.insert("", DebuggerUtilsEx.signatureToName(className), ref, classesWithDefinition.contains(className));
}
}
root.sortByCount();
return root;
}
use of org.jf.dexlib2.dexbacked.DexBackedDexFile in project android by JetBrains.
the class DexParser method getMethodsByClassName.
@NotNull
private static Multimap<String, MethodReference> getMethodsByClassName(@NotNull DexBackedDexFile dexFile) {
Multimap<String, MethodReference> methodsByClass = ArrayListMultimap.create();
for (int i = 0, m = dexFile.getMethodCount(); i < m; i++) {
MethodReference methodRef = new DexBackedMethodReference(dexFile, i);
methodsByClass.put(methodRef.getDefiningClass(), methodRef);
}
return methodsByClass;
}
use of org.jf.dexlib2.dexbacked.DexBackedDexFile in project soot by Sable.
the class DexlibWrapper method initialize.
public void initialize() {
// resolve classes in dex files
for (DexBackedDexFile dexFile : dexFiles) {
for (ClassDef defItem : dexFile.getClasses()) {
String forClassName = Util.dottedClassName(defItem.getType());
classesToDefItems.put(forClassName, new ClassInformation(dexFile, defItem));
}
}
// produce an error during type resolution.
for (DexBackedDexFile dexFile : dexFiles) {
for (int i = 0; i < dexFile.getTypeCount(); i++) {
String t = dexFile.getType(i);
Type st = DexType.toSoot(t);
if (st instanceof ArrayType) {
st = ((ArrayType) st).baseType;
}
String sootTypeName = st.toString();
if (!Scene.v().containsClass(sootTypeName)) {
if (st instanceof PrimType || st instanceof VoidType || systemAnnotationNames.contains(sootTypeName)) {
/*
* dex files contain references to the Type IDs of the
* system annotations. They are only visible to the
* Dalvik VM (for reflection, see
* vm/reflect/Annotations.cpp), and not to the user - so
* we do not want them to be resolved.
*/
continue;
}
SootResolver.v().makeClassRef(sootTypeName);
}
SootResolver.v().resolveClass(sootTypeName, SootClass.SIGNATURES);
}
}
}
use of org.jf.dexlib2.dexbacked.DexBackedDexFile in project soot by Sable.
the class DexClassProvider method classesOfDex.
public static Set<String> classesOfDex(DexBackedDexFile dexFile) {
Set<String> classes = new HashSet<String>();
for (ClassDef c : dexFile.getClasses()) {
String name = Util.dottedClassName(c.getType());
classes.add(name);
}
return classes;
}
Aggregations