Ghidra is a software reverse engineering (SRE) framework
GP-5111 don't filter 'pointer' built-in data type like other pointers Also fix data type drop down filtering to not exclude built-in pointerdata types (pointer, pointer16, etc)
dev747368dbc56811caf1
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/DtFilterState.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/DtFilterState.javaindex 6dd5d83d1b..825711aa2f 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/DtFilterState.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/DtFilterState.java@@ -134,16 +134,23 @@ public class DtFilterState {return true;}- DataType baseDt = DataTypeUtils.getBaseDataType(dt);-if (dt instanceof Array) {return passes(arraysFilter, dt);}- if (dt instanceof Pointer) {+ if (dt instanceof Pointer ptrDt) {+ if (ptrDt.getDataType() == null) {+ // special check for a pointer data type that is equivalent to the+ // built-in base "pointer" data type ("pointer" does not have a target type).+ // Returning 'true' here allows this data type to bypass the filter just like+ // builtin int/float types will at the bottom of this method.+ return true;+ }return passes(pointersFilter, dt);}+ DataType baseDt = DataTypeUtils.getBaseDataType(dt);+if (baseDt instanceof Enum) {return passes(enumsFilter, dt);}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/datatype/DataTypeDropDownSelectionDataModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/datatype/DataTypeDropDownSelectionDataModel.javaindex 6fb9b36f92..6bbe66a347 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/datatype/DataTypeDropDownSelectionDataModel.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/datatype/DataTypeDropDownSelectionDataModel.java@@ -147,15 +147,17 @@ public class DataTypeDropDownSelectionDataModel implements DropDownTextFieldData// another dtm. In the second step, duplicate data types will be omitted from the// final results, in favor of the data type that is already in the preferred dtm.Set<UniversalID> preferredUids = new HashSet<>();- Set<Class<?>> preferredBuiltins = new HashSet<>();+ Set<String> preferredBuiltinNames = new HashSet<>();for (DataType dt : dtList) {- DataType baseDt = DataTypeUtilities.getBaseDataType(dt);+ // only look at data types that are already in the preferred DTM+ DataType baseDt = Objects.requireNonNullElse(DataTypeUtilities.getBaseDataType(dt), dt);if (!isFromPreferredDtm(baseDt)) {continue;}- if (baseDt instanceof BuiltInDataType) {- preferredBuiltins.add(baseDt.getClass());+ if (isBuiltinDataType(baseDt)) {+ // add any builtin data types that are already in the pref DTM to this exclude list+ preferredBuiltinNames.add(baseDt.getName());}else if (baseDt.getUniversalID() != null) {preferredUids.add(baseDt.getUniversalID());@@ -167,14 +169,14 @@ public class DataTypeDropDownSelectionDataModel implements DropDownTextFieldDataif (dt instanceof Array) {continue;}- DataType baseDt = DataTypeUtilities.getBaseDataType(dt);+ DataType baseDt =+ Objects.requireNonNullElse(DataTypeUtilities.getBaseDataType(dt), dt);if (baseDt == null) {continue;}if (preferredDtm != null && !isFromPreferredDtm(baseDt)) {- if (baseDt instanceof BuiltInDataType &&- preferredBuiltins.contains(baseDt.getClass())) {+ if (isBuiltinDataType(baseDt) && preferredBuiltinNames.contains(baseDt.getName())) {continue;}if (baseDt.getUniversalID() != null &&@@ -204,6 +206,14 @@ public class DataTypeDropDownSelectionDataModel implements DropDownTextFieldDatareturn false;}+ private boolean isBuiltinDataType(DataType dt) {+ // check for normal builtin data types, as well as any pointer (which will probably be a+ // DataTypeDB that does not derive from Builtin) that does not point to anything.+ // This ptr data type is equiv to the "pointer" built-in data type.+ return dt instanceof BuiltInDataType ||+ (dt instanceof Pointer ptrDT && ptrDT.getDataType() == null);+ }+@Overridepublic int getIndexOfFirstMatchingEntry(List<DataType> data, String text) {