Actually implemented Procyon.
Actually implemented Procyon.
This commit is contained in:
parent
9c1063198d
commit
515ee4f48b
Binary file not shown.
|
@ -115,6 +115,8 @@ import the.bytecode.club.bytecodeviewer.plugins.PluginManager;
|
||||||
* 10/16/2014 - Added Replace Strings plugin.
|
* 10/16/2014 - Added Replace Strings plugin.
|
||||||
* 10/16/2014 - Added a loading icon that displays whenever a background task is being executed.
|
* 10/16/2014 - Added a loading icon that displays whenever a background task is being executed.
|
||||||
* 10/19/2014 - Fixed harcoded \\.
|
* 10/19/2014 - Fixed harcoded \\.
|
||||||
|
* 10/19/2014 - Started importing Procyon and CFR decompilers.
|
||||||
|
* 10/19/2014 - Partially finished importing Procyon and CFR, just need to finish export java files as zip.
|
||||||
*
|
*
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
*
|
*
|
||||||
|
|
|
@ -3,19 +3,31 @@ package the.bytecode.club.bytecodeviewer.decompilers.java;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.util.ArrayList;
|
||||||
import me.konloch.kontainer.io.DiskReader;
|
import java.util.List;
|
||||||
|
|
||||||
import org.objectweb.asm.ClassWriter;
|
import org.objectweb.asm.ClassWriter;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
|
||||||
import com.strobel.decompiler.Decompiler;
|
import com.strobel.decompiler.DecompilationOptions;
|
||||||
import com.strobel.decompiler.DecompilerSettings;
|
import com.strobel.decompiler.DecompilerSettings;
|
||||||
import com.strobel.decompiler.PlainTextOutput;
|
import com.strobel.decompiler.PlainTextOutput;
|
||||||
|
import com.strobel.assembler.InputTypeLoader;
|
||||||
|
import com.strobel.assembler.metadata.Buffer;
|
||||||
|
import com.strobel.assembler.metadata.ITypeLoader;
|
||||||
|
import com.strobel.assembler.metadata.MetadataSystem;
|
||||||
|
import com.strobel.assembler.metadata.TypeDefinition;
|
||||||
|
import com.strobel.assembler.metadata.TypeReference;
|
||||||
|
|
||||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
import the.bytecode.club.bytecodeviewer.JarUtils;
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Konloch
|
||||||
|
* @author DeathMarine
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
public class ProcyonDecompiler extends JavaDecompiler {
|
public class ProcyonDecompiler extends JavaDecompiler {
|
||||||
|
|
||||||
|
@ -40,40 +52,30 @@ public class ProcyonDecompiler extends JavaDecompiler {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
File tempJava = new File(fileStart + getClassNumber(fileStart, ".java") + ".java");
|
|
||||||
|
|
||||||
final FileOutputStream stream = new FileOutputStream(tempJava);
|
DecompilerSettings settings = new DecompilerSettings();
|
||||||
|
LuytenTypeLoader typeLoader = new LuytenTypeLoader();
|
||||||
|
MetadataSystem metadataSystem = new MetadataSystem(typeLoader);
|
||||||
|
TypeReference type = metadataSystem.lookupType(tempClass.getCanonicalPath());
|
||||||
|
|
||||||
try {
|
DecompilationOptions decompilationOptions = new DecompilationOptions();
|
||||||
final OutputStreamWriter writer = new OutputStreamWriter(stream);
|
decompilationOptions.setSettings(DecompilerSettings.javaDefaults());
|
||||||
final PlainTextOutput p = new PlainTextOutput(writer);
|
decompilationOptions.setFullDecompilation(true);
|
||||||
|
|
||||||
try {
|
TypeDefinition resolvedType = null;
|
||||||
Decompiler.decompile(
|
if (type == null || ((resolvedType = type.resolve()) == null)) {
|
||||||
cn.getClass().getCanonicalName(),
|
throw new Exception("Unable to resolve type.");
|
||||||
p,
|
|
||||||
DecompilerSettings.javaDefaults()
|
|
||||||
);
|
|
||||||
} finally {
|
|
||||||
writer.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
stream.close();
|
|
||||||
}
|
}
|
||||||
|
StringWriter stringwriter = new StringWriter();
|
||||||
|
settings.getLanguage().decompileType(resolvedType,
|
||||||
|
new PlainTextOutput(stringwriter), decompilationOptions);
|
||||||
|
String decompiledSource = stringwriter.toString();
|
||||||
|
|
||||||
|
|
||||||
String s = DiskReader.loadAsString(tempJava.getAbsolutePath());
|
return decompiledSource;
|
||||||
|
} catch(Exception e) {
|
||||||
tempJava.delete();
|
|
||||||
tempClass.delete();
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
catch (final Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Procyon error! Send the stacktrace to Konloch at http://the.bytecode.club or konloch@gmail.com";
|
return "Procyon error! Send the stacktrace to Konloch at http://the.bytecode.club or konloch@gmail.com";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,4 +124,36 @@ public class ProcyonDecompiler extends JavaDecompiler {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author DeathMarine
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public final class LuytenTypeLoader implements ITypeLoader {
|
||||||
|
private final List<ITypeLoader> _typeLoaders;
|
||||||
|
|
||||||
|
public LuytenTypeLoader() {
|
||||||
|
_typeLoaders = new ArrayList<ITypeLoader>();
|
||||||
|
_typeLoaders.add(new InputTypeLoader());
|
||||||
|
}
|
||||||
|
|
||||||
|
public final List<ITypeLoader> getTypeLoaders() {
|
||||||
|
return _typeLoaders;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean tryLoadType(final String internalName, final Buffer buffer) {
|
||||||
|
for (final ITypeLoader typeLoader : _typeLoaders) {
|
||||||
|
if (typeLoader.tryLoadType(internalName, buffer)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user