Ghidra is a software reverse engineering (SRE) framework
GP-4592 Find references to structure fields in local variables and in functions that call externals that might use the structure field
emteeredea69c7027a2
diff --git a/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/DecompilerDataTypeReferenceFinder.java b/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/DecompilerDataTypeReferenceFinder.javaindex e06a7475d5..b3de9e39ed 100644--- a/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/DecompilerDataTypeReferenceFinder.java+++ b/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/DecompilerDataTypeReferenceFinder.java@@ -129,6 +129,20 @@ public class DecompilerDataTypeReferenceFinder implements DataTypeReferenceFindecallers.addAll(callingFunctions);}+ results.addAll(callers);++ // Add any callers to external function that use any form of the data type+ it = listing.getExternalFunctions();+ callers = new HashSet<>();+ for (Function f : it) {+ monitor.checkCancelled();++ if (usesAnyType(f, types)) {+ Set<Function> callingFunctions = f.getCallingFunctions(monitor);+ callers.addAll(callingFunctions);+ }+ }+results.addAll(callers);return results;diff --git a/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/VariableAccessDR.java b/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/VariableAccessDR.javaindex c7b7981f9f..cb62fd64d2 100644--- a/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/VariableAccessDR.java+++ b/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/VariableAccessDR.java@@ -188,11 +188,11 @@ public class VariableAccessDR extends DecompilerReference {// the thing that contains it. So, if you have:// foo.bar// then the 'bar' field will have a data type of Foo. Unfortunately, this is not always- // the case. For now, when the variable is global, we need to check the field. Sad face+ // the case. For now, if there is a high variable, we need to check the field. Sad face// emoji.//HighVariable highVariable = var.variable.getHighVariable();- if (highVariable instanceof HighGlobal) {+ if (highVariable != null) {if (matchesParentType(potentialField, dt)) {DtrfDbg.println(this, indent + "MATCHED on parent type: " + dt);return potentialField;