New Abstract Decompiler API
This commit is contained in:
parent
22e008c37d
commit
88aa5a9595
|
@ -27,7 +27,26 @@ import org.objectweb.asm.tree.ClassNode;
|
|||
*/
|
||||
public abstract class AbstractDecompiler
|
||||
{
|
||||
private final String decompilerName;
|
||||
private final String decompilerNameProgrammatic;
|
||||
|
||||
protected AbstractDecompiler(String decompilerName, String decompilerNameProgrammatic)
|
||||
{
|
||||
this.decompilerName = decompilerName;
|
||||
this.decompilerNameProgrammatic = decompilerNameProgrammatic;
|
||||
}
|
||||
|
||||
public abstract String decompileClassNode(ClassNode cn, byte[] bytes);
|
||||
|
||||
public abstract void decompileToZip(String sourceJar, String zipName);
|
||||
|
||||
public String getDecompilerName()
|
||||
{
|
||||
return decompilerName;
|
||||
}
|
||||
|
||||
public String getDecompilerNameProgrammatic()
|
||||
{
|
||||
return decompilerNameProgrammatic;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,51 +21,54 @@ package the.bytecode.club.bytecodeviewer.decompilers;
|
|||
import the.bytecode.club.bytecodeviewer.decompilers.impl.*;
|
||||
|
||||
/**
|
||||
* All of the decompilers/disassemblers BCV uses
|
||||
* All the decompilers/disassemblers BCV uses
|
||||
*
|
||||
* @author Konloch
|
||||
*/
|
||||
public enum Decompiler
|
||||
{
|
||||
//TODO WARNING: do not change the decompiler order, when adding a new decompiler just add it to the end
|
||||
// enum ordinal is used for settings serialization instead of the enum name
|
||||
NONE("None", "", null),
|
||||
PROCYON_DECOMPILER("Procyon Decompiler", "proycon", new ProcyonDecompiler()),
|
||||
CFR_DECOMPILER("CFR Decompiler", "cfr", new CFRDecompiler()),
|
||||
FERNFLOWER_DECOMPILER("FernFlower Decompiler", "fernflower", new FernFlowerDecompiler()),
|
||||
//TODO WARNING: do not change the decompiler order, when adding a new decompiler just add it to the end.
|
||||
// Enum ordinal is used for settings serialization instead of the enum name.
|
||||
|
||||
BYTECODE_DISASSEMBLER("Bytecode Disassembler", "bcvbd", new BytecodeDisassembler()),
|
||||
HEXCODE_VIEWER("Hexcode Viewer", "bcvhex", null),
|
||||
NONE(null),
|
||||
PROCYON_DECOMPILER(new ProcyonDecompiler()), //java decompiler
|
||||
CFR_DECOMPILER(new CFRDecompiler()), //java decompiler
|
||||
FERNFLOWER_DECOMPILER(new FernFlowerDecompiler()), //java decompiler
|
||||
|
||||
SMALI_DISASSEMBLER("Smali Disassembler", "smali", new SmaliDisassembler()),
|
||||
KRAKATAU_DECOMPILER("Krakatau Decompiler", "krakatau", new KrakatauDecompiler()),
|
||||
KRAKATAU_DISASSEMBLER("Krakatau Disassembler", "krakataud", new KrakatauDisassembler()),
|
||||
JD_DECOMPILER("JD-GUI Decompiler", "jdgui", new JDGUIDecompiler()),
|
||||
JADX_DECOMPILER("JADX Decompiler", "jadx", new JADXDecompiler()),
|
||||
BYTECODE_DISASSEMBLER(new BytecodeDisassembler()), //bytecode disassembler
|
||||
HEXCODE_VIEWER(null), //hexcode viewer
|
||||
|
||||
ASM_TEXTIFY_DISASSEMBLER("ASM Disassembler", "asm", new ASMTextifierDisassembler()),
|
||||
ASMIFIER_DECOMPILER("ASMifier Generator", "asmifier", new ASMifierGenerator()),
|
||||
JAVAP_DISASSEMBLER("Javap Disassembler", "javap", new JavapDisassembler());
|
||||
SMALI_DISASSEMBLER(new SmaliDisassembler()), //bytecode disassembler
|
||||
KRAKATAU_DECOMPILER(new KrakatauDecompiler()), //java decompiler
|
||||
KRAKATAU_DISASSEMBLER(new KrakatauDisassembler()), //bytecode disassembler
|
||||
JD_DECOMPILER(new JDGUIDecompiler()), //java decompiler
|
||||
JADX_DECOMPILER(new JADXDecompiler()), //java decompiler
|
||||
|
||||
ASM_TEXTIFY_DISASSEMBLER(new ASMTextifierDisassembler()), //bytecode disassembler
|
||||
ASMIFIER_DECOMPILER(new ASMifierGenerator()), //bytecode disassembler / code gen
|
||||
JAVAP_DISASSEMBLER(new JavapDisassembler()); //bytecode disassembler
|
||||
|
||||
private final String decompilerName;
|
||||
private final String decompilerNameProgrammic;
|
||||
private final AbstractDecompiler decompiler;
|
||||
|
||||
Decompiler(String decompilerName, String decompilerNameProgrammic, AbstractDecompiler decompiler)
|
||||
Decompiler(AbstractDecompiler decompiler)
|
||||
{
|
||||
this.decompilerName = decompilerName;
|
||||
this.decompilerNameProgrammic = decompilerNameProgrammic;
|
||||
this.decompiler = decompiler;
|
||||
}
|
||||
|
||||
public String getDecompilerName()
|
||||
{
|
||||
return decompilerName;
|
||||
if(decompiler == null)
|
||||
return "None";
|
||||
|
||||
return getDecompiler().getDecompilerName();
|
||||
}
|
||||
|
||||
public String getDecompilerNameProgrammic()
|
||||
{
|
||||
return decompilerNameProgrammic;
|
||||
if(decompiler == null)
|
||||
return "";
|
||||
|
||||
return getDecompiler().getDecompilerNameProgrammatic();
|
||||
}
|
||||
|
||||
public AbstractDecompiler getDecompiler()
|
||||
|
|
|
@ -33,6 +33,11 @@ import java.io.StringWriter;
|
|||
*/
|
||||
public class ASMTextifierDisassembler extends AbstractDecompiler
|
||||
{
|
||||
public ASMTextifierDisassembler()
|
||||
{
|
||||
super("ASM Disassembler", "asm");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
||||
{
|
||||
|
|
|
@ -33,6 +33,11 @@ import java.io.StringWriter;
|
|||
*/
|
||||
public class ASMifierGenerator extends AbstractDecompiler
|
||||
{
|
||||
public ASMifierGenerator()
|
||||
{
|
||||
super("ASMifier Generator", "asmifier");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
||||
{
|
||||
|
|
|
@ -31,6 +31,11 @@ import java.util.ArrayList;
|
|||
*/
|
||||
public class BytecodeDisassembler extends AbstractDecompiler
|
||||
{
|
||||
public BytecodeDisassembler()
|
||||
{
|
||||
super("Bytecode Disassembler", "bcvbd");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
||||
{
|
||||
|
|
|
@ -58,6 +58,11 @@ public class CFRDecompiler extends AbstractDecompiler
|
|||
|
||||
private static final String CLASS_SUFFIX = ".class";
|
||||
|
||||
public CFRDecompiler()
|
||||
{
|
||||
super("CFR Decompiler", "cfr");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
||||
{
|
||||
|
|
|
@ -41,6 +41,11 @@ import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.FER
|
|||
*/
|
||||
public class FernFlowerDecompiler extends AbstractDecompiler
|
||||
{
|
||||
public FernFlowerDecompiler()
|
||||
{
|
||||
super("FernFlower Decompiler", "fernflower");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decompileToZip(String sourceJar, String zipName)
|
||||
{
|
||||
|
|
|
@ -41,6 +41,11 @@ import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.JAD
|
|||
*/
|
||||
public class JADXDecompiler extends AbstractDecompiler
|
||||
{
|
||||
public JADXDecompiler()
|
||||
{
|
||||
super("JADX Decompiler", "jadx");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
||||
{
|
||||
|
|
|
@ -49,6 +49,11 @@ import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.JDG
|
|||
public class JDGUIDecompiler extends AbstractDecompiler
|
||||
{
|
||||
|
||||
public JDGUIDecompiler()
|
||||
{
|
||||
super("JD-GUI Decompiler", "jdgui");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
||||
{
|
||||
|
|
|
@ -48,6 +48,11 @@ import static the.bytecode.club.bytecodeviewer.api.ExceptionUI.SEND_STACKTRACE_T
|
|||
|
||||
public class JavapDisassembler extends AbstractDecompiler
|
||||
{
|
||||
public JavapDisassembler()
|
||||
{
|
||||
super("Javap Disassembler", "javap");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
||||
{
|
||||
|
|
|
@ -46,6 +46,11 @@ import static the.bytecode.club.bytecodeviewer.Constants.*;
|
|||
|
||||
public class KrakatauDecompiler extends AbstractDecompiler
|
||||
{
|
||||
public KrakatauDecompiler()
|
||||
{
|
||||
super("Krakatau Decompiler", "krakatau");
|
||||
}
|
||||
|
||||
public String buildCLIArguments()
|
||||
{
|
||||
if (Configuration.library.isEmpty())
|
||||
|
|
|
@ -44,6 +44,11 @@ import static the.bytecode.club.bytecodeviewer.Constants.*;
|
|||
|
||||
public class KrakatauDisassembler extends AbstractDecompiler
|
||||
{
|
||||
public KrakatauDisassembler()
|
||||
{
|
||||
super("Krakatau Disassembler", "krakataud");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
||||
{
|
||||
|
|
|
@ -53,6 +53,11 @@ import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.PRO
|
|||
public class ProcyonDecompiler extends AbstractDecompiler
|
||||
{
|
||||
|
||||
public ProcyonDecompiler()
|
||||
{
|
||||
super("Procyon Decompiler", "proycon");
|
||||
}
|
||||
|
||||
public DecompilerSettings getDecompilerSettings()
|
||||
{
|
||||
DecompilerSettings settings = new DecompilerSettings();
|
||||
|
|
|
@ -43,6 +43,11 @@ import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.*;
|
|||
|
||||
public class SmaliDisassembler extends AbstractDecompiler
|
||||
{
|
||||
public SmaliDisassembler()
|
||||
{
|
||||
super("Smali Disassembler", "smali");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user