diff --git a/BytecodeViewer 2.3.0.jar b/BytecodeViewer 2.4.0.jar similarity index 93% rename from BytecodeViewer 2.3.0.jar rename to BytecodeViewer 2.4.0.jar index e37dac3bd..f4d4f1231 100644 Binary files a/BytecodeViewer 2.3.0.jar and b/BytecodeViewer 2.4.0.jar differ diff --git a/README.txt b/README.txt index 9fbf0d942..db9a863ad 100644 --- a/README.txt +++ b/README.txt @@ -209,4 +209,13 @@ Changelog: 12/18/2014 - Fixed not escaping the Java strings by default for the Bytecode decompiler. - http://i.imgur.com/YrRnZA7.png 12/18/2014 - Used Eclipse's code formatting tool and formatted the code 12/19/2014 - Priav03 fixed the quick class searcher. - +--- 2.4.0 ---: +12/19/2014 - Afffsdd made the Bytecode Viewer directory hidden. +12/19/2014 - Added save Java file as, for singular class file decompilation (this is threaded). +12/19/2014 - Removed unused Bytecode Decompiler debug code. +12/20/2014 - Made a new outdated pane - http://i.imgur.com/xMxkwJ9.png +12/20/2014 - Added an expand/collapse the packages in the file navigator. +12/20/2014 - Moved all of the settings to the.bytecode.club.bytecodeviewer.Settings +12/20/2014 - If the class file does not start with CAFEBABE it won't be processed. +12/20/2014 - Properly handled file not found error. +12/21/2014 - Fixed the Refresh Class causing a dupe. \ No newline at end of file diff --git a/VERSION b/VERSION index cc6612c36..9183195ac 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.3.0 \ No newline at end of file +2.4.0 \ 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 04bec28f4..bec9e426b 100644 --- a/src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java +++ b/src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java @@ -1,10 +1,16 @@ package the.bytecode.club.bytecodeviewer; +import java.awt.Desktop; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.BufferedImage; -import java.io.*; +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStreamReader; import java.net.HttpURLConnection; +import java.net.URI; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; @@ -31,12 +37,14 @@ import the.bytecode.club.bytecodeviewer.plugins.PluginManager; /** - * A lightweight Java Bytecode Viewer/GUI Decompiler, developed by Konloch - + * A lightweight Java Reverse Engineering suite, developed by Konloch - * http://konloch.me * * Are you a Java Reverse Engineer? Or maybe you want to learn Java Reverse - * Engineering? Join The Bytecode Club - http://the.bytecode.club We're noob - * friendly, and censorship free. + * Engineering? Join The Bytecode Club, we're noob friendly, and censorship + * free. + * + * http://the.bytecode.club * * All you have to do is add a jar or class file into the workspace, select the * file you want then it will start decompiling the class in the background, @@ -51,23 +59,16 @@ * every single class loaded in the file system to the execute function, this * allows the user to handle it completely using ASM. * - * File Navigation Pane, Search Pane and Work Pane based off of J-RET by - * WaterWolf - https://github.com/Waterwolf/Java-ReverseEngineeringTool Java - * Decompiler is a modified version of FernFlower, Procyon and CFR. Bytecode - * Decompiler base & ByteAnalysis lib by Bibl. - * * TODO: * The import jar method eats up a lot of memory, look into some how reducing this. * Add a tool to build a flowchart of all the classes, and what methods execute what classes, and those method, read chatlog * Add obfuscation * Add progress bars on saving all zips/java decompile jar * Add the jump/save mark system Ida Pro has. - * Add a search function to the plugin console? * Add integer boxing and other obfuscation methods contra implemented * Insert unadded/debug opcodes to try to fuck up decompilers * ClassAnylyzterAdapter * Add class annotations to bytecode decompiler. - * Quick class search isn't working fully. * Option to make the bytecode pane automatically scroll to where the source code pane is * * ----Beta 1.0.0-----: @@ -215,7 +216,7 @@ * -----2.3.0-----: * 12/16/2014 - Started updating the class viewer. * 12/18/2014 - Finished a basic concept of the new class viewer. - * 12/18/2014 - Fixed an error with importing some jars. + * 12/18/2014 - Fixed an error with importing some jars. (Thanks sahitya-pavurala) * 12/18/2014 - Fixed the about window. * 12/18/2014 - Finished the final concept for the new class viewer. * 12/18/2014 - Threaded save Java files as zip, it now runs in a background thread. @@ -225,6 +226,16 @@ * 12/18/2014 - Fixed not escaping the Java strings by default for the Bytecode decompiler. - http://i.imgur.com/YrRnZA7.png * 12/18/2014 - Used Eclipse's code formatting tool and formatted the code * 12/19/2014 - Priav03 fixed the quick class searcher. + * -----2.4.0-----: + * 12/19/2014 - Afffsdd made the Bytecode Viewer directory hidden. + * 12/19/2014 - Added save Java file as, for singular class file decompilation (this is threaded). + * 12/19/2014 - Removed unused Bytecode Decompiler debug code. + * 12/20/2014 - Made a new outdated pane - http://i.imgur.com/xMxkwJ9.png + * 12/20/2014 - Added an expand/collapse the packages in the file navigator. + * 12/20/2014 - Moved all of the settings to the.bytecode.club.bytecodeviewer.Settings + * 12/20/2014 - If the class file does not start with CAFEBABE it won't be processed. + * 12/20/2014 - Properly handled file not found error. + * 12/21/2014 - Fixed the Refresh Class causing a dupe. * * @author Konloch * @@ -240,12 +251,12 @@ public class BytecodeViewer { public static String nl = System.getProperty("line.separator"); private static String filesName = getBCVDirectory() + fs + "recentfiles.bcv"; private static String pluginsName = getBCVDirectory() + fs + "recentplugins.bcv"; - private static String settingsName = getBCVDirectory() + fs + "settings.bcv"; + public static String settingsName = getBCVDirectory() + fs + "settings.bcv"; public static String tempDirectory = getBCVDirectory() + fs + "bcv_temp" + fs; private static ArrayList recentFiles = DiskReader.loadArrayList(filesName, false); private static ArrayList recentPlugins = DiskReader.loadArrayList(pluginsName, false); public static boolean runningObfuscation = false; - public static String version = "2.3.0"; + public static String version = "2.4.0"; public static void main(String[] args) { iconList = new ArrayList(); @@ -258,7 +269,7 @@ public static void main(String[] args) { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { - saveGUISettings(); + Settings.saveGUI(); cleanup(); } }); @@ -269,7 +280,7 @@ public void run() { } viewer = new MainViewerGUI(); - loadGUISettings(); + Settings.loadGUI(); resetRecentFilesMenu(); Thread versionChecker = new Thread() { @@ -286,14 +297,66 @@ public void run() { new InputStreamReader(connection.getInputStream())); String version = reader.readLine(); reader.close(); - if (!BytecodeViewer.version.equals(version)) - showMessage("You're running an outdated version of Bytecode Viewer, current version: " + if (!BytecodeViewer.version.equals(version)) { + connection = (HttpURLConnection) new URL( + "https://raw.githubusercontent.com/Konloch/bytecode-viewer/master/README.txt") + .openConnection(); + connection.setUseCaches(false); + connection.setRequestProperty("User-Agent", + "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0"); + reader = new BufferedReader( + new InputStreamReader(connection.getInputStream())); + ArrayList readme = new ArrayList(); + String s; + while((s = reader.readLine()) != null) + readme.add(s); + reader.close(); + + String changelog = ""; + boolean trigger = false; + for(String st : readme) { + if(st.equals("--- "+version+" ---:")) + trigger = true; + + if(trigger == true && !st.equals("--- "+version+" ---:")) { + if(st.startsWith("--- ")) + trigger = false; + else + changelog += st + nl; + } + } + + JOptionPane pane = new JOptionPane("Your version: " + BytecodeViewer.version + ", latest version: " + version + nl + nl - + "https://github.com/Konloch/bytecode-viewer"); + + "Version " + version + "'s Change Log:" + + nl + + changelog + + nl + + "Would you like to automatically open the download page? (https://github.com/Konloch/bytecode-viewer/releases)"); + Object[] options = new String[] { "Yes", "No" }; + pane.setOptions(options); + JDialog dialog = pane.createDialog(BytecodeViewer.viewer, + "Bytecode Viewer - Outdated Version"); + dialog.setVisible(true); + Object obj = pane.getValue(); + int result = -1; + for (int k = 0; k < options.length; k++) + if (options[k].equals(obj)) + result = k; + + if (result == 0) { + if(Desktop.isDesktopSupported()) + { + Desktop.getDesktop().browse(new URI("https://github.com/Konloch/bytecode-viewer/releases")); + } else { + showMessage("Cannot open the page, please manually type it."); + } + } + } } catch (Exception e) { new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); } @@ -336,9 +399,13 @@ public static ArrayList getLoadedClasses() { } public static void openFiles(File[] files) { + for (File f : files) + BytecodeViewer.addRecentFile(f); + BytecodeViewer.viewer.setC(true); BytecodeViewer.viewer.setIcon(true); - + boolean update = true; + for (final File f : files) { final String fn = f.getName(); if (fn.endsWith(".jar")) { @@ -350,22 +417,32 @@ public static void openFiles(File[] files) { } else if (fn.endsWith(".class")) { try { - final ClassNode cn = JarUtils.getNode(JarUtils - .getBytes(new FileInputStream(f))); - BytecodeViewer.loadedClasses.put(cn.name, cn); + byte[] bytes = JarUtils.getBytes(new FileInputStream(f)); + String cafebabe = String.format("%02X", bytes[0]) + + String.format("%02X", bytes[1]) + + String.format("%02X", bytes[2]) + + String.format("%02X", bytes[3]); + if(cafebabe.toLowerCase().equals("cafebabe")) { + final ClassNode cn = JarUtils.getNode(bytes); + BytecodeViewer.loadedClasses.put(cn.name, cn); + } else { + showMessage(fn+": Header does not start with CAFEBABE, ignoring."); + update = false; + } + } catch (java.io.FileNotFoundException e) { + showMessage("The file " + f.getAbsolutePath() + " could not be found."); + update = false; } catch (final Exception e) { new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); - } + } } } - for (File f : files) - BytecodeViewer.addRecentFile(f); - BytecodeViewer.viewer.setC(false); BytecodeViewer.viewer.setIcon(false); - - MainViewerGUI.getComponent(FileNavigationPane.class).updateTree(); + + if(update) + MainViewerGUI.getComponent(FileNavigationPane.class).updateTree(); } public static void startPlugin(File plugin) { @@ -507,14 +584,12 @@ public static void cleanup() { public static String getBCVDirectory() { File f = new File(System.getProperty("user.home") + fs + ".Bytecode-Viewer"); - while (!f.exists()) { - System.out.println("it doesn't exist."); // debug + while (!f.exists()) f.mkdirs(); - } - System.out.println("it exists now."); // debug + if (!f.isHidden() && isWindows()) hideFile(f); - + return f.getAbsolutePath(); } @@ -527,10 +602,8 @@ private static void hideFile(File f) { try { // Hide file by running attrib system command (on Windows) Runtime.getRuntime().exec("attrib +H " + f.getAbsolutePath()); - } catch (IOException e) { - System.out.println("Could not hide settings folder (~/.Bytecode-Viewer) using attrib!"); - System.out.println(e.getMessage()); - e.printStackTrace(); + } catch (Exception e) { + new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); } } @@ -541,258 +614,6 @@ private static String quickConvert(ArrayList a) { return s; } - public static void saveGUISettings() { - try { - DiskWriter.replaceFile(settingsName, "", false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.rbr.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.rsy.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.din.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.dc4.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.das.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.hes.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.hdc.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.dgs.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.ner.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.den.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.rgn.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.bto.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.nns.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.uto.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.udv.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.rer.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.fdi.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.asc.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.decodeenumswitch.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.sugarenums.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.decodestringswitch.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.arrayiter.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.collectioniter.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.innerclasses.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.removeboilerplate.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.removeinnerclasssynthetics.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.decodelambdas.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.hidebridgemethods.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.liftconstructorinit.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.removedeadmethods.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.removebadgenerics.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.sugarasserts.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.sugarboxing.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.showversion.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.decodefinally.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.tidymonitors.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.lenient.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.dumpclasspath.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.comments.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.forcetopsort.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.forcetopsortaggress.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.stringbuffer.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.stringbuilder.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.silent.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.recover.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.eclipse.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.override.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.showinferrable.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.aexagg.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.forcecondpropagate.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.hideutf.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.hidelongstrings.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.commentmonitor.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.allowcorrecting.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.labelledblocks.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.j14classobj.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.hidelangimports.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.recoverytypeclash.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.recoverytypehints.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.forceturningifs.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.forloopaggcapture.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.forceexceptionprune.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.chckbxmntmShowDebugLine.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.chckbxmntmSimplifyMemberReferences.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.mnMergeVariables.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.chckbxmntmNewCheckItem_1.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.chckbxmntmNewCheckItem_2.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.chckbxmntmNewCheckItem_3.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.chckbxmntmNewCheckItem_4.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.chckbxmntmNewCheckItem_5.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.chckbxmntmNewCheckItem_6.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.chckbxmntmNewCheckItem_7.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.chckbxmntmNewCheckItem_8.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.chckbxmntmNewCheckItem_9.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.chckbxmntmNewCheckItem_10.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.chckbxmntmNewCheckItem_11.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.chckbxmntmAppendBrackets.isSelected()), false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.debugHelpers.isSelected()), false); - DiskWriter.writeNewLine(settingsName, "deprecated", false); - DiskWriter.writeNewLine(settingsName, String.valueOf(viewer.chckbxmntmNewCheckItem_12.isSelected()), false); - if(BytecodeViewer.viewer.decompilerGroup1.isSelected(BytecodeViewer.viewer.panel1None.getModel())) - DiskWriter.writeNewLine(settingsName, "0", false); - else if(BytecodeViewer.viewer.decompilerGroup1.isSelected(BytecodeViewer.viewer.panel1Proc.getModel())) - DiskWriter.writeNewLine(settingsName, "1", false); - else if(BytecodeViewer.viewer.decompilerGroup1.isSelected(BytecodeViewer.viewer.panel1CFR.getModel())) - DiskWriter.writeNewLine(settingsName, "2", false); - else if(BytecodeViewer.viewer.decompilerGroup1.isSelected(BytecodeViewer.viewer.panel1Fern.getModel())) - DiskWriter.writeNewLine(settingsName, "3", false); - else if(BytecodeViewer.viewer.decompilerGroup1.isSelected(BytecodeViewer.viewer.panel1Bytecode.getModel())) - DiskWriter.writeNewLine(settingsName, "4", false); - else if(BytecodeViewer.viewer.decompilerGroup1.isSelected(BytecodeViewer.viewer.panel1Hexcode.getModel())) - DiskWriter.writeNewLine(settingsName, "5", false); - - if(BytecodeViewer.viewer.decompilerGroup2.isSelected(BytecodeViewer.viewer.panel2None.getModel())) - DiskWriter.writeNewLine(settingsName, "0", false); - else if(BytecodeViewer.viewer.decompilerGroup2.isSelected(BytecodeViewer.viewer.panel2Proc.getModel())) - DiskWriter.writeNewLine(settingsName, "1", false); - else if(BytecodeViewer.viewer.decompilerGroup2.isSelected(BytecodeViewer.viewer.panel2CFR.getModel())) - DiskWriter.writeNewLine(settingsName, "2", false); - else if(BytecodeViewer.viewer.decompilerGroup2.isSelected(BytecodeViewer.viewer.panel2Fern.getModel())) - DiskWriter.writeNewLine(settingsName, "3", false); - else if(BytecodeViewer.viewer.decompilerGroup2.isSelected(BytecodeViewer.viewer.panel2Bytecode.getModel())) - DiskWriter.writeNewLine(settingsName, "4", false); - else if(BytecodeViewer.viewer.decompilerGroup2.isSelected(BytecodeViewer.viewer.panel2Hexcode.getModel())) - DiskWriter.writeNewLine(settingsName, "5", false); - - if(BytecodeViewer.viewer.decompilerGroup3.isSelected(BytecodeViewer.viewer.panel3None.getModel())) - DiskWriter.writeNewLine(settingsName, "0", false); - else if(BytecodeViewer.viewer.decompilerGroup3.isSelected(BytecodeViewer.viewer.panel3Proc.getModel())) - DiskWriter.writeNewLine(settingsName, "1", false); - else if(BytecodeViewer.viewer.decompilerGroup3.isSelected(BytecodeViewer.viewer.panel3CFR.getModel())) - DiskWriter.writeNewLine(settingsName, "2", false); - else if(BytecodeViewer.viewer.decompilerGroup3.isSelected(BytecodeViewer.viewer.panel3Fern.getModel())) - DiskWriter.writeNewLine(settingsName, "3", false); - else if(BytecodeViewer.viewer.decompilerGroup3.isSelected(BytecodeViewer.viewer.panel3Bytecode.getModel())) - DiskWriter.writeNewLine(settingsName, "4", false); - else if(BytecodeViewer.viewer.decompilerGroup3.isSelected(BytecodeViewer.viewer.panel3Hexcode.getModel())) - DiskWriter.writeNewLine(settingsName, "5", false); - } catch(Exception e) { - new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); - } - } - - public static void loadGUISettings() { //utilizes the Disk Reader's caching system. - try { - viewer.rbr.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 1, true))); - viewer.rsy.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 2, false))); - viewer.din.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 3, false))); - viewer.dc4.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 4, false))); - viewer.das.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 5, false))); - viewer.hes.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 6, false))); - viewer.hdc.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 7, false))); - viewer.dgs.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 8, false))); - viewer.ner.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 9, false))); - viewer.den.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 10, false))); - viewer.rgn.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 11, false))); - viewer.bto.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 12, false))); - viewer.nns.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 13, false))); - viewer.uto.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 14, false))); - viewer.udv.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 15, false))); - viewer.rer.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 16, false))); - viewer.fdi.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 17, false))); - viewer.asc.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 18, false))); - viewer.decodeenumswitch.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 19, false))); - viewer.sugarenums.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 20, false))); - viewer.decodestringswitch.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 21, false))); - viewer.arrayiter.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 22, false))); - viewer.collectioniter.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 23, false))); - viewer.innerclasses.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 24, false))); - viewer.removeboilerplate.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 25, false))); - viewer.removeinnerclasssynthetics.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 26, false))); - viewer.decodelambdas.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 27, false))); - viewer.hidebridgemethods.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 28, false))); - viewer.liftconstructorinit.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 29, false))); - viewer.removedeadmethods.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 30, false))); - viewer.removebadgenerics.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 31, false))); - viewer.sugarasserts.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 32, false))); - viewer.sugarboxing.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 33, false))); - viewer.showversion.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 34, false))); - viewer.decodefinally.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 35, false))); - viewer.tidymonitors.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 36, false))); - viewer.lenient.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 37, false))); - viewer.dumpclasspath.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 38, false))); - viewer.comments.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 39, false))); - viewer.forcetopsort.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 40, false))); - viewer.forcetopsortaggress.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 41, false))); - viewer.stringbuffer.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 42, false))); - viewer.stringbuilder.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 43, false))); - viewer.silent.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 44, false))); - viewer.recover.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 45, false))); - viewer.eclipse.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 46, false))); - viewer.override.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 47, false))); - viewer.showinferrable.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 48, false))); - viewer.aexagg.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 49, false))); - viewer.forcecondpropagate.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 50, false))); - viewer.hideutf.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 51, false))); - viewer.hidelongstrings.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 52, false))); - viewer.commentmonitor.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 53, false))); - viewer.allowcorrecting.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 54, false))); - viewer.labelledblocks.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 55, false))); - viewer.j14classobj.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 56, false))); - viewer.hidelangimports.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 57, false))); - viewer.recoverytypeclash.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 58, false))); - viewer.recoverytypehints.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 59, false))); - viewer.forceturningifs.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 60, false))); - viewer.forloopaggcapture.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 61, false))); - viewer.forceexceptionprune.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 62, false))); - viewer.chckbxmntmShowDebugLine.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 63, false))); - viewer.chckbxmntmSimplifyMemberReferences.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 64, false))); - viewer.mnMergeVariables.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 65, false))); - viewer.chckbxmntmNewCheckItem_1.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 66, false))); - viewer.chckbxmntmNewCheckItem_2.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 67, false))); - viewer.chckbxmntmNewCheckItem_3.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 68, false))); - viewer.chckbxmntmNewCheckItem_4.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 69, false))); - viewer.chckbxmntmNewCheckItem_5.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 70, false))); - viewer.chckbxmntmNewCheckItem_6.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 71, false))); - viewer.chckbxmntmNewCheckItem_7.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 72, false))); - viewer.chckbxmntmNewCheckItem_8.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 73, false))); - viewer.chckbxmntmNewCheckItem_9.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 74, false))); - viewer.chckbxmntmNewCheckItem_10.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 75, false))); - viewer.chckbxmntmNewCheckItem_11.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 76, false))); - viewer.chckbxmntmAppendBrackets.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 77, false))); - viewer.debugHelpers.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 78, false))); - //79 is deprecated - viewer.chckbxmntmNewCheckItem_12.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 80, false))); - int decompiler = Integer.parseInt(DiskReader.loadString(settingsName, 81, false)); - if(decompiler == 0) - viewer.decompilerGroup1.setSelected(viewer.panel1None.getModel(), true); - else if(decompiler == 1) - viewer.decompilerGroup1.setSelected(viewer.panel1Proc.getModel(), true); - else if(decompiler == 2) - viewer.decompilerGroup1.setSelected(viewer.panel1CFR.getModel(), true); - else if(decompiler == 3) - viewer.decompilerGroup1.setSelected(viewer.panel1Fern.getModel(), true); - else if(decompiler == 4) - viewer.decompilerGroup1.setSelected(viewer.panel1Bytecode.getModel(), true); - else if(decompiler == 5) - viewer.decompilerGroup1.setSelected(viewer.panel1Hexcode.getModel(), true); - decompiler = Integer.parseInt(DiskReader.loadString(settingsName, 82, false)); - if(decompiler == 0) - viewer.decompilerGroup2.setSelected(viewer.panel2None.getModel(), true); - else if(decompiler == 1) - viewer.decompilerGroup2.setSelected(viewer.panel2Proc.getModel(), true); - else if(decompiler == 2) - viewer.decompilerGroup2.setSelected(viewer.panel2CFR.getModel(), true); - else if(decompiler == 3) - viewer.decompilerGroup2.setSelected(viewer.panel2Fern.getModel(), true); - else if(decompiler == 4) - viewer.decompilerGroup2.setSelected(viewer.panel2Bytecode.getModel(), true); - else if(decompiler == 5) - viewer.decompilerGroup2.setSelected(viewer.panel2Hexcode.getModel(), true); - decompiler = Integer.parseInt(DiskReader.loadString(settingsName, 83, false)); - if(decompiler == 0) - viewer.decompilerGroup3.setSelected(viewer.panel3None.getModel(), true); - else if(decompiler == 1) - viewer.decompilerGroup3.setSelected(viewer.panel3Proc.getModel(), true); - else if(decompiler == 2) - viewer.decompilerGroup3.setSelected(viewer.panel3CFR.getModel(), true); - else if(decompiler == 3) - viewer.decompilerGroup3.setSelected(viewer.panel3Fern.getModel(), true); - else if(decompiler == 4) - viewer.decompilerGroup3.setSelected(viewer.panel3Bytecode.getModel(), true); - else if(decompiler == 5) - viewer.decompilerGroup3.setSelected(viewer.panel3Hexcode.getModel(), true); - } catch(Exception e) { - //ignore because errors are expected, first start up and outdated settings. - } - } - public static ArrayList iconList; public static BufferedImage icon = b642IMG("iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAUd0lEQVR42pWaWXRbVZaGq5iHqgaSeJZsy7YkD7KtwZItebblQfI8x/HseIodO3bixE5iZw4ZSBwyACkCXQ003dD0oigq1UBqFVQ1HSB0wkyvXt1VPNSiavHCC288/b3/I11ZSszQDzuRfO89Z39n/3uffST9BMBP17Dbgna72B1hdmfQ7hK7W+yeoN0btPvE7v8Rdl+Y3Rsc4+7guHcF5wif9/ag3fYd/v70J/zHWlGFcLPRKqth99Yoc1TVKssTc1b74Krxw1Vbh3yxAl+9Mre/QZmnrvFHG+/Xnud4alwxzpEXnJOm+UGfbEH/wv2NAHkwMQ4P6GLk/1hlDyXFKVuXFI/1yQnKolJ0yqLTEhFjTEKsKRlxZgPi01OQkJ6qTJeRBn2mEYlZpjWN13gP7+VzfJ7G8WjRqXo1xwZDQmhe+kBfHhR7QHz7O300fq6LUhYBQkJ1UxDkFggZdEMQIJoTCkCsAhDn6TgdpKMWE5KyzcqSc9JDZsjNCL3WridZAmA3Q3F8zhMVBFpHELGHxJcHk2KVPZAYE4K5BYSkD+hjQuR8kAMQYENKgkwgUTBJFMzJgQhkpIrzRnHKJA6axdl0pFgzkGrNRJotS5nRbokw7e8pco8GRygugk4ixYXhAnGhOF90ml7Nvd5AX7SoRMKsGRElK7mJD9E4SFSqTg1KgLh0wy0AdF5z2uTIRrozV1lmvg2ZBQHLyLfK33KQnifX8nJgFuO9fC5VQaWr8RhRXWaaWijO92NgbAGQ2whyG5NIu0FJag0IDs5JOBkBtJXXnKfjWW47LG4HcgqdyC1yKePrDAFItaSjrrkZlf5aZBXYA4AuawgqH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M3xvy2yd5bRJHzLbskJlsgb8ZZZMz5sp+YM1SZ3BHVTHyastgqypCZlGe6mrVV3z8ZoxVSiKSREkJCBc4zmoUkDRZeClEqyC3h0BiLKkBGEqMkREQwuhpUueTRGps1FSXLMmXLg0mD2FZMjmbOVuFR/QqTkm77RC55NHktbMqYHzNv7H5s8n5O1daIBtfC4BVopFdXiB7jFPywaYqJsssO41wCEqfqqF6YrIJkhrx1Zv6MpQgNEZFg2FkqEmGleGlVpl43DA5qaUsHznigLXSA5s4Y68WZ0UqTllhl68M+f7ykPE9/87rvM8uAHyGz3McjmcutMPksQXKv0CoUuvQImG6BSJKIhIEuS309TTDFAETJrNwGE6gdn+ZkBNnFOchq9QVgsqtcIfAFJw4rDlN4zXel122CsCWiIujVSctJ1hqVXLbAnlBnwK5ETD6HP6tbghEg9HyRYPhQIENMzMExAk1IDqhQdExDWwt4zXNeS0C4QCMgkps+2qZ1UrtzRBRWQYNZPW3KPxjOEwE0BpS44RahDQoJbswsLVM9XFB5/nMzQCBDS9dLZ4CCEaCdjME7ZYf1WzINIQufh/MzUA3Q4WDrWW8pjmvSehmGYWi8B1y0vxcEyTiJ05r/Mwp7wd+5vRdP2XiMTrc1vqZE8dZ62dOed/zMyfbWj9z+n/+8OyuNX54ds/3/OjsZzfZzT8+uzdsjO/68dkP/vDs/wBUXNeRym9KEQAAAABJRU5ErkJggg=="); diff --git a/src/the/bytecode/club/bytecodeviewer/JarUtils.java b/src/the/bytecode/club/bytecodeviewer/JarUtils.java index 1fe37d546..43aeb27d5 100644 --- a/src/the/bytecode/club/bytecodeviewer/JarUtils.java +++ b/src/the/bytecode/club/bytecodeviewer/JarUtils.java @@ -35,17 +35,31 @@ public static void put(final File jarFile, final HashMap clazzList) throws IOException { jis = new JarInputStream(new FileInputStream(jarFile)); while ((entry = jis.getNextJarEntry()) != null) { - final String name = entry.getName(); - if (!name.endsWith(".class")) { - BytecodeViewer.loadedResources.put(name, getBytes(jis)); + try { + final String name = entry.getName(); + if (!name.endsWith(".class")) { + BytecodeViewer.loadedResources.put(name, getBytes(jis)); + jis.closeEntry(); + continue; + } + + byte[] bytes = getBytes(jis); + String cafebabe = String.format("%02X", bytes[0]) + + String.format("%02X", bytes[1]) + + String.format("%02X", bytes[2]) + + String.format("%02X", bytes[3]); + if(cafebabe.toLowerCase().equals("cafebabe")) { + final ClassNode cn = getNode(bytes); + clazzList.put(cn.name, cn); + } else { + System.out.println(jarFile+">"+name+": Header does not start with CAFEBABE, ignoring."); + } + + } catch(Exception e) { + e.printStackTrace(); + } finally { jis.closeEntry(); - continue; } - - final ClassNode cn = getNode(getBytes(jis)); - clazzList.put(cn.name, cn); - - jis.closeEntry(); } jis.close(); diff --git a/src/the/bytecode/club/bytecodeviewer/Settings.java b/src/the/bytecode/club/bytecodeviewer/Settings.java new file mode 100644 index 000000000..6da5da6a9 --- /dev/null +++ b/src/the/bytecode/club/bytecodeviewer/Settings.java @@ -0,0 +1,267 @@ +package the.bytecode.club.bytecodeviewer; + +import me.konloch.kontainer.io.DiskReader; +import me.konloch.kontainer.io.DiskWriter; + +/** + * Used to handle loading/saving the GUI (options). + * + * @author Konloch + * + */ + +public class Settings { + + public static void saveGUI() { + try { + DiskWriter.replaceFile(BytecodeViewer.settingsName, "", false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.rbr.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.rsy.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.din.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.dc4.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.das.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.hes.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.hdc.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.dgs.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.ner.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.den.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.rgn.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.bto.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.nns.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.uto.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.udv.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.rer.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.fdi.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.asc.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.decodeenumswitch.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.sugarenums.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.decodestringswitch.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.arrayiter.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.collectioniter.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.innerclasses.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.removeboilerplate.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.removeinnerclasssynthetics.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.decodelambdas.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.hidebridgemethods.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.liftconstructorinit.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.removedeadmethods.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.removebadgenerics.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.sugarasserts.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.sugarboxing.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.showversion.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.decodefinally.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.tidymonitors.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.lenient.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.dumpclasspath.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.comments.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.forcetopsort.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.forcetopsortaggress.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.stringbuffer.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.stringbuilder.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.silent.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.recover.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.eclipse.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.override.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.showinferrable.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.aexagg.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.forcecondpropagate.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.hideutf.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.hidelongstrings.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.commentmonitor.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.allowcorrecting.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.labelledblocks.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.j14classobj.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.hidelangimports.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.recoverytypeclash.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.recoverytypehints.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.forceturningifs.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.forloopaggcapture.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.forceexceptionprune.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmShowDebugLine.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmSimplifyMemberReferences.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.mnMergeVariables.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_1.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_2.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_3.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_4.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_5.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_6.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_7.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_8.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_9.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_10.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_11.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmAppendBrackets.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.debugHelpers.isSelected()), false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, "deprecated", false); + DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_12.isSelected()), false); + if(BytecodeViewer.viewer.decompilerGroup1.isSelected(BytecodeViewer.viewer.panel1None.getModel())) + DiskWriter.writeNewLine(BytecodeViewer.settingsName, "0", false); + else if(BytecodeViewer.viewer.decompilerGroup1.isSelected(BytecodeViewer.viewer.panel1Proc.getModel())) + DiskWriter.writeNewLine(BytecodeViewer.settingsName, "1", false); + else if(BytecodeViewer.viewer.decompilerGroup1.isSelected(BytecodeViewer.viewer.panel1CFR.getModel())) + DiskWriter.writeNewLine(BytecodeViewer.settingsName, "2", false); + else if(BytecodeViewer.viewer.decompilerGroup1.isSelected(BytecodeViewer.viewer.panel1Fern.getModel())) + DiskWriter.writeNewLine(BytecodeViewer.settingsName, "3", false); + else if(BytecodeViewer.viewer.decompilerGroup1.isSelected(BytecodeViewer.viewer.panel1Bytecode.getModel())) + DiskWriter.writeNewLine(BytecodeViewer.settingsName, "4", false); + else if(BytecodeViewer.viewer.decompilerGroup1.isSelected(BytecodeViewer.viewer.panel1Hexcode.getModel())) + DiskWriter.writeNewLine(BytecodeViewer.settingsName, "5", false); + + if(BytecodeViewer.viewer.decompilerGroup2.isSelected(BytecodeViewer.viewer.panel2None.getModel())) + DiskWriter.writeNewLine(BytecodeViewer.settingsName, "0", false); + else if(BytecodeViewer.viewer.decompilerGroup2.isSelected(BytecodeViewer.viewer.panel2Proc.getModel())) + DiskWriter.writeNewLine(BytecodeViewer.settingsName, "1", false); + else if(BytecodeViewer.viewer.decompilerGroup2.isSelected(BytecodeViewer.viewer.panel2CFR.getModel())) + DiskWriter.writeNewLine(BytecodeViewer.settingsName, "2", false); + else if(BytecodeViewer.viewer.decompilerGroup2.isSelected(BytecodeViewer.viewer.panel2Fern.getModel())) + DiskWriter.writeNewLine(BytecodeViewer.settingsName, "3", false); + else if(BytecodeViewer.viewer.decompilerGroup2.isSelected(BytecodeViewer.viewer.panel2Bytecode.getModel())) + DiskWriter.writeNewLine(BytecodeViewer.settingsName, "4", false); + else if(BytecodeViewer.viewer.decompilerGroup2.isSelected(BytecodeViewer.viewer.panel2Hexcode.getModel())) + DiskWriter.writeNewLine(BytecodeViewer.settingsName, "5", false); + + if(BytecodeViewer.viewer.decompilerGroup3.isSelected(BytecodeViewer.viewer.panel3None.getModel())) + DiskWriter.writeNewLine(BytecodeViewer.settingsName, "0", false); + else if(BytecodeViewer.viewer.decompilerGroup3.isSelected(BytecodeViewer.viewer.panel3Proc.getModel())) + DiskWriter.writeNewLine(BytecodeViewer.settingsName, "1", false); + else if(BytecodeViewer.viewer.decompilerGroup3.isSelected(BytecodeViewer.viewer.panel3CFR.getModel())) + DiskWriter.writeNewLine(BytecodeViewer.settingsName, "2", false); + else if(BytecodeViewer.viewer.decompilerGroup3.isSelected(BytecodeViewer.viewer.panel3Fern.getModel())) + DiskWriter.writeNewLine(BytecodeViewer.settingsName, "3", false); + else if(BytecodeViewer.viewer.decompilerGroup3.isSelected(BytecodeViewer.viewer.panel3Bytecode.getModel())) + DiskWriter.writeNewLine(BytecodeViewer.settingsName, "4", false); + else if(BytecodeViewer.viewer.decompilerGroup3.isSelected(BytecodeViewer.viewer.panel3Hexcode.getModel())) + DiskWriter.writeNewLine(BytecodeViewer.settingsName, "5", false); + } catch(Exception e) { + new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); + } + } + + public static void loadGUI() { //utilizes the Disk Reader's caching system. + try { + BytecodeViewer.viewer.rbr.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 1, true))); + BytecodeViewer.viewer.rsy.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 2, false))); + BytecodeViewer.viewer.din.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 3, false))); + BytecodeViewer.viewer.dc4.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 4, false))); + BytecodeViewer.viewer.das.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 5, false))); + BytecodeViewer.viewer.hes.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 6, false))); + BytecodeViewer.viewer.hdc.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 7, false))); + BytecodeViewer.viewer.dgs.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 8, false))); + BytecodeViewer.viewer.ner.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 9, false))); + BytecodeViewer.viewer.den.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 10, false))); + BytecodeViewer.viewer.rgn.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 11, false))); + BytecodeViewer.viewer.bto.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 12, false))); + BytecodeViewer.viewer.nns.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 13, false))); + BytecodeViewer.viewer.uto.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 14, false))); + BytecodeViewer.viewer.udv.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 15, false))); + BytecodeViewer.viewer.rer.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 16, false))); + BytecodeViewer.viewer.fdi.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 17, false))); + BytecodeViewer.viewer.asc.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 18, false))); + BytecodeViewer.viewer.decodeenumswitch.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 19, false))); + BytecodeViewer.viewer.sugarenums.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 20, false))); + BytecodeViewer.viewer.decodestringswitch.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 21, false))); + BytecodeViewer.viewer.arrayiter.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 22, false))); + BytecodeViewer.viewer.collectioniter.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 23, false))); + BytecodeViewer.viewer.innerclasses.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 24, false))); + BytecodeViewer.viewer.removeboilerplate.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 25, false))); + BytecodeViewer.viewer.removeinnerclasssynthetics.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 26, false))); + BytecodeViewer.viewer.decodelambdas.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 27, false))); + BytecodeViewer.viewer.hidebridgemethods.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 28, false))); + BytecodeViewer.viewer.liftconstructorinit.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 29, false))); + BytecodeViewer.viewer.removedeadmethods.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 30, false))); + BytecodeViewer.viewer.removebadgenerics.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 31, false))); + BytecodeViewer.viewer.sugarasserts.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 32, false))); + BytecodeViewer.viewer.sugarboxing.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 33, false))); + BytecodeViewer.viewer.showversion.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 34, false))); + BytecodeViewer.viewer.decodefinally.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 35, false))); + BytecodeViewer.viewer.tidymonitors.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 36, false))); + BytecodeViewer.viewer.lenient.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 37, false))); + BytecodeViewer.viewer.dumpclasspath.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 38, false))); + BytecodeViewer.viewer.comments.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 39, false))); + BytecodeViewer.viewer.forcetopsort.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 40, false))); + BytecodeViewer.viewer.forcetopsortaggress.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 41, false))); + BytecodeViewer.viewer.stringbuffer.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 42, false))); + BytecodeViewer.viewer.stringbuilder.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 43, false))); + BytecodeViewer.viewer.silent.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 44, false))); + BytecodeViewer.viewer.recover.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 45, false))); + BytecodeViewer.viewer.eclipse.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 46, false))); + BytecodeViewer.viewer.override.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 47, false))); + BytecodeViewer.viewer.showinferrable.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 48, false))); + BytecodeViewer.viewer.aexagg.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 49, false))); + BytecodeViewer.viewer.forcecondpropagate.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 50, false))); + BytecodeViewer.viewer.hideutf.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 51, false))); + BytecodeViewer.viewer.hidelongstrings.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 52, false))); + BytecodeViewer.viewer.commentmonitor.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 53, false))); + BytecodeViewer.viewer.allowcorrecting.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 54, false))); + BytecodeViewer.viewer.labelledblocks.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 55, false))); + BytecodeViewer.viewer.j14classobj.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 56, false))); + BytecodeViewer.viewer.hidelangimports.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 57, false))); + BytecodeViewer.viewer.recoverytypeclash.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 58, false))); + BytecodeViewer.viewer.recoverytypehints.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 59, false))); + BytecodeViewer.viewer.forceturningifs.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 60, false))); + BytecodeViewer.viewer.forloopaggcapture.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 61, false))); + BytecodeViewer.viewer.forceexceptionprune.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 62, false))); + BytecodeViewer.viewer.chckbxmntmShowDebugLine.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 63, false))); + BytecodeViewer.viewer.chckbxmntmSimplifyMemberReferences.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 64, false))); + BytecodeViewer.viewer.mnMergeVariables.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 65, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_1.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 66, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_2.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 67, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_3.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 68, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_4.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 69, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_5.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 70, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_6.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 71, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_7.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 72, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_8.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 73, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_9.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 74, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_10.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 75, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_11.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 76, false))); + BytecodeViewer.viewer.chckbxmntmAppendBrackets.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 77, false))); + BytecodeViewer.viewer.debugHelpers.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 78, false))); + //79 is deprecated + BytecodeViewer.viewer.chckbxmntmNewCheckItem_12.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 80, false))); + int decompiler = Integer.parseInt(DiskReader.loadString(BytecodeViewer.settingsName, 81, false)); + if(decompiler == 0) + BytecodeViewer.viewer.decompilerGroup1.setSelected(BytecodeViewer.viewer.panel1None.getModel(), true); + else if(decompiler == 1) + BytecodeViewer.viewer.decompilerGroup1.setSelected(BytecodeViewer.viewer.panel1Proc.getModel(), true); + else if(decompiler == 2) + BytecodeViewer.viewer.decompilerGroup1.setSelected(BytecodeViewer.viewer.panel1CFR.getModel(), true); + else if(decompiler == 3) + BytecodeViewer.viewer.decompilerGroup1.setSelected(BytecodeViewer.viewer.panel1Fern.getModel(), true); + else if(decompiler == 4) + BytecodeViewer.viewer.decompilerGroup1.setSelected(BytecodeViewer.viewer.panel1Bytecode.getModel(), true); + else if(decompiler == 5) + BytecodeViewer.viewer.decompilerGroup1.setSelected(BytecodeViewer.viewer.panel1Hexcode.getModel(), true); + decompiler = Integer.parseInt(DiskReader.loadString(BytecodeViewer.settingsName, 82, false)); + if(decompiler == 0) + BytecodeViewer.viewer.decompilerGroup2.setSelected(BytecodeViewer.viewer.panel2None.getModel(), true); + else if(decompiler == 1) + BytecodeViewer.viewer.decompilerGroup2.setSelected(BytecodeViewer.viewer.panel2Proc.getModel(), true); + else if(decompiler == 2) + BytecodeViewer.viewer.decompilerGroup2.setSelected(BytecodeViewer.viewer.panel2CFR.getModel(), true); + else if(decompiler == 3) + BytecodeViewer.viewer.decompilerGroup2.setSelected(BytecodeViewer.viewer.panel2Fern.getModel(), true); + else if(decompiler == 4) + BytecodeViewer.viewer.decompilerGroup2.setSelected(BytecodeViewer.viewer.panel2Bytecode.getModel(), true); + else if(decompiler == 5) + BytecodeViewer.viewer.decompilerGroup2.setSelected(BytecodeViewer.viewer.panel2Hexcode.getModel(), true); + decompiler = Integer.parseInt(DiskReader.loadString(BytecodeViewer.settingsName, 83, false)); + if(decompiler == 0) + BytecodeViewer.viewer.decompilerGroup3.setSelected(BytecodeViewer.viewer.panel3None.getModel(), true); + else if(decompiler == 1) + BytecodeViewer.viewer.decompilerGroup3.setSelected(BytecodeViewer.viewer.panel3Proc.getModel(), true); + else if(decompiler == 2) + BytecodeViewer.viewer.decompilerGroup3.setSelected(BytecodeViewer.viewer.panel3CFR.getModel(), true); + else if(decompiler == 3) + BytecodeViewer.viewer.decompilerGroup3.setSelected(BytecodeViewer.viewer.panel3Fern.getModel(), true); + else if(decompiler == 4) + BytecodeViewer.viewer.decompilerGroup3.setSelected(BytecodeViewer.viewer.panel3Bytecode.getModel(), true); + else if(decompiler == 5) + BytecodeViewer.viewer.decompilerGroup3.setSelected(BytecodeViewer.viewer.panel3Hexcode.getModel(), true); + } catch(Exception e) { + //ignore because errors are expected, first start up and outdated settings. + } + } + +} \ No newline at end of file diff --git a/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/MethodNodeDecompiler.java b/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/MethodNodeDecompiler.java index 2ec2e86c0..9c59a9395 100644 --- a/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/MethodNodeDecompiler.java +++ b/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/MethodNodeDecompiler.java @@ -42,7 +42,6 @@ public static PrefixedStringBuilder decompile(PrefixedStringBuilder sb, if (s.length() > 0) sb.append(" "); - System.out.println(m.name); if (m.name.equals("")) { sb.append(class_); } else if (m.name.equals("")) { diff --git a/src/the/bytecode/club/bytecodeviewer/decompilers/java/CFRDecompiler.java b/src/the/bytecode/club/bytecodeviewer/decompilers/java/CFRDecompiler.java index adff70553..1a7ef2139 100644 --- a/src/the/bytecode/club/bytecodeviewer/decompilers/java/CFRDecompiler.java +++ b/src/the/bytecode/club/bytecodeviewer/decompilers/java/CFRDecompiler.java @@ -14,6 +14,7 @@ import java.util.zip.ZipOutputStream; import me.konloch.kontainer.io.DiskReader; +import me.konloch.kontainer.io.DiskWriter; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.tree.ClassNode; @@ -29,6 +30,12 @@ public class CFRDecompiler extends JavaDecompiler { + @Override + public void decompileToClass(String className, String classNameSaved) { + String contents = decompileClassNode(BytecodeViewer.getClassNode(className)); + DiskWriter.replaceFile(classNameSaved, contents, false); + } + @Override public String decompileClassNode(ClassNode cn) { final ClassWriter cw = new ClassWriter(0); diff --git a/src/the/bytecode/club/bytecodeviewer/decompilers/java/FernFlowerDecompiler.java b/src/the/bytecode/club/bytecodeviewer/decompilers/java/FernFlowerDecompiler.java index 01f4d8a3d..c954ae6db 100644 --- a/src/the/bytecode/club/bytecodeviewer/decompilers/java/FernFlowerDecompiler.java +++ b/src/the/bytecode/club/bytecodeviewer/decompilers/java/FernFlowerDecompiler.java @@ -5,6 +5,7 @@ import java.io.IOException; import me.konloch.kontainer.io.DiskReader; +import me.konloch.kontainer.io.DiskWriter; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.tree.ClassNode; @@ -22,6 +23,12 @@ public class FernFlowerDecompiler extends JavaDecompiler { + @Override + public void decompileToClass(String className, String classNameSaved) { + String contents = decompileClassNode(BytecodeViewer.getClassNode(className)); + DiskWriter.replaceFile(classNameSaved, contents, false); + } + @Override public void decompileToZip(String zipName) { File tempZip = new File(BytecodeViewer.tempDirectory + "temp.zip"); diff --git a/src/the/bytecode/club/bytecodeviewer/decompilers/java/JavaDecompiler.java b/src/the/bytecode/club/bytecodeviewer/decompilers/java/JavaDecompiler.java index 0ac630dc5..ac677a1d2 100644 --- a/src/the/bytecode/club/bytecodeviewer/decompilers/java/JavaDecompiler.java +++ b/src/the/bytecode/club/bytecodeviewer/decompilers/java/JavaDecompiler.java @@ -16,6 +16,8 @@ public abstract class JavaDecompiler { public abstract void decompileToZip(String zipName); + public abstract void decompileToClass(String className, String classNameSaved); + File tempF = null; public int getClassNumber(String start, String ext) { diff --git a/src/the/bytecode/club/bytecodeviewer/decompilers/java/ProcyonDecompiler.java b/src/the/bytecode/club/bytecodeviewer/decompilers/java/ProcyonDecompiler.java index 959abd271..3d7fba4cc 100644 --- a/src/the/bytecode/club/bytecodeviewer/decompilers/java/ProcyonDecompiler.java +++ b/src/the/bytecode/club/bytecodeviewer/decompilers/java/ProcyonDecompiler.java @@ -18,6 +18,8 @@ import java.util.zip.ZipException; import java.util.zip.ZipOutputStream; +import me.konloch.kontainer.io.DiskWriter; + import org.objectweb.asm.ClassWriter; import org.objectweb.asm.tree.ClassNode; @@ -46,6 +48,12 @@ public class ProcyonDecompiler extends JavaDecompiler { + @Override + public void decompileToClass(String className, String classNameSaved) { + String contents = decompileClassNode(BytecodeViewer.getClassNode(className)); + DiskWriter.replaceFile(classNameSaved, contents, false); + } + public DecompilerSettings getDecompilerSettings() { DecompilerSettings settings = new DecompilerSettings(); settings.setAlwaysGenerateExceptionVariableForCatchBlocks(BytecodeViewer.viewer.chckbxmntmNewCheckItem_6 diff --git a/src/the/bytecode/club/bytecodeviewer/gui/AboutWindow.java b/src/the/bytecode/club/bytecodeviewer/gui/AboutWindow.java index 773af9b06..2da4fd09a 100644 --- a/src/the/bytecode/club/bytecodeviewer/gui/AboutWindow.java +++ b/src/the/bytecode/club/bytecodeviewer/gui/AboutWindow.java @@ -24,7 +24,7 @@ public AboutWindow() { txtrBytecodeViewerIs.setWrapStyleWord(true); getContentPane().add(txtrBytecodeViewerIs, "name_140466526081695"); txtrBytecodeViewerIs - .setText("Bytecode Viewer 2.3.0 is an open source program\r\ndeveloped by Konloch (konloch@gmail.com)\r\nDir: " + .setText("Bytecode Viewer "+BytecodeViewer.version+" is an open source program\r\ndeveloped by Konloch (konloch@gmail.com)\r\nDir: " + BytecodeViewer.getBCVDirectory() + "\r\n\r\nIt uses code from the following:\r\n J-RET by WaterWolf\r\n JHexPane by Sam Koivu\r\n RSyntaxTextArea by Bobbylight\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\nhttps://the.bytecode.club"); txtrBytecodeViewerIs.setEnabled(false); diff --git a/src/the/bytecode/club/bytecodeviewer/gui/ClassViewer.java b/src/the/bytecode/club/bytecodeviewer/gui/ClassViewer.java index f1613e0ca..edfedf7cc 100644 --- a/src/the/bytecode/club/bytecodeviewer/gui/ClassViewer.java +++ b/src/the/bytecode/club/bytecodeviewer/gui/ClassViewer.java @@ -420,7 +420,7 @@ public void keyTyped(KeyEvent arg0) { hex.setSize(0, Integer.MAX_VALUE); BytecodeViewer.viewer.setIcon(true); - startPaneUpdater(); + startPaneUpdater(null); this.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { resetDivider(); @@ -454,7 +454,7 @@ else if (pane1 == 0 && pane2 == 0) static CFRDecompiler cfr_dc = new CFRDecompiler(); PaneUpdaterThread t; - public void startPaneUpdater() { + public void startPaneUpdater(final JButton button) { if (BytecodeViewer.viewer.decompilerGroup1 .isSelected(BytecodeViewer.viewer.panel1None.getModel())) pane1 = 0; @@ -515,183 +515,190 @@ else if (BytecodeViewer.viewer.decompilerGroup3 t = new PaneUpdaterThread() { @Override public void doShit() { - panel1.removeAll(); - panel2.removeAll(); - panel3.removeAll(); - - if (pane1 != 0 && pane1 != 5) - panel1.add(panel1Search, BorderLayout.NORTH); - if (pane2 != 0 && pane2 != 5) - panel2.add(panel2Search, BorderLayout.NORTH); - if (pane3 != 0 && pane3 != 5) - panel3.add(panel3Search, BorderLayout.NORTH); - - if (pane1 == 1) { // procyon - RSyntaxTextArea panelArea = new RSyntaxTextArea(); - panelArea - .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); - panelArea.setCodeFoldingEnabled(true); - panelArea.setAntiAliasingEnabled(true); - RTextScrollPane scrollPane = new RTextScrollPane(panelArea); - panelArea.setText(proc_dc.decompileClassNode(cn)); - panelArea.setCaretPosition(0); - panel1.add(scrollPane); - } - - if (pane1 == 2) {// cfr - RSyntaxTextArea panelArea = new RSyntaxTextArea(); - panelArea - .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); - panelArea.setCodeFoldingEnabled(true); - panelArea.setAntiAliasingEnabled(true); - RTextScrollPane scrollPane = new RTextScrollPane(panelArea); - panelArea.setText(cfr_dc.decompileClassNode(cn)); - panelArea.setCaretPosition(0); - panel1.add(scrollPane); - } - - if (pane1 == 3) {// fern - RSyntaxTextArea panelArea = new RSyntaxTextArea(); - panelArea - .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); - panelArea.setCodeFoldingEnabled(true); - panelArea.setAntiAliasingEnabled(true); - RTextScrollPane scrollPane = new RTextScrollPane(panelArea); - panelArea.setText(ff_dc.decompileClassNode(cn)); - panelArea.setCaretPosition(0); - panel1.add(scrollPane); - } - - if (pane1 == 4) {// bytecode - RSyntaxTextArea bytecodeArea = new RSyntaxTextArea(); - bytecodeArea - .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); - bytecodeArea.setCodeFoldingEnabled(true); - bytecodeArea.setAntiAliasingEnabled(true); - RTextScrollPane bytecodeSPane = new RTextScrollPane( - bytecodeArea); - bytecodeArea.setText(ClassNodeDecompiler.decompile(cn)); - bytecodeArea.setCaretPosition(0); - panel1.add(bytecodeSPane); - } - - if (pane1 == 5) {// hex - final ClassWriter cw = new ClassWriter(0); - cn.accept(cw); - JHexEditor hex = new JHexEditor(cw.toByteArray()); - panel1.add(hex); - } - - if (pane2 == 1) { - RSyntaxTextArea panelArea = new RSyntaxTextArea(); - panelArea - .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); - panelArea.setCodeFoldingEnabled(true); - panelArea.setAntiAliasingEnabled(true); - RTextScrollPane scrollPane = new RTextScrollPane(panelArea); - panelArea.setText(proc_dc.decompileClassNode(cn)); - panelArea.setCaretPosition(0); - panel2.add(scrollPane); - } - - if (pane2 == 2) { - RSyntaxTextArea panelArea = new RSyntaxTextArea(); - panelArea - .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); - panelArea.setCodeFoldingEnabled(true); - panelArea.setAntiAliasingEnabled(true); - RTextScrollPane scrollPane = new RTextScrollPane(panelArea); - panelArea.setText(cfr_dc.decompileClassNode(cn)); - panelArea.setCaretPosition(0); - panel2.add(scrollPane); - } - - if (pane2 == 3) { - RSyntaxTextArea panelArea = new RSyntaxTextArea(); - panelArea - .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); - panelArea.setCodeFoldingEnabled(true); - panelArea.setAntiAliasingEnabled(true); - RTextScrollPane scrollPane = new RTextScrollPane(panelArea); - panelArea.setText(ff_dc.decompileClassNode(cn)); - panelArea.setCaretPosition(0); - panel2.add(scrollPane); - } - - if (pane2 == 4) { - RSyntaxTextArea paneArea = new RSyntaxTextArea(); - paneArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); - paneArea.setCodeFoldingEnabled(true); - paneArea.setAntiAliasingEnabled(true); - RTextScrollPane scrollPane = new RTextScrollPane(paneArea); - paneArea.setText(ClassNodeDecompiler.decompile(cn)); - paneArea.setCaretPosition(0); - panel2.add(scrollPane); - } - - if (pane2 == 5) { - final ClassWriter cw = new ClassWriter(0); - cn.accept(cw); - JHexEditor hex = new JHexEditor(cw.toByteArray()); - panel2.add(hex); - } - - if (pane3 == 1) { - RSyntaxTextArea panelArea = new RSyntaxTextArea(); - panelArea - .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); - panelArea.setCodeFoldingEnabled(true); - panelArea.setAntiAliasingEnabled(true); - RTextScrollPane scrollPane = new RTextScrollPane(panelArea); - panelArea.setText(proc_dc.decompileClassNode(cn)); - panelArea.setCaretPosition(0); - panel3.add(scrollPane); - } - - if (pane3 == 2) { - RSyntaxTextArea panelArea = new RSyntaxTextArea(); - panelArea - .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); - panelArea.setCodeFoldingEnabled(true); - panelArea.setAntiAliasingEnabled(true); - RTextScrollPane scrollPane = new RTextScrollPane(panelArea); - panelArea.setText(cfr_dc.decompileClassNode(cn)); - panelArea.setCaretPosition(0); - panel3.add(scrollPane); - } - - if (pane3 == 3) { - RSyntaxTextArea panelArea = new RSyntaxTextArea(); - panelArea - .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); - panelArea.setCodeFoldingEnabled(true); - panelArea.setAntiAliasingEnabled(true); - RTextScrollPane scrollPane = new RTextScrollPane(panelArea); - panelArea.setText(ff_dc.decompileClassNode(cn)); - panelArea.setCaretPosition(0); - panel3.add(scrollPane); - } - - if (pane3 == 4) { - RSyntaxTextArea paneArea = new RSyntaxTextArea(); - paneArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); - paneArea.setCodeFoldingEnabled(true); - paneArea.setAntiAliasingEnabled(true); - RTextScrollPane scrollPane = new RTextScrollPane(paneArea); - paneArea.setText(ClassNodeDecompiler.decompile(cn)); - paneArea.setCaretPosition(0); - panel3.add(scrollPane); - } - - if (pane3 == 5) { - final ClassWriter cw = new ClassWriter(0); - cn.accept(cw); - JHexEditor hex = new JHexEditor(cw.toByteArray()); - panel3.add(hex); + try { + panel1.removeAll(); + panel2.removeAll(); + panel3.removeAll(); + + if (pane1 != 0 && pane1 != 5) + panel1.add(panel1Search, BorderLayout.NORTH); + if (pane2 != 0 && pane2 != 5) + panel2.add(panel2Search, BorderLayout.NORTH); + if (pane3 != 0 && pane3 != 5) + panel3.add(panel3Search, BorderLayout.NORTH); + + if (pane1 == 1) { // procyon + RSyntaxTextArea panelArea = new RSyntaxTextArea(); + panelArea + .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); + panelArea.setCodeFoldingEnabled(true); + panelArea.setAntiAliasingEnabled(true); + RTextScrollPane scrollPane = new RTextScrollPane(panelArea); + panelArea.setText(proc_dc.decompileClassNode(cn)); + panelArea.setCaretPosition(0); + panel1.add(scrollPane); + } + + if (pane1 == 2) {// cfr + RSyntaxTextArea panelArea = new RSyntaxTextArea(); + panelArea + .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); + panelArea.setCodeFoldingEnabled(true); + panelArea.setAntiAliasingEnabled(true); + RTextScrollPane scrollPane = new RTextScrollPane(panelArea); + panelArea.setText(cfr_dc.decompileClassNode(cn)); + panelArea.setCaretPosition(0); + panel1.add(scrollPane); + } + + if (pane1 == 3) {// fern + RSyntaxTextArea panelArea = new RSyntaxTextArea(); + panelArea + .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); + panelArea.setCodeFoldingEnabled(true); + panelArea.setAntiAliasingEnabled(true); + RTextScrollPane scrollPane = new RTextScrollPane(panelArea); + panelArea.setText(ff_dc.decompileClassNode(cn)); + panelArea.setCaretPosition(0); + panel1.add(scrollPane); + } + + if (pane1 == 4) {// bytecode + RSyntaxTextArea bytecodeArea = new RSyntaxTextArea(); + bytecodeArea + .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); + bytecodeArea.setCodeFoldingEnabled(true); + bytecodeArea.setAntiAliasingEnabled(true); + RTextScrollPane bytecodeSPane = new RTextScrollPane( + bytecodeArea); + bytecodeArea.setText(ClassNodeDecompiler.decompile(cn)); + bytecodeArea.setCaretPosition(0); + panel1.add(bytecodeSPane); + } + + if (pane1 == 5) {// hex + final ClassWriter cw = new ClassWriter(0); + cn.accept(cw); + JHexEditor hex = new JHexEditor(cw.toByteArray()); + panel1.add(hex); + } + + if (pane2 == 1) { + RSyntaxTextArea panelArea = new RSyntaxTextArea(); + panelArea + .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); + panelArea.setCodeFoldingEnabled(true); + panelArea.setAntiAliasingEnabled(true); + RTextScrollPane scrollPane = new RTextScrollPane(panelArea); + panelArea.setText(proc_dc.decompileClassNode(cn)); + panelArea.setCaretPosition(0); + panel2.add(scrollPane); + } + + if (pane2 == 2) { + RSyntaxTextArea panelArea = new RSyntaxTextArea(); + panelArea + .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); + panelArea.setCodeFoldingEnabled(true); + panelArea.setAntiAliasingEnabled(true); + RTextScrollPane scrollPane = new RTextScrollPane(panelArea); + panelArea.setText(cfr_dc.decompileClassNode(cn)); + panelArea.setCaretPosition(0); + panel2.add(scrollPane); + } + + if (pane2 == 3) { + RSyntaxTextArea panelArea = new RSyntaxTextArea(); + panelArea + .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); + panelArea.setCodeFoldingEnabled(true); + panelArea.setAntiAliasingEnabled(true); + RTextScrollPane scrollPane = new RTextScrollPane(panelArea); + panelArea.setText(ff_dc.decompileClassNode(cn)); + panelArea.setCaretPosition(0); + panel2.add(scrollPane); + } + + if (pane2 == 4) { + RSyntaxTextArea paneArea = new RSyntaxTextArea(); + paneArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); + paneArea.setCodeFoldingEnabled(true); + paneArea.setAntiAliasingEnabled(true); + RTextScrollPane scrollPane = new RTextScrollPane(paneArea); + paneArea.setText(ClassNodeDecompiler.decompile(cn)); + paneArea.setCaretPosition(0); + panel2.add(scrollPane); + } + + if (pane2 == 5) { + final ClassWriter cw = new ClassWriter(0); + cn.accept(cw); + JHexEditor hex = new JHexEditor(cw.toByteArray()); + panel2.add(hex); + } + + if (pane3 == 1) { + RSyntaxTextArea panelArea = new RSyntaxTextArea(); + panelArea + .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); + panelArea.setCodeFoldingEnabled(true); + panelArea.setAntiAliasingEnabled(true); + RTextScrollPane scrollPane = new RTextScrollPane(panelArea); + panelArea.setText(proc_dc.decompileClassNode(cn)); + panelArea.setCaretPosition(0); + panel3.add(scrollPane); + } + + if (pane3 == 2) { + RSyntaxTextArea panelArea = new RSyntaxTextArea(); + panelArea + .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); + panelArea.setCodeFoldingEnabled(true); + panelArea.setAntiAliasingEnabled(true); + RTextScrollPane scrollPane = new RTextScrollPane(panelArea); + panelArea.setText(cfr_dc.decompileClassNode(cn)); + panelArea.setCaretPosition(0); + panel3.add(scrollPane); + } + + if (pane3 == 3) { + RSyntaxTextArea panelArea = new RSyntaxTextArea(); + panelArea + .setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); + panelArea.setCodeFoldingEnabled(true); + panelArea.setAntiAliasingEnabled(true); + RTextScrollPane scrollPane = new RTextScrollPane(panelArea); + panelArea.setText(ff_dc.decompileClassNode(cn)); + panelArea.setCaretPosition(0); + panel3.add(scrollPane); + } + + if (pane3 == 4) { + RSyntaxTextArea paneArea = new RSyntaxTextArea(); + paneArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); + paneArea.setCodeFoldingEnabled(true); + paneArea.setAntiAliasingEnabled(true); + RTextScrollPane scrollPane = new RTextScrollPane(paneArea); + paneArea.setText(ClassNodeDecompiler.decompile(cn)); + paneArea.setCaretPosition(0); + panel3.add(scrollPane); + } + + if (pane3 == 5) { + final ClassWriter cw = new ClassWriter(0); + cn.accept(cw); + JHexEditor hex = new JHexEditor(cw.toByteArray()); + panel3.add(hex); + } + + resetDivider(); + BytecodeViewer.viewer.setIcon(false); + } catch(Exception e) { + new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); + } finally { + if(button != null) + button.setEnabled(true); } - - resetDivider(); - BytecodeViewer.viewer.setIcon(false); } }; diff --git a/src/the/bytecode/club/bytecodeviewer/gui/FileNavigationPane.java b/src/the/bytecode/club/bytecodeviewer/gui/FileNavigationPane.java index 243619c10..7c6848a91 100644 --- a/src/the/bytecode/club/bytecodeviewer/gui/FileNavigationPane.java +++ b/src/the/bytecode/club/bytecodeviewer/gui/FileNavigationPane.java @@ -7,6 +7,8 @@ import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.event.KeyAdapter; @@ -18,6 +20,7 @@ import java.util.Iterator; import java.util.Map.Entry; +import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -40,6 +43,8 @@ public class FileNavigationPane extends VisibleComponent implements FileChangeNotifier fcn; JCheckBox exact = new JCheckBox("Exact"); + JButton open = new JButton("+"); + JButton close = new JButton("-"); MyTreeNode treeRoot = new MyTreeNode("Root"); MyTree tree; @@ -49,6 +54,27 @@ public FileNavigationPane(final FileChangeNotifier fcn) { setTitle("Files"); this.fcn = fcn; + + open.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + final TreeNode root = (TreeNode) tree.getModel().getRoot(); + expandAll(tree, new TreePath(root), true); + } + + }); + + close.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + final TreeNode root = (TreeNode) tree.getModel().getRoot(); + expandAll(tree, new TreePath(root), false); + tree.expandPath(new TreePath(root)); + } + + }); getContentPane().setLayout(new BorderLayout()); @@ -190,7 +216,13 @@ public void focusLost(final FocusEvent arg0) { JPanel p2 = new JPanel(); p2.setLayout(new BorderLayout()); p2.add(quickSearch, BorderLayout.NORTH); - p2.add(exact, BorderLayout.SOUTH); + JPanel p3 = new JPanel(new BorderLayout()); + p3.add(exact, BorderLayout.WEST); + JPanel p4 = new JPanel(new BorderLayout()); + p4.add(open, BorderLayout.EAST); + p4.add(close, BorderLayout.WEST); + p3.add(p4, BorderLayout.EAST); + p2.add(p3, BorderLayout.SOUTH); getContentPane().add(p2, BorderLayout.SOUTH); @@ -243,15 +275,6 @@ public void updateTree() { // expandAll(tree, true); } - // If expand is true, expands all nodes in the tree. - // Otherwise, collapses all nodes in the tree. - public void expandAll(final JTree tree, final boolean expand) { - final TreeNode root = (TreeNode) tree.getModel().getRoot(); - - // Traverse tree from root - expandAll(tree, new TreePath(root), expand); - } - @SuppressWarnings("rawtypes") private void expandAll(final JTree tree, final TreePath parent, final boolean expand) { diff --git a/src/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java b/src/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java index a1c4a014f..1ee1f07dd 100644 --- a/src/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java +++ b/src/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java @@ -291,7 +291,9 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { "Bytecode"); public final JRadioButtonMenuItem panel3Hexcode = new JRadioButtonMenuItem( "Hexcode"); - + private final JMenuItem mntmNewMenuItem_12 = new JMenuItem("Save Java File.."); + public WorkPane workPane = new WorkPane(this); + public void setC(boolean busy) { if (busy) { this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); @@ -589,6 +591,89 @@ public void run() { } } }); + mntmNewMenuItem_12.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + if(workPane.getCurrentClass() == null) { + BytecodeViewer.showMessage("First open a class file."); + return; + } + final String s = workPane.getCurrentClass().name; + + JFileChooser fc = new JFileChooser(); + fc.setFileFilter(new JavaFileFilter()); + fc.setFileHidingEnabled(false); + fc.setAcceptAllFileFilterUsed(false); + int returnVal = fc.showSaveDialog(MainViewerGUI.this); + if (returnVal == JFileChooser.APPROVE_OPTION) { + File file = fc.getSelectedFile(); + BytecodeViewer.viewer.setIcon(true); + final String path = appendClass(file);// cheap hax cause + // string is final + + JOptionPane pane = new JOptionPane( + "What decompiler will you use?"); + Object[] options = new String[] { "Procyon", "CFR", + "Fernflower", "Cancel" }; + pane.setOptions(options); + JDialog dialog = pane.createDialog(BytecodeViewer.viewer, + "Bytecode Viewer - Select Decompiler"); + dialog.setVisible(true); + Object obj = pane.getValue(); + int result = -1; + for (int k = 0; k < options.length; k++) + if (options[k].equals(obj)) + result = k; + + if (result == 0) { + Thread t = new Thread() { + @Override + public void run() { + try { + proc_dc.decompileToClass(s,path); + BytecodeViewer.viewer.setIcon(false); + } catch (Exception e) { + new the.bytecode.club.bytecodeviewer.api.ExceptionUI( + e); + } + } + }; + t.start(); + } + if (result == 1) { + Thread t = new Thread() { + @Override + public void run() { + try { + cfr_dc.decompileToClass(s,path); + BytecodeViewer.viewer.setIcon(false); + } catch (Exception e) { + new the.bytecode.club.bytecodeviewer.api.ExceptionUI( + e); + } + } + }; + t.start(); + } + if (result == 2) { + Thread t = new Thread() { + @Override + public void run() { + try { + ff_dc.decompileToClass(s,path); + BytecodeViewer.viewer.setIcon(false); + } catch (Exception e) { + new the.bytecode.club.bytecodeviewer.api.ExceptionUI( + e); + } + } + }; + t.start(); + } + } + } + }); + + mnNewMenu.add(mntmNewMenuItem_12); mnNewMenu.add(mntmNewMenuItem); @@ -982,7 +1067,7 @@ public void actionPerformed(ActionEvent e) { }); setSize(new Dimension(800, 400)); - setTitle("Bytecode Viewer 2.3.0 - https://the.bytecode.club - @Konloch"); + setTitle("Bytecode Viewer "+BytecodeViewer.version+" - https://the.bytecode.club - @Konloch"); getContentPane().setLayout( new BoxLayout(getContentPane(), BoxLayout.X_AXIS)); @@ -999,15 +1084,14 @@ public void actionPerformed(ActionEvent e) { // panel.add(sp1); cn.setPreferredSize(new Dimension(200, 50)); cn.setMaximumSize(new Dimension(200, 2147483647)); - WorkPane cv = new WorkPane(this); - sp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp1, cv); + sp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp1, workPane); getContentPane().add(sp2); sp2.setResizeWeight(0.05); sp1.setResizeWeight(0.5); rfComps.add(cn); rfComps.add(s); - rfComps.add(cv); + rfComps.add(workPane); this.setLocationRelativeTo(null); } @@ -1017,6 +1101,13 @@ public String appendZip(File file) { path = path + ".zip"; return path; } + + public String appendClass(File file) { + String path = file.getAbsolutePath(); + if (!path.endsWith(".class")) + path = path + ".class"; + return path; + } @Override public void openClassFile(final String name, final ClassNode cn) { @@ -1156,4 +1247,34 @@ public String getExtension(File f) { return ext; } } + + public class JavaFileFilter extends FileFilter { + @Override + public boolean accept(File f) { + if (f.isDirectory()) + return true; + + String extension = getExtension(f); + if (extension != null) + return (extension.equals("Java")); + + return false; + } + + @Override + public String getDescription() { + return "Java Source Files"; + } + + public String getExtension(File f) { + String ext = null; + String s = f.getName(); + int i = s.lastIndexOf('.'); + + if (i > 0 && i < s.length() - 1) + ext = s.substring(i + 1).toLowerCase(); + + return ext; + } + } } \ No newline at end of file diff --git a/src/the/bytecode/club/bytecodeviewer/gui/WorkPane.java b/src/the/bytecode/club/bytecodeviewer/gui/WorkPane.java index 9b321557b..63f2a2e24 100644 --- a/src/the/bytecode/club/bytecodeviewer/gui/WorkPane.java +++ b/src/the/bytecode/club/bytecodeviewer/gui/WorkPane.java @@ -119,8 +119,9 @@ public void actionPerformed(final ActionEvent arg0) { if (src == refreshClass) { final Component tabComp = tabs.getSelectedComponent(); if (tabComp != null) { + src.setEnabled(false); BytecodeViewer.viewer.setC(true); - ((ClassViewer) tabComp).startPaneUpdater(); + ((ClassViewer) tabComp).startPaneUpdater(src); BytecodeViewer.viewer.setC(false); } }