Search in sources :

Example 1 with Decompiler

use of the.bytecode.club.bytecodeviewer.decompilers.Decompiler in project bytecode-viewer by Konloch.

the class CommandLineInput method executeCommandLine.

public void executeCommandLine() {
    try {
        File input = new File(parsed.getOptionValue("i"));
        File output = new File(parsed.getOptionValue("o"));
        String target = parsed.getOptionValue("t");
        Decompiler use = null;
        if (parsed.getOptionValue("decompiler") == null) {
            System.out.println("You can define another decompiler by appending -decompiler \"name\", by default procyon has been set.");
            use = Decompiler.PROCYON;
        } else if ((use = Decompiler.getByName(parsed.getOptionValue("decompiler"))) == null) {
            System.out.println("Decompiler not found. By default Procyon has been set.");
            use = Decompiler.PROCYON;
        }
        System.out.println("Decompiling " + input.getAbsolutePath() + " with " + use.getName());
        BytecodeViewer.openFiles(new File[] { input }, false);
        String containerName = BytecodeViewer.files.get(0).name;
        Thread.sleep(5 * 1000);
        if (target.equalsIgnoreCase("all")) {
            use.decompileToZip(output.getAbsolutePath());
        } else {
            try {
                ClassNode cn = BytecodeViewer.getClassNode(containerName, target);
                byte[] bytes = BytecodeViewer.getClassBytes(containerName, target);
                String contents = use.decompileClassNode(cn, bytes);
                FileUtils.write(output, contents, "UTF-8", false);
            } catch (Exception e) {
                new ExceptionUI(e);
            }
        }
        System.out.println("Finished.");
        System.out.println("Bytecode Viewer CLI v" + BytecodeViewer.version + " by @Konloch - http://bytecodeviewer.com");
        System.exit(0);
    } catch (Exception e) {
        new ExceptionUI(e);
    }
}
Also used : ClassNode(org.objectweb.asm.tree.ClassNode) Decompiler(the.bytecode.club.bytecodeviewer.decompilers.Decompiler) ExceptionUI(the.bytecode.club.bytecodeviewer.api.ExceptionUI) File(java.io.File)

Example 2 with Decompiler

use of the.bytecode.club.bytecodeviewer.decompilers.Decompiler in project bytecode-viewer by Konloch.

the class ClassViewer method isPaneEditable.

public boolean isPaneEditable(int pane) {
    setPanes();
    ButtonGroup buttonGroup = BytecodeViewer.viewer.allPanes.get(pane);
    Decompiler selected = decompilers.get(pane);
    if (buttonGroup != null && BytecodeViewer.viewer.editButtons.get(buttonGroup) != null && BytecodeViewer.viewer.editButtons.get(buttonGroup).get(selected) != null && BytecodeViewer.viewer.editButtons.get(buttonGroup).get(selected).isSelected()) {
        return true;
    }
    return false;
}
Also used : Decompiler(the.bytecode.club.bytecodeviewer.decompilers.Decompiler)

Aggregations

Decompiler (the.bytecode.club.bytecodeviewer.decompilers.Decompiler)2 File (java.io.File)1 ClassNode (org.objectweb.asm.tree.ClassNode)1 ExceptionUI (the.bytecode.club.bytecodeviewer.api.ExceptionUI)1