Ghidra is a software reverse engineering (SRE) framework
GP-3967 - Fixed bug in structure table searching that prevented the searching of all columns; updated the search to also check the default name
dragonmacherd2d396946423
diff --git a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeEditors/StructureEditor.htm b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeEditors/StructureEditor.htmindex 7dcdfdbc87..eb0c250284 100644--- a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeEditors/StructureEditor.htm+++ b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeEditors/StructureEditor.htm@@ -128,7 +128,12 @@Alternatively, the down <IMG src="images/go-down.tango.16.png" alt=""> and up <IMG src="images/go-up.tango.16.png" alt=""> arrows next to the search field can be used to searchforwards and backwards respectively. Searches are not case sensitive.</P>+++ <P><IMG src="help/shared/tip.png" alt="" border="0">The default name of each structure field+ will also be examined when searching, even though they are not visible in the UI.</P></BLOCKQUOTE>+<H2><A name="Structure_Editor_Name"></A>Changing the Name</H2>diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorPanel.javaindex cfea806fff..e9288a844f 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorPanel.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorPanel.java@@ -1031,9 +1031,6 @@ public abstract class CompositeEditorPanel extends JPanel}}- /* (non-Javadoc)- * @see ghidra.app.plugin.datamanager.editor.CompositeEditorModelListener#endFieldEditing()- */@Overridepublic void endFieldEditing() {stopCellEditing();@@ -1042,9 +1039,6 @@ public abstract class CompositeEditorPanel extends JPanel}}- /* (non-Javadoc)- * @see ghidra.app.plugin.compositeeditor.CompositeModelStatusListener#statusChanged(java.lang.String, boolean)- */@Overridepublic void statusChanged(String message, boolean beep) {if ((message == null) || (message.length() == 0)) {@@ -1068,8 +1062,10 @@ public abstract class CompositeEditorPanel extends JPanel}- private Integer findForward(String searchText) {- int colCount = model.getColumnCount();+ private Integer findForward(String text) {++ String searchText = text.toLowerCase();+ int colCount = table.getColumnCount();int currentRow = Math.max(0, model.getRow());// search remaining lines@@ -1081,7 +1077,7 @@ public abstract class CompositeEditorPanel extends JPanel}}}- // wrap search search rows from beginning+ // wrap search - search rows from beginningfor (int row = 0; row < currentRow; row++) {for (int col = 0; col < colCount; col++) {if (matchesSearch(searchText, row, col)) {@@ -1094,7 +1090,9 @@ public abstract class CompositeEditorPanel extends JPanelreturn null;}- private Integer findBackward(String searchText) {+ private Integer findBackward(String text) {++ String searchText = text.toLowerCase();int colCount = model.getColumnCount();int currentRow = Math.max(0, model.getRow());@@ -1106,7 +1104,7 @@ public abstract class CompositeEditorPanel extends JPanel}}}- //wrap search - search from last row to current row+ // wrap search - search from last row to current rowfor (int row = model.getRowCount() - 1; row >= currentRow; row--) {for (int col = colCount - 1; col >= 0; col--) {if (matchesSearch(searchText, row, col)) {@@ -1120,13 +1118,35 @@ public abstract class CompositeEditorPanel extends JPanel}private boolean matchesSearch(String searchText, int row, int col) {- Object valueAt = model.getValueAt(row, col);+ int modelCol = table.convertColumnIndexToModel(col);+ Object valueAt = model.getValueAt(row, modelCol);if (valueAt == null) {return false;}- String value = getString(valueAt);- return value.toLowerCase().contains(searchText);+ String value = getString(valueAt).toLowerCase();+ if (modelCol == model.getNameColumn()) {+ return nameMatchesSearch(searchText, row, value);+ }++ return value.contains(searchText);+ }++ private boolean nameMatchesSearch(String searchText, int row, String value) {++ if (value.contains(searchText)) {+ return true;+ }++ // see if the default name is a match+ DataTypeComponent dtc = model.getComponent(row);+ if (dtc != null) {+ // this allows this to match a search even though it is not seen in the UI+ String defaultName = dtc.getDefaultFieldName().toLowerCase();+ return defaultName.contains(searchText);+ }++ return false;}private String getString(Object object) {