diff --git a/README.md b/README.md index 61aaefb..de5f92c 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,42 @@ # AngryGhidra -
+
-The plugin allows you to use [angr](https://github.com/angr/angr) for binary analysis and symbolic execution from Ghidra interface.
+The plugin allows you to use [angr](https://github.com/angr/angr) for binary analysis and symbolic execution in Ghidra interface.
Solving [CTF challenge from SecurityFest 2016 "fairlight"](https://github.com/angr/angr-doc/blob/master/examples/securityfest_fairlight/fairlight) with AngryGhidra plugin:
-![AngryGhidra Plugin](./images/AngryGhidraPlugin.gif)
+![AngryGhidra Plugin](./images/AngryPluginDemo.gif)
-# Screenshots
-
-![AngryGhidraView](./images/AngryGhidraView.png)
+# Hotkeys
-Apply patched bytes to write them to the memory of angr project:
-
-![ApplyPatchedBytes](./images/ApplyPatchedBytes.png)
+##### Set:
+`Z` – **destination** address
+`X` – **start** address
+`J` – **avoid** address (multiple choice)
-# Installation
-
-- `pip3 install angr` at first
-- Make sure that python3 directory added to the `PATH` (required, `python3` only)
-- Download Release version of extension and install it in Ghidra `File → Install Extensions...`
-- Use gradle to build extension: `GHIDRA_INSTALL_DIR=${GHIDRA_HOME} gradle` and use Ghidra to install it: `File → Install Extensions...`
+##### Reset:
+`K` – **destination** address
+`T` – **start** address
+`P` – **avoid** address
+##### Apply bytes:
+`U` – apply patched bytes to angr project memory
+# Screenshots
+Let's keygen:
+![AngryGhidraView](./images/View.png)
+Apply patched bytes to write them into the memory of angr project:
+![ApplyPatchedBytes](./images/ApplyPatchedBytes.png)
+# Installation
+1) `pip3 install angr`
+2) Make sure `python3` directory is added to the `PATH` (required, `Python 3` only)
+3) Download the release version of the plugin and install it in Ghidra `File → Install Extensions...`
+4) Use Gradle to build the plugin: `GHIDRA_INSTALL_DIR=${GHIDRA_HOME} gradle` and use Ghidra to install it: `File → Install Extensions...`
+5) Check the box in the "New Plugins Found" window to apply AngryGhidra plugin to your project
diff --git a/angryghidra_script/angryghidra.py b/angryghidra_script/angryghidra.py
index ae44fa5..29e4190 100644
--- a/angryghidra_script/angryghidra.py
+++ b/angryghidra_script/angryghidra.py
@@ -2,17 +2,16 @@
import angr
import claripy
import json
-import time
-EXPLORE_OPT = {} # Explore options
-REGISTERS = [] # Main registers of your binary
+EXPLORE_OPT = {}
+REGISTERS = []
SYMVECTORS = []
-
def hook_function(state):
+ global SYMVECTORS
for object in EXPLORE_OPT["hooks"]:
for frame in object.items():
- if frame[0] == str(hex(state.solver.eval(state.regs.ip))):
+ if frame[0] == hex(state.solver.eval(state.regs.ip)):
for option, data in frame[1].items():
if "sv" in data:
symbvector_length = int(data[2:], 0)
@@ -26,14 +25,18 @@ def hook_function(state):
setattr(state.regs, option, data)
break
-
def main(file):
+ global EXPLORE_OPT
+ global REGISTERS
+ global SYMVECTORS
+ find = None
+ avoid = None
+ blank_state = None
+ vectors = None
+
with open(file, encoding='utf-8') as json_file:
- global EXPLORE_OPT
EXPLORE_OPT = json.load(json_file)
- # Options parser
- # JSON can't handle with hex values, so we need to do it manually
if "blank_state" in EXPLORE_OPT:
blank_state = int(EXPLORE_OPT["blank_state"], 16)
@@ -61,12 +64,11 @@ def main(file):
else:
p = angr.Project(EXPLORE_OPT["binary_file"], load_options={'main_opts': {'base_addr': base_address}, "auto_load_libs": EXPLORE_OPT["auto_load_libs"]})
- global REGISTERS
REGISTERS = p.arch.default_symbolic_registers
if len(argv) > 1:
state = p.factory.entry_state(args=argv)
- elif "blank_state" in locals():
+ elif blank_state != None:
state = p.factory.blank_state(addr=blank_state)
else:
state = p.factory.entry_state()
@@ -89,7 +91,7 @@ def main(file):
store_length = len(value) - 2
state.memory.store(store_addr, state.solver.BVV(store_value, 4 * store_length))
- # Handle Symbolic Registers
+ # Handle symbolic registers
if "regs_vals" in EXPLORE_OPT:
for register, data in EXPLORE_OPT["regs_vals"].items():
if "sv" in data:
@@ -104,43 +106,48 @@ def main(file):
setattr(state.regs, register, data)
break
- # Handle Hooks
+ # Handle hooks
if "hooks" in EXPLORE_OPT:
for object in EXPLORE_OPT["hooks"]:
for frame in object.items():
hook_address = frame[0]
for option, data in frame[1].items():
data = int(str(data), 0)
- if option == "Length":
+ if option == "length":
hook_length = data
break
p.hook(int(hook_address, 16), hook_function, length=hook_length)
simgr = p.factory.simulation_manager(state)
- if "avoid_address" in locals():
+ if avoid != None:
simgr.use_technique(angr.exploration_techniques.Explorer(find=find, avoid=avoid))
else:
simgr.use_technique(angr.exploration_techniques.Explorer(find=find))
-
simgr.run()
if simgr.found:
found_path = simgr.found[0]
-
win_sequence = ""
+ finishedTracing = False
for win_block in found_path.history.bbl_addrs.hardcopy:
win_block = p.factory.block(win_block)
addresses = win_block.instruction_addrs
for address in addresses:
- win_sequence += hex(address) + ","
+ win_sequence += 't:' + hex(address) + '\n'
+ if address == find:
+ # Prevent sending the rest of the block addresses that aren't desired
+ finishedTracing = True
+ break
+ if finishedTracing:
+ break
win_sequence = win_sequence[:-1]
- print("Trace:" + win_sequence)
+ print(win_sequence)
if len(argv) > 1:
for i in range(1, len(argv)):
print("argv[{id}] = {solution}".format(id=i, solution=found_path.solver.eval(argv[i], cast_to=bytes)))
- if "vectors" in locals() and len(vectors) != 0:
+ if vectors != None and len(vectors) != 0:
for address, length in vectors.items():
print("{addr} = {value}".format(addr=hex(address),
value=found_path.solver.eval(found_path.memory.load(address, length),
@@ -167,5 +174,4 @@ def main(file):
if len(sys.argv) < 2:
print("Usage: *thisScript.py* angr_options.json")
exit()
- file = sys.argv[1]
- main(file)
+ main(sys.argv[1])
diff --git a/images/AngryGhidraPlugin.gif b/images/AngryGhidraPlugin.gif
deleted file mode 100644
index 6b82fbf..0000000
Binary files a/images/AngryGhidraPlugin.gif and /dev/null differ
diff --git a/images/AngryGhidraView.png b/images/AngryGhidraView.png
deleted file mode 100644
index fcf51a8..0000000
Binary files a/images/AngryGhidraView.png and /dev/null differ
diff --git a/images/AngryPluginDemo.gif b/images/AngryPluginDemo.gif
new file mode 100644
index 0000000..609bd02
Binary files /dev/null and b/images/AngryPluginDemo.gif differ
diff --git a/images/ApplyPatchedBytes.png b/images/ApplyPatchedBytes.png
index 0a0b873..6538988 100644
Binary files a/images/ApplyPatchedBytes.png and b/images/ApplyPatchedBytes.png differ
diff --git a/images/angryGhidraIcon.png b/images/Icon.png
similarity index 100%
rename from images/angryGhidraIcon.png
rename to images/Icon.png
diff --git a/images/View.png b/images/View.png
new file mode 100644
index 0000000..095ba24
Binary files /dev/null and b/images/View.png differ
diff --git a/src/main/java/angryghidra/AngrProcessing.java b/src/main/java/angryghidra/AngrProcessing.java
new file mode 100644
index 0000000..701233d
--- /dev/null
+++ b/src/main/java/angryghidra/AngrProcessing.java
@@ -0,0 +1,249 @@
+package angryghidra;
+
+import java.awt.Color;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.InputStreamReader;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JLabel;
+import javax.swing.JScrollPane;
+import javax.swing.SwingUtilities;
+import javax.swing.SwingWorker;
+import ghidra.program.model.address.Address;
+import ghidra.program.model.address.AddressFactory;
+
+
+public class AngrProcessing {
+ private AddressFactory mAddressFactory;
+ private LocalColorizingService mColorService;
+ private UserAddressStorage mAddressStorage;
+ private AngryGhidraProvider mProvider;
+ private String solution;
+ private JLabel statusLabelFound;
+ private JLabel statusLabel;
+ private JScrollPane scrollSolutionTextArea;
+ private List
Hint: to create and store symbolic vector enter \"sv{length}\", for example \"sv16\"";
+ public final String configuringString = "[+] Configuring options";
+ private boolean isHookWindowClosed;
+ private boolean isTerminated;
+ private boolean isWindows;
+ private int guiRegNextId;
+ private int guiArgNextId;
+ private int guiMemNextId;
+ private int guiStoreNextId;
+ private String tmpDir;
private Program thisProgram;
- private String solution;
- private String insntrace;
- private JTextArea SolutionArea;
- private JScrollPane scrollSolution;
- private JCheckBox chckbxAutoloadlibs;
+ private LocalColorizingService mColorService;
+ private HookHandler hookHandler;
+ private AngrProcessing angrProcessing;
+ private UserAddressStorage addressStorage;
+ private JPanel mainPanel;
+ private JPanel customOptionsPanel;
+ private JPanel argumentsPanel;
+ private JPanel mainOptionsPanel;
+ private JPanel statusPanel;
+ private JPanel hookLablesPanel;
+ private JPanel writeMemoryPanel;
+ private JPanel argSetterPanel;
+ private JPanel vectorsPanel;
+ private JPanel regPanel;
+ private JScrollPane scrollSolutionTextArea;
+ private JScrollPane scrollAvoidAddrsArea;
+ private JTextField blankStateTF;
+ private JTextField dstAddressTF;
+ private JTextField valueTF;
+ private JTextField registerTF;
+ private IntegerTextField firstArgTF;
+ private IntegerTextField vectorAddressTF;
+ private IntegerTextField vectorLenTF;
+ private IntegerTextField memStoreAddrTF;
+ private IntegerTextField memStoreValueTF;
+ private JCheckBox chckbxBlankState;
+ private JCheckBox chckbxAvoidAddresses;
+ private JCheckBox chckbxAutoLoadLibs;
private JCheckBox chckbxArg;
- private Boolean isTerminated;
- private JPanel EndPanel;
- private String TmpDir;
- private JScrollPane scroll;
- private JPanel MemPanel;
- private JPanel RegPanel;
- private JTextField TFReg1;
- static JPanel WMPanel;
- private JPanel ArgPanel;
- private JButton btnAddWM;
+ private JTextArea avoidTextArea;
+ private JTextArea solutionTextArea;
+ private JLabel statusLabel;
+ private JLabel statusLabelFound;
+ private JLabel lbStatus;
private JLabel lbStoreAddr;
private JLabel lbStoreVal;
private JLabel lblWriteToMemory;
- public static JPanel RegHookPanel;
- public static Map
Hint: to create and store symbolic vector enter \"sv{length}\", for example \"sv16\"");
- lbRegisters.setHorizontalAlignment(SwingConstants.CENTER);
- lbRegisters.setFont(new Font("SansSerif", Font.PLAIN, 12));
+ lbMemory.setFont(sansSerif12);
+ JLabel lbRegisters = new JLabel(htmlString);
+ lbRegisters.setFont(sansSerif12);
- RegPanel = new JPanel();
-
- WMPanel = new JPanel();
- WMPanel.setBorder(null);
- GridBagLayout gbl_WMPanel = new GridBagLayout();
- gbl_WMPanel.columnWidths = new int[] {
+ GridBagLayout gbl_writeMemoryPanel = new GridBagLayout();
+ gbl_writeMemoryPanel.columnWidths = new int[] {
0,
0,
0,
@@ -514,12 +552,12 @@ public void itemStateChanged(ItemEvent e) {
0,
0
};
- gbl_WMPanel.rowHeights = new int[] {
+ gbl_writeMemoryPanel.rowHeights = new int[] {
0,
0,
0
};
- gbl_WMPanel.columnWeights = new double[] {
+ gbl_writeMemoryPanel.columnWeights = new double[] {
0.0,
0.0,
0.0,
@@ -527,58 +565,58 @@ public void itemStateChanged(ItemEvent e) {
0.0,
Double.MIN_VALUE
};
- gbl_WMPanel.rowWeights = new double[] {
+ gbl_writeMemoryPanel.rowWeights = new double[] {
0.0,
0.0,
Double.MIN_VALUE
};
- WMPanel.setLayout(gbl_WMPanel);
+ writeMemoryPanel.setLayout(gbl_writeMemoryPanel);
lblWriteToMemory = new JLabel("Write to memory:");
lblWriteToMemory.setHorizontalAlignment(SwingConstants.CENTER);
- lblWriteToMemory.setFont(new Font("SansSerif", Font.PLAIN, 12));
+ lblWriteToMemory.setFont(sansSerif12);
lbStoreAddr = new JLabel("Address");
- lbStoreAddr.setFont(new Font("SansSerif", Font.PLAIN, 12));
+ lbStoreAddr.setFont(sansSerif12);
GridBagConstraints gbc_lbStoreAddr = new GridBagConstraints();
gbc_lbStoreAddr.weightx = 1.0;
gbc_lbStoreAddr.insets = new Insets(0, 0, 0, 5);
gbc_lbStoreAddr.gridx = 1;
gbc_lbStoreAddr.gridy = 0;
- WMPanel.add(lbStoreAddr, gbc_lbStoreAddr);
+ writeMemoryPanel.add(lbStoreAddr, gbc_lbStoreAddr);
lbStoreVal = new JLabel("Value");
- lbStoreVal.setFont(new Font("SansSerif", Font.PLAIN, 12));
+ lbStoreVal.setFont(sansSerif12);
GridBagConstraints gbc_lbStoreVal = new GridBagConstraints();
gbc_lbStoreVal.weightx = 1.0;
gbc_lbStoreVal.insets = new Insets(0, 0, 0, 5);
gbc_lbStoreVal.gridx = 3;
gbc_lbStoreVal.gridy = 0;
- WMPanel.add(lbStoreVal, gbc_lbStoreVal);
-
- TFstore_addr = new IntegerTextField();
- TFstore_addr.setHexMode();
- GridBagConstraints gbc_TFstore_addr = new GridBagConstraints();
- gbc_TFstore_addr.anchor = GridBagConstraints.NORTH;
- gbc_TFstore_addr.fill = GridBagConstraints.HORIZONTAL;
- gbc_TFstore_addr.insets = new Insets(0, 0, 0, 5);
- gbc_TFstore_addr.gridx = 1;
- gbc_TFstore_addr.gridy = 1;
- gbc_TFstore_addr.weightx = 1;
- gbc_TFstore_addr.weighty = 0.1;
- WMPanel.add(TFstore_addr.getComponent(), gbc_TFstore_addr);
-
- TFstore_val = new IntegerTextField();
- TFstore_val.setHexMode();
- GridBagConstraints gbc_TFstore_val = new GridBagConstraints();
- gbc_TFstore_val.insets = new Insets(0, 0, 0, 5);
- gbc_TFstore_val.fill = GridBagConstraints.HORIZONTAL;
- gbc_TFstore_val.anchor = GridBagConstraints.NORTH;
- gbc_TFstore_val.gridx = 3;
- gbc_TFstore_val.gridy = 1;
- gbc_TFstore_val.weightx = 1;
- gbc_TFstore_val.weighty = 0.1;
- WMPanel.add(TFstore_val.getComponent(), gbc_TFstore_val);
+ writeMemoryPanel.add(lbStoreVal, gbc_lbStoreVal);
+
+ memStoreAddrTF = new IntegerTextField();
+ memStoreAddrTF.setHexMode();
+ GridBagConstraints gbc_memStoreAddrTF = new GridBagConstraints();
+ gbc_memStoreAddrTF.anchor = GridBagConstraints.CENTER;
+ gbc_memStoreAddrTF.fill = GridBagConstraints.HORIZONTAL;
+ gbc_memStoreAddrTF.insets = new Insets(0, 0, 0, 5);
+ gbc_memStoreAddrTF.gridx = 1;
+ gbc_memStoreAddrTF.gridy = 1;
+ gbc_memStoreAddrTF.weightx = 1;
+ gbc_memStoreAddrTF.weighty = 0.1;
+ writeMemoryPanel.add(memStoreAddrTF.getComponent(), gbc_memStoreAddrTF);
+
+ memStoreValueTF = new IntegerTextField();
+ memStoreValueTF.setHexMode();
+ GridBagConstraints gbc_memStoreValueTF = new GridBagConstraints();
+ gbc_memStoreValueTF.insets = new Insets(0, 0, 0, 5);
+ gbc_memStoreValueTF.fill = GridBagConstraints.HORIZONTAL;
+ gbc_memStoreValueTF.anchor = GridBagConstraints.CENTER;
+ gbc_memStoreValueTF.gridx = 3;
+ gbc_memStoreValueTF.gridy = 1;
+ gbc_memStoreValueTF.weightx = 1;
+ gbc_memStoreValueTF.weighty = 0.1;
+ writeMemoryPanel.add(memStoreValueTF.getComponent(), gbc_memStoreValueTF);
btnAddWM = new JButton("");
btnAddWM.setContentAreaFilled(false);
@@ -587,38 +625,38 @@ public void itemStateChanged(ItemEvent e) {
GridBagConstraints gbc_btnAddWM = new GridBagConstraints();
gbc_btnAddWM.weighty = 0.1;
gbc_btnAddWM.fill = GridBagConstraints.HORIZONTAL;
- gbc_btnAddWM.anchor = GridBagConstraints.NORTH;
+ gbc_btnAddWM.anchor = GridBagConstraints.CENTER;
gbc_btnAddWM.insets = new Insets(0, 0, 0, 5);
gbc_btnAddWM.gridx = 0;
gbc_btnAddWM.gridy = 1;
gbc_btnAddWM.weighty = 0.1;
- WMPanel.add(btnAddWM, gbc_btnAddWM);
+ writeMemoryPanel.add(btnAddWM, gbc_btnAddWM);
btnAddWM.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- IntegerTextField TFaddr = new IntegerTextField();
- TFaddr.setHexMode();
- GridBagConstraints gbc_TFaddr = new GridBagConstraints();
- gbc_TFaddr.fill = GridBagConstraints.HORIZONTAL;
- gbc_TFaddr.anchor = GridBagConstraints.NORTH;
- gbc_TFaddr.gridx = 1;
- gbc_TFaddr.insets = new Insets(0, 0, 0, 5);
- gbc_TFaddr.gridy = GuiStoreCounter;
- gbc_TFaddr.weightx = 1;
- gbc_TFaddr.weighty = 0.1;
- WMPanel.add(TFaddr.getComponent(), gbc_TFaddr);
-
- IntegerTextField TFval = new IntegerTextField();
- TFval.setHexMode();
- GridBagConstraints gbc_TFval = new GridBagConstraints();
- gbc_TFval.fill = GridBagConstraints.HORIZONTAL;
- gbc_TFval.anchor = GridBagConstraints.NORTH;
- gbc_TFval.insets = new Insets(0, 0, 0, 5);
- gbc_TFval.gridx = 3;
- gbc_TFval.gridy = GuiStoreCounter;
- gbc_TFval.weightx = 1;
- gbc_TFval.weighty = 0.1;
- WMPanel.add(TFval.getComponent(), gbc_TFval);
- memStore.put(TFaddr, TFval);
+ IntegerTextField addrTF = new IntegerTextField();
+ addrTF.setHexMode();
+ GridBagConstraints gbc_addrTF = new GridBagConstraints();
+ gbc_addrTF.fill = GridBagConstraints.HORIZONTAL;
+ gbc_addrTF.anchor = GridBagConstraints.CENTER;
+ gbc_addrTF.gridx = 1;
+ gbc_addrTF.insets = new Insets(0, 0, 0, 5);
+ gbc_addrTF.gridy = guiStoreNextId;
+ gbc_addrTF.weightx = 1;
+ gbc_addrTF.weighty = 0.1;
+ writeMemoryPanel.add(addrTF.getComponent(), gbc_addrTF);
+
+ IntegerTextField valTF = new IntegerTextField();
+ valTF.setHexMode();
+ GridBagConstraints gbc_valTF = new GridBagConstraints();
+ gbc_valTF.fill = GridBagConstraints.HORIZONTAL;
+ gbc_valTF.anchor = GridBagConstraints.CENTER;
+ gbc_valTF.insets = new Insets(0, 0, 0, 5);
+ gbc_valTF.gridx = 3;
+ gbc_valTF.gridy = guiStoreNextId;
+ gbc_valTF.weightx = 1;
+ gbc_valTF.weighty = 0.1;
+ writeMemoryPanel.add(valTF.getComponent(), gbc_valTF);
+ memStore.put(addrTF, valTF);
JButton btnDel = new JButton("");
btnDel.setBorder(null);
@@ -626,182 +664,183 @@ public void actionPerformed(ActionEvent e) {
btnDel.setIcon(deleteIcon);
GridBagConstraints gbc_btnDel = new GridBagConstraints();
gbc_btnDel.fill = GridBagConstraints.HORIZONTAL;
- gbc_btnDel.anchor = GridBagConstraints.NORTH;
+ gbc_btnDel.anchor = GridBagConstraints.CENTER;
gbc_btnDel.insets = new Insets(0, 0, 0, 5);
gbc_btnDel.gridx = 0;
- gbc_btnDel.gridy = GuiStoreCounter++;
+ gbc_btnDel.gridy = guiStoreNextId++;
gbc_btnDel.weighty = 0.1;
- WMPanel.add(btnDel, gbc_btnDel);
+ writeMemoryPanel.add(btnDel, gbc_btnDel);
delStoreBtns.add(btnDel);
btnDel.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- GuiStoreCounter--;
- WMPanel.remove(TFaddr.getComponent());
- WMPanel.remove(TFval.getComponent());
- WMPanel.remove(btnDel);
+ public void actionPerformed(ActionEvent actionEvent) {
+ guiStoreNextId--;
+ writeMemoryPanel.remove(addrTF.getComponent());
+ writeMemoryPanel.remove(valTF.getComponent());
+ writeMemoryPanel.remove(btnDel);
delStoreBtns.remove(btnDel);
- memStore.remove(TFaddr, TFval);
- WMPanel.repaint();
- WMPanel.revalidate();
+ memStore.remove(addrTF, valTF);
+ writeMemoryPanel.repaint();
+ writeMemoryPanel.revalidate();
}
});
- WMPanel.repaint();
- WMPanel.revalidate();
+ writeMemoryPanel.repaint();
+ writeMemoryPanel.revalidate();
}
});
- GroupLayout gl_CSOPanel = new GroupLayout(CSOPanel);
- gl_CSOPanel.setHorizontalGroup(
- gl_CSOPanel.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_CSOPanel.createSequentialGroup()
+ GroupLayout gl_customOptionsPanel = new GroupLayout(customOptionsPanel);
+ gl_customOptionsPanel.setHorizontalGroup(
+ gl_customOptionsPanel.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_customOptionsPanel.createSequentialGroup()
.addContainerGap()
- .addComponent(MemPanel, GroupLayout.DEFAULT_SIZE, 257, Short.MAX_VALUE)
- .addGap(24))
- .addGroup(gl_CSOPanel.createSequentialGroup()
+ .addComponent(vectorsPanel, GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE)
+ .addGap(25))
+ .addGroup(gl_customOptionsPanel.createSequentialGroup()
.addContainerGap()
- .addGroup(gl_CSOPanel.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_CSOPanel.createSequentialGroup()
+ .addGroup(gl_customOptionsPanel.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_customOptionsPanel.createSequentialGroup()
.addComponent(lblWriteToMemory)
- .addPreferredGap(ComponentPlacement.RELATED, 150, GroupLayout.PREFERRED_SIZE))
- .addComponent(WMPanel, GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE))
+ .addPreferredGap(ComponentPlacement.RELATED, 237, GroupLayout.PREFERRED_SIZE))
+ .addComponent(writeMemoryPanel, GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE))
.addGap(25))
- .addGroup(gl_CSOPanel.createSequentialGroup()
+ .addGroup(gl_customOptionsPanel.createSequentialGroup()
.addContainerGap()
- .addComponent(RegPanel, GroupLayout.DEFAULT_SIZE, 251, Short.MAX_VALUE)
- .addGap(30))
- .addGroup(gl_CSOPanel.createSequentialGroup()
+ .addComponent(regPanel, GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE)
+ .addGap(25))
+ .addGroup(gl_customOptionsPanel.createSequentialGroup()
.addContainerGap()
- .addComponent(lbRegisters, GroupLayout.PREFERRED_SIZE, 258, GroupLayout.PREFERRED_SIZE)
- .addContainerGap(23, Short.MAX_VALUE))
- .addGroup(gl_CSOPanel.createSequentialGroup()
+ .addComponent(lbRegisters, GroupLayout.PREFERRED_SIZE, 327, Short.MAX_VALUE)
+ )
+ .addGroup(gl_customOptionsPanel.createSequentialGroup()
.addComponent(lbMemory, GroupLayout.PREFERRED_SIZE, 148, GroupLayout.PREFERRED_SIZE)
- .addContainerGap(145, Short.MAX_VALUE))
+ .addContainerGap(232, Short.MAX_VALUE))
);
- gl_CSOPanel.setVerticalGroup(
- gl_CSOPanel.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_CSOPanel.createSequentialGroup()
+ gl_customOptionsPanel.setVerticalGroup(
+ gl_customOptionsPanel.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_customOptionsPanel.createSequentialGroup()
.addContainerGap()
.addComponent(lbMemory, GroupLayout.PREFERRED_SIZE, 13, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(MemPanel, GroupLayout.DEFAULT_SIZE, 40, Short.MAX_VALUE)
+ .addComponent(vectorsPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(23)
.addComponent(lblWriteToMemory)
.addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(WMPanel, GroupLayout.DEFAULT_SIZE, 39, Short.MAX_VALUE)
+ .addComponent(writeMemoryPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(lbRegisters)
.addGap(9)
- .addComponent(RegPanel, GroupLayout.DEFAULT_SIZE, 38, Short.MAX_VALUE)
+ .addComponent(regPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(54))
);
- GridBagLayout gbl_RegPanel = new GridBagLayout();
- gbl_RegPanel.columnWidths = new int[] {
- 0,
+ customOptionsPanel.setLayout(gl_customOptionsPanel);
+
+ GridBagLayout gbl_regPanel = new GridBagLayout();
+ gbl_regPanel.columnWidths = new int[] {
0,
0,
0,
0,
0
};
- gbl_RegPanel.rowHeights = new int[] {
+ gbl_regPanel.rowHeights = new int[] {
0,
0
};
- gbl_RegPanel.columnWeights = new double[] {
- 0.0,
+ gbl_regPanel.columnWeights = new double[] {
0.0,
0.0,
0.0,
0.0,
Double.MIN_VALUE
};
- gbl_RegPanel.rowWeights = new double[] {
+ gbl_regPanel.rowWeights = new double[] {
0.0,
0.0
};
- RegPanel.setLayout(gbl_RegPanel);
+ regPanel.setLayout(gbl_regPanel);
JLabel lblReg = new JLabel("Register");
- lblReg.setFont(new Font("SansSerif", Font.PLAIN, 12));
+ lblReg.setFont(sansSerif12);
GridBagConstraints gbc_lblReg = new GridBagConstraints();
gbc_lblReg.anchor = GridBagConstraints.SOUTH;
gbc_lblReg.insets = new Insets(0, 0, 0, 5);
gbc_lblReg.gridx = 1;
gbc_lblReg.gridy = 0;
gbc_lblReg.weightx = 1;
- RegPanel.add(lblReg, gbc_lblReg);
+ regPanel.add(lblReg, gbc_lblReg);
- JLabel lblValue = new JLabel("Value");
- lblValue.setFont(new Font("SansSerif", Font.PLAIN, 12));
+ JLabel lblValue = new JLabel(" Value ");
+ lblValue.setFont(sansSerif12);
GridBagConstraints gbc_lblValue = new GridBagConstraints();
gbc_lblValue.anchor = GridBagConstraints.SOUTH;
gbc_lblValue.insets = new Insets(0, 0, 0, 5);
gbc_lblValue.gridx = 3;
gbc_lblValue.gridy = 0;
gbc_lblValue.weightx = 1;
- RegPanel.add(lblValue, gbc_lblValue);
+ regPanel.add(lblValue, gbc_lblValue);
JButton btnAddButton = new JButton("");
GridBagConstraints gbc_btnAddButton = new GridBagConstraints();
- gbc_btnAddButton.anchor = GridBagConstraints.NORTH;
+ gbc_btnAddButton.anchor = GridBagConstraints.CENTER;
gbc_btnAddButton.fill = GridBagConstraints.HORIZONTAL;
gbc_btnAddButton.insets = new Insets(0, 0, 0, 5);
gbc_btnAddButton.gridx = 0;
gbc_btnAddButton.gridy = 1;
gbc_btnAddButton.weighty = 0.1;
- RegPanel.add(btnAddButton, gbc_btnAddButton);
+ regPanel.add(btnAddButton, gbc_btnAddButton);
btnAddButton.setBorder(null);
btnAddButton.setContentAreaFilled(false);
btnAddButton.setIcon(addIcon);
- TFVal1 = new JTextField();
- TFVal1.setBorder(Classic_border);
- GridBagConstraints gbc_TFVal1 = new GridBagConstraints();
- gbc_TFVal1.insets = new Insets(0, 0, 0, 5);
- gbc_TFVal1.anchor = GridBagConstraints.NORTH;
- gbc_TFVal1.fill = GridBagConstraints.HORIZONTAL;
- gbc_TFVal1.gridx = 3;
- gbc_TFVal1.gridy = 1;
- gbc_TFVal1.weightx = 1;
- gbc_TFVal1.weighty = 0.1;
- RegPanel.add(TFVal1, gbc_TFVal1);
-
- TFReg1 = new JTextField();
- GridBagConstraints gbc_TFReg1 = new GridBagConstraints();
- gbc_TFReg1.anchor = GridBagConstraints.NORTH;
- gbc_TFReg1.fill = GridBagConstraints.HORIZONTAL;
- gbc_TFReg1.insets = new Insets(0, 0, 0, 5);
- gbc_TFReg1.gridx = 1;
- gbc_TFReg1.gridy = 1;
- gbc_TFReg1.weighty = 0.1;
- RegPanel.add(TFReg1, gbc_TFReg1);
- TFReg1.setBorder(Classic_border);
+ valueTF = new JTextField();
+ valueTF.setColumns(5);
+ GridBagConstraints gbc_valueTF = new GridBagConstraints();
+ gbc_valueTF.insets = new Insets(0, 0, 0, 5);
+ gbc_valueTF.anchor = GridBagConstraints.CENTER;
+ gbc_valueTF.fill = GridBagConstraints.HORIZONTAL;
+ gbc_valueTF.gridx = 3;
+ gbc_valueTF.gridy = 1;
+ gbc_valueTF.weightx = 1;
+ gbc_valueTF.weighty = 0.1;
+ regPanel.add(valueTF, gbc_valueTF);
+
+ registerTF = new JTextField();
+ registerTF.setColumns(5);
+ GridBagConstraints gbc_registerTF = new GridBagConstraints();
+ gbc_registerTF.anchor = GridBagConstraints.CENTER;
+ gbc_registerTF.fill = GridBagConstraints.HORIZONTAL;
+ gbc_registerTF.insets = new Insets(0, 0, 0, 5);
+ gbc_registerTF.gridx = 1;
+ gbc_registerTF.gridy = 1;
+ gbc_registerTF.weighty = 0.1;
+ regPanel.add(registerTF, gbc_registerTF);
btnAddButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- JTextField TFReg = new JTextField();
- GridBagConstraints gbc_TFReg = new GridBagConstraints();
- gbc_TFReg.fill = GridBagConstraints.HORIZONTAL;
- gbc_TFReg.anchor = GridBagConstraints.NORTH;
- gbc_TFReg.gridx = 1;
- gbc_TFReg.insets = new Insets(0, 0, 0, 5);
- gbc_TFReg.gridy = GuiRegCounter;
- gbc_TFReg.weightx = 1;
- gbc_TFReg.weighty = 0.1;
- RegPanel.add(TFReg, gbc_TFReg);
-
- JTextField TFVal = new JTextField();
- TFVal.setBorder(Classic_border);
- GridBagConstraints gbc_TFVal = new GridBagConstraints();
- gbc_TFVal.fill = GridBagConstraints.HORIZONTAL;
- gbc_TFVal.anchor = GridBagConstraints.NORTH;
- gbc_TFVal.insets = new Insets(0, 0, 0, 5);
- gbc_TFVal.gridx = 3;
- gbc_TFVal.gridy = GuiRegCounter;
- gbc_TFVal.weightx = 1;
- gbc_TFVal.weighty = 0.1;
- RegPanel.add(TFVal, gbc_TFVal);
- presetRegs.put(TFReg, TFVal);
+ JTextField regTF = new JTextField();
+ regTF.setColumns(5);
+ GridBagConstraints gbc_regTF = new GridBagConstraints();
+ gbc_regTF.fill = GridBagConstraints.HORIZONTAL;
+ gbc_regTF.anchor = GridBagConstraints.CENTER;
+ gbc_regTF.gridx = 1;
+ gbc_regTF.insets = new Insets(0, 0, 0, 5);
+ gbc_regTF.gridy = guiRegNextId;
+ gbc_regTF.weightx = 1;
+ gbc_regTF.weighty = 0.1;
+ regPanel.add(regTF, gbc_regTF);
+
+ JTextField valTF = new JTextField();
+ valTF.setColumns(5);
+ GridBagConstraints gbc_valTF = new GridBagConstraints();
+ gbc_valTF.fill = GridBagConstraints.HORIZONTAL;
+ gbc_valTF.anchor = GridBagConstraints.CENTER;
+ gbc_valTF.insets = new Insets(0, 0, 0, 5);
+ gbc_valTF.gridx = 3;
+ gbc_valTF.gridy = guiRegNextId;
+ gbc_valTF.weightx = 1;
+ gbc_valTF.weighty = 0.1;
+ regPanel.add(valTF, gbc_valTF);
+ presetRegs.put(regTF, valTF);
JButton btnDel = new JButton("");
btnDel.setBorder(null);
@@ -810,32 +849,31 @@ public void actionPerformed(ActionEvent e) {
GridBagConstraints gbc_btnDel = new GridBagConstraints();
gbc_btnDel.insets = new Insets(0, 0, 0, 5);
gbc_btnDel.fill = GridBagConstraints.HORIZONTAL;
- gbc_btnDel.anchor = GridBagConstraints.NORTH;
+ gbc_btnDel.anchor = GridBagConstraints.CENTER;
gbc_btnDel.gridx = 0;
- gbc_btnDel.gridy = GuiRegCounter++;
+ gbc_btnDel.gridy = guiRegNextId++;
gbc_btnDel.weighty = 0.1;
- RegPanel.add(btnDel, gbc_btnDel);
+ regPanel.add(btnDel, gbc_btnDel);
delRegsBtns.add(btnDel);
btnDel.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- GuiRegCounter--;
- RegPanel.remove(TFReg);
- RegPanel.remove(TFVal);
- RegPanel.remove(btnDel);
- delRegsBtns.remove(btnDel);
- presetRegs.remove(TFReg, TFVal);
- RegPanel.repaint();
- RegPanel.revalidate();
+ public void actionPerformed(ActionEvent actionEvent) {
+ guiRegNextId--;
+ delRegsBtns.remove(btnDel);
+ presetRegs.remove(regTF, valTF);
+ regPanel.remove(regTF);
+ regPanel.remove(valTF);
+ regPanel.remove(btnDel);
+ regPanel.repaint();
+ regPanel.revalidate();
}
-
});
- RegPanel.repaint();
- RegPanel.revalidate();
+ regPanel.repaint();
+ regPanel.revalidate();
}
});
- GridBagLayout gbl_MemPanel = new GridBagLayout();
- gbl_MemPanel.columnWidths = new int[] {
+ GridBagLayout gbl_vectorsPanel = new GridBagLayout();
+ gbl_vectorsPanel.columnWidths = new int[] {
0,
0,
0,
@@ -843,11 +881,11 @@ public void actionPerformed(ActionEvent e) {
0,
0
};
- gbl_MemPanel.rowHeights = new int[] {
+ gbl_vectorsPanel.rowHeights = new int[] {
0,
0
};
- gbl_MemPanel.columnWeights = new double[] {
+ gbl_vectorsPanel.columnWeights = new double[] {
0.0,
0.0,
0.0,
@@ -855,369 +893,353 @@ public void actionPerformed(ActionEvent e) {
0.0,
Double.MIN_VALUE
};
- gbl_MemPanel.rowWeights = new double[] {
+ gbl_vectorsPanel.rowWeights = new double[] {
0.0,
0.0
};
- MemPanel.setLayout(gbl_MemPanel);
-
+ vectorsPanel.setLayout(gbl_vectorsPanel);
JButton btnAddMem = new JButton("");
GridBagConstraints gbc_btnAddMem = new GridBagConstraints();
- gbc_btnAddMem.anchor = GridBagConstraints.NORTH;
+ gbc_btnAddMem.anchor = GridBagConstraints.CENTER;
gbc_btnAddMem.fill = GridBagConstraints.HORIZONTAL;
gbc_btnAddMem.insets = new Insets(0, 0, 0, 5);
gbc_btnAddMem.gridx = 0;
gbc_btnAddMem.gridy = 1;
gbc_btnAddMem.weighty = 0.1;
- MemPanel.add(btnAddMem, gbc_btnAddMem);
+ vectorsPanel.add(btnAddMem, gbc_btnAddMem);
btnAddMem.setIcon(addIcon);
btnAddMem.setBorder(null);
btnAddMem.setContentAreaFilled(false);
JLabel lbMemAddr = new JLabel("Address");
- lbMemAddr.setFont(new Font("SansSerif", Font.PLAIN, 12));
+ lbMemAddr.setFont(sansSerif12);
GridBagConstraints gbc_lbMemAddr = new GridBagConstraints();
gbc_lbMemAddr.insets = new Insets(0, 0, 0, 5);
gbc_lbMemAddr.gridx = 1;
gbc_lbMemAddr.gridy = 0;
gbc_lbMemAddr.weightx = 1;
- MemPanel.add(lbMemAddr, gbc_lbMemAddr);
+ vectorsPanel.add(lbMemAddr, gbc_lbMemAddr);
JLabel lblLentgh = new JLabel("Length");
- lblLentgh.setFont(new Font("SansSerif", Font.PLAIN, 12));
+ lblLentgh.setFont(sansSerif12);
GridBagConstraints gbc_lblLentgh = new GridBagConstraints();
gbc_lblLentgh.insets = new Insets(0, 0, 0, 5);
gbc_lblLentgh.gridx = 3;
gbc_lblLentgh.gridy = 0;
gbc_lblLentgh.weightx = 1;
- MemPanel.add(lblLentgh, gbc_lblLentgh);
-
- TFsymbmem_addr = new IntegerTextField();
- TFsymbmem_addr.setHexMode();
- GridBagConstraints gbc_TFsymbmem_addr = new GridBagConstraints();
- gbc_TFsymbmem_addr.anchor = GridBagConstraints.NORTH;
- gbc_TFsymbmem_addr.fill = GridBagConstraints.HORIZONTAL;
- gbc_TFsymbmem_addr.insets = new Insets(0, 0, 0, 5);
- gbc_TFsymbmem_addr.gridx = 1;
- gbc_TFsymbmem_addr.gridy = 1;
- gbc_TFsymbmem_addr.weightx = 1;
- gbc_TFsymbmem_addr.weighty = 0.1;
- MemPanel.add(TFsymbmem_addr.getComponent(), gbc_TFsymbmem_addr);
-
- TFsymbmem_len = new IntegerTextField();
- GridBagConstraints gbc_TFsymbmem_len = new GridBagConstraints();
- gbc_TFsymbmem_len.insets = new Insets(0, 0, 0, 5);
- gbc_TFsymbmem_len.fill = GridBagConstraints.HORIZONTAL;
- gbc_TFsymbmem_len.anchor = GridBagConstraints.NORTH;
- gbc_TFsymbmem_len.gridx = 3;
- gbc_TFsymbmem_len.gridy = 1;
- gbc_TFsymbmem_len.weightx = 1;
- gbc_TFsymbmem_len.weighty = 0.1;
- MemPanel.add(TFsymbmem_len.getComponent(), gbc_TFsymbmem_len);
+ vectorsPanel.add(lblLentgh, gbc_lblLentgh);
+
+ vectorAddressTF = new IntegerTextField();
+ vectorAddressTF.setHexMode();
+ GridBagConstraints gbc_vectorAddressTF = new GridBagConstraints();
+ gbc_vectorAddressTF.anchor = GridBagConstraints.CENTER;
+ gbc_vectorAddressTF.fill = GridBagConstraints.HORIZONTAL;
+ gbc_vectorAddressTF.insets = new Insets(0, 0, 0, 5);
+ gbc_vectorAddressTF.gridx = 1;
+ gbc_vectorAddressTF.gridy = 1;
+ gbc_vectorAddressTF.weightx = 1;
+ gbc_vectorAddressTF.weighty = 0.1;
+ vectorsPanel.add(vectorAddressTF.getComponent(), gbc_vectorAddressTF);
+
+ vectorLenTF = new IntegerTextField();
+ GridBagConstraints gbc_vectorLenTF = new GridBagConstraints();
+ gbc_vectorLenTF.insets = new Insets(0, 0, 0, 5);
+ gbc_vectorLenTF.fill = GridBagConstraints.HORIZONTAL;
+ gbc_vectorLenTF.anchor = GridBagConstraints.CENTER;
+ gbc_vectorLenTF.gridx = 3;
+ gbc_vectorLenTF.gridy = 1;
+ gbc_vectorLenTF.weightx = 1;
+ gbc_vectorLenTF.weighty = 0.1;
+ vectorsPanel.add(vectorLenTF.getComponent(), gbc_vectorLenTF);
btnAddMem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- IntegerTextField TFaddr = new IntegerTextField();
- TFaddr.setHexMode();
- GridBagConstraints gbc_TFaddr = new GridBagConstraints();
- gbc_TFaddr.fill = GridBagConstraints.HORIZONTAL;
- gbc_TFaddr.anchor = GridBagConstraints.NORTH;
- gbc_TFaddr.gridx = 1;
- gbc_TFaddr.insets = new Insets(0, 0, 0, 5);
- gbc_TFaddr.gridy = GuiMemCounter;
- gbc_TFaddr.weightx = 1;
- gbc_TFaddr.weighty = 0.1;
- MemPanel.add(TFaddr.getComponent(), gbc_TFaddr);
-
- IntegerTextField TFlen = new IntegerTextField();
- GridBagConstraints gbc_TFlen = new GridBagConstraints();
- gbc_TFlen.fill = GridBagConstraints.HORIZONTAL;
- gbc_TFlen.anchor = GridBagConstraints.NORTH;
- gbc_TFlen.insets = new Insets(0, 0, 0, 5);
- gbc_TFlen.gridx = 3;
- gbc_TFlen.gridy = GuiMemCounter;
- gbc_TFlen.weightx = 1;
- gbc_TFlen.weighty = 0.1;
- MemPanel.add(TFlen.getComponent(), gbc_TFlen);
- vectors.put(TFaddr, TFlen);
-
+ IntegerTextField addrTF = new IntegerTextField();
+ addrTF.setHexMode();
+ GridBagConstraints gbc_addrTF = new GridBagConstraints();
+ gbc_addrTF.fill = GridBagConstraints.HORIZONTAL;
+ gbc_addrTF.anchor = GridBagConstraints.CENTER;
+ gbc_addrTF.gridx = 1;
+ gbc_addrTF.insets = new Insets(0, 0, 0, 5);
+ gbc_addrTF.gridy = guiMemNextId;
+ gbc_addrTF.weightx = 1;
+ gbc_addrTF.weighty = 0.1;
+ vectorsPanel.add(addrTF.getComponent(), gbc_addrTF);
+
+ IntegerTextField lenTF = new IntegerTextField();
+ GridBagConstraints gbc_lenTF = new GridBagConstraints();
+ gbc_lenTF.fill = GridBagConstraints.HORIZONTAL;
+ gbc_lenTF.anchor = GridBagConstraints.CENTER;
+ gbc_lenTF.insets = new Insets(0, 0, 0, 5);
+ gbc_lenTF.gridx = 3;
+ gbc_lenTF.gridy = guiMemNextId;
+ gbc_lenTF.weightx = 1;
+ gbc_lenTF.weighty = 0.1;
+ vectorsPanel.add(lenTF.getComponent(), gbc_lenTF);
+ vectors.put(addrTF, lenTF);
+
JButton btnDel = new JButton("");
btnDel.setBorder(null);
btnDel.setContentAreaFilled(false);
btnDel.setIcon(deleteIcon);
GridBagConstraints gbc_btnDel = new GridBagConstraints();
gbc_btnDel.fill = GridBagConstraints.HORIZONTAL;
- gbc_btnDel.anchor = GridBagConstraints.NORTH;
+ gbc_btnDel.anchor = GridBagConstraints.CENTER;
gbc_btnDel.insets = new Insets(0, 0, 0, 5);
gbc_btnDel.gridx = 0;
- gbc_btnDel.gridy = GuiMemCounter++;
+ gbc_btnDel.gridy = guiMemNextId++;
gbc_btnDel.weighty = 0.1;
- MemPanel.add(btnDel, gbc_btnDel);
+ vectorsPanel.add(btnDel, gbc_btnDel);
delMemBtns.add(btnDel);
btnDel.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- GuiMemCounter--;
- MemPanel.remove(TFaddr.getComponent());
- MemPanel.remove(TFlen.getComponent());
- MemPanel.remove(btnDel);
- delMemBtns.remove(btnDel);
- vectors.remove(TFaddr, TFlen);
- MemPanel.repaint();
- MemPanel.revalidate();
+ public void actionPerformed(ActionEvent actionEvent) {
+ guiMemNextId--;
+ vectorsPanel.remove(addrTF.getComponent());
+ vectorsPanel.remove(lenTF.getComponent());
+ vectorsPanel.remove(btnDel);
+ delMemBtns.remove(btnDel);
+ vectors.remove(addrTF, lenTF);
+ vectorsPanel.repaint();
+ vectorsPanel.revalidate();
}
});
- MemPanel.repaint();
- MemPanel.revalidate();
+ vectorsPanel.repaint();
+ vectorsPanel.revalidate();
}
});
- CSOPanel.setLayout(gl_CSOPanel);
- ImageIcon Starticon = new ImageIcon(getClass().getResource("/images/flag.png"));
- ImageIcon Stopicon = new ImageIcon(getClass().getResource("/images/stop.png"));
-
- EndPanel = new JPanel();
- EndPanel.setBorder(null);
lbStatus = new JLabel("Status:");
lbStatus.setForeground(Color.BLUE);
- lbStatus.setFont(new Font("SansSerif", Font.PLAIN, 13));
+ lbStatus.setFont(sansSerif13);
- StatusLabel = new JLabel(main_str);
- StatusLabel.setFont(new Font("SansSerif", Font.PLAIN, 12));
+ statusLabel = new JLabel(configuringString);
+ statusLabel.setFont(sansSerif13);
- StatusLabelFound = new JLabel("");
- StatusLabelFound.setFont(new Font("SansSerif", Font.PLAIN, 12));
+ statusLabelFound = new JLabel("");
+ statusLabelFound.setFont(sansSerif13);
btnRun = new JButton("Run");
- btnRun.setIcon(Starticon);
- btnRun.setFont(new Font("SansSerif", Font.PLAIN, 12));
+ btnRun.setIcon(startIcon);
+ btnRun.setFont(sansSerif12);
- SolutionArea = new JTextArea();
- SolutionArea.setFont(new Font("SansSerif", Font.PLAIN, 12));
- scrollSolution = new JScrollPane(SolutionArea);
- SolutionArea.setEditable(false);
- scrollSolution.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
- scrollSolution.setBorder(new LineBorder(Color.blue, 1));
- scrollSolution.setVisible(false);
+ solutionTextArea = new JTextArea();
+ solutionTextArea.setFont(sansSerif12);
+ scrollSolutionTextArea = new JScrollPane(solutionTextArea);
+ solutionTextArea.setEditable(false);
+ scrollSolutionTextArea.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
+ scrollSolutionTextArea.setBorder(new LineBorder(Color.blue, 1));
+ scrollSolutionTextArea.setVisible(false);
btnStop = new JButton("Stop");
btnStop.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- if (new File(TmpDir + "angr_options.json").exists()) {
- isTerminated = true;
- StatusLabel.setText("[+] Stopping...");
- StatusLabelFound.setText("");
- scrollSolution.setVisible(false);
+ if (new File(tmpDir + "angr_options.json").exists()) {
+ setIsTerminated(true);
+ statusLabel.setText("[+] Stopping...");
+ statusLabelFound.setText("");
+ scrollSolutionTextArea.setVisible(false);
}
}
});
- btnStop.setFont(new Font("SansSerif", Font.PLAIN, 12));
- btnStop.setIcon(Stopicon);
-
+ btnStop.setFont(sansSerif12);
+ btnStop.setIcon(stopIcon);
+
btnReset = new JButton("Reset");
- btnReset.setFont(new Font("SansSerif", Font.PLAIN, 12));
+ btnReset.setIcon(resetIcon);
+ btnReset.setFont(sansSerif12);
btnReset.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
resetState();
}
- });
+ });
- GroupLayout gl_EndPanel = new GroupLayout(EndPanel);
- gl_EndPanel.setHorizontalGroup(
- gl_EndPanel.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_EndPanel.createSequentialGroup()
+ GroupLayout gl_statusPanel = new GroupLayout(statusPanel);
+ gl_statusPanel.setHorizontalGroup(
+ gl_statusPanel.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_statusPanel.createSequentialGroup()
.addGap(10)
- .addComponent(StatusLabelFound, GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE)
+ .addComponent(statusLabelFound, GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE)
.addGap(71)
- .addComponent(scrollSolution, GroupLayout.DEFAULT_SIZE, 378, Short.MAX_VALUE)
+ .addComponent(scrollSolutionTextArea, GroupLayout.DEFAULT_SIZE, 378, Short.MAX_VALUE)
.addGap(10))
- .addGroup(gl_EndPanel.createSequentialGroup()
- .addGroup(gl_EndPanel.createParallelGroup(Alignment.TRAILING)
- .addGroup(gl_EndPanel.createSequentialGroup()
+ .addGroup(gl_statusPanel.createSequentialGroup()
+ .addGroup(gl_statusPanel.createParallelGroup(Alignment.TRAILING)
+ .addGroup(gl_statusPanel.createSequentialGroup()
.addGap(77)
.addComponent(btnRun, GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE)
.addGap(77)
.addComponent(btnStop, GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE)
.addGap(77)
.addComponent(btnReset, GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE)
- .addGap(1))
- .addGroup(gl_EndPanel.createSequentialGroup()
+ .addGap(1))
+ .addGroup(gl_statusPanel.createSequentialGroup()
.addGap(10)
- .addComponent(StatusLabel, GroupLayout.DEFAULT_SIZE, 495, Short.MAX_VALUE)))
+ .addComponent(statusLabel, GroupLayout.DEFAULT_SIZE, 495, Short.MAX_VALUE)))
.addGap(91))
- .addGroup(gl_EndPanel.createSequentialGroup()
+ .addGroup(gl_statusPanel.createSequentialGroup()
.addContainerGap()
.addComponent(lbStatus, GroupLayout.PREFERRED_SIZE, 46, GroupLayout.PREFERRED_SIZE)
.addContainerGap(538, Short.MAX_VALUE))
);
- gl_EndPanel.setVerticalGroup(
- gl_EndPanel.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_EndPanel.createSequentialGroup()
+ gl_statusPanel.setVerticalGroup(
+ gl_statusPanel.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_statusPanel.createSequentialGroup()
.addGap(10)
- .addGroup(gl_EndPanel.createParallelGroup(Alignment.BASELINE)
+ .addGroup(gl_statusPanel.createParallelGroup(Alignment.BASELINE)
.addComponent(btnRun, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
.addComponent(btnStop, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
- .addComponent(btnReset, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
+ .addComponent(btnReset, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(lbStatus, GroupLayout.PREFERRED_SIZE, 13, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(StatusLabel, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)
- .addGroup(gl_EndPanel.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_EndPanel.createSequentialGroup()
+ .addComponent(statusLabel, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)
+ .addGroup(gl_statusPanel.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_statusPanel.createSequentialGroup()
.addGap(5)
- .addComponent(StatusLabelFound, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
- .addGroup(gl_EndPanel.createSequentialGroup()
+ .addComponent(statusLabelFound, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
+ .addGroup(gl_statusPanel.createSequentialGroup()
.addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(scrollSolution, GroupLayout.DEFAULT_SIZE, 36, Short.MAX_VALUE)))
+ .addComponent(scrollSolutionTextArea, GroupLayout.DEFAULT_SIZE, 36, Short.MAX_VALUE)))
.addContainerGap())
);
- EndPanel.setLayout(gl_EndPanel);
+ statusPanel.setLayout(gl_statusPanel);
- JPanel HookPanel = new JPanel();
+ JPanel hookPanel = new JPanel();
TitledBorder borderHP = BorderFactory.createTitledBorder("Hook options");
- borderHP.setTitleFont(new Font("SansSerif", Font.PLAIN, 12));
- HookPanel.setBorder(borderHP);
-
- GroupLayout gl_panel = new GroupLayout(panel);
- gl_panel.setHorizontalGroup(
- gl_panel.createParallelGroup(Alignment.TRAILING)
- .addGroup(gl_panel.createSequentialGroup()
- .addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_panel.createSequentialGroup()
+ borderHP.setTitleFont(sansSerif12);
+ hookPanel.setBorder(borderHP);
+
+ GroupLayout gl_mainPanel = new GroupLayout(mainPanel);
+ gl_mainPanel.setHorizontalGroup(
+ gl_mainPanel.createParallelGroup(Alignment.TRAILING)
+ .addGroup(gl_mainPanel.createSequentialGroup()
+ .addGroup(gl_mainPanel.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_mainPanel.createSequentialGroup()
.addContainerGap()
- .addComponent(EndPanel, GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE))
- .addGroup(gl_panel.createSequentialGroup()
- .addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_panel.createSequentialGroup()
+ .addComponent(statusPanel, GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE))
+ .addGroup(gl_mainPanel.createSequentialGroup()
+ .addGroup(gl_mainPanel.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_mainPanel.createSequentialGroup()
.addGap(10)
- .addComponent(MPOPanel, GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE))
- .addGroup(gl_panel.createSequentialGroup()
+ .addComponent(mainOptionsPanel, GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE))
+ .addGroup(gl_mainPanel.createSequentialGroup()
.addContainerGap()
- .addComponent(SAPanel, GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE))
- .addGroup(gl_panel.createSequentialGroup()
+ .addComponent(argumentsPanel, GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE))
+ .addGroup(gl_mainPanel.createSequentialGroup()
.addContainerGap()
- .addComponent(HookPanel, GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)))
+ .addComponent(hookPanel, GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)))
.addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(CSOPanel, GroupLayout.DEFAULT_SIZE, 269, Short.MAX_VALUE)))
+ .addComponent(customOptionsPanel, GroupLayout.DEFAULT_SIZE, 269, Short.MAX_VALUE)))
.addGap(13))
);
- gl_panel.setVerticalGroup(
- gl_panel.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_panel.createSequentialGroup()
- .addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_panel.createSequentialGroup()
+ gl_mainPanel.setVerticalGroup(
+ gl_mainPanel.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_mainPanel.createSequentialGroup()
+ .addGroup(gl_mainPanel.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_mainPanel.createSequentialGroup()
.addGap(10)
- .addComponent(MPOPanel, GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)
+ .addComponent(mainOptionsPanel, GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)
.addGap(2)
- .addComponent(SAPanel, GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE)
+ .addComponent(argumentsPanel, GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE)
.addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(HookPanel, GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE))
- .addGroup(gl_panel.createSequentialGroup()
+ .addComponent(hookPanel, GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE))
+ .addGroup(gl_mainPanel.createSequentialGroup()
.addContainerGap()
- .addComponent(CSOPanel, GroupLayout.DEFAULT_SIZE, 357, Short.MAX_VALUE)))
+ .addComponent(customOptionsPanel, GroupLayout.DEFAULT_SIZE, 357, Short.MAX_VALUE)))
.addPreferredGap(ComponentPlacement.UNRELATED)
- .addComponent(EndPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(statusPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(5))
);
+ mainPanel.setLayout(gl_mainPanel);
JButton btnAddHook = new JButton("Add Hook");
btnAddHook.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- HookCreation window = new HookCreation();
- window.main();
+ if (getHookWindowState()) {
+ hookHandler = new HookHandler(AngryGhidraProvider.this);
+ hookHandler.main();
+ setHookWindowState(false);
+ } else {
+ hookHandler.toFront();
+ }
}
});
btnAddHook.setFont(new Font("SansSerif", Font.PLAIN, 11));
- RegHookPanel = new JPanel();
- GroupLayout gl_HookPanel = new GroupLayout(HookPanel);
- gl_HookPanel.setHorizontalGroup(
- gl_HookPanel.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_HookPanel.createSequentialGroup()
+ GroupLayout gl_hookPanel = new GroupLayout(hookPanel);
+ gl_hookPanel.setHorizontalGroup(
+ gl_hookPanel.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_hookPanel.createSequentialGroup()
.addContainerGap()
.addComponent(btnAddHook, GroupLayout.PREFERRED_SIZE, 105, Short.MAX_VALUE)
.addGap(43)
- .addComponent(RegHookPanel, GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE)
+ .addComponent(hookLablesPanel, GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE)
.addContainerGap())
);
- gl_HookPanel.setVerticalGroup(
- gl_HookPanel.createParallelGroup(Alignment.TRAILING)
- .addGroup(gl_HookPanel.createSequentialGroup()
- .addGroup(gl_HookPanel.createParallelGroup(Alignment.TRAILING)
- .addGroup(Alignment.LEADING, gl_HookPanel.createSequentialGroup()
+ gl_hookPanel.setVerticalGroup(
+ gl_hookPanel.createParallelGroup(Alignment.TRAILING)
+ .addGroup(gl_hookPanel.createSequentialGroup()
+ .addGroup(gl_hookPanel.createParallelGroup(Alignment.TRAILING)
+ .addGroup(Alignment.LEADING, gl_hookPanel.createSequentialGroup()
.addContainerGap()
.addComponent(btnAddHook))
- .addGroup(gl_HookPanel.createSequentialGroup()
+ .addGroup(gl_hookPanel.createSequentialGroup()
.addGap(10)
- .addComponent(RegHookPanel, GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)))
+ .addComponent(hookLablesPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
.addGap(34))
);
- GridBagLayout gbl_RegHookPanel = new GridBagLayout();
- gbl_RegHookPanel.columnWidths = new int[] {
- 0
- };
- gbl_RegHookPanel.rowHeights = new int[] {
- 0
- };
- gbl_RegHookPanel.columnWeights = new double[] {
- Double.MIN_VALUE
- };
- gbl_RegHookPanel.rowWeights = new double[] {
- Double.MIN_VALUE
- };
- RegHookPanel.setLayout(gbl_RegHookPanel);
- HookPanel.setLayout(gl_HookPanel);
- panel.setLayout(gl_panel);
+ hookPanel.setLayout(gl_hookPanel);
+
+ GridBagLayout gbl_hookLablesPanel = new GridBagLayout();
+ gbl_hookLablesPanel.columnWidths = new int[] {0};
+ gbl_hookLablesPanel.rowHeights = new int[] {0};
+ gbl_hookLablesPanel.columnWeights = new double[] {Double.MIN_VALUE};
+ gbl_hookLablesPanel.rowWeights = new double[] {Double.MIN_VALUE};
+ hookLablesPanel.setLayout(gbl_hookLablesPanel);
btnRun.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- StatusLabel.setText(main_str);
- StatusLabelFound.setText("");
- isTerminated = false;
- angr_options = new JSONObject();
-
+ statusLabel.setText(configuringString);
+ statusLabelFound.setText("");
+ setIsTerminated(false);
+ angrProcessing.clearTraceList(false);
+ JSONObject angr_options = new JSONObject();
Boolean auto_load_libs = false;
- if (chckbxAutoloadlibs.isSelected()) {
+ if (chckbxAutoLoadLibs.isSelected()) {
auto_load_libs = true;
}
-
angr_options.put("auto_load_libs", auto_load_libs);
-
if (chckbxBlankState.isSelected()) {
- if (!TFBlankState.getText().matches("0x[0-9A-Fa-f]+")) {
- TFBlankState.setBorder(new LineBorder(Color.red, 1));
- StatusLabel.setText("[-] Error: please, enter the correct hex value.");
+ if (!blankStateTF.getText().matches("0x[0-9A-Fa-f]+")) {
+ statusLabel.setForeground(Color.red);
+ statusLabel.setText("[–] Error: enter the correct blank state address value in hex format!");
return;
}
- TFBlankState.setBorder(Classic_border);
- String blank_state = TFBlankState.getText();
+ String blank_state = blankStateTF.getText();
angr_options.put("blank_state", blank_state);
}
- if (!TFFind.getText().matches("0x[0-9A-Fa-f]+")) {
- TFFind.setBorder(new LineBorder(Color.red, 1));
- StatusLabel.setText("[-] Error: please, enter the correct hex value without spaces.");
+ if (!dstAddressTF.getText().matches("0x[0-9A-Fa-f]+")) {
+ statusLabel.setForeground(Color.red);
+ statusLabel.setText("[–] Error: enter the correct destination address in hex format!");
return;
}
- TFFind.setBorder(Classic_border);
- String find_addr = TFFind.getText();
+ String find_addr = dstAddressTF.getText();
angr_options.put("find_address", find_addr);
-
if (chckbxAvoidAddresses.isSelected()) {
- if (!textArea.getText().replaceAll("\\s+", "").matches("[0x0-9a-fA-F, /,]+")) {
- textArea.setBorder(new LineBorder(Color.red, 1));
- StatusLabel.setText("[-] Error: please, enter the correct hex values separated by comma.");
+ if (!avoidTextArea.getText().replaceAll("\\s+", "").matches("[0x0-9a-fA-F, /,]+")) {
+ statusLabel.setForeground(Color.red);
+ statusLabel.setText("[–] Error: enter the correct avoid addresses in hex format separated by comma!");
return;
}
- textArea.setBorder(textAreaDefaultBorder);
- String avoid = textArea.getText().replaceAll("\\s+", "");
+ String avoid = avoidTextArea.getText().replaceAll("\\s+", "");
angr_options.put("avoid_address", avoid);
}
-
if (chckbxArg.isSelected()) {
- if (!TFFirstArg.getText().isEmpty()) {
+ if (!firstArgTF.getText().isEmpty()) {
JSONObject argDetails = new JSONObject();
int id = 1;
- argDetails.put(String.valueOf(id++), TFFirstArg.getText());
- for (IntegerTextField itf : TFsOfArgs) {
+ argDetails.put(String.valueOf(id++), firstArgTF.getText());
+ for (IntegerTextField itf : argsTF) {
String value = itf.getText();
if (!value.isEmpty()) {
argDetails.put(String.valueOf(id), value);
@@ -1227,11 +1249,10 @@ public void actionPerformed(ActionEvent e) {
angr_options.put("arguments", argDetails);
}
}
-
- if (!TFsymbmem_addr.getText().isEmpty() &&
- !TFsymbmem_len.getText().isEmpty()) {
+ if (!vectorAddressTF.getText().isEmpty() &&
+ !vectorLenTF.getText().isEmpty()) {
JSONObject vectorDetails = new JSONObject();
- vectorDetails.put(TFsymbmem_addr.getText(), TFsymbmem_len.getText());
+ vectorDetails.put(vectorAddressTF.getText(), vectorLenTF.getText());
for (Entry
Hint: to create and store symbolic vector enter \"sv{length}\", for example \"sv16\"");
- lbRegisters.setHorizontalAlignment(SwingConstants.CENTER);
- lbRegisters.setFont(new Font("SansSerif", Font.PLAIN, 12));
-
- RegPanel = new JPanel();
- GridBagLayout gbl_RegPanel = new GridBagLayout();
- gbl_RegPanel.columnWidths = new int[]{0, 0, 0, 0, 0, 0};
- gbl_RegPanel.rowHeights = new int[]{0, 0, 0};
- gbl_RegPanel.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
- gbl_RegPanel.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
- RegPanel.setLayout(gbl_RegPanel);
-
+ JLabel lbRegisters = new JLabel(mProvider.htmlString);
+ lbRegisters.setFont(sansSerif);
+
+ regPanel = new JPanel();
+ GridBagLayout gbl_regPanel = new GridBagLayout();
+ gbl_regPanel.columnWidths = new int[]{0, 0, 0, 0, 0, 0};
+ gbl_regPanel.rowHeights = new int[]{0, 0, 0};
+ gbl_regPanel.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
+ gbl_regPanel.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
+ regPanel.setLayout(gbl_regPanel);
+
JLabel lblReg = new JLabel("Register");
- lblReg.setFont(new Font("SansSerif", Font.PLAIN, 12));
+ lblReg.setFont(sansSerif);
GridBagConstraints gbc_lblReg = new GridBagConstraints();
gbc_lblReg.anchor = GridBagConstraints.SOUTH;
gbc_lblReg.insets = new Insets(0, 0, 0, 5);
gbc_lblReg.gridx = 1;
gbc_lblReg.gridy = 0;
- gbc_lblReg.weightx = 1;
- RegPanel.add(lblReg, gbc_lblReg);
+ gbc_lblReg.weightx = 1;
+ regPanel.add(lblReg, gbc_lblReg);
- JLabel lblValue = new JLabel("Value");
- lblValue.setFont(new Font("SansSerif", Font.PLAIN, 12));
+ JLabel lblValue = new JLabel(" Value ");
+ lblValue.setFont(sansSerif);
GridBagConstraints gbc_lblValue = new GridBagConstraints();
gbc_lblValue.anchor = GridBagConstraints.SOUTH;
gbc_lblValue.insets = new Insets(0, 0, 0, 5);
gbc_lblValue.gridx = 3;
gbc_lblValue.gridy = 0;
- gbc_lblValue.weightx = 1;
- RegPanel.add(lblValue, gbc_lblValue);
+ gbc_lblValue.weightx = 1;
+ regPanel.add(lblValue, gbc_lblValue);
JButton btnAddButton = new JButton("");
GridBagConstraints gbc_btnAddButton = new GridBagConstraints();
- gbc_btnAddButton.anchor = GridBagConstraints.NORTH;
+ gbc_btnAddButton.anchor = GridBagConstraints.CENTER;
gbc_btnAddButton.fill = GridBagConstraints.HORIZONTAL;
gbc_btnAddButton.insets = new Insets(0, 0, 0, 5);
gbc_btnAddButton.gridx = 0;
gbc_btnAddButton.gridy = 1;
gbc_btnAddButton.weighty = 0.1;
- RegPanel.add(btnAddButton, gbc_btnAddButton);
+ regPanel.add(btnAddButton, gbc_btnAddButton);
btnAddButton.setBorder(null);
btnAddButton.setContentAreaFilled(false);
- btnAddButton.setIcon(AngryGhidraProvider.addIcon);
+ btnAddButton.setIcon(mProvider.getAddIcon());
- TFHookReg1 = new JTextField();
- TFHookReg1.setBorder(TFAddress.getComponent().getBorder());
+ hookRegTF = new JTextField();
+ hookRegTF.setBorder(border);
+ hookRegTF.setColumns(5);
GridBagConstraints gbc_TFReg1 = new GridBagConstraints();
- gbc_TFReg1.anchor = GridBagConstraints.NORTH;
+ gbc_TFReg1.anchor = GridBagConstraints.CENTER;
gbc_TFReg1.fill = GridBagConstraints.HORIZONTAL;
gbc_TFReg1.insets = new Insets(0, 0, 0, 5);
gbc_TFReg1.gridx = 1;
gbc_TFReg1.gridy = 1;
gbc_TFReg1.weighty = 0.1;
- RegPanel.add(TFHookReg1, gbc_TFReg1);
- TFHookReg1.setBorder(TFAddress.getComponent().getBorder());
-
- TFHookVal1 = new JTextField();
- TFHookVal1.setBorder(TFAddress.getComponent().getBorder());
+ regPanel.add(hookRegTF, gbc_TFReg1);
+ hookRegTF.setBorder(border);
+
+ hookValTF = new JTextField();
+ hookValTF.setBorder(border);
+ hookValTF.setColumns(5);
GridBagConstraints gbc_TFVal1 = new GridBagConstraints();
gbc_TFVal1.insets = new Insets(0, 0, 0, 5);
- gbc_TFVal1.anchor = GridBagConstraints.NORTH;
+ gbc_TFVal1.anchor = GridBagConstraints.CENTER;
gbc_TFVal1.fill = GridBagConstraints.HORIZONTAL;
gbc_TFVal1.gridx = 3;
gbc_TFVal1.gridy = 1;
gbc_TFVal1.weightx = 1;
gbc_TFVal1.weighty = 0.1;
- RegPanel.add(TFHookVal1, gbc_TFVal1);
-
+ regPanel.add(hookValTF, gbc_TFVal1);
+
btnAddButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- JTextField TFReg = new JTextField();
- TFReg.setBorder(TFAddress.getComponent().getBorder());
+ JTextField regTF = new JTextField();
+ regTF.setBorder(border);
+ regTF.setColumns(5);
GridBagConstraints gbc_TFReg = new GridBagConstraints();
gbc_TFReg.fill = GridBagConstraints.HORIZONTAL;
- gbc_TFReg.anchor = GridBagConstraints.NORTH;
+ gbc_TFReg.anchor = GridBagConstraints.CENTER;
gbc_TFReg.gridx = 1;
gbc_TFReg.insets = new Insets(0, 0, 0, 5);
- gbc_TFReg.gridy = GuiHookRegCounter;
+ gbc_TFReg.gridy = hookRegNextId;
gbc_TFReg.weightx = 1;
gbc_TFReg.weighty = 0.1;
- RegPanel.add(TFReg, gbc_TFReg);
+ regPanel.add(regTF, gbc_TFReg);
- JTextField TFVal = new JTextField();
- TFVal.setBorder(TFAddress.getComponent().getBorder());
+ JTextField valTF = new JTextField();
+ valTF.setColumns(5);
+ valTF.setBorder(border);
GridBagConstraints gbc_TFVal = new GridBagConstraints();
gbc_TFVal.fill = GridBagConstraints.HORIZONTAL;
- gbc_TFVal.anchor = GridBagConstraints.NORTH;
+ gbc_TFVal.anchor = GridBagConstraints.CENTER;
gbc_TFVal.insets = new Insets(0, 0, 0, 5);
gbc_TFVal.gridx = 3;
- gbc_TFVal.gridy = GuiHookRegCounter;
+ gbc_TFVal.gridy = hookRegNextId;
gbc_TFVal.weightx = 1;
gbc_TFVal.weighty = 0.1;
- RegPanel.add(TFVal, gbc_TFVal);
- regsVals.put(TFReg, TFVal);
+ regPanel.add(valTF, gbc_TFVal);
+ regsVals.put(regTF, valTF);
JButton btnDel = new JButton("");
btnDel.setBorder(null);
btnDel.setContentAreaFilled(false);
- btnDel.setIcon(AngryGhidraProvider.deleteIcon);
+ btnDel.setIcon(mProvider.getDeleteIcon());
GridBagConstraints gbc_btnDel = new GridBagConstraints();
gbc_btnDel.insets = new Insets(0, 0, 0, 5);
gbc_btnDel.fill = GridBagConstraints.HORIZONTAL;
- gbc_btnDel.anchor = GridBagConstraints.NORTH;
+ gbc_btnDel.anchor = GridBagConstraints.CENTER;
gbc_btnDel.gridx = 0;
- gbc_btnDel.gridy = GuiHookRegCounter++;
+ gbc_btnDel.gridy = hookRegNextId++;
gbc_btnDel.weighty = 0.1;
- RegPanel.add(btnDel, gbc_btnDel);
+ regPanel.add(btnDel, gbc_btnDel);
delButtons.add(btnDel);
btnDel.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- GuiHookRegCounter--;
- RegPanel.remove(TFReg);
- RegPanel.remove(TFVal);
- RegPanel.remove(btnDel);
+ public void actionPerformed(ActionEvent actionEvent) {
+ hookRegNextId--;
delButtons.remove(btnDel);
- regsVals.remove(TFReg, TFVal);
- RegPanel.repaint();
- RegPanel.revalidate();
+ regsVals.remove(regTF, valTF);
+ regPanel.remove(regTF);
+ regPanel.remove(valTF);
+ regPanel.remove(btnDel);
+ regPanel.repaint();
+ regPanel.revalidate();
+ frame.setSize(frame.getWidth(), frame.getHeight() - 25);
}
});
- RegPanel.repaint();
- RegPanel.revalidate();
+ regPanel.repaint();
+ regPanel.revalidate();
+ frame.setSize(frame.getWidth(), frame.getHeight() + 25);
}
});
+
JPanel AddrPanel = new JPanel();
-
- GroupLayout groupLayout = new GroupLayout(hookframe.getContentPane());
+ GroupLayout groupLayout = new GroupLayout(frame.getContentPane());
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.TRAILING)
.addGroup(groupLayout.createSequentialGroup()
@@ -283,7 +305,7 @@ public void actionPerformed(ActionEvent e) {
.addComponent(AddrPanel, GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)
.addGap(39)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
- .addComponent(RegPanel, GroupLayout.DEFAULT_SIZE, 238, Short.MAX_VALUE)
+ .addComponent(regPanel, GroupLayout.DEFAULT_SIZE, 238, Short.MAX_VALUE)
.addComponent(lbRegisters, GroupLayout.DEFAULT_SIZE, 238, Short.MAX_VALUE))
.addContainerGap())
.addGroup(groupLayout.createSequentialGroup()
@@ -299,7 +321,7 @@ public void actionPerformed(ActionEvent e) {
.addGroup(groupLayout.createSequentialGroup()
.addComponent(lbRegisters, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
- .addComponent(RegPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+ .addComponent(regPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addComponent(AddrPanel, 0, 0, Short.MAX_VALUE))
.addPreferredGap(ComponentPlacement.RELATED, 130, Short.MAX_VALUE)
.addComponent(btnCreate)
@@ -311,63 +333,67 @@ public void actionPerformed(ActionEvent e) {
gbl_AddrPanel.columnWeights = new double[]{1.0, Double.MIN_VALUE};
gbl_AddrPanel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
AddrPanel.setLayout(gbl_AddrPanel);
-
- JLabel lbAddress = new JLabel("Hook at address:");
- lbAddress.setFont(new Font("SansSerif", Font.PLAIN, 12));
+
+ JLabel lbAddress = new JLabel("Hook address:");
+ lbAddress.setFont(sansSerif);
GridBagConstraints gbc_lbAddress = new GridBagConstraints();
gbc_lbAddress.anchor = GridBagConstraints.SOUTH;
gbc_lbAddress.insets = new Insets(0, 0, 5, 5);
gbc_lbAddress.gridx = 0;
gbc_lbAddress.gridy = 0;
AddrPanel.add(lbAddress, gbc_lbAddress);
-
- TFAddress = new IntegerTextField();
- TFAddress.setHexMode();
+
+ addressTF = new IntegerTextField();
+ addressTF.setHexMode();
GridBagConstraints gbc_AddrPanel = new GridBagConstraints();
gbc_AddrPanel.fill = GridBagConstraints.HORIZONTAL;
gbc_AddrPanel.gridx = 0;
gbc_AddrPanel.gridy = 1;
- AddrPanel.add(TFAddress.getComponent(), gbc_AddrPanel);
-
+ AddrPanel.add(addressTF.getComponent(), gbc_AddrPanel);
+
JLabel lblHookLength = new JLabel("Hook length:");
- lblHookLength.setFont(new Font("SansSerif", Font.PLAIN, 12));
+ lblHookLength.setFont(sansSerif);
GridBagConstraints gbc_lblHookLength = new GridBagConstraints();
gbc_lblHookLength.anchor = GridBagConstraints.SOUTH;
gbc_lblHookLength.insets = new Insets(0, 0, 5, 5);
gbc_lblHookLength.gridx = 0;
gbc_lblHookLength.gridy = 2;
AddrPanel.add(lblHookLength, gbc_lblHookLength);
-
- TFLength = new IntegerTextField();
- TFLength.setDecimalMode();
- GridBagConstraints gbc_TFLength = new GridBagConstraints();
- gbc_TFLength.fill = GridBagConstraints.HORIZONTAL;
- gbc_TFLength.gridx = 0;
- gbc_TFLength.gridy = 3;
- AddrPanel.add(TFLength.getComponent(), gbc_TFLength);
- hookframe.getContentPane().setLayout(groupLayout);
+
+ lengthTF = new IntegerTextField();
+ lengthTF.setDecimalMode();
+ GridBagConstraints gbc_lengthTF = new GridBagConstraints();
+ gbc_lengthTF.fill = GridBagConstraints.HORIZONTAL;
+ gbc_lengthTF.gridx = 0;
+ gbc_lengthTF.gridy = 3;
+ AddrPanel.add(lengthTF.getComponent(), gbc_lengthTF);
+ frame.getContentPane().setLayout(groupLayout);
}
-
-
- public static void requestClearHooks() {
- GuiHookRegCounter = 2;
- if (RegPanel == null) {
+
+ public void requestClearHooks() {
+ hookNextId = 2;
+ hookRegNextId = 2;
+ if (regPanel == null) {
return;
}
if (delButtons != null){
for (JButton button : delButtons) {
- RegPanel.remove(button);
+ regPanel.remove(button);
}
delButtons.clear();
}
if (regsVals != null){
for (Entry