Conflicts:
	src/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java
	src/the/bytecode/club/bytecodeviewer/plugins/CodeSequenceDiagram.java
This commit is contained in:
TheBiblMan 2015-06-01 14:57:31 +01:00
commit 5b87048682
9 changed files with 323 additions and 38 deletions

View file

@ -88,9 +88,15 @@ import the.bytecode.club.bytecodeviewer.plugin.PluginManager;
* add stackmapframes to bytecode decompiler * add stackmapframes to bytecode decompiler
* add stackmapframes remover? * add stackmapframes remover?
* In BCV if you open a class and the name is so big, you cannot close because the [X] does not appear." * In BCV if you open a class and the name is so big, you cannot close because the [X] does not appear."
* refresh appears under panes that are non refreshable
* make ez-injection plugin console show all sys.out calls
* edit then save issues?
* *
* -----2.9.5-----: * -----2.9.6-----:
* 05/01/2015 - Added 'pingback' for statistics (to track how many people globally use BCV) * 05/05/2015 - Fixed a typo in the about window
* 05/28/2015 - Started importing JD-GUI Decompiler.
* 05/28/2015 - Compile on refresh and compile on save are now enabled by default.
* 05/28/2015 - Renamed the File>Save As options to be much more informative.
* *
* @author Konloch * @author Konloch
* *
@ -99,7 +105,7 @@ import the.bytecode.club.bytecodeviewer.plugin.PluginManager;
public class BytecodeViewer { public class BytecodeViewer {
/*per version*/ /*per version*/
public static String version = "2.9.5"; public static String version = "2.9.6";
public static String krakatauVersion = "2"; public static String krakatauVersion = "2";
/*the rest*/ /*the rest*/
public static MainViewerGUI viewer = null; public static MainViewerGUI viewer = null;

View file

@ -115,6 +115,8 @@ public class Settings {
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "7", false); DiskWriter.writeNewLine(BytecodeViewer.settingsName, "7", false);
else if(BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1KrakatauBytecode.getModel())) else if(BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1KrakatauBytecode.getModel()))
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "8", false); DiskWriter.writeNewLine(BytecodeViewer.settingsName, "8", false);
else if(BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1JDGUI.getModel()))
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "9", false);
if(BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2None.getModel())) if(BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2None.getModel()))
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "0", false); DiskWriter.writeNewLine(BytecodeViewer.settingsName, "0", false);
@ -134,6 +136,8 @@ public class Settings {
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "7", false); DiskWriter.writeNewLine(BytecodeViewer.settingsName, "7", false);
else if(BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2KrakatauBytecode.getModel())) else if(BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2KrakatauBytecode.getModel()))
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "8", false); DiskWriter.writeNewLine(BytecodeViewer.settingsName, "8", false);
else if(BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2JDGUI.getModel()))
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "9", false);
if(BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3None.getModel())) if(BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3None.getModel()))
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "0", false); DiskWriter.writeNewLine(BytecodeViewer.settingsName, "0", false);
@ -153,6 +157,8 @@ public class Settings {
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "7", false); DiskWriter.writeNewLine(BytecodeViewer.settingsName, "7", false);
else if(BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3KrakatauBytecode.getModel())) else if(BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3KrakatauBytecode.getModel()))
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "8", false); DiskWriter.writeNewLine(BytecodeViewer.settingsName, "8", false);
else if(BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3JDGUI.getModel()))
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "9", false);
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.refreshOnChange.isSelected()), false); DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.refreshOnChange.isSelected()), false);
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.isMaximized), false); DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.isMaximized), false);
@ -179,6 +185,9 @@ public class Settings {
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.decodeAPKResources.isSelected()), false); DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.decodeAPKResources.isSelected()), false);
DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.library, false); DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.library, false);
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.pingback), false); DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.pingback), false);
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.panel1JDGUI_E.isSelected()), false);
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.panel2JDGUI_E.isSelected()), false);
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.panel3JDGUI_E.isSelected()), false);
} catch(Exception e) { } catch(Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
} }
@ -285,6 +294,8 @@ public class Settings {
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.panel1Krakatau.getModel(), true); BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.panel1Krakatau.getModel(), true);
else if(decompiler == 8) else if(decompiler == 8)
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.panel1KrakatauBytecode.getModel(), true); BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.panel1KrakatauBytecode.getModel(), true);
else if(decompiler == 9)
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.panel1JDGUI.getModel(), true);
decompiler = Integer.parseInt(DiskReader.loadString(BytecodeViewer.settingsName, 82, false)); decompiler = Integer.parseInt(DiskReader.loadString(BytecodeViewer.settingsName, 82, false));
if(decompiler == 0) if(decompiler == 0)
@ -305,6 +316,8 @@ public class Settings {
BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.panel2Krakatau.getModel(), true); BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.panel2Krakatau.getModel(), true);
else if(decompiler == 8) else if(decompiler == 8)
BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.panel2KrakatauBytecode.getModel(), true); BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.panel2KrakatauBytecode.getModel(), true);
else if(decompiler == 9)
BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.panel2JDGUI.getModel(), true);
decompiler = Integer.parseInt(DiskReader.loadString(BytecodeViewer.settingsName, 83, false)); decompiler = Integer.parseInt(DiskReader.loadString(BytecodeViewer.settingsName, 83, false));
if(decompiler == 0) if(decompiler == 0)
@ -325,6 +338,8 @@ public class Settings {
BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.panel3Krakatau.getModel(), true); BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.panel3Krakatau.getModel(), true);
else if(decompiler == 8) else if(decompiler == 8)
BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.panel3KrakatauBytecode.getModel(), true); BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.panel3KrakatauBytecode.getModel(), true);
else if(decompiler == 9)
BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.panel3JDGUI.getModel(), true);
BytecodeViewer.viewer.refreshOnChange.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 84, false))); BytecodeViewer.viewer.refreshOnChange.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 84, false)));
@ -356,6 +371,9 @@ public class Settings {
BytecodeViewer.viewer.decodeAPKResources.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 106, false))); BytecodeViewer.viewer.decodeAPKResources.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 106, false)));
BytecodeViewer.library = DiskReader.loadString(BytecodeViewer.settingsName, 107, false); BytecodeViewer.library = DiskReader.loadString(BytecodeViewer.settingsName, 107, false);
BytecodeViewer.pingback = Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 108, false)); BytecodeViewer.pingback = Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 108, false));
BytecodeViewer.viewer.panel1JDGUI_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 109, false)));
BytecodeViewer.viewer.panel2JDGUI_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 110, false)));
BytecodeViewer.viewer.panel3JDGUI_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 111, false)));
} catch(Exception e) { } catch(Exception e) {
//ignore because errors are expected, first start up and outdated settings. //ignore because errors are expected, first start up and outdated settings.
//e.printStackTrace(); //e.printStackTrace();

View file

@ -245,4 +245,12 @@ public class BytecodeViewer {
public static the.bytecode.club.bytecodeviewer.compilers.Compiler getSmaliCompiler() { public static the.bytecode.club.bytecodeviewer.compilers.Compiler getSmaliCompiler() {
return the.bytecode.club.bytecodeviewer.compilers.Compiler.smali; return the.bytecode.club.bytecodeviewer.compilers.Compiler.smali;
} }
/**
* Returns the wrapped JD-GUI Decompiler instance.
* @return The wrapped JD-GUI Decompiler instance
*/
public static the.bytecode.club.bytecodeviewer.decompilers.Decompiler getDJGUIDecompiler() {
return the.bytecode.club.bytecodeviewer.decompilers.Decompiler.jdgui;
}
} }

