use of jadx.api.plugins.input.data.ILoadResult in project jadx by skylot.
the class DexInputPluginTest method processFile.
private static void processFile(Path sample) throws IOException {
System.out.println("Input file: " + sample.toAbsolutePath());
long start = System.currentTimeMillis();
List<Path> files = Collections.singletonList(sample);
try (ILoadResult result = new DexInputPlugin().loadFiles(files)) {
AtomicInteger count = new AtomicInteger();
result.visitClasses(cls -> {
System.out.println();
System.out.println("Class: " + cls.getType());
System.out.println("AccessFlags: " + AccessFlags.format(cls.getAccessFlags(), AccessFlagsScope.CLASS));
System.out.println("SuperType: " + cls.getSuperType());
System.out.println("Interfaces: " + cls.getInterfacesTypes());
System.out.println("Attributes: " + cls.getAttributes());
count.getAndIncrement();
cls.visitFieldsAndMethods(System.out::println, mth -> {
System.out.println("---");
System.out.println(mth);
ICodeReader codeReader = mth.getCodeReader();
if (codeReader != null) {
codeReader.visitInstructions(insn -> {
insn.decode();
System.out.println(insn);
});
}
System.out.println("---");
System.out.println(mth.disassembleMethod());
System.out.println("---");
});
System.out.println("----");
System.out.println(cls.getDisassembledCode());
System.out.println("----");
});
assertThat(count.get()).isGreaterThan(0);
}
System.out.println("Time: " + (System.currentTimeMillis() - start) + "ms");
}
use of jadx.api.plugins.input.data.ILoadResult in project jadx by skylot.
the class JadxDecompiler method loadInputFiles.
private void loadInputFiles() {
loadedInputs.clear();
List<Path> inputPaths = Utils.collectionMap(args.getInputFiles(), File::toPath);
List<Path> inputFiles = FileUtils.expandDirs(inputPaths);
long start = System.currentTimeMillis();
for (JadxInputPlugin inputPlugin : pluginManager.getInputPlugins()) {
ILoadResult loadResult = inputPlugin.loadFiles(inputFiles);
if (loadResult != null && !loadResult.isEmpty()) {
loadedInputs.add(loadResult);
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("Loaded using {} inputs plugin in {} ms", loadedInputs.size(), System.currentTimeMillis() - start);
}
}
use of jadx.api.plugins.input.data.ILoadResult in project jadx by skylot.
the class ConvertToClsSet method main.
public static void main(String[] args) throws Exception {
if (args.length < 2) {
usage();
System.exit(1);
}
List<Path> inputPaths = Stream.of(args).map(Paths::get).collect(Collectors.toList());
Path output = inputPaths.remove(0);
JadxPluginManager pluginManager = new JadxPluginManager();
pluginManager.load();
List<ILoadResult> loadedInputs = new ArrayList<>();
for (JadxInputPlugin inputPlugin : pluginManager.getInputPlugins()) {
loadedInputs.add(inputPlugin.loadFiles(inputPaths));
}
JadxArgs jadxArgs = new JadxArgs();
jadxArgs.setRenameFlags(EnumSet.noneOf(JadxArgs.RenameEnum.class));
RootNode root = new RootNode(jadxArgs);
root.loadClasses(loadedInputs);
// from pre-decompilation stage run only SignatureProcessor
SignatureProcessor signatureProcessor = new SignatureProcessor();
signatureProcessor.init(root);
for (ClassNode classNode : root.getClasses()) {
signatureProcessor.visit(classNode);
}
ClsSet set = new ClsSet(root);
set.loadFrom(root);
set.save(output);
LOG.info("Output: {}", output);
LOG.info("done");
}
use of jadx.api.plugins.input.data.ILoadResult in project jadx by skylot.
the class RootNode method loadClasses.
public void loadClasses(List<ILoadResult> loadedInputs) {
for (ILoadResult loadedInput : loadedInputs) {
loadedInput.visitClasses(cls -> {
try {
addClassNode(new ClassNode(RootNode.this, cls));
} catch (Exception e) {
addDummyClass(cls, e);
}
Utils.checkThreadInterrupt();
});
}
if (classes.size() != clsMap.size()) {
// class name duplication detected
markDuplicatedClasses(classes);
}
classes = new ArrayList<>(clsMap.values());
// print stats for loaded classes
int mthCount = classes.stream().mapToInt(c -> c.getMethods().size()).sum();
int insnsCount = classes.stream().flatMap(c -> c.getMethods().stream()).mapToInt(MethodNode::getInsnsCount).sum();
LOG.info("Loaded classes: {}, methods: {}, instructions: {}", classes.size(), mthCount, insnsCount);
// sort classes by name, expect top classes before inner
classes.sort(Comparator.comparing(ClassNode::getFullName));
// move inner classes
initInnerClasses();
}
Aggregations