-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1d476de
Showing
8 changed files
with
452 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/.idea | ||
/out |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# java-decompiler-plugin-cfr | ||
基于[CFR](http://www.benf.org/other/cfr/)后端的,用于[IntelliJ IDEA](https://www.jetbrains.com/idea/)的反编译插件。 | ||
|
||
## 已知的问题 | ||
与文本编辑器的Parser系统似乎有些不兼容,右下角会有报错提示,但是可以不用理会。 | ||
|
||
## 为什么做这个 | ||
自带的反编译插件后端有非常多的错误,这个虽然也不完美,但更加强力,可以用来对付原本无法反编译的字节码。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="PLUGIN_MODULE" version="4"> | ||
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/resources/META-INF/plugin.xml" /> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="cfr_0_120" level="project" /> | ||
</component> | ||
</module> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<idea-plugin> | ||
<id>com.i5mc.idea.decompiler.cfr</id> | ||
<name>CFR Decompiler</name> | ||
<version>1.0</version> | ||
<vendor email="[email protected]" url="http://www.i5mc.com">i5mc</vendor> | ||
|
||
<description> | ||
The plugin decompile .class with CFR. | ||
http://www.benf.org/other/cfr/ | ||
</description> | ||
|
||
<change-notes> | ||
- 2017-03-08 INIT | ||
</change-notes> | ||
|
||
<idea-version since-build="145.0"/> | ||
|
||
<extensions defaultExtensionNs="com.intellij"> | ||
<psi.classFileDecompiler implementation="com.i5mc.idea.decompiler.MyDecompiler"/> | ||
</extensions> | ||
</idea-plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.i5mc.idea.decompiler; | ||
|
||
import org.benf.cfr.reader.PluginRunner; | ||
|
||
/** | ||
* Created on 17-3-8. | ||
*/ | ||
public interface Impl { | ||
|
||
String decompile(String path); | ||
|
||
static String fuck(String path) { | ||
PluginRunner r = new PluginRunner(); | ||
r.addJarPath(path); | ||
return r.getDecompilationFor(path); | ||
} | ||
|
||
static String clazz(String path) { | ||
int i = path.lastIndexOf("!/");// filesystem path can contain ! but java can not | ||
if (i == -1) throw new IllegalArgumentException(); | ||
PluginRunner r = new PluginRunner(); | ||
String head = path.substring(0, i); | ||
r.addJarPath(head); | ||
String tail = path.substring(i + 2, path.length() - 6); | ||
return r.getDecompilationFor(tail); | ||
} | ||
|
||
enum Protocol { | ||
|
||
FILE(Impl::fuck), | ||
JAR(Impl::clazz); | ||
|
||
private final Impl impl; | ||
|
||
Protocol(Impl impl) { | ||
this.impl = impl; | ||
} | ||
} | ||
|
||
static String decompile(String protocol, String path) { | ||
try { | ||
return Protocol.valueOf(protocol.toUpperCase()).impl.decompile(path); | ||
} catch (Exception ignore) { | ||
} | ||
return "Plz feed back! (" + protocol + "|" + path + ")"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.i5mc.idea.decompiler | ||
|
||
import com.intellij.openapi.vfs.VirtualFile | ||
import com.intellij.psi.PsiJavaModule | ||
import com.intellij.psi.PsiPackage | ||
import com.intellij.psi.compiled.ClassFileDecompilers | ||
import com.intellij.psi.impl.compiled.ClsFileImpl | ||
|
||
class MyDecompiler : ClassFileDecompilers.Light() { | ||
|
||
override fun accepts(input: VirtualFile): Boolean = true | ||
|
||
override fun getText(input: VirtualFile): CharSequence { | ||
if (PsiPackage.PACKAGE_INFO_CLS_FILE == input.name || PsiJavaModule.MODULE_INFO_CLS_FILE == input.name) { | ||
return ClsFileImpl.decompile(input) | ||
} | ||
return Impl.decompile(input.fileSystem.protocol, input.path) | ||
} | ||
|
||
} |