-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support to change registers from ghidra
- Loading branch information
Benedikt Schmotzle
committed
May 28, 2019
1 parent
35b7aa8
commit c817839
Showing
5 changed files
with
152 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package gdbghidra; | ||
|
||
import java.awt.event.ActionEvent; | ||
import java.beans.PropertyChangeEvent; | ||
import java.beans.PropertyChangeListener; | ||
|
||
import javax.swing.Action; | ||
import javax.swing.JTable; | ||
import javax.swing.SwingUtilities; | ||
|
||
public class RegisterChangeListener implements PropertyChangeListener, Runnable { | ||
private JTable table; | ||
private Action action; | ||
|
||
private int row; | ||
private int column; | ||
private Object oldValue; | ||
private Object newValue; | ||
|
||
public RegisterChangeListener(JTable table, Action action) { | ||
this.table = table; | ||
this.action = action; | ||
this.table.addPropertyChangeListener(this); | ||
} | ||
|
||
private RegisterChangeListener(JTable table, int row, int column, Object oldValue, Object newValue) { | ||
this.table = table; | ||
this.row = row; | ||
this.column = column; | ||
this.oldValue = oldValue; | ||
this.newValue = newValue; | ||
} | ||
|
||
public int getColumn() { | ||
return column; | ||
} | ||
|
||
public Object getNewValue() { | ||
return newValue; | ||
} | ||
|
||
public Object getOldValue() { | ||
return oldValue; | ||
} | ||
|
||
public int getRow() { | ||
return row; | ||
} | ||
|
||
public JTable getTable() { | ||
return table; | ||
} | ||
|
||
@Override | ||
public void propertyChange(PropertyChangeEvent e) { | ||
if ("tableCellEditor".equals(e.getPropertyName())) { | ||
if (table.isEditing()) | ||
processEditingStarted(); | ||
else | ||
processEditingStopped(); | ||
} | ||
} | ||
|
||
private void processEditingStarted() { | ||
SwingUtilities.invokeLater(this); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
row = table.convertRowIndexToModel(table.getEditingRow()); | ||
column = table.convertColumnIndexToModel(table.getEditingColumn()); | ||
oldValue = table.getModel().getValueAt(row, column); | ||
newValue = null; | ||
} | ||
|
||
private void processEditingStopped() { | ||
newValue = table.getModel().getValueAt(row, column); | ||
|
||
if (!newValue.equals(oldValue)) { | ||
RegisterChangeListener tcl = new RegisterChangeListener(getTable(), getRow(), getColumn(), getOldValue(), | ||
getNewValue()); | ||
|
||
ActionEvent event = new ActionEvent(tcl, ActionEvent.ACTION_PERFORMED, ""); | ||
action.actionPerformed(event); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters