Search in sources :

Example 1 with JadxPluginManager

use of jadx.api.plugins.JadxPluginManager 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");
}
Also used : Path(java.nio.file.Path) RootNode(jadx.core.dex.nodes.RootNode) ClassNode(jadx.core.dex.nodes.ClassNode) ClsSet(jadx.core.clsp.ClsSet) ILoadResult(jadx.api.plugins.input.data.ILoadResult) ArrayList(java.util.ArrayList) SignatureProcessor(jadx.core.dex.visitors.SignatureProcessor) JadxPluginManager(jadx.api.plugins.JadxPluginManager) JadxArgs(jadx.api.JadxArgs) JadxInputPlugin(jadx.api.plugins.input.JadxInputPlugin)

Example 2 with JadxPluginManager

use of jadx.api.plugins.JadxPluginManager in project jadx by skylot.

the class JadxSettingsWindow method makePluginOptionsGroup.

private SettingsGroup makePluginOptionsGroup() {
    SettingsGroup pluginsGroup = new SettingsGroup(NLS.str("preferences.plugins"));
    JadxPluginManager pluginManager = mainWindow.getWrapper().getDecompiler().getPluginManager();
    for (JadxPlugin plugin : pluginManager.getAllPlugins()) {
        if (!(plugin instanceof JadxPluginOptions)) {
            continue;
        }
        JadxPluginInfo pluginInfo = plugin.getPluginInfo();
        JadxPluginOptions optPlugin = (JadxPluginOptions) plugin;
        for (OptionDescription opt : optPlugin.getOptionsDescriptions()) {
            String title = "[" + pluginInfo.getPluginId() + "]  " + opt.description();
            if (opt.values().isEmpty()) {
                JTextField textField = new JTextField();
                textField.getDocument().addDocumentListener(new DocumentUpdateListener(event -> {
                    settings.getPluginOptions().put(opt.name(), textField.getText());
                    needReload();
                }));
                pluginsGroup.addRow(title, textField);
            } else {
                String curValue = settings.getPluginOptions().get(opt.name());
                JComboBox<String> combo = new JComboBox<>(opt.values().toArray(new String[0]));
                combo.setSelectedItem(curValue != null ? curValue : opt.defaultValue());
                combo.addActionListener(e -> {
                    settings.getPluginOptions().put(opt.name(), ((String) combo.getSelectedItem()));
                    needReload();
                });
                pluginsGroup.addRow(title, combo);
            }
        }
    }
    return pluginsGroup;
}
Also used : JsonObject(com.google.gson.JsonObject) Arrays(java.util.Arrays) DocumentListener(javax.swing.event.DocumentListener) JDialog(javax.swing.JDialog) EditorTheme(jadx.gui.ui.codearea.EditorTheme) LafManager(jadx.gui.utils.LafManager) LoggerFactory(org.slf4j.LoggerFactory) GraphicsEnvironment(java.awt.GraphicsEnvironment) GsonBuilder(com.google.gson.GsonBuilder) CommentsLevel(jadx.api.CommentsLevel) MouseAdapter(java.awt.event.MouseAdapter) ChangeListener(javax.swing.event.ChangeListener) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) OptionDescription(jadx.api.plugins.options.OptionDescription) Clipboard(java.awt.datatransfer.Clipboard) KeyStroke(javax.swing.KeyStroke) ScrollPaneConstants(javax.swing.ScrollPaneConstants) ChangeEvent(javax.swing.event.ChangeEvent) ItemEvent(java.awt.event.ItemEvent) Font(java.awt.Font) Collection(java.util.Collection) Set(java.util.Set) BorderFactory(javax.swing.BorderFactory) GridBagConstraints(java.awt.GridBagConstraints) Component(java.awt.Component) Box(javax.swing.Box) JFontChooser(say.swing.JFontChooser) Dimension(java.awt.Dimension) JadxArgs(jadx.api.JadxArgs) JadxPlugin(jadx.api.plugins.JadxPlugin) JadxPluginInfo(jadx.api.plugins.JadxPluginInfo) AbstractAction(javax.swing.AbstractAction) JCheckBox(javax.swing.JCheckBox) DocumentUpdateListener(jadx.gui.utils.ui.DocumentUpdateListener) GridBagLayout(java.awt.GridBagLayout) MainWindow(jadx.gui.ui.MainWindow) JPanel(javax.swing.JPanel) WindowConstants(javax.swing.WindowConstants) Toolkit(java.awt.Toolkit) Insets(java.awt.Insets) JadxPluginManager(jadx.api.plugins.JadxPluginManager) JTextField(javax.swing.JTextField) SpinnerNumberModel(javax.swing.SpinnerNumberModel) NLS(jadx.gui.utils.NLS) SwingConstants(javax.swing.SwingConstants) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) SwingUtilities(javax.swing.SwingUtilities) UiUtils(jadx.gui.utils.UiUtils) JadxPluginOptions(jadx.api.plugins.options.JadxPluginOptions) StringSelection(java.awt.datatransfer.StringSelection) Container(java.awt.Container) DocumentEvent(javax.swing.event.DocumentEvent) BoxLayout(javax.swing.BoxLayout) JComponent(javax.swing.JComponent) JButton(javax.swing.JButton) JSpinner(javax.swing.JSpinner) Logger(org.slf4j.Logger) JOptionPane(javax.swing.JOptionPane) ActionEvent(java.awt.event.ActionEvent) MouseEvent(java.awt.event.MouseEvent) JScrollPane(javax.swing.JScrollPane) DeobfuscationMapFileMode(jadx.api.args.DeobfuscationMapFileMode) LangLocale(jadx.gui.utils.LangLocale) JLabel(javax.swing.JLabel) UseKotlinMethodsForVarNames(jadx.api.JadxArgs.UseKotlinMethodsForVarNames) InputMap(javax.swing.InputMap) Collections(java.util.Collections) FontUtils(jadx.gui.utils.FontUtils) DocumentUpdateListener(jadx.gui.utils.ui.DocumentUpdateListener) JadxPluginOptions(jadx.api.plugins.options.JadxPluginOptions) OptionDescription(jadx.api.plugins.options.OptionDescription) JComboBox(javax.swing.JComboBox) JadxPlugin(jadx.api.plugins.JadxPlugin) JadxPluginInfo(jadx.api.plugins.JadxPluginInfo) JadxPluginManager(jadx.api.plugins.JadxPluginManager) JTextField(javax.swing.JTextField)

