A bunch of changes for 2.9.3

* -----2.9.3-----:
* 02/28/2015 - Added drag and drop for any file.
* 02/28/2015 - Added ctrl + w to close the current opened tab.
* 02/28/2015 - Updated to CFR 0_97.jar
* 02/28/2015 - Fixed a concurrency issue with the decompilers.
* 02/28/2015 - Added image resize via scroll on mouse.
* 02/28/2015 - Added resource refreshing.
* 02/28/2015 - Im Frizzy started working on Obfuscation.
This commit is contained in:
Kalen Kinloch 2015-02-28 22:24:49 -08:00
parent 90241eb232
commit a1dc3aecc6
26 changed files with 378 additions and 170 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/bin/
.classpath
.project

View File

@ -8,6 +8,6 @@ public class Skeleton extends Plugin {
public void execute(ArrayList<ClassNode> classNodesList) { public void execute(ArrayList<ClassNode> classNodesList) {
PluginConsole gui = new PluginConsole("Skeleton"); PluginConsole gui = new PluginConsole("Skeleton");
gui.setVisible(true); gui.setVisible(true);
gui.appendText("exceuted skeleton"); gui.appendText("executed skeleton");
} }
} }

View File

@ -3,6 +3,7 @@ package the.bytecode.club.bytecodeviewer;
import java.awt.Desktop; import java.awt.Desktop;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -14,7 +15,6 @@ import java.net.URI;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import javax.swing.JDialog; import javax.swing.JDialog;
@ -76,15 +76,22 @@ import the.bytecode.club.bytecodeviewer.obfuscators.mapping.Refactorer;
* bytecode editor that works by editing per method instead of entire class, methods are in a pane like the file navigator * bytecode editor that works by editing per method instead of entire class, methods are in a pane like the file navigator
* Make the tabs menu and middle mouse button click work on the tab itself not just the close button. * Make the tabs menu and middle mouse button click work on the tab itself not just the close button.
* *
* 2.9.2: * before 3.0.0:
* make it use that global last used inside of export as jar * make it use that global last used inside of export as jar
* Spiffy up the plugin console with hilighted lines * Spiffy up the plugin console with hilighted lines
* Take https://github.com/ptnkjke/Java-Bytecode-Editor visualize * Take https://github.com/ptnkjke/Java-Bytecode-Editor visualize
* fix the randomly sometimes fucked up names on file navigation bug * fix the randomly sometimes fucked up names on file navigation bug
* make zipfile not include the decode shit * make zipfile not include the decode shit
* When you drag a folder, it must add the folder name not just the child into the root jtree path
* *
* -----2.9.2-----: * -----2.9.3-----:
* 02/24/2015 - Actually fixed the compiler, LOL. * 02/28/2015 - Added drag and drop for any file.
* 02/28/2015 - Added ctrl + w to close the current opened tab.
* 02/28/2015 - Updated to CFR 0_97.jar
* 02/28/2015 - Fixed a concurrency issue with the decompilers.
* 02/28/2015 - Added image resize via scroll on mouse.
* 02/28/2015 - Added resource refreshing.
* 02/28/2015 - Im Frizzy started working on Obfuscation.
* *
* @author Konloch * @author Konloch
* *
@ -93,7 +100,7 @@ import the.bytecode.club.bytecodeviewer.obfuscators.mapping.Refactorer;
public class BytecodeViewer { public class BytecodeViewer {
/*per version*/ /*per version*/
public static String version = "2.9.2"; public static String version = "2.9.3";
public static String krakatauVersion = "2"; public static String krakatauVersion = "2";
/*the rest*/ /*the rest*/
public static MainViewerGUI viewer = null; public static MainViewerGUI viewer = null;
@ -118,10 +125,7 @@ public class BytecodeViewer {
private static long start = System.currentTimeMillis(); private static long start = System.currentTimeMillis();
public static String lastDirectory = ""; public static String lastDirectory = "";
public static ArrayList<Process> krakatau = new ArrayList<Process>(); public static ArrayList<Process> krakatau = new ArrayList<Process>();
/* ASM Re-mapping Constants */
public static Refactorer refactorer = new Refactorer(); public static Refactorer refactorer = new Refactorer();
/* ASM Re-mapping Constants */
/** /**
* The version checker thread * The version checker thread
@ -354,7 +358,7 @@ public class BytecodeViewer {
* @return the currently opened ClassNode * @return the currently opened ClassNode
*/ */
public static ClassNode getCurrentlyOpenedClassNode() { public static ClassNode getCurrentlyOpenedClassNode() {
return viewer.workPane.getCurrentClass().cn; return viewer.workPane.getCurrentViewer().cn;
} }
/** /**
@ -388,18 +392,6 @@ public class BytecodeViewer {
BytecodeViewer.loadedClasses.remove(oldNode.name); BytecodeViewer.loadedClasses.remove(oldNode.name);
BytecodeViewer.loadedClasses.put(oldNode.name, newNode); BytecodeViewer.loadedClasses.put(oldNode.name, newNode);
} }
/**
* Replaces an old node with a new instance
* @param oldNode the old instance
* @param newNode the new instance
*/
public static void relocate(String name, ClassNode node) {
if (BytecodeViewer.loadedClasses.containsKey(name))
BytecodeViewer.loadedClasses.remove(name);
BytecodeViewer.loadedClasses.put(node.name, node);
}
/** /**
* Gets all of the loaded classes as an array list * Gets all of the loaded classes as an array list
@ -422,9 +414,6 @@ public class BytecodeViewer {
* @return true if no errors, false if it failed to compile. * @return true if no errors, false if it failed to compile.
*/ */
public static boolean compile(boolean message) { public static boolean compile(boolean message) {
if(getLoadedClasses().isEmpty())
return false;
boolean actuallyTried = false; boolean actuallyTried = false;
for(java.awt.Component c : BytecodeViewer.viewer.workPane.getLoadedViewers()) { for(java.awt.Component c : BytecodeViewer.viewer.workPane.getLoadedViewers()) {
@ -620,6 +609,9 @@ public class BytecodeViewer {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
} }
return; return;
} else {
byte[] bytes = JarUtils.getBytes(new FileInputStream(f));
BytecodeViewer.loadedResources.put(f.getName(), bytes);
} }
} }
} }
@ -672,12 +664,10 @@ public class BytecodeViewer {
if(!ask) { if(!ask) {
loadedResources.clear(); loadedResources.clear();
loadedClasses.clear(); loadedClasses.clear();
MainViewerGUI.getComponent(FileNavigationPane.class) MainViewerGUI.getComponent(FileNavigationPane.class).resetWorkspace();
.resetWorkspace();
MainViewerGUI.getComponent(WorkPane.class).resetWorkspace(); MainViewerGUI.getComponent(WorkPane.class).resetWorkspace();
MainViewerGUI.getComponent(SearchingPane.class).resetWorkspace(); MainViewerGUI.getComponent(SearchingPane.class).resetWorkspace();
the.bytecode.club.bytecodeviewer.api.BytecodeViewer the.bytecode.club.bytecodeviewer.api.BytecodeViewer.getClassNodeLoader().clear();
.getClassNodeLoader().clear();
} else { } else {
JOptionPane pane = new JOptionPane( JOptionPane pane = new JOptionPane(
"Are you sure you want to reset the workspace?\n\rIt will also reset your file navigator and search."); "Are you sure you want to reset the workspace?\n\rIt will also reset your file navigator and search.");
@ -695,12 +685,10 @@ public class BytecodeViewer {
if (result == 0) { if (result == 0) {
loadedResources.clear(); loadedResources.clear();
loadedClasses.clear(); loadedClasses.clear();
MainViewerGUI.getComponent(FileNavigationPane.class) MainViewerGUI.getComponent(FileNavigationPane.class).resetWorkspace();
.resetWorkspace();
MainViewerGUI.getComponent(WorkPane.class).resetWorkspace(); MainViewerGUI.getComponent(WorkPane.class).resetWorkspace();
MainViewerGUI.getComponent(SearchingPane.class).resetWorkspace(); MainViewerGUI.getComponent(SearchingPane.class).resetWorkspace();
the.bytecode.club.bytecodeviewer.api.BytecodeViewer the.bytecode.club.bytecodeviewer.api.BytecodeViewer.getClassNodeLoader().clear();
.getClassNodeLoader().clear();
} }
} }
} }
@ -828,6 +816,19 @@ public class BytecodeViewer {
return name; return name;
} }
/**
* Replaces an old node with a new instance
* @param oldNode the old instance
* @param newNode the new instance
*/
public static void relocate(String name, ClassNode node) {
if (BytecodeViewer.loadedClasses.containsKey(name))
BytecodeViewer.loadedClasses.remove(name);
BytecodeViewer.loadedClasses.put(node.name, node);
}
/** /**
* Returns the BCV directory * Returns the BCV directory
* @return the static BCV directory * @return the static BCV directory
@ -876,4 +877,46 @@ public class BytecodeViewer {
s += r + nl; s += r + nl;
return s; return s;
} }
private static long last = System.currentTimeMillis();
/**
* Checks the hotkeys
* @param e
*/
public static void checkHotKey(KeyEvent e) {
if(System.currentTimeMillis() - last <= (4000))
return;
if ((e.getKeyCode() == KeyEvent.VK_O) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
last = System.currentTimeMillis();
JFileChooser fc = new JFileChooser();
try {
fc.setSelectedFile(new File(BytecodeViewer.lastDirectory));
} catch(Exception e2) {
}
fc.setFileFilter(viewer.new APKDEXJarZipClassFileFilter());
fc.setFileHidingEnabled(false);
fc.setAcceptAllFileFilterUsed(false);
int returnVal = fc.showOpenDialog(BytecodeViewer.viewer);
if (returnVal == JFileChooser.APPROVE_OPTION) {
BytecodeViewer.lastDirectory = fc.getSelectedFile().getAbsolutePath();
try {
BytecodeViewer.viewer.setIcon(true);
BytecodeViewer.openFiles(new File[] { fc.getSelectedFile() }, true);
BytecodeViewer.viewer.setIcon(false);
} catch (Exception e1) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1);
}
}
} else if ((e.getKeyCode() == KeyEvent.VK_N) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
last = System.currentTimeMillis();
BytecodeViewer.resetWorkSpace(true);
} else if ((e.getKeyCode() == KeyEvent.VK_W) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
last = System.currentTimeMillis();
if(viewer.workPane.getCurrentViewer() != null)
viewer.workPane.tabs.remove(viewer.workPane.getCurrentViewer());
}
}
} }

