Class FunctionUtility

java.lang.Object
ghidra.program.util.FunctionUtility

public class FunctionUtility extends Object
Utility methods for performing function related actions.
  • Method Details

    • updateFunction

      public static void updateFunction(Function destinationFunction, Function sourceFunction) throws InvalidInputException, DuplicateNameException
      Updates the destination function so its signature will match the source function's signature as closely as possible. This method will try to create conflict names if necessary for the function and its parameters.
      Parameters:
      destinationFunction - the destination function to update
      sourceFunction - the source function to use as a template
      Throws:
      InvalidInputException - if the function name or a variable name is invalid or if a parameter data type is not a fixed length.
      DuplicateNameException - This shouldn't happen since it will try to create conflict names for the function and its variables if necessary. Otherwise, this would be because the function's name or a variable name already exists.
    • setUniqueParameterNames

      public static void setUniqueParameterNames(Function function, List<Parameter> parameters) throws DuplicateNameException, InvalidInputException
      Changes the names of the parameters in the array to unique names that won't conflict with any other names in the function's namespace when the parameters are used to replace the existing parameters in the function. Appends an integer number to the base name if necessary to create a unique name in the function's namespace.
      Parameters:
      function - the function
      parameters - the parameters that need names that won't conflict. These should be Impl objects and not DB objects since their names will be changed within this method.
      Throws:
      InvalidInputException
      DuplicateNameException
    • isSameLanguageAndCompilerSpec

      public static boolean isSameLanguageAndCompilerSpec(Program program1, Program program2)
      Determines whether or not the two programs are considered to have the same processor language and compiler specification.
      Parameters:
      program1 - the first program
      program2 - the second program
      Returns:
      true if the two programs have the same processor language and compiler spec.
    • isDefaultFunctionName

      public static boolean isDefaultFunctionName(Function function)
      Determines if the indicated function has a default name.
      Parameters:
      function - the function
      Returns:
      true if the function has a default name.
    • getFunctionTitle

      public static String getFunctionTitle(Function function)
      Gets a title string wrapped as HTML and indicating the function's name and the program containing it.
      Parameters:
      function - the function to be indicated in the title.
      Returns:
      the title string as HTML.