Documentation Index
Fetch the complete documentation index at: https://mintlify.com/NationalSecurityAgency/ghidra/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The FunctionManager interface provides methods for creating, retrieving, and managing functions within a Ghidra program. It handles function creation, deletion, iteration, and querying.Interface
Package:ghidra.program.model.listingLocation:
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/FunctionManager.java
Basic Methods
getProgram()
Returns this manager’s program.getFunctionCount()
Returns the total number of functions in the program, including external functions.Function Creation
createFunction() - Basic
Creates a function with the given body at entry point within the global namespace.name- The name of the new function or null for default nameentryPoint- Entry point of the functionbody- Addresses contained in the function bodysource- The source of this function (e.g.,SourceType.USER_DEFINED,SourceType.ANALYSIS)
InvalidInputException- If the name has invalid charactersOverlappingFunctionException- If the address set overlaps an existing function
createFunction() - With Namespace
Creates a function with the given body at entry point in a specific namespace.name- The name of the new function or null for default namenameSpace- The namespace in which to create the functionentryPoint- Entry point of the functionbody- Addresses contained in the function bodysource- The source of this function
InvalidInputException- If the name has invalid charactersOverlappingFunctionException- If the address set overlaps an existing function
createThunkFunction()
Creates a thunk function with the given body at entry point.name- The name of the new function or null for default namenameSpace- The namespace in which to create the functionentryPoint- Entry point of the functionbody- Addresses contained in the function bodythunkedFunction- Referenced function (required when creating a thunk)source- The source of this function
OverlappingFunctionException- If the address set overlaps an existing functionUnsupportedOperationException- If invoked on an external entryPoint address
Function Deletion
removeFunction()
Removes the function defined at the specified entry point.entryPoint- The entry point of the function to remove
true if the function was removed
Function Retrieval
getFunctionAt()
Returns the function at the specified entry point.entryPoint- The entry point address
getReferencedFunction()
Returns the function which resides at or is referenced from the specified address.address- Function address or address of pointer to a function
getFunctionContaining()
Returns the function containing the specified address.addr- Address within the function
getFunction()
Returns a function by its unique key.key- Function symbol key
Function Iteration
getFunctions() - All Functions
Returns an iterator over all non-external functions in address (entry point) order.forward-trueto iterate in ascending address order
getFunctions() - Starting at Address
Returns an iterator over non-external functions starting at an address.start- Starting addressforward-trueto iterate in ascending address order
getFunctions() - Address Set
Returns an iterator over functions with entry points in the specified address set.asv- Address set to iterate overforward-trueto iterate in ascending address order
getFunctionsNoStubs()
Returns an iterator over REAL functions (functions with instructions, not stubs).forward-trueto iterate in ascending address order
getFunctionsNoStubs() - Starting at Address
Returns an iterator over REAL functions starting at an address.start- Starting addressforward-trueto iterate in ascending address order
getFunctionsNoStubs() - Address Set
Returns an iterator over REAL functions in the specified address set.asv- Address set to iterate overforward-trueto iterate in ascending address order
getExternalFunctions()
Returns an iterator over all external functions.getFunctionsOverlapping()
Returns an iterator over functions that overlap the given address set.set- Address set of interest
Query Methods
isInFunction()
Checks if an address is contained within a function.addr- Address to check
true if the address is contained in a function
Calling Convention Methods
getCallingConventionNames()
Returns the ordered list of defined calling convention names.The reserved names “unknown” and “default” are not included. This set is limited to those defined by the compiler specification.
getDefaultCallingConvention()
Returns the default calling convention’s prototype model.getCallingConvention()
Returns the prototype model of the specified calling convention.name- The calling convention name
Variable Methods
getReferencedVariable()
Determines which local function variable is referenced by a specific reference.instrAddr- The instruction addressstorageAddr- The storage addresssize- Varnode size in bytes (1 is assumed if value is less than or equal to 0)isRead-trueif the reference is a read reference
Tag Management
getFunctionTagManager()
Returns the function tag manager.Usage Examples
Creating a Function
Iterating Over Functions
Finding Functions
Working with Calling Conventions
See Also
- Decompiler - Decompiling functions
- Reference Manager - Managing references to/from functions
- Analyzers - Creating analyzers that work with functions
