diff --git a/BytecodeViewer Beta 1.3.1.jar b/BytecodeViewer Beta 1.3.1.jar new file mode 100644 index 000000000..5d4bf3304 Binary files /dev/null and b/BytecodeViewer Beta 1.3.1.jar differ diff --git a/README.txt b/README.txt index cfffb048b..168f79da8 100644 --- a/README.txt +++ b/README.txt @@ -107,4 +107,8 @@ Changelog: 10/29/2014 - When saving as jars or zips, it'll automatically append the file extension if it's not added. 10/29/2014 - All the built in plugins no longer set the cursor to busy. 10/29/2014 - Tried to fix the issue with JSyntaxPane by making it create the object in a background thread, it still freezes the UI. Changes kept for later implementation of another syntax highlighter. -10/29/2014 - Sped up start up time \ No newline at end of file +10/29/2014 - Sped up start up time +--- Beta 1.3.1 ---: +10/29/2014 - Replaced JSyntaxPane with RSyntaxArea, this sadly removes the search feature inside of source/bytecode files, I'll implement a search function soon. +10/29/2014 - Added a new decompiler option to append brackets to labels. +10/31/2014 - Fixed an issue with the decompiler still running when the source code pane isn't toggled. \ No newline at end of file diff --git a/VERSION b/VERSION index e93a6fa7e..0aa8e35fe 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Beta 1.3 \ No newline at end of file +Beta 1.3.1 \ No newline at end of file diff --git a/src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java b/src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java index 6aa98e908..c2b925e05 100644 --- a/src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java +++ b/src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java @@ -137,6 +137,10 @@ * 10/29/2014 - All the built in plugins no longer set the cursor to busy. * 10/29/2014 - Tried to fix the issue with JSyntaxPane by making it create the object in a background thread, it still freezes the UI. Changes kept for later implementation of another syntax highlighter. * 10/29/2014 - Sped up start up time. + * ----Beta 1.3.1-----: + * 10/29/2014 - Replaced JSyntaxPane with RSyntaxArea, this sadly removes the search feature inside of source/bytecode files, I'll implement a search function soon. + * 10/29/2014 - Added a new decompiler option to append brackets to labels. + * 10/31/2014 - Fixed an issue with the decompiler still running when the source code pane isn't toggled. * * @author Konloch * @@ -155,7 +159,7 @@ public class BytecodeViewer { public static String tempDirectory = "bcv_temp"; public static String fs = System.getProperty("file.separator"); public static String nl = System.getProperty("line.separator"); - public static String version = "Beta 1.3"; + public static String version = "Beta 1.3.1"; public static void main(String[] args) { cleanup(); @@ -176,7 +180,7 @@ public void run() { String version = reader.readLine(); reader.close(); if(!BytecodeViewer.version.equals(version)) - showMessage("You're running an outdated version of Bytecode Viewer, current version: " + BytecodeViewer.version + ", latest version: " + version); + showMessage("You're running an outdated version of Bytecode Viewer, current version: " + BytecodeViewer.version + ", latest version: " + version+nl+nl+"https://github.com/Konloch/bytecode-viewer"); } catch(Exception e) { e.printStackTrace(); } diff --git a/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/InstructionPrinter.java b/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/InstructionPrinter.java index 7722e2fc1..060572442 100644 --- a/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/InstructionPrinter.java +++ b/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/InstructionPrinter.java @@ -83,6 +83,7 @@ public InstructionPrinter(MethodNode m, InstructionPattern pattern, TypeAndName[ public ArrayList createPrint() { ArrayList info = new ArrayList(); ListIterator it = mNode.instructions.iterator(); + boolean firstLabel = false; while (it.hasNext()) { AbstractInsnNode ain = (AbstractInsnNode) it.next(); String line = ""; @@ -103,7 +104,16 @@ public ArrayList createPrint() { } else if (ain instanceof LineNumberNode) { line = printLineNumberNode((LineNumberNode) ain, it); } else if (ain instanceof LabelNode) { + if(firstLabel && BytecodeViewer.viewer.chckbxmntmAppendBrackets.isSelected()) + info.add("}"); + line = printLabelnode((LabelNode) ain); + + if(BytecodeViewer.viewer.chckbxmntmAppendBrackets.isSelected()) { + if(!firstLabel) + firstLabel = true; + line += " {"; + } } else if (ain instanceof TypeInsnNode) { line = printTypeInsnNode((TypeInsnNode) ain); } else if (ain instanceof FrameNode) { @@ -125,6 +135,8 @@ public ArrayList createPrint() { info.add(line); } } + if(firstLabel && BytecodeViewer.viewer.chckbxmntmAppendBrackets.isSelected()) + info.add("}"); return info; } diff --git a/src/the/bytecode/club/bytecodeviewer/gui/AboutWindow.java b/src/the/bytecode/club/bytecodeviewer/gui/AboutWindow.java index 9523a93d6..b82826e5f 100644 --- a/src/the/bytecode/club/bytecodeviewer/gui/AboutWindow.java +++ b/src/the/bytecode/club/bytecodeviewer/gui/AboutWindow.java @@ -8,7 +8,7 @@ public class AboutWindow extends JFrame { public AboutWindow() { - setSize(new Dimension(403, 484)); + setSize(new Dimension(403, 374)); setType(Type.UTILITY); setTitle("Bytecode Viewer - About"); getContentPane().setLayout(new CardLayout(0, 0)); @@ -17,7 +17,7 @@ public AboutWindow() { txtrBytecodeViewerIs.setDisabledTextColor(Color.BLACK); txtrBytecodeViewerIs.setWrapStyleWord(true); getContentPane().add(txtrBytecodeViewerIs, "name_140466526081695"); - txtrBytecodeViewerIs.setText("Bytecode Viewer is an open source program\r\ndeveloped by Konloch (konloch@gmail.com)\r\n\r\nIt uses code from the following:\r\n J-RET by WaterWolf\r\n JHexPane by Sam Koivu\r\n JSyntaxPane by Ayman Al\r\n Commons IO by Apache\r\n ASM by OW2\r\n CFIDE by Bibl\r\n FernFlower by Stiver\r\n Procyon by Mstrobel\r\n CFR by Lee Benfield\r\n\r\nLimitations:\r\n Syntax highlighting on files that are\r\nbigger than 10K lines can take a while to\r\nload, you may want to disable the syntax\r\nhighlighting for large files.\r\n\r\nIf you're interested in Java Reverse\r\nEngineering, join The Bytecode Club\r\nhttp://the.bytecode.club"); + txtrBytecodeViewerIs.setText("Bytecode Viewer is an open source program\r\ndeveloped by Konloch (konloch@gmail.com)\r\n\r\nIt uses code from the following:\r\n J-RET by WaterWolf\r\n JHexPane by Sam Koivu\r\n JSyntaxPane by Ayman Al\r\n Commons IO by Apache\r\n ASM by OW2\r\n CFIDE by Bibl\r\n FernFlower by Stiver\r\n Procyon by Mstrobel\r\n CFR by Lee Benfield\r\n\r\nIf you're interested in Java Reverse\r\nEngineering, join The Bytecode Club\r\nhttp://the.bytecode.club"); txtrBytecodeViewerIs.setEnabled(false); this.setResizable(false); this.setLocationRelativeTo(null); diff --git a/src/the/bytecode/club/bytecodeviewer/gui/ClassViewer.java b/src/the/bytecode/club/bytecodeviewer/gui/ClassViewer.java index d1d835b72..a817c0e78 100644 --- a/src/the/bytecode/club/bytecodeviewer/gui/ClassViewer.java +++ b/src/the/bytecode/club/bytecodeviewer/gui/ClassViewer.java @@ -10,7 +10,6 @@ import static javax.swing.ScrollPaneConstants.*; -import javax.swing.JEditorPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; @@ -27,6 +26,9 @@ import javax.swing.text.ViewFactory; import javax.swing.text.html.ParagraphView; +import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; +import org.fife.ui.rsyntaxtextarea.SyntaxConstants; +import org.fife.ui.rtextarea.RTextScrollPane; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Type; import org.objectweb.asm.tree.ClassNode; @@ -101,8 +103,6 @@ public ClassViewer(final String name, final ClassNode cn) { sourcePane = BytecodeViewer.viewer.sourcePane.isSelected(); bytecodePane = BytecodeViewer.viewer.bytecodePane.isSelected(); hexPane = BytecodeViewer.viewer.hexPane.isSelected(); - boolean bytecodeSyntax = BytecodeViewer.viewer.bycSyntax.isSelected(); - boolean sourcecodeSyntax = BytecodeViewer.viewer.srcSyntax.isSelected(); this.name = name; this.cn = cn; this.setName(name); @@ -127,8 +127,6 @@ public ClassViewer(final String name, final ClassNode cn) { resetDivider(); BytecodeViewer.viewer.setIcon(true); - // - startPaneUpdater(); this.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { @@ -166,38 +164,39 @@ public void startPaneUpdater() { public void doShit() { final String b = ClassNodeDecompiler.decompile(cn); - if(BytecodeViewer.viewer.decompilerGroup.isSelected(BytecodeViewer.viewer.fernflowerDec.getModel())) - s = ff_dc.decompileClassNode(cn); - else if(BytecodeViewer.viewer.decompilerGroup.isSelected(BytecodeViewer.viewer.procyonDec.getModel())) - s = proc_dc.decompileClassNode(cn); - else if(BytecodeViewer.viewer.decompilerGroup.isSelected(BytecodeViewer.viewer.cfrDec.getModel())) - s = cfr_dc.decompileClassNode(cn); + if(BytecodeViewer.viewer.sourcePane.isSelected()) { + if(BytecodeViewer.viewer.decompilerGroup.isSelected(BytecodeViewer.viewer.fernflowerDec.getModel())) + s = ff_dc.decompileClassNode(cn); + else if(BytecodeViewer.viewer.decompilerGroup.isSelected(BytecodeViewer.viewer.procyonDec.getModel())) + s = proc_dc.decompileClassNode(cn); + else if(BytecodeViewer.viewer.decompilerGroup.isSelected(BytecodeViewer.viewer.cfrDec.getModel())) + s = cfr_dc.decompileClassNode(cn); + } SwingUtilities.invokeLater(new Runnable() { public void run() { - JEditorPane - bytecode = new JEditorPane(), - decomp = new JEditorPane(); - JScrollPane - bytecodeScroll = new JScrollPane(bytecode), - decompScroll = new JScrollPane(decomp); - - if(bytecodePane && BytecodeViewer.viewer.bycSyntax.isSelected()) - bytecode.setContentType("text/java"); - if(sourcePane && BytecodeViewer.viewer.srcSyntax.isSelected()) - decomp.setContentType("text/java"); - - if(bytecodePane) - bytecode.setText(b); - if(sourcePane) - decomp.setText(s); + RSyntaxTextArea bytecodeArea = new RSyntaxTextArea(); + bytecodeArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); + bytecodeArea.setCodeFoldingEnabled(true); + bytecodeArea.setAntiAliasingEnabled(true); + RTextScrollPane bytecodeSPane = new RTextScrollPane(bytecodeArea); + bytecodeArea.setText(b); - bytePanel.add(bytecodeScroll); - decompPanel.add(decompScroll); + RSyntaxTextArea sourcecodeArea = new RSyntaxTextArea(); + sourcecodeArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); + sourcecodeArea.setCodeFoldingEnabled(true); + sourcecodeArea.setAntiAliasingEnabled(true); + RTextScrollPane sourcecodeSPane = new RTextScrollPane(sourcecodeArea); + sourcecodeArea.setText(s); + + if(BytecodeViewer.viewer.bytecodePane.isSelected()) + bytePanel.add(bytecodeSPane); + if(BytecodeViewer.viewer.sourcePane.isSelected()) + decompPanel.add(sourcecodeSPane); + + bytecodeArea.setCaretPosition(0); + sourcecodeArea.setCaretPosition(0); - bytecode.setCaretPosition(0); - decomp.setCaretPosition(0); - BytecodeViewer.viewer.setIcon(false); } }); diff --git a/src/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java b/src/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java index ffb411a10..0bf9f0879 100644 --- a/src/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java +++ b/src/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java @@ -99,7 +99,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { private final JMenuItem mntmShowMainMethods = new JMenuItem("Show Main Methods"); private final JMenuItem mntmNewMenuItem_3 = new JMenuItem("Save As Jar.."); private JMenuBar menuBar = new JMenuBar(); - public JCheckBoxMenuItem chckbxmntmNewCheckItem = new JCheckBoxMenuItem("Allow only ASCII characters in strings"); + public JCheckBoxMenuItem chckbxmntmNewCheckItem = new JCheckBoxMenuItem("Allow Only ASCII Characters In Strings"); private final JMenuItem mntmReplaceStrings = new JMenuItem("Replace Strings"); private final JMenuItem mntmNewMenuItem_4 = new JMenuItem(""); private final JMenu mnNewMenu_2 = new JMenu("Java Decompiler"); @@ -167,6 +167,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { public final JCheckBoxMenuItem chckbxmntmNewCheckItem_9 = new JCheckBoxMenuItem("Force Explicit Imports"); public final JCheckBoxMenuItem chckbxmntmNewCheckItem_10 = new JCheckBoxMenuItem("Flatten Switch Blocks"); public final JCheckBoxMenuItem chckbxmntmNewCheckItem_11 = new JCheckBoxMenuItem("Exclude Nested Types"); + public final JCheckBoxMenuItem chckbxmntmAppendBrackets = new JCheckBoxMenuItem("Append Brackets To Labels"); public void setC(boolean busy) { @@ -308,6 +309,9 @@ public MainViewerGUI() { forceturningifs.setSelected(true); forloopaggcapture.setSelected(true); //procyon + /*none*/ + //other + chckbxmntmAppendBrackets.setSelected(true); setJMenuBar(menuBar); @@ -600,6 +604,8 @@ public void actionPerformed(ActionEvent arg0) { mnBytecodeDecompilerSettings.add(debugHelpers); + mnBytecodeDecompilerSettings.add(chckbxmntmAppendBrackets); + mnBytecodeDecompilerSettings.add(chckbxmntmNewCheckItem); menuBar.add(mnNewMenu_1); diff --git a/src/the/bytecode/club/bytecodeviewer/gui/WorkPane.java b/src/the/bytecode/club/bytecodeviewer/gui/WorkPane.java index 287811902..a27ce3204 100644 --- a/src/the/bytecode/club/bytecodeviewer/gui/WorkPane.java +++ b/src/the/bytecode/club/bytecodeviewer/gui/WorkPane.java @@ -3,12 +3,10 @@ import java.awt.BorderLayout; import java.awt.Component; import java.awt.FlowLayout; -import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ContainerEvent; import java.awt.event.ContainerListener; -import java.lang.reflect.Field; import java.util.HashMap; import javax.swing.JButton; @@ -17,8 +15,6 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import jsyntaxpane.DefaultSyntaxKit; - import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; @@ -51,17 +47,6 @@ public WorkPane(final FileChangeNotifier fcn) { super("WorkPanel"); setTitle("Work Space"); - DefaultSyntaxKit.initKit(); - Font defFont = null; - try { - final Field defFontField = DefaultSyntaxKit.class.getDeclaredField("DEFAULT_FONT"); - defFontField.setAccessible(true); - defFont = (Font) defFontField.get(null); - } catch (final Exception e) { - e.printStackTrace(); - } - SyntaxFontHeight = defFont.getSize(); - this.tabs = new JTabbedPane(); this.fcn = fcn;