public void openFile(File file) { this.openFile = file; try { this.decompiler = new JadxDecompiler(settings.toJadxArgs()); this.decompiler.getArgs().setInputFiles(Collections.singletonList(file)); this.decompiler.load(); } catch (Exception e) { LOG.error("Error load file: {}", file, e); } }
public JadxArgs toJadxArgs() { JadxArgs args = new JadxArgs(); args.setInputFiles(files.stream().map(FileUtils::toFile).collect(Collectors.toList())); args.setOutDir(FileUtils.toFile(outDir)); args.setOutDirSrc(FileUtils.toFile(outDirSrc)); args.setOutDirRes(FileUtils.toFile(outDirRes)); args.setThreadsCount(threadsCount); args.setSkipSources(skipSources); args.setSkipResources(skipResources); args.setFallbackMode(fallbackMode); args.setShowInconsistentCode(showInconsistentCode); args.setCfgOutput(cfgOutput); args.setRawCFGOutput(rawCfgOutput); args.setReplaceConsts(replaceConsts); args.setDeobfuscationOn(deobfuscationOn); args.setDeobfuscationForceSave(deobfuscationForceSave); args.setDeobfuscationMinLength(deobfuscationMinLength); args.setDeobfuscationMaxLength(deobfuscationMaxLength); args.setUseSourceNameAsClassAlias(deobfuscationUseSourceNameAsAlias); args.setEscapeUnicode(escapeUnicode); args.setExportAsGradleProject(exportAsGradleProject); args.setUseImports(useImports); return args; }
public ClassNode getClassNodeFromFile(File file, String clsName) { JadxDecompiler d = null; try { args.setInputFiles(Collections.singletonList(file)); d = new JadxDecompiler(args); d.load(); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } RootNode root = JadxInternalAccess.getRoot(d); insertResources(root); ClassNode cls = root.searchClassByName(clsName); assertThat("Class not found: " + clsName, cls, notNullValue()); assertThat(clsName, is(cls.getClassInfo().getFullName())); if (unloadCls) { decompile(d, cls); } else { decompileWithoutUnload(d, cls); } System.out.println("-----------------------------------------------------------"); System.out.println(cls.getCode()); System.out.println("-----------------------------------------------------------"); checkCode(cls); compile(cls); runAutoCheck(clsName); return cls; }