use of org.jf.dexlib2.iface.DexFile 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.iface.DexFile 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.iface.DexFile in project android-classyshark by google.
the class ApkDashboard method fillAnalysisPerClassesDexIndex.
public static ClassesDexDataEntry fillAnalysisPerClassesDexIndex(int dexIndex, File classesDex) {
ClassesDexDataEntry dexData = new ClassesDexDataEntry(dexIndex);
try {
InputStream is = new FileInputStream(classesDex);
ApplicationVisitor av = new ApkNativeMethodsVisitor(dexData);
ApplicationReader ar = new ApplicationReader(Opcodes.ASM4, is);
ar.accept(av, 0);
} catch (Exception e) {
e.printStackTrace();
}
try {
DexFile dxFile = DexlibLoader.loadDexFile(classesDex);
DexBackedDexFile dataPack = (DexBackedDexFile) dxFile;
dexData.allMethods = dataPack.getMethodCount();
//dexData.syntheticAccessors =
// new SyntheticAccessorsInspector(dxFile).getSyntheticAccessors();
} catch (Exception e) {
e.printStackTrace();
System.out.println("here " + e);
}
return dexData;
}
use of org.jf.dexlib2.iface.DexFile in project android-classyshark by google.
the class DexInfoTranslator method apply.
@Override
public void apply() {
try {
elements.clear();
File classesDex = extractClassesDex(dexFileName, apkFile, this);
DexFile dxFile = DexlibLoader.loadDexFile(classesDex);
DexBackedDexFile dataPack = (DexBackedDexFile) dxFile;
ELEMENT element = new ELEMENT("\nclasses: " + dataPack.getClassCount(), TAG.MODIFIER);
elements.add(element);
element = new ELEMENT("\nstrings: " + dataPack.getStringCount(), TAG.DOCUMENT);
elements.add(element);
element = new ELEMENT("\ntypes: " + dataPack.getTypeCount(), TAG.DOCUMENT);
elements.add(element);
element = new ELEMENT("\nprotos: " + dataPack.getProtoCount(), TAG.DOCUMENT);
elements.add(element);
element = new ELEMENT("\nfields: " + dataPack.getFieldCount(), TAG.DOCUMENT);
elements.add(element);
element = new ELEMENT("\nmethods: " + dataPack.getMethodCount(), TAG.IDENTIFIER);
elements.add(element);
element = new ELEMENT("\n\nFile size: " + JarInfoTranslator.readableFileSize(classesDex.length()), TAG.DOCUMENT);
elements.add(element);
element = new ELEMENT("\n\nClasses with Native Calls\n", TAG.MODIFIER);
elements.add(element);
Set<String> classesWithNativeMethods = getClassesWithNativeMethodsPerDexIndex(index, classesDex);
for (String classWithNativeMethods : classesWithNativeMethods) {
element = new ELEMENT(classWithNativeMethods + "\n", TAG.DOCUMENT);
elements.add(element);
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.jf.dexlib2.iface.DexFile in project android-classyshark by google.
the class DexReader method readClassNamesFromDex.
public static List<String> readClassNamesFromDex(File binaryArchiveFile) throws Exception {
DexFile dexFile = DexlibLoader.loadDexFile(binaryArchiveFile);
List<String> result = new ArrayList<>();
for (ClassDef classDef : dexFile.getClasses()) {
result.add(classDef.getType().replaceAll("/", ".").substring(1, classDef.getType().length() - 1));
}
Collections.sort(result);
return result;
}
Aggregations