Example 3 with JadxPluginManager

use of jadx.api.plugins.JadxPluginManager in project jadx by skylot.

the class JCommanderWrapper method appendPluginOptions.

private String appendPluginOptions(int maxNamesLen) {
    StringBuilder sb = new StringBuilder();
    JadxPluginManager pluginManager = new JadxPluginManager();
    pluginManager.load();
    int k = 1;
    for (JadxPlugin plugin : pluginManager.getAllPlugins()) {
        if (plugin instanceof JadxPluginOptions) {
            if (appendPlugin(((JadxPluginOptions) plugin), sb, maxNamesLen, k)) {
                k++;
            }
        }
    }
    if (sb.length() == 0) {
        return "";
    }
    return "\nPlugin options (-P<name>=<value>):" + sb;
}
Also used : JadxPluginOptions(jadx.api.plugins.options.JadxPluginOptions) JadxPlugin(jadx.api.plugins.JadxPlugin) JadxPluginManager(jadx.api.plugins.JadxPluginManager)

Aggregations

JadxPluginManager (jadx.api.plugins.JadxPluginManager)3 JadxArgs (jadx.api.JadxArgs)2 JadxPlugin (jadx.api.plugins.JadxPlugin)2 JadxPluginOptions (jadx.api.plugins.options.JadxPluginOptions)2 ArrayList (java.util.ArrayList)2 GsonBuilder (com.google.gson.GsonBuilder)1 JsonObject (com.google.gson.JsonObject)1 CommentsLevel (jadx.api.CommentsLevel)1 UseKotlinMethodsForVarNames (jadx.api.JadxArgs.UseKotlinMethodsForVarNames)1 DeobfuscationMapFileMode (jadx.api.args.DeobfuscationMapFileMode)1 JadxPluginInfo (jadx.api.plugins.JadxPluginInfo)1 JadxInputPlugin (jadx.api.plugins.input.JadxInputPlugin)1 ILoadResult (jadx.api.plugins.input.data.ILoadResult)1 OptionDescription (jadx.api.plugins.options.OptionDescription)1 ClsSet (jadx.core.clsp.ClsSet)1 ClassNode (jadx.core.dex.nodes.ClassNode)1 RootNode (jadx.core.dex.nodes.RootNode)1 SignatureProcessor (jadx.core.dex.visitors.SignatureProcessor)1 MainWindow (jadx.gui.ui.MainWindow)1 EditorTheme (jadx.gui.ui.codearea.EditorTheme)1