View file

@ -26,4 +26,5 @@ public abstract class Decompiler {
public static Decompiler krakatau = new KrakatauDecompiler(); public static Decompiler krakatau = new KrakatauDecompiler();
public static Decompiler krakatauDA = new KrakatauDisassembler(); public static Decompiler krakatauDA = new KrakatauDisassembler();
public static Decompiler smali = new SmaliDisassembler(); public static Decompiler smali = new SmaliDisassembler();
public static Decompiler jdgui = new JDGUIDecompiler();
} }

View file

@ -48,7 +48,7 @@ import the.bytecode.club.bytecodeviewer.MiscUtils;
* *
*/ */
public class JDCoreDecompiler extends Decompiler { public class JDGUIDecompiler extends Decompiler {
@Override @Override
public void decompileToClass(String className, String classNameSaved) { public void decompileToClass(String className, String classNameSaved) {
@ -81,11 +81,11 @@ public class JDCoreDecompiler extends Decompiler {
exception = "Bytecode Viewer Version: " + BytecodeViewer.version + BytecodeViewer.nl + BytecodeViewer.nl + sw.toString(); exception = "Bytecode Viewer Version: " + BytecodeViewer.version + BytecodeViewer.nl + BytecodeViewer.nl + sw.toString();
} }
return "Procyon error! Send the stacktrace to Konloch at http://the.bytecode.club or konloch@gmail.com"+BytecodeViewer.nl+BytecodeViewer.nl+"Suggested Fix: Click refresh class, if it fails again try another decompiler."+BytecodeViewer.nl+BytecodeViewer.nl+exception; return "JD-GUI error! Send the stacktrace to Konloch at http://the.bytecode.club or konloch@gmail.com"+BytecodeViewer.nl+BytecodeViewer.nl+"Suggested Fix: Click refresh class, if it fails again try another decompiler."+BytecodeViewer.nl+BytecodeViewer.nl+exception;
} }
@Override @Override
public void decompileToZip(String zipName) { public void decompileToZip(String zipName) {
}
}
} }

