Ghidra is a software reverse engineering (SRE) framework
GP-7044 - Find Uses - Updated finding code for FunctionDefinitions to find all references
dragonmacherc0d344faba2f
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/FunctionDefinitionLocationDescriptor.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/FunctionDefinitionLocationDescriptor.javaindex 9da5e83915..0f217cc1fa 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/FunctionDefinitionLocationDescriptor.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/FunctionDefinitionLocationDescriptor.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -16,6 +16,7 @@package ghidra.app.plugin.core.navigation.locationreferences;import ghidra.program.database.symbol.FunctionSymbol;+import ghidra.program.model.address.Address;import ghidra.program.model.data.*;import ghidra.program.model.listing.*;import ghidra.program.model.symbol.*;@@ -39,6 +40,13 @@ public class FunctionDefinitionLocationDescriptor extends GenericDataTypeLocatioprotected void doGetReferences(Accumulator<LocationReference> accumulator, TaskMonitor monitor)throws CancelledException {+ findAppliedFunctionDefinition(accumulator);++ ReferenceUtils.findDataTypeReferences(accumulator, functionDefinition, program, true,+ monitor);+ }++ private void findAppliedFunctionDefinition(Accumulator<LocationReference> accumulator) {DataType myReturnType = functionDefinition.getReturnType();ParameterDefinition[] myParameters = functionDefinition.getArguments();@@ -48,15 +56,14 @@ public class FunctionDefinitionLocationDescriptor extends GenericDataTypeLocatio// the definition could be applied in more than one namespace, so handle each applicationwhile (symbols.hasNext()) {- Symbol symbol = symbols.next();- if (!(symbol instanceof FunctionSymbol)) {+ Symbol symbol = symbols.next();+ if (!(symbol instanceof FunctionSymbol functionSymbol)) {continue;}- FunctionSymbol functionSymbol = (FunctionSymbol) symbol;+long symbolID = functionSymbol.getID();Function function = functionManager.getFunction(symbolID);-FunctionSignature signature = function.getSignature(true);ParameterDefinition[] theirParameters = signature.getArguments();if (!isSameParamters(myParameters, theirParameters)) {@@ -67,7 +74,14 @@ public class FunctionDefinitionLocationDescriptor extends GenericDataTypeLocatiocontinue;}- accumulator.add(new LocationReference(symbol.getAddress()));+ ProgramLocation location = symbol.getProgramLocation();+ Address address = symbol.getAddress();+ if (location != null) {+ accumulator.add(new LocationReference(address, null, location));+ }+ else {+ accumulator.add(new LocationReference(address));+ }}}