From 0db4c358281f05ef6ed48c653e8f48b72c01b32f Mon Sep 17 00:00:00 2001 From: ItzSomebody <23221108+ItzSomebody@users.noreply.github.com> Date: Tue, 30 Jan 2018 14:50:10 -0800 Subject: [PATCH] Fixed CFR not returning code + some improvements over all --- .../decompilers/CFRDecompiler.java | 26 +++++++------- .../bytecode/ClassNodeDecompiler.java | 35 +++++++++---------- .../bytecode/InstructionPrinter.java | 12 +++---- .../bytecode/MethodNodeDecompiler.java | 2 ++ 4 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/the/bytecode/club/bytecodeviewer/decompilers/CFRDecompiler.java b/src/the/bytecode/club/bytecodeviewer/decompilers/CFRDecompiler.java index c05138c8..29e6ac2a 100644 --- a/src/the/bytecode/club/bytecodeviewer/decompilers/CFRDecompiler.java +++ b/src/the/bytecode/club/bytecodeviewer/decompilers/CFRDecompiler.java @@ -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") diff --git a/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/ClassNodeDecompiler.java b/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/ClassNodeDecompiler.java index d7f220c6..9aaf7e78 100644 --- a/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/ClassNodeDecompiler.java +++ b/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/ClassNodeDecompiler.java @@ -67,6 +67,23 @@ public class ClassNodeDecompiler extends Decompiler { } sb.append(" {"); sb.append(BytecodeViewer.nl); + if (cn.sourceDebug != null) { + sb.append(" "); + sb.append(""); + sb.append(BytecodeViewer.nl); + } + + if (cn.sourceFile != null) { + sb.append(" "); + sb.append(""); + sb.append(BytecodeViewer.nl); + } + + if (cn.signature != null) { + sb.append(" "); + sb.append(""); + } + 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 + diff --git a/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/InstructionPrinter.java b/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/InstructionPrinter.java index e57ab71b..50832b58 100644 --- a/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/InstructionPrinter.java +++ b/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/InstructionPrinter.java @@ -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(")"); diff --git a/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/MethodNodeDecompiler.java b/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/MethodNodeDecompiler.java index 0941f0a3..fdb333cc 100644 --- a/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/MethodNodeDecompiler.java +++ b/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/MethodNodeDecompiler.java @@ -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)