Add ObjectWeb ASM Textifier 'decompiler'
This commit is contained in:
parent
f3a5fee946
commit
86d8018b51
6 changed files with 207 additions and 0 deletions
BIN
libs/asm-util-7.1.jar
Normal file
BIN
libs/asm-util-7.1.jar
Normal file
Binary file not shown.
|
@ -134,6 +134,8 @@ public class Settings {
|
|||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "8", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1JDGUI.getModel()))
|
||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "9", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.asmText1.getModel()))
|
||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "11", false);
|
||||
|
||||
if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2None.getModel()))
|
||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "0", false);
|
||||
|
@ -155,6 +157,8 @@ public class Settings {
|
|||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "8", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2JDGUI.getModel()))
|
||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "9", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.asmText2.getModel()))
|
||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "11", false);
|
||||
|
||||
if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3None.getModel()))
|
||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "0", false);
|
||||
|
@ -176,6 +180,8 @@ public class Settings {
|
|||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "8", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3JDGUI.getModel()))
|
||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "9", false);
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.asmText3.getModel()))
|
||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "11", false);
|
||||
|
||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.refreshOnChange.isSelected()), false);
|
||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.isMaximized), false);
|
||||
|
@ -331,6 +337,8 @@ public class Settings {
|
|||
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.panel1JDGUI.getModel(), true);
|
||||
else if (decompiler == 10)
|
||||
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.jadxJ1.getModel(), true);
|
||||
else if (decompiler == 11)
|
||||
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.asmText1.getModel(), true);
|
||||
|
||||
decompiler = Integer.parseInt(DiskReader.loadString(BytecodeViewer.settingsName, 82, false));
|
||||
if (decompiler == 0)
|
||||
|
@ -355,6 +363,8 @@ public class Settings {
|
|||
BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.panel2JDGUI.getModel(), true);
|
||||
else if (decompiler == 10)
|
||||
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.jadxJ2.getModel(), true);
|
||||
else if (decompiler == 11)
|
||||
BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.asmText2.getModel(), true);
|
||||
|
||||
decompiler = Integer.parseInt(DiskReader.loadString(BytecodeViewer.settingsName, 83, false));
|
||||
if (decompiler == 0)
|
||||
|
@ -379,6 +389,8 @@ public class Settings {
|
|||
BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.panel3JDGUI.getModel(), true);
|
||||
else if (decompiler == 10)
|
||||
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.jadxJ3.getModel(), true);
|
||||
else if (decompiler == 11)
|
||||
BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.asmText3.getModel(), true);
|
||||
|
||||
BytecodeViewer.viewer.refreshOnChange.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 84, false)));
|
||||
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package the.bytecode.club.bytecodeviewer.decompilers;
|
||||
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.util.Textifier;
|
||||
import org.objectweb.asm.util.TraceClassVisitor;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/***************************************************************************
|
||||
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
||||
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
/**
|
||||
* Objectweb ASM Textifier output
|
||||
*
|
||||
* @author Thiakil
|
||||
*/
|
||||
public class ASMTextifierDecompiler extends Decompiler {
|
||||
@Override
|
||||
public String decompileClassNode(ClassNode cn, byte[] b) {
|
||||
StringWriter writer = new StringWriter();
|
||||
cn.accept(new TraceClassVisitor(null, new Textifier(), new PrintWriter(writer)));
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decompileToZip(String sourceJar, String zipName) {
|
||||
|
||||
}
|
||||
}
|
|
@ -39,6 +39,7 @@ public abstract class Decompiler {
|
|||
public final static SmaliDisassembler smali = new SmaliDisassembler();
|
||||
public final static Decompiler jdgui = new JDGUIDecompiler();
|
||||
public final static Decompiler jadx = new JADXDecompiler();
|
||||
public final static Decompiler textifier = new ASMTextifierDecompiler();
|
||||
|
||||
public abstract String decompileClassNode(ClassNode cn, byte[] b);
|
||||
|
||||
|
|
|
@ -901,6 +901,50 @@ public class ClassViewer extends Viewer
|
|||
|
||||
java1 = panelArea;
|
||||
}
|
||||
|
||||
if (pane1 == 11) {// asm text
|
||||
panelArea = new RSyntaxTextArea();
|
||||
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
panelArea.setAntiAliasingEnabled(true);
|
||||
scrollPane = new RTextScrollPane(panelArea);
|
||||
panelArea.setText(Decompiler.textifier.decompileClassNode(cn, b));
|
||||
panelArea.setCaretPosition(0);
|
||||
panelArea.setEditable(false);
|
||||
panelArea.addKeyListener(new KeyListener()
|
||||
{
|
||||
public void keyPressed(KeyEvent e)
|
||||
{
|
||||
if ((e.getKeyCode() == KeyEvent.VK_F) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0))
|
||||
{
|
||||
field1.requestFocus();
|
||||
}
|
||||
|
||||
BytecodeViewer.checkHotKey(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent arg0)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent arg0)
|
||||
{
|
||||
}
|
||||
});
|
||||
scrollPane.setColumnHeaderView(new JLabel("ASM Textified - Editable: " + panelArea.isEditable()));
|
||||
panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue()));
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
panel1.add(scrollPane);
|
||||
}
|
||||
});
|
||||
java1 = panelArea;
|
||||
}
|
||||
|
||||
} catch (java.lang.IndexOutOfBoundsException | java.lang.NullPointerException e) {
|
||||
//ignore
|
||||
} catch (Exception e) {
|
||||
|
@ -1284,6 +1328,49 @@ public class ClassViewer extends Viewer
|
|||
|
||||
java2 = panelArea;
|
||||
}
|
||||
|
||||
if (pane2 == 11) {// asm text
|
||||
panelArea = new RSyntaxTextArea();
|
||||
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
panelArea.setAntiAliasingEnabled(true);
|
||||
scrollPane = new RTextScrollPane(panelArea);
|
||||
panelArea.setText(Decompiler.textifier.decompileClassNode(cn, b));
|
||||
panelArea.setCaretPosition(0);
|
||||
panelArea.setEditable(false);
|
||||
panelArea.addKeyListener(new KeyListener()
|
||||
{
|
||||
public void keyPressed(KeyEvent e)
|
||||
{
|
||||
if ((e.getKeyCode() == KeyEvent.VK_F) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0))
|
||||
{
|
||||
field2.requestFocus();
|
||||
}
|
||||
|
||||
BytecodeViewer.checkHotKey(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent arg0)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent arg0)
|
||||
{
|
||||
}
|
||||
});
|
||||
scrollPane.setColumnHeaderView(new JLabel("ASM Textified - Editable: " + panelArea.isEditable()));
|
||||
panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue()));
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
panel2.add(scrollPane);
|
||||
}
|
||||
});
|
||||
java2 = panelArea;
|
||||
}
|
||||
} catch (java.lang.IndexOutOfBoundsException | java.lang.NullPointerException e) {
|
||||
//ignore
|
||||
} catch (Exception e) {
|
||||
|
@ -1667,6 +1754,49 @@ public class ClassViewer extends Viewer
|
|||
|
||||
java3 = panelArea;
|
||||
}
|
||||
|
||||
if (pane3 == 11) {// asm text
|
||||
panelArea = new RSyntaxTextArea();
|
||||
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
panelArea.setAntiAliasingEnabled(true);
|
||||
scrollPane = new RTextScrollPane(panelArea);
|
||||
panelArea.setText(Decompiler.textifier.decompileClassNode(cn, b));
|
||||
panelArea.setCaretPosition(0);
|
||||
panelArea.setEditable(false);
|
||||
panelArea.addKeyListener(new KeyListener()
|
||||
{
|
||||
public void keyPressed(KeyEvent e)
|
||||
{
|
||||
if ((e.getKeyCode() == KeyEvent.VK_F) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0))
|
||||
{
|
||||
field3.requestFocus();
|
||||
}
|
||||
|
||||
BytecodeViewer.checkHotKey(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent arg0)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent arg0)
|
||||
{
|
||||
}
|
||||
});
|
||||
scrollPane.setColumnHeaderView(new JLabel("ASM Textified - Editable: " + panelArea.isEditable()));
|
||||
panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue()));
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
panel3.add(scrollPane);
|
||||
}
|
||||
});
|
||||
java3 = panelArea;
|
||||
}
|
||||
} catch (java.lang.IndexOutOfBoundsException | java.lang.NullPointerException e) {
|
||||
//ignore
|
||||
} catch (Exception e) {
|
||||
|
@ -1857,6 +1987,8 @@ public class ClassViewer extends Viewer
|
|||
pane1 = 9;
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.jadxJ1.getModel()))
|
||||
pane1 = 10;
|
||||
else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.asmText1.getModel()))
|
||||
pane1 = 11;
|
||||
|
||||
if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2None.getModel()))
|
||||
pane2 = 0;
|
||||
|
@ -1880,6 +2012,8 @@ public class ClassViewer extends Viewer
|
|||
pane2 = 9;
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.jadxJ2.getModel()))
|
||||
pane2 = 10;
|
||||
else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.asmText2.getModel()))
|
||||
pane2 = 11;
|
||||
|
||||
if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3None.getModel()))
|
||||
pane3 = 0;
|
||||
|
@ -1903,6 +2037,8 @@ public class ClassViewer extends Viewer
|
|||
pane3 = 9;
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.jadxJ3.getModel()))
|
||||
pane3 = 10;
|
||||
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.asmText3.getModel()))
|
||||
pane3 = 11;
|
||||
}
|
||||
|
||||
public boolean isPanel1Editable()
|
||||
|
|
|
@ -426,6 +426,10 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier
|
|||
public final JRadioButtonMenuItem jadxJ3 = new JRadioButtonMenuItem("Java");
|
||||
public final JCheckBoxMenuItem jadxE3 = new JCheckBoxMenuItem("Editable");
|
||||
|
||||
public final JRadioButtonMenuItem asmText1 = new JRadioButtonMenuItem("ASM Textify");
|
||||
public final JRadioButtonMenuItem asmText2 = new JRadioButtonMenuItem("ASM Textify");
|
||||
public final JRadioButtonMenuItem asmText3 = new JRadioButtonMenuItem("ASM Textify");
|
||||
|
||||
private final JMenu mnFontSize = new JMenu("Font Size");
|
||||
private final JMenu visualSettings = new JMenu("Visual Settings");
|
||||
public final JSpinner fontSpinner = new JSpinner();
|
||||
|
@ -1825,6 +1829,8 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier
|
|||
|
||||
mnNewMenu_7.add(panel1Hexcode);
|
||||
|
||||
mnNewMenu_7.add(asmText1);
|
||||
|
||||
mnNewMenu_6.add(mnPane);
|
||||
|
||||
mnPane.add(panel2None);
|
||||
|
@ -1891,6 +1897,8 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier
|
|||
|
||||
mnPane.add(panel2Hexcode);
|
||||
|
||||
mnPane.add(asmText2);
|
||||
|
||||
mnNewMenu_6.add(mnPane_1);
|
||||
|
||||
mnPane_1.add(panel3None);
|
||||
|
@ -1956,6 +1964,8 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier
|
|||
|
||||
mnPane_1.add(panel3Hexcode);
|
||||
|
||||
mnPane_1.add(asmText3);
|
||||
|
||||
compileOnSave.setSelected(false);
|
||||
|
||||
menuBar.add(mnSettings);
|
||||
|
@ -2535,6 +2545,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier
|
|||
panelGroup1.add(panel1Smali);
|
||||
panelGroup1.add(panel1Bytecode);
|
||||
panelGroup1.add(panel1Hexcode);
|
||||
panelGroup1.add(asmText1);
|
||||
|
||||
panelGroup2.add(panel2None);
|
||||
panelGroup2.add(panel2Proc);
|
||||
|
@ -2547,6 +2558,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier
|
|||
panelGroup2.add(panel2Smali);
|
||||
panelGroup2.add(panel2Bytecode);
|
||||
panelGroup2.add(panel2Hexcode);
|
||||
panelGroup2.add(asmText2);
|
||||
|
||||
panelGroup3.add(panel3None);
|
||||
panelGroup3.add(panel3Proc);
|
||||
|
@ -2559,6 +2571,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier
|
|||
panelGroup3.add(panel3Smali);
|
||||
panelGroup3.add(panel3Bytecode);
|
||||
panelGroup3.add(panel3Hexcode);
|
||||
panelGroup3.add(asmText3);
|
||||
|
||||
fontSpinner.setPreferredSize(new Dimension(42, 20));
|
||||
fontSpinner.setSize(new Dimension(42, 20));
|
||||
|
|
Loading…
Reference in a new issue