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
|
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 String decompileClassNode(ClassNode cn, byte[] bytes);
|
||||||
|
|
||||||
public abstract void decompileToZip(String sourceJar, String zipName);
|
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.*;
|
import the.bytecode.club.bytecodeviewer.decompilers.impl.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All of the decompilers/disassemblers BCV uses
|
* All the decompilers/disassemblers BCV uses
|
||||||
*
|
*
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
*/
|
*/
|
||||||
public enum Decompiler
|
public enum Decompiler
|
||||||
{
|
{
|
||||||
//TODO WARNING: do not change the decompiler order, when adding a new decompiler just add it to the end
|
//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
|
// 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()),
|
|
||||||
|
|
||||||
BYTECODE_DISASSEMBLER("Bytecode Disassembler", "bcvbd", new BytecodeDisassembler()),
|
NONE(null),
|
||||||
HEXCODE_VIEWER("Hexcode Viewer", "bcvhex", 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()),
|
BYTECODE_DISASSEMBLER(new BytecodeDisassembler()), //bytecode disassembler
|
||||||
KRAKATAU_DECOMPILER("Krakatau Decompiler", "krakatau", new KrakatauDecompiler()),
|
HEXCODE_VIEWER(null), //hexcode viewer
|
||||||
KRAKATAU_DISASSEMBLER("Krakatau Disassembler", "krakataud", new KrakatauDisassembler()),
|
|
||||||
JD_DECOMPILER("JD-GUI Decompiler", "jdgui", new JDGUIDecompiler()),
|
|
||||||
JADX_DECOMPILER("JADX Decompiler", "jadx", new JADXDecompiler()),
|
|
||||||
|
|
||||||
ASM_TEXTIFY_DISASSEMBLER("ASM Disassembler", "asm", new ASMTextifierDisassembler()),
|
SMALI_DISASSEMBLER(new SmaliDisassembler()), //bytecode disassembler
|
||||||
ASMIFIER_DECOMPILER("ASMifier Generator", "asmifier", new ASMifierGenerator()),
|
KRAKATAU_DECOMPILER(new KrakatauDecompiler()), //java decompiler
|
||||||
JAVAP_DISASSEMBLER("Javap Disassembler", "javap", new JavapDisassembler());
|
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;
|
private final AbstractDecompiler decompiler;
|
||||||
|
|
||||||
Decompiler(String decompilerName, String decompilerNameProgrammic, AbstractDecompiler decompiler)
|
Decompiler(AbstractDecompiler decompiler)
|
||||||
{
|
{
|
||||||
this.decompilerName = decompilerName;
|
|
||||||
this.decompilerNameProgrammic = decompilerNameProgrammic;
|
|
||||||
this.decompiler = decompiler;
|
this.decompiler = decompiler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDecompilerName()
|
public String getDecompilerName()
|
||||||
{
|
{
|
||||||
return decompilerName;
|
if(decompiler == null)
|
||||||
|
return "None";
|
||||||
|
|
||||||
|
return getDecompiler().getDecompilerName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDecompilerNameProgrammic()
|
public String getDecompilerNameProgrammic()
|
||||||
{
|
{
|
||||||
return decompilerNameProgrammic;
|
if(decompiler == null)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
return getDecompiler().getDecompilerNameProgrammatic();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractDecompiler getDecompiler()
|
public AbstractDecompiler getDecompiler()
|
||||||
|
|
|
@ -33,6 +33,11 @@ import java.io.StringWriter;
|
||||||
*/
|
*/
|
||||||
public class ASMTextifierDisassembler extends AbstractDecompiler
|
public class ASMTextifierDisassembler extends AbstractDecompiler
|
||||||
{
|
{
|
||||||
|
public ASMTextifierDisassembler()
|
||||||
|
{
|
||||||
|
super("ASM Disassembler", "asm");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,11 @@ import java.io.StringWriter;
|
||||||
*/
|
*/
|
||||||
public class ASMifierGenerator extends AbstractDecompiler
|
public class ASMifierGenerator extends AbstractDecompiler
|
||||||
{
|
{
|
||||||
|
public ASMifierGenerator()
|
||||||
|
{
|
||||||
|
super("ASMifier Generator", "asmifier");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,6 +31,11 @@ import java.util.ArrayList;
|
||||||
*/
|
*/
|
||||||
public class BytecodeDisassembler extends AbstractDecompiler
|
public class BytecodeDisassembler extends AbstractDecompiler
|
||||||
{
|
{
|
||||||
|
public BytecodeDisassembler()
|
||||||
|
{
|
||||||
|
super("Bytecode Disassembler", "bcvbd");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,6 +58,11 @@ public class CFRDecompiler extends AbstractDecompiler
|
||||||
|
|
||||||
private static final String CLASS_SUFFIX = ".class";
|
private static final String CLASS_SUFFIX = ".class";
|
||||||
|
|
||||||
|
public CFRDecompiler()
|
||||||
|
{
|
||||||
|
super("CFR Decompiler", "cfr");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
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 class FernFlowerDecompiler extends AbstractDecompiler
|
||||||
{
|
{
|
||||||
|
public FernFlowerDecompiler()
|
||||||
|
{
|
||||||
|
super("FernFlower Decompiler", "fernflower");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decompileToZip(String sourceJar, String zipName)
|
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 class JADXDecompiler extends AbstractDecompiler
|
||||||
{
|
{
|
||||||
|
public JADXDecompiler()
|
||||||
|
{
|
||||||
|
super("JADX Decompiler", "jadx");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
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 class JDGUIDecompiler extends AbstractDecompiler
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public JDGUIDecompiler()
|
||||||
|
{
|
||||||
|
super("JD-GUI Decompiler", "jdgui");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
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 class JavapDisassembler extends AbstractDecompiler
|
||||||
{
|
{
|
||||||
|
public JavapDisassembler()
|
||||||
|
{
|
||||||
|
super("Javap Disassembler", "javap");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,6 +46,11 @@ import static the.bytecode.club.bytecodeviewer.Constants.*;
|
||||||
|
|
||||||
public class KrakatauDecompiler extends AbstractDecompiler
|
public class KrakatauDecompiler extends AbstractDecompiler
|
||||||
{
|
{
|
||||||
|
public KrakatauDecompiler()
|
||||||
|
{
|
||||||
|
super("Krakatau Decompiler", "krakatau");
|
||||||
|
}
|
||||||
|
|
||||||
public String buildCLIArguments()
|
public String buildCLIArguments()
|
||||||
{
|
{
|
||||||
if (Configuration.library.isEmpty())
|
if (Configuration.library.isEmpty())
|
||||||
|
|
|
@ -44,6 +44,11 @@ import static the.bytecode.club.bytecodeviewer.Constants.*;
|
||||||
|
|
||||||
public class KrakatauDisassembler extends AbstractDecompiler
|
public class KrakatauDisassembler extends AbstractDecompiler
|
||||||
{
|
{
|
||||||
|
public KrakatauDisassembler()
|
||||||
|
{
|
||||||
|
super("Krakatau Disassembler", "krakataud");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
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 class ProcyonDecompiler extends AbstractDecompiler
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public ProcyonDecompiler()
|
||||||
|
{
|
||||||
|
super("Procyon Decompiler", "proycon");
|
||||||
|
}
|
||||||
|
|
||||||
public DecompilerSettings getDecompilerSettings()
|
public DecompilerSettings getDecompilerSettings()
|
||||||
{
|
{
|
||||||
DecompilerSettings settings = new DecompilerSettings();
|
DecompilerSettings settings = new DecompilerSettings();
|
||||||
|
|
|
@ -43,6 +43,11 @@ import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.*;
|
||||||
|
|
||||||
public class SmaliDisassembler extends AbstractDecompiler
|
public class SmaliDisassembler extends AbstractDecompiler
|
||||||
{
|
{
|
||||||
|
public SmaliDisassembler()
|
||||||
|
{
|
||||||
|
super("Smali Disassembler", "smali");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user