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 a loading icon that displays whenever a background task is being executed.
|
||||
* 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
|
||||
*
|
||||
|
|
|
@ -3,19 +3,31 @@ package the.bytecode.club.bytecodeviewer.decompilers.java;
|
|||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
||||
import me.konloch.kontainer.io.DiskReader;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
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.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.JarUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Konloch
|
||||
* @author DeathMarine
|
||||
*
|
||||
*/
|
||||
|
||||
public class ProcyonDecompiler extends JavaDecompiler {
|
||||
|
||||
|
@ -40,40 +52,30 @@ public class ProcyonDecompiler extends JavaDecompiler {
|
|||
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 {
|
||||
final OutputStreamWriter writer = new OutputStreamWriter(stream);
|
||||
final PlainTextOutput p = new PlainTextOutput(writer);
|
||||
DecompilationOptions decompilationOptions = new DecompilationOptions();
|
||||
decompilationOptions.setSettings(DecompilerSettings.javaDefaults());
|
||||
decompilationOptions.setFullDecompilation(true);
|
||||
|
||||
try {
|
||||
Decompiler.decompile(
|
||||
cn.getClass().getCanonicalName(),
|
||||
p,
|
||||
DecompilerSettings.javaDefaults()
|
||||
);
|
||||
} finally {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
stream.close();
|
||||
TypeDefinition resolvedType = null;
|
||||
if (type == null || ((resolvedType = type.resolve()) == null)) {
|
||||
throw new Exception("Unable to resolve type.");
|
||||
}
|
||||
StringWriter stringwriter = new StringWriter();
|
||||
settings.getLanguage().decompileType(resolvedType,
|
||||
new PlainTextOutput(stringwriter), decompilationOptions);
|
||||
String decompiledSource = stringwriter.toString();
|
||||
|
||||
|
||||
String s = DiskReader.loadAsString(tempJava.getAbsolutePath());
|
||||
|
||||
tempJava.delete();
|
||||
tempClass.delete();
|
||||
|
||||
return s;
|
||||
}
|
||||
catch (final Exception e) {
|
||||
return decompiledSource;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
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