mirror of
https://github.com/SuspiciousActivity/ByteEdit.git
synced 2026-08-13 17:56:17 +00:00
Removed Fernflower
This commit is contained in:
1 parent
a9612c058c
commit
ed9b6a177b
3 files changed
+1
-147
No files matched your search
@@ -6,8 +6,7 @@ import me.ByteEdit.edit.Disassembler;
|
||||
|
||||
public enum EnumDecompiler {
|
||||
BYTEEDIT("ByteEdit", new Disassembler(), false), PROCYON("Procyon", new ProcyonDecompiler()),
|
||||
FERNFLOWER("FernFlower", new FernflowerDecompiler()), JD_GUI("JD-GUI", new JDDecompiler()),
|
||||
CFR("CFR", new CFRDecompiler());
|
||||
JD_GUI("JD-GUI", new JDDecompiler()), CFR("CFR", new CFRDecompiler());
|
||||
|
||||
private final String name;
|
||||
private final IDecompiler decompiler;
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
package me.ByteEdit.decompiler;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
import org.jetbrains.java.decompiler.main.Fernflower;
|
||||
import org.jetbrains.java.decompiler.main.extern.IBytecodeProvider;
|
||||
import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger;
|
||||
import org.jetbrains.java.decompiler.main.extern.IResultSaver;
|
||||
import org.jetbrains.java.decompiler.struct.ContextUnit;
|
||||
import org.jetbrains.java.decompiler.struct.StructClass;
|
||||
import org.jetbrains.java.decompiler.struct.StructContext;
|
||||
import org.jetbrains.java.decompiler.struct.lazy.LazyLoader;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
public class FernflowerDecompiler implements IBytecodeProvider, IResultSaver, IDecompiler {
|
||||
|
||||
private byte[] bytes;
|
||||
private String returned;
|
||||
|
||||
public static final HashMap<String, Boolean> options = new HashMap<>();
|
||||
|
||||
static {
|
||||
options.put("rbr", true);
|
||||
options.put("rsy", false);
|
||||
options.put("din", true);
|
||||
options.put("dc4", true);
|
||||
options.put("das", true);
|
||||
options.put("hes", true);
|
||||
options.put("hdc", true);
|
||||
options.put("dgs", false);
|
||||
options.put("ner", true);
|
||||
options.put("den", true);
|
||||
options.put("rgn", true);
|
||||
options.put("lit", false);
|
||||
options.put("asc", true);
|
||||
options.put("bto", true);
|
||||
options.put("nns", false);
|
||||
options.put("uto", true);
|
||||
options.put("udv", true);
|
||||
options.put("rer", true);
|
||||
options.put("fdi", true);
|
||||
options.put("ren", false);
|
||||
options.put("inn", true);
|
||||
options.put("lac", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decompile(ClassNode cn, Map<String, ClassNode> classNodes) {
|
||||
return doDecompilation(cn, IDecompiler.getBytes(cn), classNodes);
|
||||
}
|
||||
|
||||
public String doDecompilation(ClassNode cn, byte[] b, Map<String, ClassNode> classNodes) {
|
||||
try {
|
||||
// TODO decompile method only
|
||||
this.bytes = b;
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
for (Entry<String, Boolean> entry : options.entrySet()) {
|
||||
map.put(entry.getKey(), entry.getValue() ? "1" : "0");
|
||||
}
|
||||
map.put("ind", " ");
|
||||
Fernflower f = new Fernflower(this, this, map, new IFernflowerLogger() {
|
||||
@Override
|
||||
public void writeMessage(String message, Throwable t) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeMessage(String message, Severity severity) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accepts(Severity severity) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
StructContext sc = f.getStructContext();
|
||||
StructClass cl = new StructClass(b, true, sc.getLoader());
|
||||
sc.getClasses().put(cn.name, cl);
|
||||
// instead of loading a file use custom bridge, created a few getters
|
||||
String fakePath = new File("none.class").getAbsolutePath();
|
||||
ContextUnit unit = new ContextUnit(ContextUnit.TYPE_FOLDER, null, fakePath, true, sc.getSaver(),
|
||||
sc.getDecompiledData());
|
||||
sc.getUnits().put(fakePath, unit);
|
||||
unit.addClass(cl, "none.class");
|
||||
sc.getLoader().addClassLink(cn.name, new LazyLoader.Link(LazyLoader.Link.CLASS, fakePath, cn.name));
|
||||
|
||||
f.decompileContext();
|
||||
return returned;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
e.printStackTrace(pw);
|
||||
return sw.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytecode(String externalPath, String internalPath) throws IOException {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
// we can ignore most of those methods because we do not want to save the output
|
||||
// as a file
|
||||
@Override
|
||||
public void saveFolder(String path) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFile(String source, String path, String entryName) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveClassFile(String path, String qualifiedName, String entryName, String content, int[] mapping) {
|
||||
this.returned = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createArchive(String path, String archiveName, Manifest manifest) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveDirEntry(String path, String archiveName, String entryName) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyEntry(String source, String path, String archiveName, String entry) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveClassEntry(String path, String archiveName, String qualifiedName, String entryName,
|
||||
String content) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeArchive(String path, String archiveName) {
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import org.jd.core.v1.ClassFileToJavaSourceDecompiler;
|
||||
import org.jd.core.v1.api.loader.Loader;
|
||||
import org.jd.core.v1.api.loader.LoaderException;
|
||||
import org.jd.core.v1.api.printer.Printer;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
public class JDDecompiler implements Loader, Printer, IDecompiler {
|
||||
|
||||
Reference in new issue
Block a user