View File

@ -55,7 +55,7 @@ public class PluginConsole extends JFrame {
field.requestFocus(); field.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }

View File

@ -36,12 +36,7 @@ public class CFRDecompiler extends Decompiler {
@Override @Override
public void decompileToClass(String className, String classNameSaved) { public void decompileToClass(String className, String classNameSaved) {
String contents = decompileClassNode(BytecodeViewer.getClassNode(className)); ClassNode cn = BytecodeViewer.getClassNode(className);
DiskWriter.replaceFile(classNameSaved, contents, false);
}
@Override
public String decompileClassNode(ClassNode cn) {
final ClassWriter cw = new ClassWriter(0); final ClassWriter cw = new ClassWriter(0);
try { try {
cn.accept(cw); cn.accept(cw);
@ -52,7 +47,12 @@ public class CFRDecompiler extends Decompiler {
cn.accept(cw); cn.accept(cw);
} catch (InterruptedException e1) { } } catch (InterruptedException e1) { }
} }
String contents = decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(classNameSaved, contents, false);
}
@Override
public String decompileClassNode(ClassNode cn, byte[] b) {
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs; String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs;
final File tempClass = new File(MiscUtils.getUniqueName(fileStart, ".class") + ".class"); final File tempClass = new File(MiscUtils.getUniqueName(fileStart, ".class") + ".class");
@ -60,7 +60,7 @@ public class CFRDecompiler extends Decompiler {
try { try {
final FileOutputStream fos = new FileOutputStream(tempClass); final FileOutputStream fos = new FileOutputStream(tempClass);
fos.write(cw.toByteArray()); fos.write(b);
fos.close(); fos.close();
} catch (final IOException e) { } catch (final IOException e) {

View File

@ -13,7 +13,7 @@ import the.bytecode.club.bytecodeviewer.decompilers.bytecode.ClassNodeDecompiler
public abstract class Decompiler { public abstract class Decompiler {
public abstract String decompileClassNode(ClassNode cn); public abstract String decompileClassNode(ClassNode cn, byte[] b);
public abstract void decompileToZip(String zipName); public abstract void decompileToZip(String zipName);

View File

@ -28,7 +28,18 @@ public class FernFlowerDecompiler extends Decompiler {
@Override @Override
public void decompileToClass(String className, String classNameSaved) { public void decompileToClass(String className, String classNameSaved) {
String contents = decompileClassNode(BytecodeViewer.getClassNode(className)); ClassNode cn = BytecodeViewer.getClassNode(className);
final ClassWriter cw = new ClassWriter(0);
try {
cn.accept(cw);
} catch(Exception e) {
e.printStackTrace();
try {
Thread.sleep(200);
cn.accept(cw);
} catch (InterruptedException e1) { }
}
String contents = decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(classNameSaved, contents, false); DiskWriter.replaceFile(classNameSaved, contents, false);
} }
@ -60,10 +71,7 @@ public class FernFlowerDecompiler extends Decompiler {
} }
@Override @Override
public String decompileClassNode(final ClassNode cn) { public String decompileClassNode(final ClassNode cn, byte[] b) {
final ClassWriter cw = new ClassWriter(0);
cn.accept(cw);
String start = MiscUtils.getUniqueName("", ".class"); String start = MiscUtils.getUniqueName("", ".class");
final File tempClass = new File(start + ".class"); final File tempClass = new File(start + ".class");
@ -72,7 +80,7 @@ public class FernFlowerDecompiler extends Decompiler {
try { try {
final FileOutputStream fos = new FileOutputStream(tempClass); final FileOutputStream fos = new FileOutputStream(tempClass);
fos.write(cw.toByteArray()); fos.write(b);
fos.close(); fos.close();
} catch (final IOException e) { } catch (final IOException e) {

View File

@ -25,7 +25,7 @@ import the.bytecode.club.bytecodeviewer.ZipUtils;
public class KrakatauDecompiler extends Decompiler { public class KrakatauDecompiler extends Decompiler {
public String decompileClassNode(ClassNode cn) { public String decompileClassNode(ClassNode cn, byte[] b) {
if(BytecodeViewer.python.equals("")) { if(BytecodeViewer.python.equals("")) {
BytecodeViewer.showMessage("You need to set your Python 2.7 executable path."); BytecodeViewer.showMessage("You need to set your Python 2.7 executable path.");

View File

@ -24,7 +24,7 @@ import the.bytecode.club.bytecodeviewer.MiscUtils;
public class KrakatauDisassembler extends Decompiler { public class KrakatauDisassembler extends Decompiler {
public String decompileClassNode(ClassNode cn) { public String decompileClassNode(ClassNode cn, byte[] b) {
if(BytecodeViewer.python.equals("")) { if(BytecodeViewer.python.equals("")) {
BytecodeViewer.showMessage("You need to set your Python 2.7 executable path."); BytecodeViewer.showMessage("You need to set your Python 2.7 executable path.");
BytecodeViewer.viewer.pythonC(); BytecodeViewer.viewer.pythonC();

View File

@ -53,7 +53,18 @@ public class ProcyonDecompiler extends Decompiler {
@Override @Override
public void decompileToClass(String className, String classNameSaved) { public void decompileToClass(String className, String classNameSaved) {
String contents = decompileClassNode(BytecodeViewer.getClassNode(className)); ClassNode cn = BytecodeViewer.getClassNode(className);
final ClassWriter cw = new ClassWriter(0);
try {
cn.accept(cw);
} catch(Exception e) {
e.printStackTrace();
try {
Thread.sleep(200);
cn.accept(cw);
} catch (InterruptedException e1) { }
}
String contents = decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(classNameSaved, contents, false); DiskWriter.replaceFile(classNameSaved, contents, false);
} }
@ -92,12 +103,9 @@ public class ProcyonDecompiler extends Decompiler {
} }
@Override @Override
public String decompileClassNode(ClassNode cn) { public String decompileClassNode(ClassNode cn, byte[] b) {
String exception = ""; String exception = "";
try { try {
final ClassWriter cw = new ClassWriter(0);
cn.accept(cw);
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs
+ "temp"; + "temp";
@ -106,7 +114,7 @@ public class ProcyonDecompiler extends Decompiler {
try { try {
final FileOutputStream fos = new FileOutputStream(tempClass); final FileOutputStream fos = new FileOutputStream(tempClass);
fos.write(cw.toByteArray()); fos.write(b);
fos.close(); fos.close();
} catch (final IOException e) { } catch (final IOException e) {

View File

@ -6,7 +6,6 @@ import java.io.IOException;
import me.konloch.kontainer.io.DiskReader; import me.konloch.kontainer.io.DiskReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
@ -23,10 +22,7 @@ import the.bytecode.club.bytecodeviewer.ZipUtils;
public class SmaliDisassembler extends Decompiler { public class SmaliDisassembler extends Decompiler {
public String decompileClassNode(ClassNode cn) { public String decompileClassNode(ClassNode cn, byte[] b) {
final ClassWriter cw = new ClassWriter(0);
cn.accept(cw);
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs
+ "temp"; + "temp";
@ -40,7 +36,7 @@ public class SmaliDisassembler extends Decompiler {
try { try {
final FileOutputStream fos = new FileOutputStream(tempClass); final FileOutputStream fos = new FileOutputStream(tempClass);
fos.write(cw.toByteArray()); fos.write(b);
fos.close(); fos.close();
} catch (final IOException e) { } catch (final IOException e) {

View File

@ -21,7 +21,7 @@ import the.bytecode.club.bytecodeviewer.decompilers.Decompiler;
public class ClassNodeDecompiler extends Decompiler { public class ClassNodeDecompiler extends Decompiler {
public String decompileClassNode(ClassNode cn) { public String decompileClassNode(ClassNode cn, byte[] b) {
return decompile(new PrefixedStringBuilder(), return decompile(new PrefixedStringBuilder(),
new ArrayList<String>(), cn).toString(); new ArrayList<String>(), cn).toString();
} }

View File

@ -55,7 +55,7 @@ import the.bytecode.club.bytecodeviewer.decompilers.Decompiler;
* *
*/ */
public class ClassViewer extends JPanel { public class ClassViewer extends Viewer {
/** /**
* Whoever wrote this function, THANK YOU! * Whoever wrote this function, THANK YOU!
@ -544,6 +544,17 @@ public class ClassViewer extends JPanel {
if (pane3 != 0 && pane3 != 5) if (pane3 != 0 && pane3 != 5)
panel3.add(panel3Search, BorderLayout.NORTH); panel3.add(panel3Search, BorderLayout.NORTH);
final ClassWriter cw = new ClassWriter(0);
try {
cn.accept(cw);
} catch(Exception e) {
e.printStackTrace();
try {
Thread.sleep(200);
cn.accept(cw);
} catch (InterruptedException e1) { }
}
final byte[] b = cw.toByteArray();
Thread t1 = new PaneUpdaterThread() { Thread t1 = new PaneUpdaterThread() {
@Override @Override
public void doShit() { public void doShit() {
@ -555,7 +566,7 @@ public class ClassViewer extends JPanel {
panelArea.setCodeFoldingEnabled(true); panelArea.setCodeFoldingEnabled(true);
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane(panelArea); RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
panelArea.setText(Decompiler.procyon.decompileClassNode(cn)); panelArea.setText(Decompiler.procyon.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(BytecodeViewer.viewer.pane1Editable.isSelected()); panelArea.setEditable(BytecodeViewer.viewer.pane1Editable.isSelected());
panelArea.addKeyListener(new KeyListener() { panelArea.addKeyListener(new KeyListener() {
@ -565,7 +576,7 @@ public class ClassViewer extends JPanel {
field1.requestFocus(); field1.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -580,7 +591,7 @@ public class ClassViewer extends JPanel {
panelArea.setCodeFoldingEnabled(true); panelArea.setCodeFoldingEnabled(true);
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane(panelArea); RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
panelArea.setText(Decompiler.cfr.decompileClassNode(cn)); panelArea.setText(Decompiler.cfr.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(BytecodeViewer.viewer.pane1Editable.isSelected()); panelArea.setEditable(BytecodeViewer.viewer.pane1Editable.isSelected());
panelArea.addKeyListener(new KeyListener() { panelArea.addKeyListener(new KeyListener() {
@ -589,7 +600,7 @@ public class ClassViewer extends JPanel {
field1.requestFocus(); field1.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -605,7 +616,7 @@ public class ClassViewer extends JPanel {
panelArea.setCodeFoldingEnabled(true); panelArea.setCodeFoldingEnabled(true);
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane(panelArea); RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
panelArea.setText(Decompiler.fernflower.decompileClassNode(cn)); panelArea.setText(Decompiler.fernflower.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(BytecodeViewer.viewer.pane1Editable.isSelected()); panelArea.setEditable(BytecodeViewer.viewer.pane1Editable.isSelected());
panelArea.addKeyListener(new KeyListener() { panelArea.addKeyListener(new KeyListener() {
@ -614,7 +625,7 @@ public class ClassViewer extends JPanel {
field1.requestFocus(); field1.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -631,7 +642,7 @@ public class ClassViewer extends JPanel {
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane( RTextScrollPane scrollPane = new RTextScrollPane(
panelArea); panelArea);
panelArea.setText(Decompiler.bytecode.decompileClassNode(cn)); panelArea.setText(Decompiler.bytecode.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(false); panelArea.setEditable(false);
panelArea.addKeyListener(new KeyListener() { panelArea.addKeyListener(new KeyListener() {
@ -640,7 +651,7 @@ public class ClassViewer extends JPanel {
field1.requestFocus(); field1.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -663,7 +674,7 @@ public class ClassViewer extends JPanel {
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane( RTextScrollPane scrollPane = new RTextScrollPane(
panelArea); panelArea);
panelArea.setText(Decompiler.smali.decompileClassNode(cn)); panelArea.setText(Decompiler.smali.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(BytecodeViewer.viewer.pane1Editable.isSelected()); panelArea.setEditable(BytecodeViewer.viewer.pane1Editable.isSelected());
smali1 = panelArea; smali1 = panelArea;
@ -673,7 +684,7 @@ public class ClassViewer extends JPanel {
field1.requestFocus(); field1.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -689,7 +700,7 @@ public class ClassViewer extends JPanel {
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane( RTextScrollPane scrollPane = new RTextScrollPane(
panelArea); panelArea);
panelArea.setText(Decompiler.krakatau.decompileClassNode(cn)); panelArea.setText(Decompiler.krakatau.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(BytecodeViewer.viewer.pane1Editable.isSelected()); panelArea.setEditable(BytecodeViewer.viewer.pane1Editable.isSelected());
panelArea.addKeyListener(new KeyListener() { panelArea.addKeyListener(new KeyListener() {
@ -698,7 +709,7 @@ public class ClassViewer extends JPanel {
field1.requestFocus(); field1.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -717,7 +728,7 @@ public class ClassViewer extends JPanel {
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane( RTextScrollPane scrollPane = new RTextScrollPane(
panelArea); panelArea);
panelArea.setText(Decompiler.krakatauDA.decompileClassNode(cn)); panelArea.setText(Decompiler.krakatauDA.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(BytecodeViewer.viewer.pane1Editable.isSelected()); panelArea.setEditable(BytecodeViewer.viewer.pane1Editable.isSelected());
krakatau1 = panelArea; krakatau1 = panelArea;
@ -727,7 +738,7 @@ public class ClassViewer extends JPanel {
field1.requestFocus(); field1.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -757,7 +768,7 @@ public class ClassViewer extends JPanel {
panelArea.setCodeFoldingEnabled(true); panelArea.setCodeFoldingEnabled(true);
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane(panelArea); RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
panelArea.setText(Decompiler.procyon.decompileClassNode(cn)); panelArea.setText(Decompiler.procyon.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(BytecodeViewer.viewer.pane2Editable.isSelected()); panelArea.setEditable(BytecodeViewer.viewer.pane2Editable.isSelected());
panelArea.addKeyListener(new KeyListener() { panelArea.addKeyListener(new KeyListener() {
@ -766,7 +777,7 @@ public class ClassViewer extends JPanel {
field2.requestFocus(); field2.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -782,7 +793,7 @@ public class ClassViewer extends JPanel {
panelArea.setCodeFoldingEnabled(true); panelArea.setCodeFoldingEnabled(true);
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane(panelArea); RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
panelArea.setText(Decompiler.cfr.decompileClassNode(cn)); panelArea.setText(Decompiler.cfr.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(BytecodeViewer.viewer.pane2Editable.isSelected()); panelArea.setEditable(BytecodeViewer.viewer.pane2Editable.isSelected());
panelArea.addKeyListener(new KeyListener() { panelArea.addKeyListener(new KeyListener() {
@ -791,7 +802,7 @@ public class ClassViewer extends JPanel {
field2.requestFocus(); field2.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -807,7 +818,7 @@ public class ClassViewer extends JPanel {
panelArea.setCodeFoldingEnabled(true); panelArea.setCodeFoldingEnabled(true);
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane(panelArea); RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
panelArea.setText(Decompiler.fernflower.decompileClassNode(cn)); panelArea.setText(Decompiler.fernflower.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(BytecodeViewer.viewer.pane2Editable.isSelected()); panelArea.setEditable(BytecodeViewer.viewer.pane2Editable.isSelected());
panelArea.addKeyListener(new KeyListener() { panelArea.addKeyListener(new KeyListener() {
@ -816,7 +827,7 @@ public class ClassViewer extends JPanel {
field2.requestFocus(); field2.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -831,7 +842,7 @@ public class ClassViewer extends JPanel {
panelArea.setCodeFoldingEnabled(true); panelArea.setCodeFoldingEnabled(true);
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane(panelArea); RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
panelArea.setText(Decompiler.bytecode.decompileClassNode(cn)); panelArea.setText(Decompiler.bytecode.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(false); panelArea.setEditable(false);
panelArea.addKeyListener(new KeyListener() { panelArea.addKeyListener(new KeyListener() {
@ -840,7 +851,7 @@ public class ClassViewer extends JPanel {
field2.requestFocus(); field2.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -861,7 +872,7 @@ public class ClassViewer extends JPanel {
panelArea.setCodeFoldingEnabled(true); panelArea.setCodeFoldingEnabled(true);
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane(panelArea); RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
panelArea.setText(Decompiler.smali.decompileClassNode(cn)); panelArea.setText(Decompiler.smali.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(BytecodeViewer.viewer.pane2Editable.isSelected()); panelArea.setEditable(BytecodeViewer.viewer.pane2Editable.isSelected());
smali2 = panelArea; smali2 = panelArea;
@ -871,7 +882,7 @@ public class ClassViewer extends JPanel {
field2.requestFocus(); field2.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -887,7 +898,7 @@ public class ClassViewer extends JPanel {
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane( RTextScrollPane scrollPane = new RTextScrollPane(
panelArea); panelArea);
panelArea.setText(Decompiler.krakatau.decompileClassNode(cn)); panelArea.setText(Decompiler.krakatau.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(BytecodeViewer.viewer.pane2Editable.isSelected()); panelArea.setEditable(BytecodeViewer.viewer.pane2Editable.isSelected());
panelArea.addKeyListener(new KeyListener() { panelArea.addKeyListener(new KeyListener() {
@ -896,7 +907,7 @@ public class ClassViewer extends JPanel {
field2.requestFocus(); field2.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -913,7 +924,7 @@ public class ClassViewer extends JPanel {
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane( RTextScrollPane scrollPane = new RTextScrollPane(
panelArea); panelArea);
panelArea.setText(Decompiler.krakatauDA.decompileClassNode(cn)); panelArea.setText(Decompiler.krakatauDA.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(BytecodeViewer.viewer.pane2Editable.isSelected()); panelArea.setEditable(BytecodeViewer.viewer.pane2Editable.isSelected());
krakatau2 = panelArea; krakatau2 = panelArea;
@ -923,7 +934,7 @@ public class ClassViewer extends JPanel {
field2.requestFocus(); field2.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -954,7 +965,7 @@ public class ClassViewer extends JPanel {
panelArea.setCodeFoldingEnabled(true); panelArea.setCodeFoldingEnabled(true);
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane(panelArea); RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
panelArea.setText(Decompiler.procyon.decompileClassNode(cn)); panelArea.setText(Decompiler.procyon.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(BytecodeViewer.viewer.pane3Editable.isSelected()); panelArea.setEditable(BytecodeViewer.viewer.pane3Editable.isSelected());
panelArea.addKeyListener(new KeyListener() { panelArea.addKeyListener(new KeyListener() {
@ -963,7 +974,7 @@ public class ClassViewer extends JPanel {
field3.requestFocus(); field3.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -979,7 +990,7 @@ public class ClassViewer extends JPanel {
panelArea.setCodeFoldingEnabled(true); panelArea.setCodeFoldingEnabled(true);
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane(panelArea); RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
panelArea.setText(Decompiler.cfr.decompileClassNode(cn)); panelArea.setText(Decompiler.cfr.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(BytecodeViewer.viewer.pane3Editable.isSelected()); panelArea.setEditable(BytecodeViewer.viewer.pane3Editable.isSelected());
panelArea.addKeyListener(new KeyListener() { panelArea.addKeyListener(new KeyListener() {
@ -988,7 +999,7 @@ public class ClassViewer extends JPanel {
field3.requestFocus(); field3.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -1004,7 +1015,7 @@ public class ClassViewer extends JPanel {
panelArea.setCodeFoldingEnabled(true); panelArea.setCodeFoldingEnabled(true);
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane(panelArea); RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
panelArea.setText(Decompiler.fernflower.decompileClassNode(cn)); panelArea.setText(Decompiler.fernflower.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(BytecodeViewer.viewer.pane3Editable.isSelected()); panelArea.setEditable(BytecodeViewer.viewer.pane3Editable.isSelected());
panelArea.addKeyListener(new KeyListener() { panelArea.addKeyListener(new KeyListener() {
@ -1013,7 +1024,7 @@ public class ClassViewer extends JPanel {
field3.requestFocus(); field3.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -1028,7 +1039,7 @@ public class ClassViewer extends JPanel {
panelArea.setCodeFoldingEnabled(true); panelArea.setCodeFoldingEnabled(true);
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane(panelArea); RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
panelArea.setText(Decompiler.bytecode.decompileClassNode(cn)); panelArea.setText(Decompiler.bytecode.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(false); panelArea.setEditable(false);
panelArea.addKeyListener(new KeyListener() { panelArea.addKeyListener(new KeyListener() {
@ -1037,7 +1048,7 @@ public class ClassViewer extends JPanel {
field3.requestFocus(); field3.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -1058,7 +1069,7 @@ public class ClassViewer extends JPanel {
panelArea.setCodeFoldingEnabled(true); panelArea.setCodeFoldingEnabled(true);
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane(panelArea); RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
panelArea.setText(Decompiler.smali.decompileClassNode(cn)); panelArea.setText(Decompiler.smali.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(BytecodeViewer.viewer.pane3Editable.isSelected()); panelArea.setEditable(BytecodeViewer.viewer.pane3Editable.isSelected());
smali3 = panelArea; smali3 = panelArea;
@ -1068,7 +1079,7 @@ public class ClassViewer extends JPanel {
field3.requestFocus(); field3.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -1084,7 +1095,7 @@ public class ClassViewer extends JPanel {
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane( RTextScrollPane scrollPane = new RTextScrollPane(
panelArea); panelArea);
panelArea.setText(Decompiler.krakatau.decompileClassNode(cn)); panelArea.setText(Decompiler.krakatau.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(BytecodeViewer.viewer.pane3Editable.isSelected()); panelArea.setEditable(BytecodeViewer.viewer.pane3Editable.isSelected());
panelArea.addKeyListener(new KeyListener() { panelArea.addKeyListener(new KeyListener() {
@ -1093,7 +1104,7 @@ public class ClassViewer extends JPanel {
field3.requestFocus(); field3.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -1112,7 +1123,7 @@ public class ClassViewer extends JPanel {
panelArea.setAntiAliasingEnabled(true); panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane( RTextScrollPane scrollPane = new RTextScrollPane(
panelArea); panelArea);
panelArea.setText(Decompiler.krakatauDA.decompileClassNode(cn)); panelArea.setText(Decompiler.krakatauDA.decompileClassNode(cn,b));
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
panelArea.setEditable(BytecodeViewer.viewer.pane3Editable.isSelected()); panelArea.setEditable(BytecodeViewer.viewer.pane3Editable.isSelected());
krakatau3 = panelArea; krakatau3 = panelArea;
@ -1122,7 +1133,7 @@ public class ClassViewer extends JPanel {
field3.requestFocus(); field3.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }

View File

@ -2,12 +2,15 @@ package the.bytecode.club.bytecodeviewer.gui;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Image;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder; import java.nio.charset.CharsetEncoder;
@ -26,6 +29,7 @@ import javax.swing.text.JTextComponent;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rsyntaxtextarea.SyntaxConstants; import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
import org.fife.ui.rtextarea.RTextScrollPane; import org.fife.ui.rtextarea.RTextScrollPane;
import org.imgscalr.Scalr;
import com.jhe.hexed.JHexEditor; import com.jhe.hexed.JHexEditor;
@ -39,7 +43,7 @@ import the.bytecode.club.bytecodeviewer.Resources;
* *
*/ */
public class FileViewer extends JPanel { public class FileViewer extends Viewer {
private static final long serialVersionUID = 6103372882168257164L; private static final long serialVersionUID = 6103372882168257164L;
@ -50,6 +54,7 @@ public class FileViewer extends JPanel {
JPanel panel2 = new JPanel(new BorderLayout()); JPanel panel2 = new JPanel(new BorderLayout());
public JCheckBox check = new JCheckBox("Exact"); public JCheckBox check = new JCheckBox("Exact");
final JTextField field = new JTextField(); final JTextField field = new JTextField();
public BufferedImage image;
public void setContents() { public void setContents() {
String name = this.name.toLowerCase(); String name = this.name.toLowerCase();
@ -62,7 +67,7 @@ public class FileViewer extends JPanel {
field.requestFocus(); field.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }
@ -75,9 +80,26 @@ public class FileViewer extends JPanel {
name.endsWith(".gif") || name.endsWith(".tif") || name.endsWith(".bmp")) name.endsWith(".gif") || name.endsWith(".tif") || name.endsWith(".bmp"))
{ {
try { try {
final Image i = ImageIO.read(new ByteArrayInputStream(contents)); //gifs fail cause of this image = ImageIO.read(new ByteArrayInputStream(contents)); //gifs fail cause of this
JLabel label = new JLabel("", new ImageIcon(i), JLabel.CENTER); JLabel label = new JLabel("", new ImageIcon(image), JLabel.CENTER);
panel2.add( label, BorderLayout.CENTER ); panel2.add( label, BorderLayout.CENTER );
panel2.addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
int notches = e.getWheelRotation();
if (notches < 0) {
image = Scalr.resize(image, Scalr.Method.SPEED, image.getWidth() + 10, image.getHeight() + 10);
} else {
image = Scalr.resize(image, Scalr.Method.SPEED, image.getWidth() - 10, image.getHeight() - 10);
}
panel2.removeAll();
JLabel label = new JLabel("", new ImageIcon(image), JLabel.CENTER);
panel2.add( label, BorderLayout.CENTER );
panel2.updateUI();
}
});
return; return;
} catch(Exception e) { } catch(Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
@ -340,4 +362,18 @@ public class FileViewer extends JPanel {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
} }
} }
public void refresh(JButton src) {
panel2.removeAll();
try {
image = ImageIO.read(new ByteArrayInputStream(contents));
} catch (IOException e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
}
JLabel label = new JLabel("", new ImageIcon(image), JLabel.CENTER);
panel2.add( label, BorderLayout.CENTER );
panel2.updateUI();
src.setEnabled(true);
}
} }

View File

@ -385,45 +385,11 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
private class Test implements KeyEventDispatcher { private class Test implements KeyEventDispatcher {
@Override @Override
public boolean dispatchKeyEvent(KeyEvent e) { public boolean dispatchKeyEvent(KeyEvent e) {
checkKey(e); BytecodeViewer.checkHotKey(e);
return false; return false;
} }
} }
long last = System.currentTimeMillis();
public void checkKey(KeyEvent e) {
if(System.currentTimeMillis() - last <= (1000 * 4))
return;
if ((e.getKeyCode() == KeyEvent.VK_O) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
last = System.currentTimeMillis();
JFileChooser fc = new JFileChooser();
try {
fc.setSelectedFile(new File(BytecodeViewer.lastDirectory));
} catch(Exception e2) {
}
fc.setFileFilter(new APKDEXJarZipClassFileFilter());
fc.setFileHidingEnabled(false);
fc.setAcceptAllFileFilterUsed(false);
int returnVal = fc.showOpenDialog(BytecodeViewer.viewer);
if (returnVal == JFileChooser.APPROVE_OPTION) {
BytecodeViewer.lastDirectory = fc.getSelectedFile().getAbsolutePath();
try {
BytecodeViewer.viewer.setIcon(true);
BytecodeViewer.openFiles(new File[] { fc.getSelectedFile() }, true);
BytecodeViewer.viewer.setIcon(false);
} catch (Exception e1) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1);
}
}
} else if ((e.getKeyCode() == KeyEvent.VK_N) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
last = System.currentTimeMillis();
BytecodeViewer.resetWorkSpace(true);
}
}
private final JMenuItem mntmSaveAsApk = new JMenuItem("Save As DEX.."); private final JMenuItem mntmSaveAsApk = new JMenuItem("Save As DEX..");
private final JMenuItem mntmCodeSequenceDiagram = new JMenuItem("Code Sequence Diagram"); private final JMenuItem mntmCodeSequenceDiagram = new JMenuItem("Code Sequence Diagram");
private final JSeparator separator_7 = new JSeparator(); private final JSeparator separator_7 = new JSeparator();
@ -476,7 +442,6 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
public MainViewerGUI() { public MainViewerGUI() {
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new Test()); KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new Test());
mnNewMenu_5.setVisible(true);
this.addWindowStateListener(new WindowAdapter() { this.addWindowStateListener(new WindowAdapter() {
public void windowStateChanged(WindowEvent evt) { public void windowStateChanged(WindowEvent evt) {
int oldState = evt.getOldState(); int oldState = evt.getOldState();
@ -527,7 +492,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
@Override @Override
public void actionPerformed(ActionEvent arg0) { public void actionPerformed(ActionEvent arg0) {
if(refreshOnChange.isSelected()) { if(refreshOnChange.isSelected()) {
if(workPane.getCurrentClass() == null) if(workPane.getCurrentViewer() == null)
return; return;
workPane.refreshClass.doClick(); workPane.refreshClass.doClick();
@ -923,13 +888,13 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
}); });
mntmNewMenuItem_12.addActionListener(new ActionListener() { mntmNewMenuItem_12.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) { public void actionPerformed(ActionEvent arg0) {
if(workPane.getCurrentClass() == null) { if(workPane.getCurrentViewer() == null) {
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file."); BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
return; return;
} }
if(autoCompileSmali.isSelected() && !BytecodeViewer.compile(false)) if(autoCompileSmali.isSelected() && !BytecodeViewer.compile(false))
return; return;
final String s = workPane.getCurrentClass().name; final String s = workPane.getCurrentViewer().name;
JFileChooser fc = new JFileChooser(); JFileChooser fc = new JFileChooser();
fc.setFileFilter(new JavaFileFilter()); fc.setFileFilter(new JavaFileFilter());

View File

@ -164,8 +164,7 @@ public class SearchingPane extends VisibleComponent {
.showMessage("You currently have a search performing in the background, please wait for that to finish."); .showMessage("You currently have a search performing in the background, please wait for that to finish.");
} }
} else if (radius == SearchRadius.Current_Class) { } else if (radius == SearchRadius.Current_Class) {
final ClassViewer cv = MainViewerGUI.getComponent( final Viewer cv = MainViewerGUI.getComponent(WorkPane.class).getCurrentViewer();
WorkPane.class).getCurrentClass();
if (cv != null) { if (cv != null) {
searchType.details.search(cv.cn, srn, searchType.details.search(cv.cn, srn,
exact.isSelected()); exact.isSelected());

View File

@ -59,7 +59,7 @@ public class SystemErrConsole extends JFrame {
field.requestFocus(); field.requestFocus();
} }
BytecodeViewer.viewer.checkKey(e); BytecodeViewer.checkHotKey(e);
} }
@Override public void keyReleased(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { }
@Override public void keyTyped(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { }

View File

@ -0,0 +1,13 @@
package the.bytecode.club.bytecodeviewer.gui;
import javax.swing.JPanel;
import org.objectweb.asm.tree.ClassNode;
public abstract class Viewer extends JPanel {
public ClassNode cn;
public String name;
private static final long serialVersionUID = -2965538493489119191L;
}

View File

@ -33,7 +33,7 @@ public class WorkPane extends VisibleComponent implements ActionListener {
private static final long serialVersionUID = 6542337997679487946L; private static final long serialVersionUID = 6542337997679487946L;
FileChangeNotifier fcn; FileChangeNotifier fcn;
JTabbedPane tabs; public JTabbedPane tabs;
JPanel buttonPanel; JPanel buttonPanel;
JButton refreshClass; JButton refreshClass;
@ -55,7 +55,7 @@ public class WorkPane extends VisibleComponent implements ActionListener {
buttonPanel = new JPanel(new FlowLayout()); buttonPanel = new JPanel(new FlowLayout());
refreshClass = new JButton("Refresh Class"); refreshClass = new JButton("Refresh");
refreshClass.addActionListener(this); refreshClass.addActionListener(this);
buttonPanel.add(refreshClass); buttonPanel.add(refreshClass);
@ -133,8 +133,8 @@ public class WorkPane extends VisibleComponent implements ActionListener {
addFile(name, content); addFile(name, content);
} }
public ClassViewer getCurrentClass() { public Viewer getCurrentViewer() {
return (ClassViewer) tabs.getSelectedComponent(); return (Viewer) tabs.getSelectedComponent();
} }
public java.awt.Component[] getLoadedViewers() { public java.awt.Component[] getLoadedViewers() {
@ -153,11 +153,18 @@ public class WorkPane extends VisibleComponent implements ActionListener {
final JButton src = (JButton) arg0.getSource(); final JButton src = (JButton) arg0.getSource();
if (src == refreshClass) { if (src == refreshClass) {
final Component tabComp = tabs.getSelectedComponent(); final Component tabComp = tabs.getSelectedComponent();
if (tabComp != null && tabComp instanceof ClassViewer) { if (tabComp != null) {
src.setEnabled(false); if(tabComp instanceof ClassViewer) {
BytecodeViewer.viewer.setIcon(true); src.setEnabled(false);
((ClassViewer) tabComp).startPaneUpdater(src); BytecodeViewer.viewer.setIcon(true);
BytecodeViewer.viewer.setIcon(false); ((ClassViewer) tabComp).startPaneUpdater(src);
BytecodeViewer.viewer.setIcon(false);
} else if(tabComp instanceof FileViewer) {
src.setEnabled(false);
BytecodeViewer.viewer.setIcon(true);
((FileViewer) tabComp).refresh(src);
BytecodeViewer.viewer.setIcon(false);
}
} }
} }
} }

View File

@ -0,0 +1,31 @@
package the.bytecode.club.bytecodeviewer.obfuscators;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.api.ASMUtil_OLD;
/**
* Rename classes.
*
* @author Konloch
*
*/
public class RenameClasses extends JavaObfuscator {
@Override
public void obfuscate() {
int stringLength = getStringLength();
System.out.println("Obfuscating class names...");
for (ClassNode c : BytecodeViewer.getLoadedClasses()) {
String newName = generateUniqueName(stringLength);
ASMUtil_OLD.renameClassNode(c.name, newName);
c.name = newName;
}
System.out.println("Obfuscated class names.");
}
}

View File

@ -0,0 +1,36 @@
package the.bytecode.club.bytecodeviewer.obfuscators;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.api.ASMUtil_OLD;
/**
* Rename fields.
*
* @author Konloch
*
*/
public class RenameFields extends JavaObfuscator {
@Override
public void obfuscate() {
int stringLength = getStringLength();
System.out.println("Obfuscating fields names...");
for (ClassNode c : BytecodeViewer.getLoadedClasses()) {
for (Object o : c.fields.toArray()) {
FieldNode f = (FieldNode) o;
String newName = generateUniqueName(stringLength);
ASMUtil_OLD.renameFieldNode(c.name, f.name, f.desc, null,
newName, null);
f.name = newName;
}
}
System.out.println("Obfuscated field names.");
}
}

View File

@ -0,0 +1,55 @@
package the.bytecode.club.bytecodeviewer.obfuscators;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.api.ASMUtil_OLD;
/**
* Rename methods.
*
* @author Konloch
*
*/
public class RenameMethods extends JavaObfuscator {
@Override
public void obfuscate() {
int stringLength = getStringLength();
System.out.println("Obfuscating method names...");
for (ClassNode c : BytecodeViewer.getLoadedClasses()) {
for (Object o : c.methods.toArray()) {
MethodNode m = (MethodNode) o;
if (m.access != Opcodes.ACC_ABSTRACT
&& m.access != Opcodes.ACC_ABSTRACT
+ Opcodes.ACC_STATIC
&& m.access != Opcodes.ACC_ABSTRACT
+ Opcodes.ACC_STATIC + Opcodes.ACC_PUBLIC
&& m.access != Opcodes.ACC_ABSTRACT
+ Opcodes.ACC_STATIC + Opcodes.ACC_PRIVATE
&& m.access != Opcodes.ACC_ABSTRACT
+ Opcodes.ACC_STATIC + Opcodes.ACC_PROTECTED
&& m.access != Opcodes.ACC_ABSTRACT
+ Opcodes.ACC_PUBLIC
&& m.access != Opcodes.ACC_ABSTRACT
+ Opcodes.ACC_PRIVATE
&& m.access != Opcodes.ACC_ABSTRACT
+ Opcodes.ACC_PROTECTED) {
if (!m.name.equals("main") && !m.name.equals("<init>")
&& !m.name.equals("<clinit>")) {
String newName = generateUniqueName(stringLength);
ASMUtil_OLD.renameMethodNode(c.name, m.name, m.desc,
null, newName, null);
}
}
}
}
System.out.println("Obfuscated method names.");
}
}

View File

@ -1,11 +1,10 @@
package the.bytecode.club.bytecodeviewer.obfuscators.rename; package the.bytecode.club.bytecodeviewer.obfuscators.rename;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldNode; import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.MethodNode;
import com.sun.xml.internal.ws.org.objectweb.asm.Opcodes;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.api.ASMUtil_OLD; import the.bytecode.club.bytecodeviewer.api.ASMUtil_OLD;
import the.bytecode.club.bytecodeviewer.obfuscators.JavaObfuscator; import the.bytecode.club.bytecodeviewer.obfuscators.JavaObfuscator;

View File

@ -3,10 +3,7 @@ package the.bytecode.club.bytecodeviewer.obfuscators.rename;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldNode; import org.objectweb.asm.tree.FieldNode;
import com.sun.xml.internal.ws.org.objectweb.asm.Opcodes;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.api.ASMUtil_OLD;
import the.bytecode.club.bytecodeviewer.obfuscators.JavaObfuscator; import the.bytecode.club.bytecodeviewer.obfuscators.JavaObfuscator;
import the.bytecode.club.bytecodeviewer.obfuscators.mapping.data.FieldMappingData; import the.bytecode.club.bytecodeviewer.obfuscators.mapping.data.FieldMappingData;
import the.bytecode.club.bytecodeviewer.obfuscators.mapping.data.MappingData; import the.bytecode.club.bytecodeviewer.obfuscators.mapping.data.MappingData;

View File

@ -19,6 +19,7 @@ import com.mxgraph.view.mxGraph;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Resources; import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.api.Plugin; import the.bytecode.club.bytecodeviewer.api.Plugin;
import the.bytecode.club.bytecodeviewer.gui.ClassViewer;
/** /**
* A simple code sequence diagram. * A simple code sequence diagram.
@ -32,11 +33,11 @@ public class CodeSequenceDiagram extends Plugin {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public void execute(ArrayList<ClassNode> classNodeList) { public void execute(ArrayList<ClassNode> classNodeList) {
if(BytecodeViewer.viewer.workPane.getCurrentClass() == null) { if(BytecodeViewer.viewer.workPane.getCurrentViewer() == null || !(BytecodeViewer.viewer.workPane.getCurrentViewer() instanceof ClassViewer)) {
BytecodeViewer.showMessage("First open a class file."); BytecodeViewer.showMessage("First open a class file.");
return; return;
} }
ClassNode c = BytecodeViewer.viewer.workPane.getCurrentClass().cn; ClassNode c = BytecodeViewer.viewer.workPane.getCurrentViewer().cn;
JFrame frame = new JFrame("Code Sequence Diagram - " +c.name); JFrame frame = new JFrame("Code Sequence Diagram - " +c.name);
frame.setIconImages(Resources.iconList); frame.setIconImages(Resources.iconList);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);