View file

@ -40,7 +40,7 @@ public class AboutWindow extends JFrame {
super.setVisible(b); super.setVisible(b);
txtrBytecodeViewerIs txtrBytecodeViewerIs
.setText("Bytecode Viewer "+BytecodeViewer.version+" is an open source program developed and maintained by Konloch (konloch@gmail.com)\r\n"+ .setText("Bytecode Viewer "+BytecodeViewer.version+" is an open source program developed and maintained by Konloch (konloch@gmail.com)\r\n"+
"100% free and open sourced licensed under GPL v3 CopyLef\r\n\r\n"+ "100% free and open sourced licensed under GPL v3 CopyLeft\r\n\r\n"+
"Settings:"+BytecodeViewer.nl+ "Settings:"+BytecodeViewer.nl+
"BCV Dir: " + BytecodeViewer.getBCVDirectory()+BytecodeViewer.nl+ "BCV Dir: " + BytecodeViewer.getBCVDirectory()+BytecodeViewer.nl+
"Python: " + BytecodeViewer.python+BytecodeViewer.nl+ "Python: " + BytecodeViewer.python+BytecodeViewer.nl+
@ -51,6 +51,7 @@ public class AboutWindow extends JFrame {
"Keybinds:"+BytecodeViewer.nl+ "Keybinds:"+BytecodeViewer.nl+
"CTRL + O: Open/add new jar/class/apk"+BytecodeViewer.nl+ "CTRL + O: Open/add new jar/class/apk"+BytecodeViewer.nl+
"CTLR + N: Reset the workspace"+BytecodeViewer.nl+ "CTLR + N: Reset the workspace"+BytecodeViewer.nl+
"CTRL + W: Closes the currently opened tab"+BytecodeViewer.nl+
"CTRL + T: Compile"+BytecodeViewer.nl+ "CTRL + T: Compile"+BytecodeViewer.nl+
"CTRL + S: Save classes as zip"+BytecodeViewer.nl+ "CTRL + S: Save classes as zip"+BytecodeViewer.nl+
"CTRL + R: Run (EZ-Inject) - dynamically load the classes and invoke a main class"+ "CTRL + R: Run (EZ-Inject) - dynamically load the classes and invoke a main class"+

View file

@ -76,6 +76,8 @@ public class ClassViewer extends Viewer {
pane1 = 7; pane1 = 7;
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1KrakatauBytecode.getModel())) else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1KrakatauBytecode.getModel()))
pane1 = 8; pane1 = 8;
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1JDGUI.getModel()))
pane1 = 9;
if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2None.getModel())) if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2None.getModel()))
pane2 = 0; pane2 = 0;
@ -95,6 +97,8 @@ public class ClassViewer extends Viewer {
pane2 = 7; pane2 = 7;
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2KrakatauBytecode.getModel())) else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2KrakatauBytecode.getModel()))
pane2 = 8; pane2 = 8;
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2JDGUI.getModel()))
pane2 = 9;
if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3None.getModel())) if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3None.getModel()))
pane3 = 0; pane3 = 0;
@ -114,6 +118,8 @@ public class ClassViewer extends Viewer {
pane3 = 7; pane3 = 7;
else if (BytecodeViewer.viewer.panelGroup3 .isSelected(BytecodeViewer.viewer.panel3KrakatauBytecode.getModel())) else if (BytecodeViewer.viewer.panelGroup3 .isSelected(BytecodeViewer.viewer.panel3KrakatauBytecode.getModel()))
pane3 = 8; pane3 = 8;
else if (BytecodeViewer.viewer.panelGroup3 .isSelected(BytecodeViewer.viewer.panel3JDGUI.getModel()))
pane3 = 9;
} }
public boolean isPanel1Editable() { public boolean isPanel1Editable() {
@ -127,6 +133,8 @@ public class ClassViewer extends Viewer {
return true; return true;
if(pane1 == 6 && BytecodeViewer.viewer.panel1Smali_E.isSelected()) if(pane1 == 6 && BytecodeViewer.viewer.panel1Smali_E.isSelected())
return true; return true;
if(pane1 == 9 && BytecodeViewer.viewer.panel1JDGUI_E.isSelected())
return true;
if((pane1 == 7 || pane1 == 8) && BytecodeViewer.viewer.panel1Krakatau_E.isSelected()) if((pane1 == 7 || pane1 == 8) && BytecodeViewer.viewer.panel1Krakatau_E.isSelected())
return true; return true;
@ -145,6 +153,8 @@ public class ClassViewer extends Viewer {
return true; return true;
if(pane2 == 6 && BytecodeViewer.viewer.panel2Smali_E.isSelected()) if(pane2 == 6 && BytecodeViewer.viewer.panel2Smali_E.isSelected())
return true; return true;
if(pane2 == 9 && BytecodeViewer.viewer.panel2JDGUI_E.isSelected())
return true;
if((pane2 == 7 || pane2 == 8) && BytecodeViewer.viewer.panel2Krakatau_E.isSelected()) if((pane2 == 7 || pane2 == 8) && BytecodeViewer.viewer.panel2Krakatau_E.isSelected())
return true; return true;
@ -163,6 +173,8 @@ public class ClassViewer extends Viewer {
return true; return true;
if(pane3 == 6 && BytecodeViewer.viewer.panel3Smali_E.isSelected()) if(pane3 == 6 && BytecodeViewer.viewer.panel3Smali_E.isSelected())
return true; return true;
if(pane3 == 9 && BytecodeViewer.viewer.panel3JDGUI_E.isSelected())
return true;
if((pane3 == 7 || pane3 == 8) && BytecodeViewer.viewer.panel3Krakatau_E.isSelected()) if((pane3 == 7 || pane3 == 8) && BytecodeViewer.viewer.panel3Krakatau_E.isSelected())
return true; return true;
@ -776,6 +788,32 @@ public class ClassViewer extends Viewer {
}); });
panel1.add(scrollPane); panel1.add(scrollPane);
} }
if (pane1 == 9) {// JD-GUI
RSyntaxTextArea panelArea = new RSyntaxTextArea();
panelArea
.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
panelArea.setCodeFoldingEnabled(true);
panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane(
panelArea);
panelArea.setText(Decompiler.jdgui.decompileClassNode(cn,b));
panelArea.setCaretPosition(0);
panelArea.setEditable(isPanel1Editable());
panelArea.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
if ((e.getKeyCode() == KeyEvent.VK_F) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
field1.requestFocus();
}
BytecodeViewer.checkHotKey(e);
}
@Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { }
});
panel1.add(scrollPane);
java1 = panelArea;
}
} catch(Exception e) { } catch(Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
} finally { } finally {
@ -972,6 +1010,32 @@ public class ClassViewer extends Viewer {
}); });
panel2.add(scrollPane); panel2.add(scrollPane);
} }
if (pane2 == 9) {// JD-GUI
RSyntaxTextArea panelArea = new RSyntaxTextArea();
panelArea
.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
panelArea.setCodeFoldingEnabled(true);
panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane(
panelArea);
panelArea.setText(Decompiler.jdgui.decompileClassNode(cn,b));
panelArea.setCaretPosition(0);
panelArea.setEditable(isPanel2Editable());
panelArea.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
if ((e.getKeyCode() == KeyEvent.VK_F) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
field2.requestFocus();
}
BytecodeViewer.checkHotKey(e);
}
@Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { }
});
panel2.add(scrollPane);
java2 = panelArea;
}
} catch(Exception e) { } catch(Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
} finally { } finally {
@ -1144,8 +1208,6 @@ public class ClassViewer extends Viewer {
java3 = panelArea; java3 = panelArea;
} }
if (pane3 == 8) {// kraktau bytecode if (pane3 == 8) {// kraktau bytecode
RSyntaxTextArea panelArea = new RSyntaxTextArea(); RSyntaxTextArea panelArea = new RSyntaxTextArea();
panelArea panelArea
@ -1171,6 +1233,32 @@ public class ClassViewer extends Viewer {
}); });
panel3.add(scrollPane); panel3.add(scrollPane);
} }
if (pane3 == 9) {// JD-GUI
RSyntaxTextArea panelArea = new RSyntaxTextArea();
panelArea
.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
panelArea.setCodeFoldingEnabled(true);
panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane(
panelArea);
panelArea.setText(Decompiler.jdgui.decompileClassNode(cn,b));
panelArea.setCaretPosition(0);
panelArea.setEditable(isPanel3Editable());
panelArea.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
if ((e.getKeyCode() == KeyEvent.VK_F) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
field3.requestFocus();
}
BytecodeViewer.checkHotKey(e);
}
@Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { }
});
panel3.add(scrollPane);
java3 = panelArea;
}
} catch(Exception e) { } catch(Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
} finally { } finally {

View file

@ -38,11 +38,7 @@ import the.bytecode.club.bytecodeviewer.FileChangeNotifier;
import the.bytecode.club.bytecodeviewer.JarUtils; import the.bytecode.club.bytecodeviewer.JarUtils;
import the.bytecode.club.bytecodeviewer.MiscUtils; import the.bytecode.club.bytecodeviewer.MiscUtils;
import the.bytecode.club.bytecodeviewer.Resources; import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.decompilers.CFRDecompiler;
import the.bytecode.club.bytecodeviewer.decompilers.Decompiler; import the.bytecode.club.bytecodeviewer.decompilers.Decompiler;
import the.bytecode.club.bytecodeviewer.decompilers.FernFlowerDecompiler;
import the.bytecode.club.bytecodeviewer.decompilers.KrakatauDecompiler;
import the.bytecode.club.bytecodeviewer.decompilers.ProcyonDecompiler;
import the.bytecode.club.bytecodeviewer.obfuscators.rename.RenameClasses; import the.bytecode.club.bytecodeviewer.obfuscators.rename.RenameClasses;
import the.bytecode.club.bytecodeviewer.obfuscators.rename.RenameFields; import the.bytecode.club.bytecodeviewer.obfuscators.rename.RenameFields;
import the.bytecode.club.bytecodeviewer.obfuscators.rename.RenameMethods; import the.bytecode.club.bytecodeviewer.obfuscators.rename.RenameMethods;
@ -109,11 +105,6 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
} }
} }
final Decompiler ff_dc = new FernFlowerDecompiler();
final Decompiler proc_dc = new ProcyonDecompiler();
final Decompiler cfr_dc = new CFRDecompiler();
final Decompiler krak_dc = new KrakatauDecompiler();
public static final long serialVersionUID = 1851409230530948543L; public static final long serialVersionUID = 1851409230530948543L;
public JCheckBoxMenuItem debugHelpers = new JCheckBoxMenuItem("Debug Helpers"); public JCheckBoxMenuItem debugHelpers = new JCheckBoxMenuItem("Debug Helpers");
public JSplitPane sp1; public JSplitPane sp1;
@ -156,7 +147,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
public final JMenuItem mntmNewWorkspace = new JMenuItem("New Workspace"); public final JMenuItem mntmNewWorkspace = new JMenuItem("New Workspace");
public JMenu mnRecentFiles = new JMenu("Recent Files"); public JMenu mnRecentFiles = new JMenu("Recent Files");
public final JMenuItem mntmNewMenuItem = new JMenuItem( public final JMenuItem mntmNewMenuItem = new JMenuItem(
"Save Java Files As.."); "Decompile & Save All Classes..");
public final JMenuItem mntmAbout = new JMenuItem("About"); public final JMenuItem mntmAbout = new JMenuItem("About");
public AboutWindow aboutWindow = new AboutWindow(); public AboutWindow aboutWindow = new AboutWindow();
public final JSeparator separator_3 = new JSeparator(); public final JSeparator separator_3 = new JSeparator();
@ -176,7 +167,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
"Show All Strings"); "Show All Strings");
public final JMenuItem mntmShowMainMethods = new JMenuItem( public final JMenuItem mntmShowMainMethods = new JMenuItem(
"Show Main Methods"); "Show Main Methods");
public final JMenuItem mntmNewMenuItem_3 = new JMenuItem("Save As Jar.."); public final JMenuItem mntmNewMenuItem_3 = new JMenuItem("Save As Runnable Jar..");
public JMenuBar menuBar = new JMenuBar(); public JMenuBar menuBar = new JMenuBar();
public final JMenuItem mntmReplaceStrings = new JMenuItem( public final JMenuItem mntmReplaceStrings = new JMenuItem(
"Replace Strings"); "Replace Strings");
@ -323,7 +314,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
"Java"); "Java");
public final JRadioButtonMenuItem panel1Proc = new JRadioButtonMenuItem( public final JRadioButtonMenuItem panel1Proc = new JRadioButtonMenuItem(
"Java"); "Java");
public final JMenuItem mntmNewMenuItem_12 = new JMenuItem("Save Java File.."); public final JMenuItem mntmNewMenuItem_12 = new JMenuItem("Decompile & Save Opened Class..");
public WorkPane workPane = new WorkPane(this); public WorkPane workPane = new WorkPane(this);
public final JMenu mnSettings = new JMenu("Settings"); public final JMenu mnSettings = new JMenu("Settings");
public final JSeparator separator_6 = new JSeparator(); public final JSeparator separator_6 = new JSeparator();
@ -490,6 +481,18 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
public final ButtonGroup panelGroup3 = new ButtonGroup(); public final ButtonGroup panelGroup3 = new ButtonGroup();
private final JMenuItem mntmSetOpitonalLibrary = new JMenuItem("Set Optionial Library Folder"); private final JMenuItem mntmSetOpitonalLibrary = new JMenuItem("Set Optionial Library Folder");
private final JMenuItem mntmPingback = new JMenuItem("Pingback"); private final JMenuItem mntmPingback = new JMenuItem("Pingback");
private final JMenu mnJdgui = new JMenu("JD-GUI");
public final JRadioButtonMenuItem panel3JDGUI = new JRadioButtonMenuItem("Java");
private final JSeparator separator_33 = new JSeparator();
public final JCheckBoxMenuItem panel3JDGUI_E = new JCheckBoxMenuItem("Editable");
private final JMenu menu = new JMenu("JD-GUI");
public final JRadioButtonMenuItem panel2JDGUI = new JRadioButtonMenuItem("Java");
private final JSeparator separator_34 = new JSeparator();
public final JCheckBoxMenuItem panel2JDGUI_E = new JCheckBoxMenuItem("Editable");
private final JMenu menu_6 = new JMenu("JD-GUI");
public final JRadioButtonMenuItem panel1JDGUI = new JRadioButtonMenuItem("Java");
private final JSeparator separator_35 = new JSeparator();
public final JCheckBoxMenuItem panel1JDGUI_E = new JCheckBoxMenuItem("Editable");
public MainViewerGUI() { public MainViewerGUI() {
mnNewMenu_5.setVisible(false); mnNewMenu_5.setVisible(false);
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new Test()); KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new Test());
@ -581,7 +584,8 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
mnNewMenu.add(mntmNewWorkspace); mnNewMenu.add(mntmNewWorkspace);
JMenuItem mntmSave = new JMenuItem("Save Files As.."); JMenuItem mntmSave = new JMenuItem("Save As Zip..");
mntmSave.setActionCommand("");
mntmSave.addActionListener(new ActionListener() { mntmSave.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent arg0) { public void actionPerformed(ActionEvent arg0) {
@ -822,7 +826,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
JOptionPane pane = new JOptionPane( JOptionPane pane = new JOptionPane(
"What decompiler will you use?"); "What decompiler will you use?");
Object[] options = new String[] { "Procyon", "CFR", Object[] options = new String[] { "Procyon", "CFR",
"Fernflower", "Krakatau", "Cancel" }; "Fernflower", "Krakatau", "JD-GUI", "Cancel" };
pane.setOptions(options); pane.setOptions(options);
JDialog dialog = pane.createDialog(BytecodeViewer.viewer, JDialog dialog = pane.createDialog(BytecodeViewer.viewer,
"Bytecode Viewer - Select Decompiler"); "Bytecode Viewer - Select Decompiler");
@ -838,7 +842,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
@Override @Override
public void run() { public void run() {
try { try {
proc_dc.decompileToZip(path); Decompiler.procyon.decompileToZip(path);
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) { } catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
@ -852,7 +856,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
@Override @Override
public void run() { public void run() {
try { try {
cfr_dc.decompileToZip(path); Decompiler.cfr.decompileToZip(path);
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) { } catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
@ -866,7 +870,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
@Override @Override
public void run() { public void run() {
try { try {
ff_dc.decompileToZip(path); Decompiler.fernflower.decompileToZip(path);
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) { } catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
@ -881,7 +885,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
@Override @Override
public void run() { public void run() {
try { try {
krak_dc.decompileToZip(path); Decompiler.krakatau.decompileToZip(path);
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) { } catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
@ -891,7 +895,22 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
t.start(); t.start();
} }
if(result == 4) { if (result == 4) {
Thread t = new Thread() {
@Override
public void run() {
try {
Decompiler.jdgui.decompileToZip(path);
BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
}
}
};
t.start();
}
if(result == 5) {
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} }
} }
@ -944,7 +963,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
JOptionPane pane = new JOptionPane( JOptionPane pane = new JOptionPane(
"What decompiler will you use?"); "What decompiler will you use?");
Object[] options = new String[] { "Procyon", "CFR", Object[] options = new String[] { "Procyon", "CFR",
"Fernflower", "Krakatau", "Cancel" }; "Fernflower", "Krakatau", "DJ GUI", "Cancel" };
pane.setOptions(options); pane.setOptions(options);
JDialog dialog = pane.createDialog(BytecodeViewer.viewer, JDialog dialog = pane.createDialog(BytecodeViewer.viewer,
"Bytecode Viewer - Select Decompiler"); "Bytecode Viewer - Select Decompiler");
@ -960,7 +979,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
@Override @Override
public void run() { public void run() {
try { try {
proc_dc.decompileToClass(s,path); Decompiler.procyon.decompileToClass(s,path);
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) { } catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI( new the.bytecode.club.bytecodeviewer.api.ExceptionUI(
@ -975,7 +994,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
@Override @Override
public void run() { public void run() {
try { try {
cfr_dc.decompileToClass(s,path); Decompiler.cfr.decompileToClass(s,path);
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) { } catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI( new the.bytecode.club.bytecodeviewer.api.ExceptionUI(
@ -990,7 +1009,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
@Override @Override
public void run() { public void run() {
try { try {
ff_dc.decompileToClass(s,path); Decompiler.fernflower.decompileToClass(s,path);
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) { } catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI( new the.bytecode.club.bytecodeviewer.api.ExceptionUI(
@ -1005,7 +1024,22 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
@Override @Override
public void run() { public void run() {
try { try {
krak_dc.decompileToClass(s,path); Decompiler.krakatau.decompileToClass(s,path);
BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(
e);
}
}
};
t.start();
}
if (result == 4) {
Thread t = new Thread() {
@Override
public void run() {
try {
Decompiler.jdgui.decompileToClass(s,path);
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) { } catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI( new the.bytecode.club.bytecodeviewer.api.ExceptionUI(
@ -1016,7 +1050,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
t.start(); t.start();
} }
if(result == 4) { if(result == 5) {
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} }
} }
@ -1099,6 +1133,14 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
mnCfr.add(panel1CFR_E); mnCfr.add(panel1CFR_E);
mnNewMenu_7.add(menu_6);
menu_6.add(panel1JDGUI);
menu_6.add(separator_35);
menu_6.add(panel1JDGUI_E);
mnNewMenu_7.add(mnFernflower); mnNewMenu_7.add(mnFernflower);
mnFernflower.add(panel1Fern); mnFernflower.add(panel1Fern);
panel1Fern.addActionListener(listener); panel1Fern.addActionListener(listener);
@ -1156,6 +1198,14 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
menu_2.add(panel2CFR_E); menu_2.add(panel2CFR_E);
mnPane.add(menu);
menu.add(panel2JDGUI);
menu.add(separator_34);
menu.add(panel2JDGUI_E);
mnPane.add(menu_3); mnPane.add(menu_3);
menu_3.add(panel2Fern); menu_3.add(panel2Fern);
@ -1212,6 +1262,14 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
menu_8.add(panel3CFR_E); menu_8.add(panel3CFR_E);
mnPane_1.add(mnJdgui);
mnJdgui.add(panel3JDGUI);
mnJdgui.add(separator_33);
mnJdgui.add(panel3JDGUI_E);
mnPane_1.add(menu_9); mnPane_1.add(menu_9);
menu_9.add(panel3Fern); menu_9.add(panel3Fern);
@ -1247,8 +1305,10 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
mnPane_1.add(panel3Hexcode); mnPane_1.add(panel3Hexcode);
menuBar.add(mnSettings); menuBar.add(mnSettings);
autoCompileSmali.setSelected(true);
mnSettings.add(autoCompileSmali); mnSettings.add(autoCompileSmali);
autoCompileOnRefresh.setSelected(true);
mnSettings.add(autoCompileOnRefresh); mnSettings.add(autoCompileOnRefresh);
mnSettings.add(chckbxmntmNewCheckItem_12); mnSettings.add(chckbxmntmNewCheckItem_12);
@ -1607,8 +1667,6 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
@Override @Override
public void actionPerformed(ActionEvent arg0) { public void actionPerformed(ActionEvent arg0) {
JFileChooser fc = new JFileChooser(); JFileChooser fc = new JFileChooser();
/* 01/06/15, 14:32, Changed to plugin file filter rather from the
* only .java filter. */
fc.setFileFilter(PluginManager.fileFilter()); fc.setFileFilter(PluginManager.fileFilter());
fc.setFileHidingEnabled(false); fc.setFileHidingEnabled(false);
fc.setAcceptAllFileFilterUsed(false); fc.setAcceptAllFileFilterUsed(false);
@ -1690,6 +1748,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
panelGroup1.add(panel1None); panelGroup1.add(panel1None);
panelGroup1.add(panel1Proc); panelGroup1.add(panel1Proc);
panelGroup1.add(panel1CFR); panelGroup1.add(panel1CFR);
panelGroup1.add(panel1JDGUI);
panelGroup1.add(panel1Fern); panelGroup1.add(panel1Fern);
panelGroup1.add(panel1Krakatau); panelGroup1.add(panel1Krakatau);
panelGroup1.add(panel1KrakatauBytecode); panelGroup1.add(panel1KrakatauBytecode);
@ -1700,6 +1759,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
panelGroup2.add(panel2None); panelGroup2.add(panel2None);
panelGroup2.add(panel2Proc); panelGroup2.add(panel2Proc);
panelGroup2.add(panel2CFR); panelGroup2.add(panel2CFR);
panelGroup2.add(panel2JDGUI);
panelGroup2.add(panel2Fern); panelGroup2.add(panel2Fern);
panelGroup2.add(panel2Krakatau); panelGroup2.add(panel2Krakatau);
panelGroup2.add(panel2KrakatauBytecode); panelGroup2.add(panel2KrakatauBytecode);
@ -1710,6 +1770,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
panelGroup3.add(panel3None); panelGroup3.add(panel3None);
panelGroup3.add(panel3Proc); panelGroup3.add(panel3Proc);
panelGroup3.add(panel3CFR); panelGroup3.add(panel3CFR);
panelGroup3.add(panel3JDGUI);
panelGroup3.add(panel3Fern); panelGroup3.add(panel3Fern);
panelGroup3.add(panel3Krakatau); panelGroup3.add(panel3Krakatau);
panelGroup3.add(panel3KrakatauBytecode); panelGroup3.add(panel3KrakatauBytecode);

View file

@ -0,0 +1,102 @@
package the.bytecode.club.bytecodeviewer.plugins;
import java.awt.Font;
import java.awt.font.FontRenderContext;
import java.awt.geom.AffineTransform;
import java.util.ArrayList;
import javax.swing.JFrame;
import javax.swing.UIManager;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import com.mxgraph.swing.mxGraphComponent;
import com.mxgraph.view.mxGraph;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.api.Plugin;
import the.bytecode.club.bytecodeviewer.gui.ClassViewer;
/**
* A simple code sequence diagram.
*
* @author Konloch
*
*/
public class CodeSequenceDiagram extends Plugin {
@SuppressWarnings("unchecked")
@Override
public void execute(ArrayList<ClassNode> classNodeList) {
if(BytecodeViewer.viewer.workPane.getCurrentViewer() == null || !(BytecodeViewer.viewer.workPane.getCurrentViewer() instanceof ClassViewer)) {
BytecodeViewer.showMessage("First open a class file.");
return;
}
ClassNode c = BytecodeViewer.viewer.workPane.getCurrentViewer().cn;
if(c == null) {
BytecodeViewer.showMessage("ClassNode is null for CodeSequenceDiagram. Please report to @Konloch");
return;
}
JFrame frame = null;
if(c.name != null)
frame = new JFrame("Code Sequence Diagram - "+c.name);
else
frame = new JFrame("Code Sequence Diagram - Unknown Name");
frame.setIconImages(Resources.iconList);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setSize(400, 320);
mxGraph graph = new mxGraph();
graph.setVertexLabelsMovable(false);
graph.setGridEnabled(true);
graph.setEnabled(false);
graph.setCellsEditable(false);
graph.setCellsSelectable(false);
graph.setCellsMovable(false);
graph.setCellsLocked(true);
Object parent = graph.getDefaultParent();
Font font = UIManager.getDefaults().getFont("TabbedPane.font");
AffineTransform affinetransform = new AffineTransform();
FontRenderContext frc = new FontRenderContext(affinetransform,true,true);
graph.getModel().beginUpdate();
try
{
int testX = 10;
int testY = 0;
double magicNumber = 5.8;
for(MethodNode m : (ArrayList<MethodNode>)c.methods) {
String mIdentifier = c.name+"."+m.name+m.desc;
Object node = graph.insertVertex(parent, null, mIdentifier, testX, testY, mIdentifier.length() * magicNumber, 30);
Object attach = node;
testX += (int) (font.getStringBounds(mIdentifier, frc).getWidth()) + 60;
for (AbstractInsnNode i : m.instructions.toArray()) {
if (i instanceof MethodInsnNode) {
MethodInsnNode mi = (MethodInsnNode) i;
String identifier = mi.owner+"."+mi.name+mi.desc;
Object node2 = graph.insertVertex(parent, null, identifier, testX, testY, identifier.length() * 5, 30);
testX += (int) (font.getStringBounds(identifier, frc).getWidth()) + 60;
graph.insertEdge(parent, null, null, attach, node2);
attach = node2;
}
}
testY += 60;
testX = 10;
}
} finally {
graph.getModel().endUpdate();
}
mxGraphComponent graphComponent = new mxGraphComponent(graph);
frame.getContentPane().add(graphComponent);
frame.setVisible(true);
}
}