Decompiler View Types
This commit is contained in:
parent
ce06cba71f
commit
11c3aae683
4 changed files with 40 additions and 29 deletions
|
@ -35,6 +35,8 @@ import the.bytecode.club.bytecodeviewer.resources.importing.ImportResource;
|
||||||
import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
|
import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.*;
|
import static the.bytecode.club.bytecodeviewer.Constants.*;
|
||||||
import static the.bytecode.club.bytecodeviewer.Settings.addRecentPlugin;
|
import static the.bytecode.club.bytecodeviewer.Settings.addRecentPlugin;
|
||||||
|
import static the.bytecode.club.bytecodeviewer.gui.components.DecompilerViewComponent.DecompilerComponentTypes.JAVA;
|
||||||
|
import static the.bytecode.club.bytecodeviewer.gui.components.DecompilerViewComponent.DecompilerComponentTypes.JAVA_AND_BYTECODE;
|
||||||
import static the.bytecode.club.bytecodeviewer.util.MiscUtils.guessLanguage;
|
import static the.bytecode.club.bytecodeviewer.util.MiscUtils.guessLanguage;
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
|
@ -128,7 +130,7 @@ public class BytecodeViewer
|
||||||
public static Refactorer refactorer = new Refactorer();
|
public static Refactorer refactorer = new Refactorer();
|
||||||
public static List<FileContainer> files = new ArrayList<>(); //all of BCV's loaded files/classes/etc
|
public static List<FileContainer> files = new ArrayList<>(); //all of BCV's loaded files/classes/etc
|
||||||
public static List<Process> createdProcesses = new ArrayList<>();
|
public static List<Process> createdProcesses = new ArrayList<>();
|
||||||
public static final DecompilerViewComponent krakatau = new DecompilerViewComponent("Krakatau", true);
|
public static final DecompilerViewComponent krakatau = new DecompilerViewComponent("Krakatau", JAVA_AND_BYTECODE);
|
||||||
public static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
public static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
public static final boolean EXPERIMENTAL_TAB_CODE = false;
|
public static final boolean EXPERIMENTAL_TAB_CODE = false;
|
||||||
public static final boolean DEV_MODE = false; //if true error streams as preserved
|
public static final boolean DEV_MODE = false; //if true error streams as preserved
|
||||||
|
|
|
@ -6,6 +6,8 @@ import the.bytecode.club.bytecodeviewer.gui.components.DecompilerViewComponent;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
|
import static the.bytecode.club.bytecodeviewer.gui.components.DecompilerViewComponent.DecompilerComponentTypes.*;
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
||||||
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
|
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
|
||||||
|
@ -32,17 +34,17 @@ import javax.swing.*;
|
||||||
public enum Decompiler
|
public enum Decompiler
|
||||||
{
|
{
|
||||||
NONE("None", null, (JRadioButtonMenuItem) null),
|
NONE("None", null, (JRadioButtonMenuItem) null),
|
||||||
PROCYON_DECOMPILER("Procyon Decompiler", new ProcyonDecompiler(), new DecompilerViewComponent("Procyon")),
|
PROCYON_DECOMPILER("Procyon Decompiler", new ProcyonDecompiler(), new DecompilerViewComponent("Procyon", JAVA)),
|
||||||
CFR_DECOMPILER("CFR Decompiler", new CFRDecompiler(), new DecompilerViewComponent("Procyon")),
|
CFR_DECOMPILER("CFR Decompiler", new CFRDecompiler(), new DecompilerViewComponent("CFR", JAVA)),
|
||||||
FERNFLOWER_DECOMPILER("FernFlower Decompiler", new FernFlowerDecompiler(), new DecompilerViewComponent("Procyon")),
|
FERNFLOWER_DECOMPILER("FernFlower Decompiler", new FernFlowerDecompiler(), new DecompilerViewComponent("FernFlower", JAVA)),
|
||||||
BYTECODE_DISASSEMBLER("Bytecode Disassembler", new BytecodeDisassembler(), new JRadioButtonMenuItem("Bytecode")),
|
BYTECODE_DISASSEMBLER("Bytecode Disassembler", new BytecodeDisassembler(), new JRadioButtonMenuItem("Bytecode")),
|
||||||
HEXCODE_VIEWER("Hexcode Viewer", null, new JRadioButtonMenuItem("Hexcode")),
|
HEXCODE_VIEWER("Hexcode Viewer", null, new JRadioButtonMenuItem("Hexcode")),
|
||||||
SMALI_DISASSEMBLER("Smali Disassembler", new SmaliDisassembler(), new DecompilerViewComponent("Smali")),
|
SMALI_DISASSEMBLER("Smali Disassembler", new SmaliDisassembler(), new DecompilerViewComponent("Smali", BYTECODE)),
|
||||||
KRAKATAU_DECOMPILER("Krakatau Decompiler", new KrakatauDecompiler(), BytecodeViewer.krakatau),
|
KRAKATAU_DECOMPILER("Krakatau Decompiler", new KrakatauDecompiler(), BytecodeViewer.krakatau),
|
||||||
KRAKATAU_DISASSEMBLER("Krakatau Disassembler", new KrakatauDisassembler(), BytecodeViewer.krakatau),
|
KRAKATAU_DISASSEMBLER("Krakatau Disassembler", new KrakatauDisassembler(), BytecodeViewer.krakatau),
|
||||||
JD_DECOMPILER("JD-GUI Decompiler", new JDGUIDecompiler(), new DecompilerViewComponent("Bytecode")),
|
JD_DECOMPILER("JD-GUI Decompiler", new JDGUIDecompiler(), new DecompilerViewComponent("JD-GUI", JAVA)),
|
||||||
JADX_DECOMPILER("JADX Decompiler", new JADXDecompiler(), new DecompilerViewComponent("JADX")),
|
JADX_DECOMPILER("JADX Decompiler", new JADXDecompiler(), new DecompilerViewComponent("JADX", JAVA)),
|
||||||
ASM_TEXTIFY_DISASSEMBLER("ASM Disassembler", new ASMTextifierDecompiler(), new DecompilerViewComponent("ASM Textify")),
|
ASM_TEXTIFY_DISASSEMBLER("ASM Disassembler", new ASMTextifierDecompiler(), new DecompilerViewComponent("ASM Textify", BYTECODE)),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String decompilerName;
|
private final String decompilerName;
|
||||||
|
|
|
@ -32,27 +32,24 @@ import javax.swing.*;
|
||||||
public class DecompilerViewComponent
|
public class DecompilerViewComponent
|
||||||
{
|
{
|
||||||
private final String name;
|
private final String name;
|
||||||
private final boolean hasBytecodeOption;
|
|
||||||
private final JMenu menu;
|
private final JMenu menu;
|
||||||
|
private final DecompilerComponentTypes types;
|
||||||
private final JRadioButtonMenuItem java = new TranslatedJRadioButtonMenuItem("Java", Translation.JAVA);
|
private final JRadioButtonMenuItem java = new TranslatedJRadioButtonMenuItem("Java", Translation.JAVA);
|
||||||
private final JRadioButtonMenuItem bytecode = new TranslatedJRadioButtonMenuItem("Bytecode", Translation.BYTECODE);
|
private final JRadioButtonMenuItem bytecode = new TranslatedJRadioButtonMenuItem("Bytecode", Translation.BYTECODE);
|
||||||
private final JCheckBoxMenuItem editable = new TranslatedJCheckBoxMenuItem("Editable", Translation.EDITABLE);
|
private final JCheckBoxMenuItem editable = new TranslatedJCheckBoxMenuItem("Editable", Translation.EDITABLE);
|
||||||
|
|
||||||
public DecompilerViewComponent(String name) {
|
public DecompilerViewComponent(String name, DecompilerComponentTypes types) {
|
||||||
this(name, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DecompilerViewComponent(String name, boolean hasBytecodeOption) {
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.menu = new JMenu(name);
|
this.menu = new JMenu(name);
|
||||||
this.hasBytecodeOption = hasBytecodeOption;
|
this.types = types;
|
||||||
createMenu();
|
createMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createMenu()
|
private void createMenu()
|
||||||
{
|
{
|
||||||
menu.add(java);
|
if(types == DecompilerComponentTypes.JAVA || types == DecompilerComponentTypes.JAVA_AND_BYTECODE)
|
||||||
if(hasBytecodeOption)
|
menu.add(java);
|
||||||
|
if(types == DecompilerComponentTypes.BYTECODE || types == DecompilerComponentTypes.JAVA_AND_BYTECODE)
|
||||||
menu.add(bytecode);
|
menu.add(bytecode);
|
||||||
|
|
||||||
menu.add(new JSeparator());
|
menu.add(new JSeparator());
|
||||||
|
@ -63,8 +60,9 @@ public class DecompilerViewComponent
|
||||||
|
|
||||||
public void addToGroup(ButtonGroup group)
|
public void addToGroup(ButtonGroup group)
|
||||||
{
|
{
|
||||||
group.add(java);
|
if(types == DecompilerComponentTypes.JAVA || types == DecompilerComponentTypes.JAVA_AND_BYTECODE)
|
||||||
if(hasBytecodeOption)
|
group.add(java);
|
||||||
|
if(types == DecompilerComponentTypes.BYTECODE || types == DecompilerComponentTypes.JAVA_AND_BYTECODE)
|
||||||
group.add(bytecode);
|
group.add(bytecode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,4 +85,11 @@ public class DecompilerViewComponent
|
||||||
{
|
{
|
||||||
return editable;
|
return editable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum DecompilerComponentTypes
|
||||||
|
{
|
||||||
|
JAVA,
|
||||||
|
BYTECODE,
|
||||||
|
JAVA_AND_BYTECODE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@ import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJRadioB
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
|
import static the.bytecode.club.bytecodeviewer.gui.components.DecompilerViewComponent.DecompilerComponentTypes.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
* @since 6/21/2021
|
* @since 6/21/2021
|
||||||
|
@ -18,13 +20,13 @@ public class DecompilerSelectionPane
|
||||||
public final JMenu menu;
|
public final JMenu menu;
|
||||||
public final ButtonGroup group = new ButtonGroup();
|
public final ButtonGroup group = new ButtonGroup();
|
||||||
public final JRadioButtonMenuItem none = new TranslatedJRadioButtonMenuItem("None", Translation.NONE);
|
public final JRadioButtonMenuItem none = new TranslatedJRadioButtonMenuItem("None", Translation.NONE);
|
||||||
public final DecompilerViewComponent procyon = new DecompilerViewComponent("Procyon");
|
public final DecompilerViewComponent procyon = new DecompilerViewComponent("Procyon", JAVA);
|
||||||
public final DecompilerViewComponent CFR = new DecompilerViewComponent("CFR");
|
public final DecompilerViewComponent CFR = new DecompilerViewComponent("CFR", JAVA);
|
||||||
public final DecompilerViewComponent JADX = new DecompilerViewComponent("JADX");
|
public final DecompilerViewComponent JADX = new DecompilerViewComponent("JADX", JAVA);
|
||||||
public final DecompilerViewComponent JD = new DecompilerViewComponent("JD-GUI");
|
public final DecompilerViewComponent JD = new DecompilerViewComponent("JD-GUI", JAVA);
|
||||||
public final DecompilerViewComponent fern = new DecompilerViewComponent("FernFlower");
|
public final DecompilerViewComponent fern = new DecompilerViewComponent("FernFlower", JAVA);
|
||||||
public final DecompilerViewComponent krakatau = new DecompilerViewComponent("Krakatau", true);
|
public final DecompilerViewComponent krakatau = new DecompilerViewComponent("Krakatau", JAVA_AND_BYTECODE);
|
||||||
public final DecompilerViewComponent smali = new DecompilerViewComponent("Smali/DEX");
|
public final DecompilerViewComponent smali = new DecompilerViewComponent("Smali", BYTECODE);
|
||||||
public final JRadioButtonMenuItem hexcode = new TranslatedJRadioButtonMenuItem("Hexcode", Translation.HEXCODE);
|
public final JRadioButtonMenuItem hexcode = new TranslatedJRadioButtonMenuItem("Hexcode", Translation.HEXCODE);
|
||||||
public final JRadioButtonMenuItem bytecode = new TranslatedJRadioButtonMenuItem("Bytecode", Translation.BYTECODE);
|
public final JRadioButtonMenuItem bytecode = new TranslatedJRadioButtonMenuItem("Bytecode", Translation.BYTECODE);
|
||||||
public final JRadioButtonMenuItem asmTextify = new TranslatedJRadioButtonMenuItem("ASM Textify", Translation.ASM_TEXTIFY);
|
public final JRadioButtonMenuItem asmTextify = new TranslatedJRadioButtonMenuItem("ASM Textify", Translation.ASM_TEXTIFY);
|
||||||
|
@ -86,7 +88,7 @@ public class DecompilerSelectionPane
|
||||||
return Decompiler.BYTECODE_DISASSEMBLER;
|
return Decompiler.BYTECODE_DISASSEMBLER;
|
||||||
else if (group.isSelected(hexcode.getModel()))
|
else if (group.isSelected(hexcode.getModel()))
|
||||||
return Decompiler.HEXCODE_VIEWER;
|
return Decompiler.HEXCODE_VIEWER;
|
||||||
else if (group.isSelected(smali.getJava().getModel()))
|
else if (group.isSelected(smali.getBytecode().getModel()))
|
||||||
return Decompiler.SMALI_DISASSEMBLER;
|
return Decompiler.SMALI_DISASSEMBLER;
|
||||||
else if (group.isSelected(krakatau.getJava().getModel()))
|
else if (group.isSelected(krakatau.getJava().getModel()))
|
||||||
return Decompiler.KRAKATAU_DECOMPILER;
|
return Decompiler.KRAKATAU_DECOMPILER;
|
||||||
|
@ -128,7 +130,7 @@ public class DecompilerSelectionPane
|
||||||
group.setSelected(hexcode.getModel(), true);
|
group.setSelected(hexcode.getModel(), true);
|
||||||
break;
|
break;
|
||||||
case SMALI_DISASSEMBLER:
|
case SMALI_DISASSEMBLER:
|
||||||
group.setSelected(smali.getJava().getModel(), true);
|
group.setSelected(smali.getBytecode().getModel(), true);
|
||||||
break;
|
break;
|
||||||
case KRAKATAU_DECOMPILER:
|
case KRAKATAU_DECOMPILER:
|
||||||
group.setSelected(krakatau.getJava().getModel(), true);
|
group.setSelected(krakatau.getJava().getModel(), true);
|
||||||
|
@ -162,7 +164,7 @@ public class DecompilerSelectionPane
|
||||||
return true;
|
return true;
|
||||||
if((group.isSelected(krakatau.getJava().getModel()) || group.isSelected(krakatau.getBytecode().getModel())) && krakatau.getEditable().isSelected())
|
if((group.isSelected(krakatau.getJava().getModel()) || group.isSelected(krakatau.getBytecode().getModel())) && krakatau.getEditable().isSelected())
|
||||||
return true;
|
return true;
|
||||||
if(group.isSelected(smali.getJava().getModel()) && smali.getEditable().isSelected())
|
if(group.isSelected(smali.getBytecode().getModel()) && smali.getEditable().isSelected())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue