Cleaned up MainViewerGUI
Refactored a lot of the MainViewerGUI class. The settings clean up has started but it should be replaced entirely with some kind of serialization like GSON
This commit is contained in:
parent
4fd4ec5585
commit
d787ead0da
|
@ -271,7 +271,7 @@ public class BytecodeViewer
|
|||
while (empty) {
|
||||
showMessage("You need to set your Java path, this requires the JRE to be downloaded." + nl +
|
||||
"(C:/Program Files/Java/JDK_xx/bin/java.exe)");
|
||||
viewer.java();
|
||||
viewer.selectJava();
|
||||
empty = Configuration.java.isEmpty();
|
||||
}
|
||||
}
|
||||
|
@ -620,7 +620,7 @@ public class BytecodeViewer
|
|||
* resets the recent files menu
|
||||
*/
|
||||
public static void resetRecentFilesMenu() {
|
||||
viewer.mnRecentFiles.removeAll();
|
||||
viewer.recentFilesSecondaryMenu.removeAll();
|
||||
for (String s : recentFiles)
|
||||
if (!s.isEmpty()) {
|
||||
JMenuItem m = new JMenuItem(s);
|
||||
|
@ -628,7 +628,7 @@ public class BytecodeViewer
|
|||
JMenuItem m12 = (JMenuItem) e.getSource();
|
||||
openFiles(new File[]{new File(m12.getText())}, true);
|
||||
});
|
||||
viewer.mnRecentFiles.add(m);
|
||||
viewer.recentFilesSecondaryMenu.add(m);
|
||||
}
|
||||
viewer.mnRecentPlugins.removeAll();
|
||||
for (String s : recentPlugins)
|
||||
|
@ -805,17 +805,17 @@ public class BytecodeViewer
|
|||
|
||||
boolean passes = false;
|
||||
|
||||
if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1Krakatau.getModel()))
|
||||
if (BytecodeViewer.viewer.viewPane1.getGroup().isSelected(BytecodeViewer.viewer.viewPane1.getKrakatau().getJava().getModel()))
|
||||
passes = true;
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1KrakatauBytecode.getModel()))
|
||||
else if (BytecodeViewer.viewer.viewPane1.getGroup().isSelected(BytecodeViewer.viewer.viewPane1.getKrakatau().getBytecode().getModel()))
|
||||
passes = true;
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2Krakatau.getModel()))
|
||||
else if (BytecodeViewer.viewer.viewPane2.getGroup().isSelected(BytecodeViewer.viewer.viewPane2.getKrakatau().getJava().getModel()))
|
||||
passes = true;
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2KrakatauBytecode.getModel()))
|
||||
else if (BytecodeViewer.viewer.viewPane2.getGroup().isSelected(BytecodeViewer.viewer.viewPane2.getKrakatau().getBytecode().getModel()))
|
||||
passes = true;
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3Krakatau.getModel()))
|
||||
else if (BytecodeViewer.viewer.viewPane3.getGroup().isSelected(BytecodeViewer.viewer.viewPane3.getKrakatau().getJava().getModel()))
|
||||
passes = true;
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3KrakatauBytecode.getModel()))
|
||||
else if (BytecodeViewer.viewer.viewPane3.getGroup().isSelected(BytecodeViewer.viewer.viewPane3.getKrakatau().getBytecode().getModel()))
|
||||
passes = true;
|
||||
|
||||
if (Configuration.krakatauTempJar != null || !passes) {
|
||||
|
|
|
@ -196,81 +196,10 @@ public class Settings {
|
|||
"deprecated", false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_12.isSelected()), false);
|
||||
|
||||
if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1None.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "0", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1Proc.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "1", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1CFR.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "2", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1Fern.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "3", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1Bytecode.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "4", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1Hexcode.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "5", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1Smali.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "6", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1Krakatau.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "7", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1KrakatauBytecode.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "8", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1JDGUI.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "9", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.jadxJ1.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "10", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.asmText1.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "11", false);
|
||||
|
||||
if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2None.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "0", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2Proc.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "1", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2CFR.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "2", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2Fern.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "3", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2Bytecode.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "4", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2Hexcode.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "5", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2Smali.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "6", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2Krakatau.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "7", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2KrakatauBytecode.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "8", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2JDGUI.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "9", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.jadxJ2.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "10", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.asmText2.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "11", false);
|
||||
|
||||
if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3None.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "0", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3Proc.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "1", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3CFR.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "2", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3Fern.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "3", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3Bytecode.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "4", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3Hexcode.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "5", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3Smali.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "6", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3Krakatau.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "7", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3KrakatauBytecode.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "8", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3JDGUI.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "9", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.jadxJ3.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "10", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.asmText3.getModel()))
|
||||
DiskWriter.writeNewLine(settingsName, "11", false);
|
||||
|
||||
DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.viewPane1.getSelectedViewer()), false);
|
||||
DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.viewPane2.getSelectedViewer()), false);
|
||||
DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.viewPane3.getSelectedViewer()), false);
|
||||
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.refreshOnChange.isSelected()), false);
|
||||
|
@ -287,35 +216,35 @@ public class Settings {
|
|||
DiskWriter.writeNewLine(settingsName,
|
||||
Configuration.rt, false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.panel1Proc_E.isSelected()), false);
|
||||
String.valueOf(BytecodeViewer.viewer.viewPane1.getProcyon().getEditable().isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.panel1CFR_E.isSelected()), false);
|
||||
String.valueOf(BytecodeViewer.viewer.viewPane1.getCFR().getEditable().isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.panel1Fern_E.isSelected()), false);
|
||||
String.valueOf(BytecodeViewer.viewer.viewPane1.getFern().getEditable().isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.panel1Krakatau_E.isSelected()), false);
|
||||
String.valueOf(BytecodeViewer.viewer.viewPane1.getKrakatau().getEditable().isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.panel1Smali_E.isSelected()), false);
|
||||
String.valueOf(BytecodeViewer.viewer.viewPane1.getSmali().getEditable().isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.panel2Proc_E.isSelected()), false);
|
||||
String.valueOf(BytecodeViewer.viewer.viewPane2.getProcyon().getJava().isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.panel2CFR_E.isSelected()), false);
|
||||
String.valueOf(BytecodeViewer.viewer.viewPane2.getCFR().getJava().isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.panel2Fern_E.isSelected()), false);
|
||||
String.valueOf(BytecodeViewer.viewer.viewPane2.getFern().getJava().isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.panel2Krakatau_E.isSelected()), false);
|
||||
String.valueOf(BytecodeViewer.viewer.viewPane2.getKrakatau().getJava().isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.panel2Smali_E.isSelected()), false);
|
||||
String.valueOf(BytecodeViewer.viewer.viewPane2.getSmali().getJava().isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.panel3Proc_E.isSelected()), false);
|
||||
String.valueOf(BytecodeViewer.viewer.viewPane3.getProcyon().getJava().isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.panel3CFR_E.isSelected()), false);
|
||||
String.valueOf(BytecodeViewer.viewer.viewPane3.getCFR().getJava().isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.panel3Fern_E.isSelected()), false);
|
||||
String.valueOf(BytecodeViewer.viewer.viewPane3.getFern().getJava().isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.panel3Krakatau_E.isSelected()), false);
|
||||
String.valueOf(BytecodeViewer.viewer.viewPane3.getKrakatau().getJava().isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.panel3Smali_E.isSelected()), false);
|
||||
String.valueOf(BytecodeViewer.viewer.viewPane3.getSmali().getJava().isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.decodeAPKResources.isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
|
@ -323,11 +252,11 @@ public class Settings {
|
|||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(Configuration.pingback), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.panel1JDGUI_E.isSelected()), false);
|
||||
String.valueOf(BytecodeViewer.viewer.viewPane1.getJD().getEditable().isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.panel2JDGUI_E.isSelected()), false);
|
||||
String.valueOf(BytecodeViewer.viewer.viewPane2.getJD().getJava().isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.panel3JDGUI_E.isSelected()), false);
|
||||
String.valueOf(BytecodeViewer.viewer.viewPane3.getJD().getJava().isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.fontSpinner.getValue()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
|
@ -360,6 +289,8 @@ public class Settings {
|
|||
String.valueOf(BytecodeViewer.viewer.showClassMethods.isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.ren.isSelected()), false);
|
||||
DiskWriter.writeNewLine(settingsName,
|
||||
String.valueOf(BytecodeViewer.viewer.viewPane1.getJADX().getEditable().isSelected()), false);
|
||||
} catch (Exception e) {
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||
}
|
||||
|
@ -447,83 +378,9 @@ public class Settings {
|
|||
BytecodeViewer.viewer.debugHelpers.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 78, false)));
|
||||
//79 is deprecated
|
||||
BytecodeViewer.viewer.chckbxmntmNewCheckItem_12.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 80, false)));
|
||||
int decompiler = Integer.parseInt(DiskReader.loadString(settingsName, 81, false));
|
||||
if (decompiler == 0)
|
||||
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.panel1None.getModel(), true);
|
||||
else if (decompiler == 1)
|
||||
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.panel1Proc.getModel(), true);
|
||||
else if (decompiler == 2)
|
||||
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.panel1CFR.getModel(), true);
|
||||
else if (decompiler == 3)
|
||||
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.panel1Fern.getModel(), true);
|
||||
else if (decompiler == 4)
|
||||
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.panel1Bytecode.getModel(), true);
|
||||
else if (decompiler == 5)
|
||||
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.panel1Hexcode.getModel(), true);
|
||||
else if (decompiler == 6)
|
||||
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.panel1Smali.getModel(), true);
|
||||
else if (decompiler == 7)
|
||||
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.panel1Krakatau.getModel(), true);
|
||||
else if (decompiler == 8)
|
||||
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.panel1KrakatauBytecode.getModel(), true);
|
||||
else if (decompiler == 9)
|
||||
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.panel1JDGUI.getModel(), true);
|
||||
else if (decompiler == 10)
|
||||
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.jadxJ1.getModel(), true);
|
||||
else if (decompiler == 11)
|
||||
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.asmText1.getModel(), true);
|
||||
|
||||
decompiler = Integer.parseInt(DiskReader.loadString(settingsName, 82, false));
|
||||
if (decompiler == 0)
|
||||
BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.panel2None.getModel(), true);
|
||||
else if (decompiler == 1)
|
||||
BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.panel2Proc.getModel(), true);
|
||||
else if (decompiler == 2)
|
||||
BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.panel2CFR.getModel(), true);
|
||||
else if (decompiler == 3)
|
||||
BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.panel2Fern.getModel(), true);
|
||||
else if (decompiler == 4)
|
||||
BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.panel2Bytecode.getModel(), true);
|
||||
else if (decompiler == 5)
|
||||
BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.panel2Hexcode.getModel(), true);
|
||||
else if (decompiler == 6)
|
||||
BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.panel2Smali.getModel(), true);
|
||||
else if (decompiler == 7)
|
||||
BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.panel2Krakatau.getModel(), true);
|
||||
else if (decompiler == 8)
|
||||
BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.panel2KrakatauBytecode.getModel(), true);
|
||||
else if (decompiler == 9)
|
||||
BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.panel2JDGUI.getModel(), true);
|
||||
else if (decompiler == 10)
|
||||
BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.jadxJ2.getModel(), true);
|
||||
else if (decompiler == 11)
|
||||
BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.asmText2.getModel(), true);
|
||||
|
||||
decompiler = Integer.parseInt(DiskReader.loadString(settingsName, 83, false));
|
||||
if (decompiler == 0)
|
||||
BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.panel3None.getModel(), true);
|
||||
else if (decompiler == 1)
|
||||
BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.panel3Proc.getModel(), true);
|
||||
else if (decompiler == 2)
|
||||
BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.panel3CFR.getModel(), true);
|
||||
else if (decompiler == 3)
|
||||
BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.panel3Fern.getModel(), true);
|
||||
else if (decompiler == 4)
|
||||
BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.panel3Bytecode.getModel(), true);
|
||||
else if (decompiler == 5)
|
||||
BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.panel3Hexcode.getModel(), true);
|
||||
else if (decompiler == 6)
|
||||
BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.panel3Smali.getModel(), true);
|
||||
else if (decompiler == 7)
|
||||
BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.panel3Krakatau.getModel(), true);
|
||||
else if (decompiler == 8)
|
||||
BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.panel3KrakatauBytecode.getModel(), true);
|
||||
else if (decompiler == 9)
|
||||
BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.panel3JDGUI.getModel(), true);
|
||||
else if (decompiler == 10)
|
||||
BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.jadxJ3.getModel(), true);
|
||||
else if (decompiler == 11)
|
||||
BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.asmText3.getModel(), true);
|
||||
BytecodeViewer.viewer.viewPane1.setSelectedViewer(getInt(81));
|
||||
BytecodeViewer.viewer.viewPane2.setSelectedViewer(getInt(82));
|
||||
BytecodeViewer.viewer.viewPane3.setSelectedViewer(getInt(83));
|
||||
|
||||
BytecodeViewer.viewer.refreshOnChange.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 84, false)));
|
||||
|
||||
|
@ -537,51 +394,62 @@ public class Settings {
|
|||
Configuration.lastDirectory = DiskReader.loadString(settingsName, 88, false);
|
||||
Configuration.python = DiskReader.loadString(settingsName, 89, false);
|
||||
Configuration.rt = DiskReader.loadString(settingsName, 90, false);
|
||||
BytecodeViewer.viewer.panel1Proc_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 91, false)));
|
||||
BytecodeViewer.viewer.panel1CFR_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 92, false)));
|
||||
BytecodeViewer.viewer.panel1Fern_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 93, false)));
|
||||
BytecodeViewer.viewer.panel1Krakatau_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 94, false)));
|
||||
BytecodeViewer.viewer.panel1Smali_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 95, false)));
|
||||
BytecodeViewer.viewer.panel2Proc_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 96, false)));
|
||||
BytecodeViewer.viewer.panel2CFR_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 97, false)));
|
||||
BytecodeViewer.viewer.panel2Fern_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 98, false)));
|
||||
BytecodeViewer.viewer.panel2Krakatau_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 99, false)));
|
||||
BytecodeViewer.viewer.panel2Smali_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 100, false)));
|
||||
BytecodeViewer.viewer.panel3Proc_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 101, false)));
|
||||
BytecodeViewer.viewer.panel3CFR_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 101, false)));
|
||||
BytecodeViewer.viewer.panel3Fern_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 103, false)));
|
||||
BytecodeViewer.viewer.panel3Krakatau_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 104, false)));
|
||||
BytecodeViewer.viewer.panel3Smali_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 105, false)));
|
||||
BytecodeViewer.viewer.decodeAPKResources.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 106, false)));
|
||||
BytecodeViewer.viewer.viewPane1.getProcyon().getEditable().setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 91, false)));
|
||||
BytecodeViewer.viewer.viewPane1.getCFR().getEditable().setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 92, false)));
|
||||
BytecodeViewer.viewer.viewPane1.getFern().getEditable().setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 93, false)));
|
||||
BytecodeViewer.viewer.viewPane1.getKrakatau().getEditable().setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 94, false)));
|
||||
BytecodeViewer.viewer.viewPane1.getSmali().getEditable().setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 95, false)));
|
||||
BytecodeViewer.viewer.viewPane2.getProcyon().getEditable().setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 96, false)));
|
||||
BytecodeViewer.viewer.viewPane2.getCFR().getEditable().setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 97, false)));
|
||||
BytecodeViewer.viewer.viewPane2.getFern().getEditable().setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 98, false)));
|
||||
BytecodeViewer.viewer.viewPane2.getKrakatau().getEditable().setSelected(asBoolean(99));
|
||||
BytecodeViewer.viewer.viewPane2.getSmali().getEditable().setSelected(asBoolean(100));
|
||||
BytecodeViewer.viewer.viewPane3.getProcyon().getEditable().setSelected(asBoolean(101));
|
||||
BytecodeViewer.viewer.viewPane3.getCFR().getEditable().setSelected(asBoolean(102));
|
||||
BytecodeViewer.viewer.viewPane3.getFern().getEditable().setSelected(asBoolean(103));
|
||||
BytecodeViewer.viewer.viewPane3.getKrakatau().getEditable().setSelected(asBoolean(104));
|
||||
BytecodeViewer.viewer.viewPane3.getSmali().getEditable().setSelected(asBoolean(105));
|
||||
BytecodeViewer.viewer.decodeAPKResources.setSelected(asBoolean(106));
|
||||
Configuration.library = DiskReader.loadString(settingsName, 107, false);
|
||||
Configuration.pingback = Boolean.parseBoolean(DiskReader.loadString(settingsName, 108, false));
|
||||
BytecodeViewer.viewer.panel1JDGUI_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 109, false)));
|
||||
BytecodeViewer.viewer.panel2JDGUI_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 110, false)));
|
||||
BytecodeViewer.viewer.panel3JDGUI_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 111, false)));
|
||||
BytecodeViewer.viewer.fontSpinner.setValue(Integer.parseInt(DiskReader.loadString(settingsName, 112, false)));
|
||||
Configuration.deleteForeignLibraries = Boolean.parseBoolean(DiskReader.loadString(settingsName, 113, false));
|
||||
decompiler = Integer.parseInt(DiskReader.loadString(settingsName, 114, false));
|
||||
Configuration.pingback = asBoolean(108);
|
||||
BytecodeViewer.viewer.viewPane1.getJD().getEditable().setSelected(asBoolean(109));
|
||||
BytecodeViewer.viewer.viewPane2.getJD().getEditable().setSelected(asBoolean(110));
|
||||
BytecodeViewer.viewer.viewPane3.getJD().getEditable().setSelected(asBoolean(111));
|
||||
BytecodeViewer.viewer.fontSpinner.setValue(getInt(112));
|
||||
Configuration.deleteForeignLibraries = asBoolean(113);
|
||||
int apkDecompiler = getInt(114);
|
||||
|
||||
if (decompiler == 0)
|
||||
if (apkDecompiler == 0)
|
||||
BytecodeViewer.viewer.apkConversionGroup.setSelected(BytecodeViewer.viewer.apkConversionDex.getModel(), true);
|
||||
else if (decompiler == 1)
|
||||
else if (apkDecompiler == 1)
|
||||
BytecodeViewer.viewer.apkConversionGroup.setSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel(), true);
|
||||
|
||||
Configuration.python3 = DiskReader.loadString(settingsName, 115, false);
|
||||
Configuration.javac = DiskReader.loadString(settingsName, 116, false);
|
||||
Configuration.java = DiskReader.loadString(settingsName, 117, false);
|
||||
BytecodeViewer.viewer.compileOnSave.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 118, false)));
|
||||
BytecodeViewer.viewer.autoCompileOnRefresh.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 119, false)));
|
||||
BytecodeViewer.viewer.compileOnSave.setSelected(asBoolean(118));
|
||||
BytecodeViewer.viewer.autoCompileOnRefresh.setSelected(asBoolean(119));
|
||||
Configuration.warnForEditing = Boolean.parseBoolean(DiskReader.loadString(settingsName, 120, false));
|
||||
BytecodeViewer.viewer.showFileInTabTitle.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 121, false)));
|
||||
BytecodeViewer.viewer.showFileInTabTitle.setSelected(asBoolean(121));
|
||||
Configuration.displayParentInTab = BytecodeViewer.viewer.showFileInTabTitle.isSelected();
|
||||
BytecodeViewer.viewer.forcePureAsciiAsText.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 122, false)));
|
||||
BytecodeViewer.viewer.synchronizedViewing.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 123, false)));
|
||||
BytecodeViewer.viewer.showClassMethods.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 124, false)));
|
||||
BytecodeViewer.viewer.ren.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 125, false)));
|
||||
BytecodeViewer.viewer.forcePureAsciiAsText.setSelected(asBoolean(122));
|
||||
BytecodeViewer.viewer.synchronizedViewing.setSelected(asBoolean(123));
|
||||
BytecodeViewer.viewer.showClassMethods.setSelected(asBoolean(124));
|
||||
BytecodeViewer.viewer.ren.setSelected(asBoolean(125));
|
||||
BytecodeViewer.viewer.viewPane1.getJADX().getEditable().setSelected(asBoolean(126));
|
||||
} catch (Exception e) {
|
||||
//ignore because errors are expected, first start up and outdated settings.
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean asBoolean(int lineNumber) throws Exception
|
||||
{
|
||||
return Boolean.parseBoolean(DiskReader.loadString(settingsName, lineNumber, false));
|
||||
}
|
||||
|
||||
public static int getInt(int lineNumber) throws Exception
|
||||
{
|
||||
return Integer.parseInt(DiskReader.loadString(settingsName, lineNumber, false));
|
||||
}
|
||||
}
|
|
@ -1763,128 +1763,27 @@ public class ClassViewer extends Viewer {
|
|||
|
||||
|
||||
public void setPanes() {
|
||||
if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1None.getModel()))
|
||||
pane1 = 0;
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1Proc.getModel()))
|
||||
pane1 = 1;
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1CFR.getModel()))
|
||||
pane1 = 2;
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1Fern.getModel()))
|
||||
pane1 = 3;
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1Bytecode.getModel()))
|
||||
pane1 = 4;
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1Hexcode.getModel()))
|
||||
pane1 = 5;
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1Smali.getModel()))
|
||||
pane1 = 6;
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1Krakatau.getModel()))
|
||||
pane1 = 7;
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1KrakatauBytecode.getModel()))
|
||||
pane1 = 8;
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1JDGUI.getModel()))
|
||||
pane1 = 9;
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.jadxJ1.getModel()))
|
||||
pane1 = 10;
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.asmText1.getModel()))
|
||||
pane1 = 11;
|
||||
|
||||
if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2None.getModel()))
|
||||
pane2 = 0;
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2Proc.getModel()))
|
||||
pane2 = 1;
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2CFR.getModel()))
|
||||
pane2 = 2;
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2Fern.getModel()))
|
||||
pane2 = 3;
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2Bytecode.getModel()))
|
||||
pane2 = 4;
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2Hexcode.getModel()))
|
||||
pane2 = 5;
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2Smali.getModel()))
|
||||
pane2 = 6;
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2Krakatau.getModel()))
|
||||
pane2 = 7;
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2KrakatauBytecode.getModel()))
|
||||
pane2 = 8;
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2JDGUI.getModel()))
|
||||
pane2 = 9;
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.jadxJ2.getModel()))
|
||||
pane2 = 10;
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.asmText2.getModel()))
|
||||
pane2 = 11;
|
||||
|
||||
if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3None.getModel()))
|
||||
pane3 = 0;
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3Proc.getModel()))
|
||||
pane3 = 1;
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3CFR.getModel()))
|
||||
pane3 = 2;
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3Fern.getModel()))
|
||||
pane3 = 3;
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3Bytecode.getModel()))
|
||||
pane3 = 4;
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3Hexcode.getModel()))
|
||||
pane3 = 5;
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3Smali.getModel()))
|
||||
pane3 = 6;
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3Krakatau.getModel()))
|
||||
pane3 = 7;
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3KrakatauBytecode.getModel()))
|
||||
pane3 = 8;
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3JDGUI.getModel()))
|
||||
pane3 = 9;
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.jadxJ3.getModel()))
|
||||
pane3 = 10;
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.asmText3.getModel()))
|
||||
pane3 = 11;
|
||||
pane1 = BytecodeViewer.viewer.viewPane1.getSelectedViewer();
|
||||
pane2 = BytecodeViewer.viewer.viewPane2.getSelectedViewer();
|
||||
pane3 = BytecodeViewer.viewer.viewPane3.getSelectedViewer();
|
||||
}
|
||||
|
||||
public boolean isPanel1Editable() {
|
||||
setPanes();
|
||||
|
||||
if (pane1 == 1 && BytecodeViewer.viewer.panel1Proc_E.isSelected())
|
||||
return true;
|
||||
if (pane1 == 2 && BytecodeViewer.viewer.panel1CFR_E.isSelected())
|
||||
return true;
|
||||
if (pane1 == 3 && BytecodeViewer.viewer.panel1Fern_E.isSelected())
|
||||
return true;
|
||||
if (pane1 == 6 && BytecodeViewer.viewer.panel1Smali_E.isSelected())
|
||||
return true;
|
||||
if (pane1 == 9 && BytecodeViewer.viewer.panel1JDGUI_E.isSelected())
|
||||
return true;
|
||||
return (pane1 == 7 || pane1 == 8) && BytecodeViewer.viewer.panel1Krakatau_E.isSelected();
|
||||
return BytecodeViewer.viewer.viewPane1.isPaneEditable();
|
||||
}
|
||||
|
||||
public boolean isPanel2Editable() {
|
||||
setPanes();
|
||||
|
||||
if (pane2 == 1 && BytecodeViewer.viewer.panel2Proc_E.isSelected())
|
||||
return true;
|
||||
if (pane2 == 2 && BytecodeViewer.viewer.panel2CFR_E.isSelected())
|
||||
return true;
|
||||
if (pane2 == 3 && BytecodeViewer.viewer.panel2Fern_E.isSelected())
|
||||
return true;
|
||||
if (pane2 == 6 && BytecodeViewer.viewer.panel2Smali_E.isSelected())
|
||||
return true;
|
||||
if (pane2 == 9 && BytecodeViewer.viewer.panel2JDGUI_E.isSelected())
|
||||
return true;
|
||||
return (pane2 == 7 || pane2 == 8) && BytecodeViewer.viewer.panel2Krakatau_E.isSelected();
|
||||
|
||||
return BytecodeViewer.viewer.viewPane2.isPaneEditable();
|
||||
}
|
||||
|
||||
public boolean isPanel3Editable() {
|
||||
setPanes();
|
||||
|
||||
if (pane3 == 1 && BytecodeViewer.viewer.panel3Proc_E.isSelected())
|
||||
return true;
|
||||
if (pane3 == 2 && BytecodeViewer.viewer.panel3CFR_E.isSelected())
|
||||
return true;
|
||||
if (pane3 == 3 && BytecodeViewer.viewer.panel3Fern_E.isSelected())
|
||||
return true;
|
||||
if (pane3 == 6 && BytecodeViewer.viewer.panel3Smali_E.isSelected())
|
||||
return true;
|
||||
if (pane3 == 9 && BytecodeViewer.viewer.panel3JDGUI_E.isSelected())
|
||||
return true;
|
||||
return (pane3 == 7 || pane3 == 8) && BytecodeViewer.viewer.panel3Krakatau_E.isSelected();
|
||||
|
||||
return BytecodeViewer.viewer.viewPane3.isPaneEditable();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package the.bytecode.club.bytecodeviewer.gui;
|
||||
|
||||
import the.bytecode.club.bytecodeviewer.util.RefreshWorkPane;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Konloch
|
||||
* @since 6/21/2021
|
||||
*/
|
||||
public class DecompilerViewComponent
|
||||
{
|
||||
private final String name;
|
||||
private final boolean hasBytecodeOption;
|
||||
private final JMenu menu;
|
||||
private final JRadioButtonMenuItem java = new JRadioButtonMenuItem("Java");
|
||||
private final JRadioButtonMenuItem bytecode = new JRadioButtonMenuItem("Bytecode");
|
||||
private final JCheckBoxMenuItem editable = new JCheckBoxMenuItem("Editable");
|
||||
|
||||
public DecompilerViewComponent(String name) {
|
||||
this(name, false);
|
||||
}
|
||||
|
||||
public DecompilerViewComponent(String name, boolean hasBytecodeOption) {
|
||||
this.name = name;
|
||||
this.menu = new JMenu(name);
|
||||
this.hasBytecodeOption = hasBytecodeOption;
|
||||
createMenu();
|
||||
}
|
||||
|
||||
private void createMenu()
|
||||
{
|
||||
menu.add(java);
|
||||
if(hasBytecodeOption)
|
||||
menu.add(bytecode);
|
||||
menu.add(new JSeparator());
|
||||
menu.add(editable);
|
||||
|
||||
java.addActionListener(new RefreshWorkPane());
|
||||
}
|
||||
|
||||
public void addToGroup(ButtonGroup group)
|
||||
{
|
||||
group.add(java);
|
||||
if(hasBytecodeOption)
|
||||
group.add(bytecode);
|
||||
}
|
||||
|
||||
public JMenu getMenu()
|
||||
{
|
||||
return menu;
|
||||
}
|
||||
|
||||
public JRadioButtonMenuItem getJava()
|
||||
{
|
||||
return java;
|
||||
}
|
||||
|
||||
public JRadioButtonMenuItem getBytecode()
|
||||
{
|
||||
return bytecode;
|
||||
}
|
||||
|
||||
public JCheckBoxMenuItem getEditable()
|
||||
{
|
||||
return editable;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -4,6 +4,8 @@ import java.awt.Dimension;
|
|||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||
import the.bytecode.club.bytecodeviewer.Resources;
|
||||
import the.bytecode.club.bytecodeviewer.plugin.PluginManager;
|
||||
import the.bytecode.club.bytecodeviewer.plugin.preinstalled.MaliciousCodeScanner;
|
||||
|
@ -34,6 +36,14 @@ import the.bytecode.club.bytecodeviewer.plugin.preinstalled.MaliciousCodeScanner
|
|||
*/
|
||||
|
||||
public class MaliciousCodeScannerOptions extends JFrame {
|
||||
public static void showOptionPanel()
|
||||
{
|
||||
if (BytecodeViewer.getLoadedClasses().isEmpty()) {
|
||||
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
|
||||
return;
|
||||
}
|
||||
new MaliciousCodeScannerOptions().setVisible(true);
|
||||
}
|
||||
public MaliciousCodeScannerOptions() {
|
||||
this.setIconImages(Resources.iconList);
|
||||
setSize(new Dimension(250, 323));
|
||||
|
|
215
src/main/java/the/bytecode/club/bytecodeviewer/gui/ViewPane.java
Normal file
215
src/main/java/the/bytecode/club/bytecodeviewer/gui/ViewPane.java
Normal file
|
@ -0,0 +1,215 @@
|
|||
package the.bytecode.club.bytecodeviewer.gui;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Konloch
|
||||
* @since 6/21/2021
|
||||
*/
|
||||
public class ViewPane
|
||||
{
|
||||
public final int paneID;
|
||||
public final JMenu menu;
|
||||
public final ButtonGroup group = new ButtonGroup();
|
||||
public final JRadioButtonMenuItem none = new JRadioButtonMenuItem("None");
|
||||
public final DecompilerViewComponent procyon = new DecompilerViewComponent("Procyon");
|
||||
public final DecompilerViewComponent CFR = new DecompilerViewComponent("CFR");
|
||||
public final DecompilerViewComponent JADX = new DecompilerViewComponent("JADX");
|
||||
public final DecompilerViewComponent JD = new DecompilerViewComponent("JD-GUI");
|
||||
public final DecompilerViewComponent fern = new DecompilerViewComponent("FernFlower");
|
||||
public final DecompilerViewComponent krakatau = new DecompilerViewComponent("Krakatau", true);
|
||||
public final DecompilerViewComponent smali = new DecompilerViewComponent("Smali/DEX");
|
||||
public final JRadioButtonMenuItem hexcode = new JRadioButtonMenuItem("Hexcode");
|
||||
public final JRadioButtonMenuItem bytecode = new JRadioButtonMenuItem("Bytecode");
|
||||
public final JRadioButtonMenuItem asmTextify = new JRadioButtonMenuItem("ASM Textify");
|
||||
|
||||
public ViewPane(int paneID) {
|
||||
this.paneID = paneID;
|
||||
this.menu = new JMenu("Pane " + paneID);
|
||||
buildMenu();
|
||||
}
|
||||
|
||||
public void buildMenu()
|
||||
{
|
||||
group.add(none);
|
||||
procyon.addToGroup(group);
|
||||
CFR.addToGroup(group);
|
||||
JADX.addToGroup(group);
|
||||
JD.addToGroup(group);
|
||||
fern.addToGroup(group);
|
||||
krakatau.addToGroup(group);
|
||||
smali.addToGroup(group);
|
||||
group.add(bytecode);
|
||||
group.add(hexcode);
|
||||
group.add(asmTextify);
|
||||
|
||||
menu.add(none);
|
||||
menu.add(new JSeparator());
|
||||
menu.add(procyon.getMenu());
|
||||
menu.add(CFR.getMenu());
|
||||
menu.add(JADX.getMenu());
|
||||
menu.add(JD.getMenu());
|
||||
menu.add(fern.getMenu());
|
||||
menu.add(krakatau.getMenu());
|
||||
menu.add(new JSeparator());
|
||||
menu.add(smali.getMenu());
|
||||
menu.add(new JSeparator());
|
||||
menu.add(hexcode);
|
||||
menu.add(bytecode);
|
||||
menu.add(asmTextify);
|
||||
}
|
||||
|
||||
public int getSelectedViewer()
|
||||
{
|
||||
if (group.isSelected(none.getModel()))
|
||||
return 0;
|
||||
else if (group.isSelected(procyon.getJava().getModel()))
|
||||
return 1;
|
||||
else if (group.isSelected(CFR.getJava().getModel()))
|
||||
return 2;
|
||||
else if (group.isSelected(fern.getJava().getModel()))
|
||||
return 3;
|
||||
else if (group.isSelected(bytecode.getModel()))
|
||||
return 4;
|
||||
else if (group.isSelected(hexcode.getModel()))
|
||||
return 5;
|
||||
else if (group.isSelected(smali.getJava().getModel()))
|
||||
return 6;
|
||||
else if (group.isSelected(krakatau.getJava().getModel()))
|
||||
return 7;
|
||||
else if (group.isSelected(krakatau.getBytecode().getModel()))
|
||||
return 8;
|
||||
else if (group.isSelected(JD.getBytecode().getModel()))
|
||||
return 9;
|
||||
else if (group.isSelected(JADX.getBytecode().getModel()))
|
||||
return 10;
|
||||
else if (group.isSelected(asmTextify.getModel()))
|
||||
return 11;
|
||||
|
||||
//default to none
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setSelectedViewer(int decompiler)
|
||||
{
|
||||
switch (decompiler)
|
||||
{
|
||||
case 0:
|
||||
group.setSelected(none.getModel(), true);
|
||||
break;
|
||||
case 1:
|
||||
group.setSelected(procyon.getJava().getModel(), true);
|
||||
break;
|
||||
case 2:
|
||||
group.setSelected(CFR.getJava().getModel(), true);
|
||||
break;
|
||||
case 3:
|
||||
group.setSelected(fern.getJava().getModel(), true);
|
||||
break;
|
||||
case 4:
|
||||
group.setSelected(bytecode.getModel(), true);
|
||||
break;
|
||||
case 5:
|
||||
group.setSelected(hexcode.getModel(), true);
|
||||
break;
|
||||
case 6:
|
||||
group.setSelected(smali.getJava().getModel(), true);
|
||||
break;
|
||||
case 7:
|
||||
group.setSelected(krakatau.getJava().getModel(), true);
|
||||
break;
|
||||
case 8:
|
||||
group.setSelected(krakatau.getBytecode().getModel(), true);
|
||||
break;
|
||||
case 9:
|
||||
group.setSelected(JD.getJava().getModel(), true);
|
||||
break;
|
||||
case 10:
|
||||
group.setSelected(JADX.getJava().getModel(), true);
|
||||
break;
|
||||
case 11:
|
||||
group.setSelected(asmTextify.getModel(), true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPaneEditable()
|
||||
{
|
||||
if(group.isSelected(procyon.getJava().getModel()) && procyon.getEditable().isSelected())
|
||||
return true;
|
||||
if(group.isSelected(CFR.getJava().getModel()) && CFR.getEditable().isSelected())
|
||||
return true;
|
||||
if(group.isSelected(JADX.getJava().getModel()) && JADX.getEditable().isSelected())
|
||||
return true;
|
||||
if(group.isSelected(JD.getJava().getModel()) && JD.getEditable().isSelected())
|
||||
return true;
|
||||
if(group.isSelected(fern.getJava().getModel()) && fern.getEditable().isSelected())
|
||||
return true;
|
||||
if((group.isSelected(krakatau.getJava().getModel()) || group.isSelected(krakatau.getBytecode().getModel())) && krakatau.getEditable().isSelected())
|
||||
return true;
|
||||
if(group.isSelected(smali.getJava().getModel()) && krakatau.getEditable().isSelected())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public ButtonGroup getGroup()
|
||||
{
|
||||
return group;
|
||||
}
|
||||
|
||||
public JRadioButtonMenuItem getNone()
|
||||
{
|
||||
return none;
|
||||
}
|
||||
|
||||
public DecompilerViewComponent getProcyon()
|
||||
{
|
||||
return procyon;
|
||||
}
|
||||
|
||||
public DecompilerViewComponent getCFR()
|
||||
{
|
||||
return CFR;
|
||||
}
|
||||
|
||||
public DecompilerViewComponent getJADX()
|
||||
{
|
||||
return JADX;
|
||||
}
|
||||
|
||||
public DecompilerViewComponent getJD()
|
||||
{
|
||||
return JD;
|
||||
}
|
||||
|
||||
public DecompilerViewComponent getFern()
|
||||
{
|
||||
return fern;
|
||||
}
|
||||
|
||||
public DecompilerViewComponent getKrakatau()
|
||||
{
|
||||
return krakatau;
|
||||
}
|
||||
|
||||
public DecompilerViewComponent getSmali()
|
||||
{
|
||||
return smali;
|
||||
}
|
||||
|
||||
public JRadioButtonMenuItem getHexcode()
|
||||
{
|
||||
return hexcode;
|
||||
}
|
||||
|
||||
public JRadioButtonMenuItem getBytecode()
|
||||
{
|
||||
return bytecode;
|
||||
}
|
||||
|
||||
public JRadioButtonMenuItem getAsmTextify()
|
||||
{
|
||||
return asmTextify;
|
||||
}
|
||||
}
|
|
@ -58,7 +58,7 @@ public class WorkPane extends VisibleComponent implements ActionListener {
|
|||
public JTabbedPane tabs;
|
||||
|
||||
JPanel buttonPanel;
|
||||
JButton refreshClass;
|
||||
public JButton refreshClass;
|
||||
|
||||
HashMap<String, Integer> workingOn = new HashMap<>();
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package the.bytecode.club.bytecodeviewer.util;
|
||||
|
||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* @author Konloch
|
||||
* @since 6/21/2021
|
||||
*/
|
||||
public class RefreshWorkPane implements ActionListener
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
if (BytecodeViewer.viewer.refreshOnChange.isSelected()) {
|
||||
if (BytecodeViewer.viewer.workPane.getCurrentViewer() == null)
|
||||
return;
|
||||
|
||||
BytecodeViewer.viewer.workPane.refreshClass.doClick();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,442 @@
|
|||
package the.bytecode.club.bytecodeviewer.util;
|
||||
|
||||
import me.konloch.kontainer.io.DiskWriter;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||
import the.bytecode.club.bytecodeviewer.api.ExceptionUI;
|
||||
import the.bytecode.club.bytecodeviewer.decompilers.Decompilers;
|
||||
import the.bytecode.club.bytecodeviewer.gui.MainViewerGUI;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
|
||||
import static the.bytecode.club.bytecodeviewer.Constants.fs;
|
||||
import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory;
|
||||
|
||||
/**
|
||||
* @author Konloch
|
||||
* @since 6/21/2021
|
||||
*/
|
||||
public class ResourceDecompiling
|
||||
{
|
||||
public static void decompileSaveAll()
|
||||
{
|
||||
if (BytecodeViewer.getLoadedClasses().isEmpty()) {
|
||||
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
|
||||
return;
|
||||
}
|
||||
|
||||
Thread t = new Thread(() -> {
|
||||
if (BytecodeViewer.viewer.compileOnSave.isSelected() && !BytecodeViewer.compile(false))
|
||||
return;
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setFileFilter(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
return f.isDirectory() || MiscUtils.extension(f.getAbsolutePath()).equals("zip");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Zip Archives";
|
||||
}
|
||||
});
|
||||
fc.setFileHidingEnabled(false);
|
||||
fc.setAcceptAllFileFilterUsed(false);
|
||||
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fc.getSelectedFile();
|
||||
if (!file.getAbsolutePath().endsWith(".zip"))
|
||||
file = new File(file.getAbsolutePath() + ".zip");
|
||||
|
||||
if (file.exists()) {
|
||||
JOptionPane pane = new JOptionPane(
|
||||
"Are you sure you wish to overwrite this existing file?");
|
||||
Object[] options = new String[]{"Yes", "No"};
|
||||
pane.setOptions(options);
|
||||
JDialog dialog = pane.createDialog(BytecodeViewer.viewer,
|
||||
"Bytecode Viewer - Overwrite File");
|
||||
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) {
|
||||
file.delete();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final File javaSucks = file;
|
||||
|
||||
final String path = MiscUtils.append(file, ".zip"); // cheap hax cause string is final
|
||||
|
||||
JOptionPane pane = new JOptionPane(
|
||||
"What decompiler will you use?");
|
||||
Object[] options = new String[]{"All", "Procyon", "CFR",
|
||||
"Fernflower", "Krakatau", "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;
|
||||
|
||||
BytecodeViewer.viewer.setIcon(true);
|
||||
|
||||
File tempZip = new File(tempDirectory + fs + "temp_" + MiscUtils.getRandomizedName() + ".jar");
|
||||
if (tempZip.exists())
|
||||
tempZip.delete();
|
||||
|
||||
JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), tempZip.getAbsolutePath());
|
||||
|
||||
if (result == 0) {
|
||||
Thread t12 = new Thread(() -> {
|
||||
try {
|
||||
Decompilers.procyon.decompileToZip(tempZip.getAbsolutePath(),
|
||||
MiscUtils.append(javaSucks, "-proycon.zip"));
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
} catch (Exception e) {
|
||||
new ExceptionUI(e);
|
||||
}
|
||||
});
|
||||
t12.start();
|
||||
Thread t2 = new Thread(() -> {
|
||||
try {
|
||||
BytecodeViewer.viewer.setIcon(true);
|
||||
Decompilers.cfr.decompileToZip(tempZip.getAbsolutePath(),
|
||||
MiscUtils.append(javaSucks, "-CFR.zip"));
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
} catch (Exception e) {
|
||||
new ExceptionUI(e);
|
||||
}
|
||||
});
|
||||
t2.start();
|
||||
Thread t3 = new Thread(() -> {
|
||||
try {
|
||||
BytecodeViewer.viewer.setIcon(true);
|
||||
Decompilers.fernflower.decompileToZip(tempZip.getAbsolutePath(),
|
||||
MiscUtils.append(javaSucks, "-fernflower.zip"));
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
} catch (Exception e) {
|
||||
new ExceptionUI(e);
|
||||
}
|
||||
});
|
||||
t3.start();
|
||||
Thread t4 = new Thread(() -> {
|
||||
try {
|
||||
BytecodeViewer.viewer.setIcon(true);
|
||||
Decompilers.krakatau.decompileToZip(tempZip.getAbsolutePath(),
|
||||
MiscUtils.append(javaSucks, "-kraktau.zip"));
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
} catch (Exception e) {
|
||||
new ExceptionUI(e);
|
||||
}
|
||||
});
|
||||
t4.start();
|
||||
}
|
||||
if (result == 1) {
|
||||
Thread t12 = new Thread(() -> {
|
||||
try {
|
||||
Decompilers.procyon.decompileToZip(tempZip.getAbsolutePath(), path);
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
} catch (Exception e) {
|
||||
new ExceptionUI(e);
|
||||
}
|
||||
});
|
||||
t12.start();
|
||||
}
|
||||
if (result == 2) {
|
||||
Thread t12 = new Thread(() -> {
|
||||
try {
|
||||
Decompilers.cfr.decompileToZip(tempZip.getAbsolutePath(), path);
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
} catch (Exception e) {
|
||||
new ExceptionUI(e);
|
||||
}
|
||||
});
|
||||
t12.start();
|
||||
}
|
||||
if (result == 3) {
|
||||
Thread t12 = new Thread(() -> {
|
||||
try {
|
||||
Decompilers.fernflower.decompileToZip(tempZip.getAbsolutePath(), path);
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
} catch (Exception e) {
|
||||
new ExceptionUI(e);
|
||||
}
|
||||
});
|
||||
t12.start();
|
||||
}
|
||||
|
||||
if (result == 4) {
|
||||
Thread t12 = new Thread(() -> {
|
||||
try {
|
||||
Decompilers.krakatau.decompileToZip(tempZip.getAbsolutePath(), path);
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
} catch (Exception e) {
|
||||
new ExceptionUI(e);
|
||||
}
|
||||
});
|
||||
t12.start();
|
||||
}
|
||||
|
||||
if (result == 5) {
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
|
||||
public static void decompileSaveOpenedOnly()
|
||||
{
|
||||
if (BytecodeViewer.viewer.workPane.getCurrentViewer() == null) {
|
||||
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
|
||||
return;
|
||||
}
|
||||
|
||||
Thread t = new Thread(() -> {
|
||||
if (BytecodeViewer.viewer.compileOnSave.isSelected() && !BytecodeViewer.compile(false))
|
||||
return;
|
||||
|
||||
final String s = BytecodeViewer.viewer.workPane.getCurrentViewer().cn.name;
|
||||
|
||||
if (s == null)
|
||||
return;
|
||||
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setFileFilter(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
return f.isDirectory() || MiscUtils.extension(f.getAbsolutePath()).equals("java");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Java Source Files";
|
||||
}
|
||||
});
|
||||
fc.setFileHidingEnabled(false);
|
||||
fc.setAcceptAllFileFilterUsed(false);
|
||||
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fc.getSelectedFile();
|
||||
|
||||
BytecodeViewer.viewer.setIcon(true);
|
||||
final String path = MiscUtils.append(file, ".java"); // cheap hax cause
|
||||
// string is final
|
||||
|
||||
if (new File(path).exists()) {
|
||||
JOptionPane pane = new JOptionPane(
|
||||
"Are you sure you wish to overwrite this existing file?");
|
||||
Object[] options = new String[]{"Yes", "No"};
|
||||
pane.setOptions(options);
|
||||
JDialog dialog = pane.createDialog(BytecodeViewer.viewer,
|
||||
"Bytecode Viewer - Overwrite File");
|
||||
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) {
|
||||
file.delete();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
JOptionPane pane = new JOptionPane(
|
||||
"What decompiler will you use?");
|
||||
Object[] options = new String[]{"All", "Procyon", "CFR",
|
||||
"Fernflower", "Krakatau", "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 t1 = new Thread(() -> {
|
||||
try {
|
||||
ClassNode cn = BytecodeViewer.getClassNode(s);
|
||||
final ClassWriter cw = new ClassWriter(0);
|
||||
try {
|
||||
Objects.requireNonNull(cn).accept(cw);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
Objects.requireNonNull(cn).accept(cw);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
DiskWriter.replaceFile(MiscUtils.append(file, "-proycon.java"),
|
||||
Decompilers.procyon.decompileClassNode(cn, cw.toByteArray()), false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
DiskWriter.replaceFile(MiscUtils.append(file, "-CFR.java"),
|
||||
Decompilers.cfr.decompileClassNode(cn, cw.toByteArray()), false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
DiskWriter.replaceFile(MiscUtils.append(file, "-fernflower.java"),
|
||||
Decompilers.fernflower.decompileClassNode(cn, cw.toByteArray()), false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
DiskWriter.replaceFile(MiscUtils.append(file, "-kraktau.java"),
|
||||
Decompilers.krakatau.decompileClassNode(cn, cw.toByteArray()), false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
} catch (Exception e) {
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
new ExceptionUI(e);
|
||||
}
|
||||
});
|
||||
t1.start();
|
||||
}
|
||||
if (result == 1) {
|
||||
Thread t1 = new Thread(() -> {
|
||||
try {
|
||||
ClassNode cn = BytecodeViewer.getClassNode(s);
|
||||
final ClassWriter cw = new ClassWriter(0);
|
||||
try {
|
||||
Objects.requireNonNull(cn).accept(cw);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
Objects.requireNonNull(cn).accept(cw);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
String contents = Decompilers.procyon.decompileClassNode(cn,
|
||||
cw.toByteArray());
|
||||
DiskWriter.replaceFile(path, contents, false);
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
} catch (Exception e) {
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
new ExceptionUI(
|
||||
e);
|
||||
}
|
||||
});
|
||||
t1.start();
|
||||
}
|
||||
if (result == 2) {
|
||||
Thread t1 = new Thread(() -> {
|
||||
try {
|
||||
ClassNode cn = BytecodeViewer.getClassNode(s);
|
||||
final ClassWriter cw = new ClassWriter(0);
|
||||
try {
|
||||
Objects.requireNonNull(cn).accept(cw);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
Objects.requireNonNull(cn).accept(cw);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
String contents = Decompilers.cfr.decompileClassNode(cn, cw.toByteArray());
|
||||
DiskWriter.replaceFile(path, contents, false);
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
} catch (Exception e) {
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
new ExceptionUI(
|
||||
e);
|
||||
}
|
||||
});
|
||||
t1.start();
|
||||
}
|
||||
if (result == 3) {
|
||||
Thread t1 = new Thread(() -> {
|
||||
try {
|
||||
ClassNode cn = BytecodeViewer.getClassNode(s);
|
||||
final ClassWriter cw = new ClassWriter(0);
|
||||
try {
|
||||
Objects.requireNonNull(cn).accept(cw);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
if (cn != null)
|
||||
cn.accept(cw);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
String contents = Decompilers.fernflower.decompileClassNode(cn,
|
||||
cw.toByteArray());
|
||||
DiskWriter.replaceFile(path, contents, false);
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
} catch (Exception e) {
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
new ExceptionUI(
|
||||
e);
|
||||
}
|
||||
});
|
||||
t1.start();
|
||||
}
|
||||
if (result == 4) {
|
||||
Thread t1 = new Thread(() -> {
|
||||
try {
|
||||
ClassNode cn = BytecodeViewer.getClassNode(s);
|
||||
final ClassWriter cw = new ClassWriter(0);
|
||||
try {
|
||||
Objects.requireNonNull(cn).accept(cw);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
Objects.requireNonNull(cn).accept(cw);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
String contents = Decompilers.krakatau.decompileClassNode(cn,
|
||||
cw.toByteArray());
|
||||
DiskWriter.replaceFile(path, contents, false);
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
} catch (Exception e) {
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
new ExceptionUI(
|
||||
e);
|
||||
}
|
||||
});
|
||||
t1.start();
|
||||
}
|
||||
if (result == 5) {
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,326 @@
|
|||
package the.bytecode.club.bytecodeviewer.util;
|
||||
|
||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||
import the.bytecode.club.bytecodeviewer.gui.ExportJar;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static the.bytecode.club.bytecodeviewer.Constants.fs;
|
||||
import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory;
|
||||
|
||||
/**
|
||||
* @author Konloch
|
||||
* @since 6/21/2021
|
||||
*/
|
||||
public class ResourceExporting
|
||||
{
|
||||
|
||||
public static void saveAsRunnableJar()
|
||||
{
|
||||
if (BytecodeViewer.getLoadedClasses().isEmpty()) {
|
||||
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
|
||||
return;
|
||||
}
|
||||
Thread t = new Thread(() -> {
|
||||
if (BytecodeViewer.viewer.compileOnSave.isSelected() && !BytecodeViewer.compile(false))
|
||||
return;
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setFileFilter(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
return f.isDirectory() || MiscUtils.extension(f.getAbsolutePath()).equals("zip");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Zip Archives";
|
||||
}
|
||||
});
|
||||
fc.setFileHidingEnabled(false);
|
||||
fc.setAcceptAllFileFilterUsed(false);
|
||||
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fc.getSelectedFile();
|
||||
String path = file.getAbsolutePath();
|
||||
if (!path.endsWith(".jar"))
|
||||
path = path + ".jar";
|
||||
|
||||
if (new File(path).exists()) {
|
||||
JOptionPane pane = new JOptionPane(
|
||||
"Are you sure you wish to overwrite this existing file?");
|
||||
Object[] options = new String[]{"Yes", "No"};
|
||||
pane.setOptions(options);
|
||||
JDialog dialog = pane.createDialog(BytecodeViewer.viewer,
|
||||
"Bytecode Viewer - Overwrite File");
|
||||
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) {
|
||||
file.delete();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
new ExportJar(path).setVisible(true);
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
|
||||
public static void saveAsZip()
|
||||
{
|
||||
if (BytecodeViewer.getLoadedClasses().isEmpty()) {
|
||||
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
|
||||
return;
|
||||
}
|
||||
Thread t = new Thread(() -> {
|
||||
if (BytecodeViewer.viewer.compileOnSave.isSelected() && !BytecodeViewer.compile(false))
|
||||
return;
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setFileFilter(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
return f.isDirectory() || MiscUtils.extension(f.getAbsolutePath()).equals("zip");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Zip Archives";
|
||||
}
|
||||
});
|
||||
fc.setFileHidingEnabled(false);
|
||||
fc.setAcceptAllFileFilterUsed(false);
|
||||
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fc.getSelectedFile();
|
||||
if (!file.getAbsolutePath().endsWith(".zip"))
|
||||
file = new File(file.getAbsolutePath() + ".zip");
|
||||
|
||||
if (file.exists()) {
|
||||
JOptionPane pane = new JOptionPane(
|
||||
"Are you sure you wish to overwrite this existing file?");
|
||||
Object[] options = new String[]{"Yes", "No"};
|
||||
pane.setOptions(options);
|
||||
JDialog dialog = pane.createDialog(BytecodeViewer.viewer,
|
||||
"Bytecode Viewer - Overwrite File");
|
||||
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) {
|
||||
file.delete();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final File file2 = file;
|
||||
|
||||
BytecodeViewer.viewer.setIcon(true);
|
||||
Thread t17 = new Thread(() -> {
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(),
|
||||
file2.getAbsolutePath());
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
});
|
||||
t17.start();
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
|
||||
public static void saveAsDex()
|
||||
{
|
||||
if (BytecodeViewer.getLoadedClasses().isEmpty()) {
|
||||
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
|
||||
return;
|
||||
}
|
||||
|
||||
Thread t = new Thread(() -> {
|
||||
if (BytecodeViewer.viewer.compileOnSave.isSelected() && !BytecodeViewer.compile(false))
|
||||
return;
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setFileFilter(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
return f.isDirectory() || MiscUtils.extension(f.getAbsolutePath()).equals("dex");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Android DEX Files";
|
||||
}
|
||||
});
|
||||
fc.setFileHidingEnabled(false);
|
||||
fc.setAcceptAllFileFilterUsed(false);
|
||||
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
final File file = fc.getSelectedFile();
|
||||
String output = file.getAbsolutePath();
|
||||
if (!output.endsWith(".dex"))
|
||||
output = output + ".dex";
|
||||
|
||||
final File file2 = new File(output);
|
||||
|
||||
if (file2.exists()) {
|
||||
JOptionPane pane = new JOptionPane(
|
||||
"Are you sure you wish to overwrite this existing file?");
|
||||
Object[] options = new String[]{"Yes", "No"};
|
||||
pane.setOptions(options);
|
||||
JDialog dialog = pane.createDialog(BytecodeViewer.viewer,
|
||||
"Bytecode Viewer - Overwrite File");
|
||||
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) {
|
||||
file.delete();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Thread t16 = new Thread(() -> {
|
||||
BytecodeViewer.viewer.setIcon(true);
|
||||
final String input = tempDirectory + fs + MiscUtils.getRandomizedName() + ".jar";
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), input);
|
||||
|
||||
Thread t15 = new Thread(() -> {
|
||||
Dex2Jar.saveAsDex(new File(input), file2);
|
||||
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
});
|
||||
t15.start();
|
||||
});
|
||||
t16.start();
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
|
||||
public static void saveAsAPK()
|
||||
{
|
||||
if (BytecodeViewer.getLoadedClasses().isEmpty()) {
|
||||
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
|
||||
return;
|
||||
}
|
||||
|
||||
//if theres only one file in the container don't bother asking
|
||||
List<FileContainer> containers = BytecodeViewer.getFiles();
|
||||
List<FileContainer> validContainers = new ArrayList<>();
|
||||
List<String> validContainersNames = new ArrayList<>();
|
||||
FileContainer container;
|
||||
|
||||
for (FileContainer fileContainer : containers) {
|
||||
if (fileContainer.APKToolContents != null && fileContainer.APKToolContents.exists()) {
|
||||
validContainersNames.add(fileContainer.name);
|
||||
validContainers.add(fileContainer);
|
||||
}
|
||||
}
|
||||
|
||||
if (!validContainers.isEmpty()) {
|
||||
container = validContainers.get(0);
|
||||
|
||||
if (validContainers.size() >= 2) {
|
||||
JOptionPane pane = new JOptionPane("Which file would you like to export as an APK?");
|
||||
Object[] options = validContainersNames.toArray(new String[0]);
|
||||
|
||||
pane.setOptions(options);
|
||||
JDialog dialog = pane.createDialog(BytecodeViewer.viewer, "Bytecode Viewer - Select APK");
|
||||
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;
|
||||
|
||||
container = containers.get(result);
|
||||
}
|
||||
} else {
|
||||
BytecodeViewer.showMessage("You can only export as APK from a valid APK file. Make sure "
|
||||
+ "Settings>Decode Resources is ticked on.\n\nTip: Try exporting as DEX, it doesn't rely on "
|
||||
+ "decoded APK resources");
|
||||
return;
|
||||
}
|
||||
|
||||
final FileContainer finalContainer = container;
|
||||
|
||||
Thread t = new Thread(() -> {
|
||||
if (BytecodeViewer.viewer.compileOnSave.isSelected() && !BytecodeViewer.compile(false))
|
||||
return;
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setFileFilter(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
return f.isDirectory() || MiscUtils.extension(f.getAbsolutePath()).equals("apk");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Android APK";
|
||||
}
|
||||
});
|
||||
fc.setFileHidingEnabled(false);
|
||||
fc.setAcceptAllFileFilterUsed(false);
|
||||
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
final File file = fc.getSelectedFile();
|
||||
String output = file.getAbsolutePath();
|
||||
if (!output.endsWith(".apk"))
|
||||
output = output + ".apk";
|
||||
|
||||
final File file2 = new File(output);
|
||||
|
||||
if (file2.exists()) {
|
||||
JOptionPane pane = new JOptionPane(
|
||||
"Are you sure you wish to overwrite this existing file?");
|
||||
Object[] options = new String[]{"Yes", "No"};
|
||||
pane.setOptions(options);
|
||||
JDialog dialog = pane.createDialog(BytecodeViewer.viewer,
|
||||
"Bytecode Viewer - Overwrite File");
|
||||
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) {
|
||||
file.delete();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Thread t14 = new Thread(() -> {
|
||||
BytecodeViewer.viewer.setIcon(true);
|
||||
final String input = tempDirectory + fs + MiscUtils.getRandomizedName() + ".jar";
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), input);
|
||||
|
||||
Thread t13 = new Thread(() -> {
|
||||
APKTool.buildAPK(new File(input), file2, finalContainer);
|
||||
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
});
|
||||
t13.start();
|
||||
});
|
||||
t14.start();
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user