private void processByPatterns(JadxDecompiler jadx, Pattern clsPattern, @Nullable Pattern mthPattern) { List<IDexTreeVisitor> passes = Jadx.getPassesList(jadx.getArgs()); RootNode root = JadxInternalAccess.getRoot(jadx); int processed = 0; for (ClassNode classNode : root.getClasses(true)) { String clsFullName = classNode.getClassInfo().getFullName(); if (clsPattern.matcher(clsFullName).matches()) { if (processCls(mthPattern, passes, classNode)) { processed++; } } } assertThat("No classes processed", processed, greaterThan(0)); }
private List<IDexTreeVisitor> getPassesList(JadxDecompiler jadx) { RootNode root = JadxInternalAccess.getRoot(jadx); List<IDexTreeVisitor> passesList = Jadx.getPassesList(jadx.getArgs()); passesList.forEach(pass -> { try { pass.init(root); } catch (JadxException e) { e.printStackTrace(); fail(e.getMessage()); } }); return passesList; }
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; }