Added stack frame and max computation (CTRL+O)

This commit is contained in:
SuspiciousActivity committed 2018-07-04 18:30:58 +02:00
1 parent 297a3d99c1
commit 6a8242958b
3 files changed
+86 -3

No files matched your search

+20 -2
View File
@@ -6,6 +6,7 @@ import java.awt.EventQueue;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.HeadlessException;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DropTarget;
@@ -77,6 +78,7 @@ public class Main extends JFrame {
public static RSyntaxTextArea textArea;
public static SearchBox searchBox;
public static OptionBox optionBox;
public static JTree tree;
@@ -145,9 +147,11 @@ public class Main extends JFrame {
public Main() {
INSTANCE = this;
searchBox = new SearchBox();
optionBox = new OptionBox();
setTitle("ByteEdit");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 813, 474);
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 407),
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 237), 814, 474);
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
@@ -225,6 +229,13 @@ public class Main extends JFrame {
}
}
}, ctrlS, JComponent.WHEN_FOCUSED);
KeyStroke ctrlO = KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_DOWN_MASK);
textArea.registerKeyboardAction(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
optionBox.setVisible(true);
}
}, ctrlO, JComponent.WHEN_IN_FOCUSED_WINDOW);
textArea.setEditable(true);
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA_DISASSEMBLE);
textArea.setCodeFoldingEnabled(true);
@@ -417,8 +428,15 @@ public class Main extends JFrame {
output.write(entry.getValue());
output.closeEntry();
}
int computeFlags = 0;
if (optionBox.chckbxComputeFrames.isSelected()) {
computeFlags |= ClassWriter.COMPUTE_FRAMES;
}
if (optionBox.chckbxComputeMax.isSelected()) {
computeFlags |= ClassWriter.COMPUTE_MAXS;
}
for (ClassNode element : classes) {
ClassWriter writer = new ClassWriter(0);
ClassWriter writer = new ClassWriter(computeFlags);
element.accept(writer);
output.putNextEntry(new JarEntry(element.name.replaceAll("\\.", "/") + ".class"));
output.write(writer.toByteArray());
+63
View File
@@ -0,0 +1,63 @@
package me.ByteEdit.main;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JCheckBox;
public class OptionBox extends JFrame {
private JPanel contentPane;
public JCheckBox chckbxComputeFrames;
public JCheckBox chckbxComputeMax;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
OptionBox frame = new OptionBox();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public OptionBox() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
setResizable(false);
setTitle("Options");
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 150),
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 100), 300, 200);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
chckbxComputeFrames = new JCheckBox("Compute Frames");
chckbxComputeFrames.setBounds(6, 7, 138, 23);
contentPane.add(chckbxComputeFrames);
chckbxComputeMax = new JCheckBox("Compute Max");
chckbxComputeMax.setBounds(6, 33, 138, 23);
contentPane.add(chckbxComputeMax);
}
}
+3 -1
View File
@@ -1,5 +1,6 @@
package me.ByteEdit.main;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
@@ -35,7 +36,8 @@ public class SearchBox extends JFrame {
setResizable(false);
setTitle("Find/Replace");
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
setBounds(100, 100, 256, 263);
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 128),
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 181), 256, 262);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);