From b15b51e48eb03ca8e6fbf3d3a589b7c9d74863a4 Mon Sep 17 00:00:00 2001 From: ghizard <50744617+ghizard@users.noreply.github.com> Date: Tue, 13 May 2025 12:45:19 -0400 Subject: [PATCH] GP-5661 - Fix SourceType issue in Apply Data Archives --- .../function/ApplyFunctionDataTypesCmd.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/ApplyFunctionDataTypesCmd.java b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/ApplyFunctionDataTypesCmd.java index caf00f7711..cc496e8c91 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/ApplyFunctionDataTypesCmd.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/ApplyFunctionDataTypesCmd.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. @@ -47,7 +47,7 @@ public class ApplyFunctionDataTypesCmd extends BackgroundCommand { /** * Constructs a new command to apply all function signature data types * in the given data type manager. - * + * * @param managers list of data type managers containing the function signature data types * @param set set of addresses containing labels to match against function names. * The addresses must not already be included in the body of any existing function. @@ -71,7 +71,7 @@ public class ApplyFunctionDataTypesCmd extends BackgroundCommand { /** * Constructs a new command to apply all function signature data types * in the given data type category (includes all subcategories). - * + * * @param sourceCategory datatype category containing the function signature data types * @param set set of addresses containing labels to match against function names. * The addresses must not already be included in the body of any existing function. @@ -158,7 +158,7 @@ public class ApplyFunctionDataTypesCmd extends BackgroundCommand { /** * Strip off the last name of the string - * + * * @param name the original string * @return the last name in the string */ @@ -259,7 +259,8 @@ public class ApplyFunctionDataTypesCmd extends BackgroundCommand { } SourceType mostTrusted = getMostTrustedParameterSource(func); - if (alwaysReplace || !source.isLowerPriorityThan(mostTrusted)) { + // Do not replace function if one with same SourceType exists + if (alwaysReplace || source.isHigherPriorityThan(mostTrusted)) { applyFunction(sym, fdef); } return; @@ -308,7 +309,7 @@ public class ApplyFunctionDataTypesCmd extends BackgroundCommand { /** * Check that the symbol looks like it is at the start of a function. * There can be internal symbols that may match a function name. - * + * * @param monitor if need to cancel * @param address location of the potential symbol * @return true if the symbol is at the start of a function flow @@ -342,7 +343,7 @@ public class ApplyFunctionDataTypesCmd extends BackgroundCommand { /** * Get the instruction directly before this address, makeing sure it is the * head instruction in a delayslot - * + * * @param address to get instruction before * @return instruction if found, null otherwise */ @@ -395,7 +396,7 @@ public class ApplyFunctionDataTypesCmd extends BackgroundCommand { /** * Lookup any program symbol with the same name as the function signature. * Also allow for a single '_' in front of the symbol name. - * + * * @param symbolMap map of symbol names to all matching symbols * @param prefix optional prefix on symbol to lookup * @param functionName function name