Fixed CFR not returning code + some improvements over all

This commit is contained in:
ItzSomebody 2018-01-30 14:50:10 -08:00
parent 3ebcc401d5
commit 0db4c35828
4 changed files with 38 additions and 37 deletions

View file

@ -67,12 +67,12 @@ public class CFRDecompiler extends Decompiler {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
}
String fuckery = fuckery(fileStart);
if (!BytecodeViewer.fatJar) {
String fileThing = fileThing(fileStart);
/*if (!BytecodeViewer.fatJar) {
try {
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(
new String[]{BytecodeViewer.getJavaCommand(), "-jar", Resources.findLibrary("cfr")},
generateMainMethod(tempClass.getAbsolutePath(), fuckery)
generateMainMethod(tempClass.getAbsolutePath(), fileThing)
));
BytecodeViewer.sm.stopBlocking();
Process p = pb.start();
@ -84,19 +84,19 @@ public class CFRDecompiler extends Decompiler {
BytecodeViewer.sm.setBlocking();
}
} else {
org.benf.cfr.reader.Main.main(generateMainMethod(tempClass.getAbsolutePath(), fuckery));
}
org.benf.cfr.reader.Main.main(generateMainMethod(tempClass.getAbsolutePath(), fileThing));
}*/
org.benf.cfr.reader.Main.main(generateMainMethod(tempClass.getAbsolutePath(), fileThing));
tempClass.delete();
return findFile(new File(fuckery).listFiles());
return findFile(new File(fileThing).listFiles());
}
Random r = new Random();
File f;
public String fuckery(String start) {
public String fileThing(String start) {
boolean b = false;
while (!b) {
f = new File(start + r.nextInt(Integer.MAX_VALUE));
@ -257,21 +257,21 @@ public class CFRDecompiler extends Decompiler {
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs;
String fuckery = fuckery(fileStart);
String fileThing = fileThing(fileStart);
org.benf.cfr.reader.Main.main(generateMainMethod(
tempZip.getAbsolutePath(), fuckery));
tempZip.getAbsolutePath(), fileThing));
tempZip.delete();
File fuck = new File(fuckery);
File file = new File(fileThing);
try {
zip(fuck, new File(zipName));
zip(file, new File(zipName));
} catch (IOException e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
}
fuck.delete();
file.delete();
}
@SuppressWarnings("resource")

View file

@ -67,6 +67,23 @@ public class ClassNodeDecompiler extends Decompiler {
}
sb.append(" {");
sb.append(BytecodeViewer.nl);
if (cn.sourceDebug != null) {
sb.append(" ");
sb.append("<SourceDebug=" + cn.sourceDebug + ">");
sb.append(BytecodeViewer.nl);
}
if (cn.sourceFile != null) {
sb.append(" ");
sb.append("<SourceFile=" + cn.sourceFile + ">");
sb.append(BytecodeViewer.nl);
}
if (cn.signature != null) {
sb.append(" ");
sb.append("<Sig=" + cn.signature + ">");
}
for (FieldNode fn : cn.fields) {
sb.append(BytecodeViewer.nl);
sb.append(" ");
@ -115,24 +132,6 @@ public class ClassNodeDecompiler extends Decompiler {
}
}
if (cn.sourceDebug != null) {
sb.append(BytecodeViewer.nl);
sb.append(" ");
sb.append("SourceDebug: " + cn.sourceDebug);
}
if (cn.sourceFile != null) {
sb.append(BytecodeViewer.nl);
sb.append(" ");
sb.append("SourceFile: " + cn.sourceFile);
}
if (cn.signature != null) {
sb.append(BytecodeViewer.nl);
sb.append(" ");
sb.append("Signature: " + cn.sourceFile);
}
sb.append(BytecodeViewer.nl);
sb.append("}");
// System.out.println("Wrote end for " + cn.name +

View file

@ -328,10 +328,10 @@ public class InstructionPrinter {
StringBuilder sb = new StringBuilder();
sb.append(nameOpcode(frame.opcode()) + " ");
sb.append("(Locals: ");
sb.append("(Locals");
if (frame.local != null
&& frame.local.size() > 0) {
sb.append(frame.local.size());
sb.append("[" + frame.local.size() + "]:");
sb.append(" ");
sb.append(frame.local.get(0).toString());
if (frame.local.size() > 1) {
@ -341,14 +341,14 @@ public class InstructionPrinter {
}
}
} else {
sb.append("0, null");
sb.append("[0]: null");
}
sb.append(") ");
sb.append("(Stack: ");
sb.append("(Stack");
if (frame.stack != null
&& frame.stack.size() > 0) {
sb.append(frame.stack.size());
sb.append("[" + frame.stack.size() + "]:");
sb.append(" ");
sb.append(frame.stack.get(0).toString());
if (frame.stack.size() > 1) {
@ -358,7 +358,7 @@ public class InstructionPrinter {
}
}
} else {
sb.append("0, null");
sb.append("[0]: null");
}
sb.append(")");

View file

@ -237,6 +237,8 @@ public class MethodNodeDecompiler {
tokens.add("strictfp");
if ((access & Opcodes.ACC_BRIDGE) != 0)
tokens.add("bridge");
if ((access & Opcodes.ACC_SYNTHETIC) != 0)
tokens.add("synthetic");
if ((access & Opcodes.ACC_VARARGS) != 0)
tokens.add("varargs");
if (tokens.size() == 0)