Package ghidra.program.model.listing
Interface FunctionManager
- All Superinterfaces:
ManagerDB
- All Known Implementing Classes:
FunctionManagerDB
The manager for functions
-
Method Summary
Modifier and TypeMethodDescriptioncreateFunction
(String name, Address entryPoint, AddressSetView body, SourceType source) Create a function with the given body at entry point within the global namespace.createFunction
(String name, Namespace nameSpace, Address entryPoint, AddressSetView body, SourceType source) Create a function with the given body at entry point.createThunkFunction
(String name, Namespace nameSpace, Address entryPoint, AddressSetView body, Function thunkedFunction, SourceType source) Create a thunk function with the given body at entry point.getCallingConvention
(String name) Gets the prototype model of the calling convention with the specified name in this programGet the ordered list of defined calling convention names.Gets the default calling convention's prototype model in this program.Get an iterator over all external functions.getFunction
(long key) Get a Function object by its keygetFunctionAt
(Address entryPoint) Get the function at entryPointgetFunctionContaining
(Address addr) Get a function containing an address.int
Returns the total number of functions in the program including external functionsgetFunctions
(boolean forward) Returns an iterator over all non-external functions in address (entry point) ordergetFunctions
(Address start, boolean forward) Get an iterator over non-external functions starting at an address and ordered by entry addressgetFunctions
(AddressSetView asv, boolean forward) Get an iterator over functions with entry points in the specified address set.getFunctionsNoStubs
(boolean forward) Returns an iterator over all REAL functions in address (entry point) order (real functions have instructions, and aren't stubs)getFunctionsNoStubs
(Address start, boolean forward) Get an iterator over REAL functions starting at an address and ordered by entry address (real functions have instructions, and aren't stubs).getFunctionsNoStubs
(AddressSetView asv, boolean forward) Get an iterator over REAL functions with entry points in the specified address set (real functions have instructions, and aren't stubs).Return an iterator over functions that overlap the given address set.Returns the function tag managerReturns this manager's programgetReferencedFunction
(Address address) Get the function which resides at the specified address or is referenced from the specified addressgetReferencedVariable
(Address instrAddr, Address storageAddr, int size, boolean isRead) Attempts to determine which if any of the local functions variables are referenced by the specified reference.void
invalidateCache
(boolean all) Clears all data cachesboolean
isInFunction
(Address addr) Check if this address contains a function.void
moveAddressRange
(Address fromAddr, Address toAddr, long length, TaskMonitor monitor) Move all objects within an address range to a new locationboolean
removeFunction
(Address entryPoint) Remove a function defined at entryPointMethods inherited from interface ghidra.program.database.ManagerDB
deleteAddressRange, dispose, programReady, setProgram
-
Method Details
-
getProgram
Program getProgram()Returns this manager's program- Returns:
- the program
-
getCallingConventionNames
Collection<String> getCallingConventionNames()Get the ordered list of defined calling convention names. The reserved names "unknown" and "default" are not included. The returned collection may not include all names referenced by various functions and function-definitions. This set is limited to those defined by the associated compiler specification. SeeDataTypeManager.getDefinedCallingConventionNames()
.For a set of all known names (including those that are not defined by compiler spec) see
DataTypeManager.getKnownCallingConventionNames()
.- Returns:
- the calling convention names.
-
getDefaultCallingConvention
PrototypeModel getDefaultCallingConvention()Gets the default calling convention's prototype model in this program.- Returns:
- the default calling convention prototype model or null.
-
getCallingConvention
Gets the prototype model of the calling convention with the specified name in this program- Parameters:
name
- the calling convention name- Returns:
- the named function calling convention prototype model or null.
-
createFunction
Function createFunction(String name, Address entryPoint, AddressSetView body, SourceType source) throws InvalidInputException, OverlappingFunctionException Create a function with the given body at entry point within the global namespace.- Parameters:
name
- the name of the new function or null for default nameentryPoint
- entry point of functionbody
- addresses contained in the function bodysource
- the source of this function- Returns:
- new function or null if one or more functions overlap the specified body address set.
- Throws:
InvalidInputException
- if the name has invalid charactersOverlappingFunctionException
- if the address set of the body overlaps an existing function
-
createFunction
Function createFunction(String name, Namespace nameSpace, Address entryPoint, AddressSetView body, SourceType source) throws InvalidInputException, OverlappingFunctionException Create a function with the given body at entry point.- Parameters:
name
- the name of the new function or null for default namenameSpace
- the nameSpace in which to create the functionentryPoint
- entry point of functionbody
- addresses contained in the function bodysource
- the source of this function- Returns:
- new function or null if one or more functions overlap the specified body address set.
- Throws:
InvalidInputException
- if the name has invalid charactersOverlappingFunctionException
- if the address set of the body overlaps an existing function
-
createThunkFunction
Function createThunkFunction(String name, Namespace nameSpace, Address entryPoint, AddressSetView body, Function thunkedFunction, SourceType source) throws OverlappingFunctionException Create a thunk function with the given body at entry point.- Parameters:
name
- the name of the new function or null for default namenameSpace
- the nameSpace in which to create the functionentryPoint
- entry point of functionbody
- addresses contained in the function bodythunkedFunction
- referenced function (required is creating a thunk function)source
- the source of this function- Returns:
- new function or null if one or more functions overlap the specified body address set.
- Throws:
OverlappingFunctionException
- if the address set of the body overlaps an existing function
-
getFunctionCount
int getFunctionCount()Returns the total number of functions in the program including external functions- Returns:
- the count
-
removeFunction
Remove a function defined at entryPoint- Parameters:
entryPoint
- the entry point- Returns:
- true if the function was removed
-
getFunctionAt
Get the function at entryPoint- Parameters:
entryPoint
- the entry point- Returns:
- null if there is no function at entryPoint
-
getReferencedFunction
Get the function which resides at the specified address or is referenced from the specified address- Parameters:
address
- function address or address of pointer to a function.- Returns:
- referenced function or null
-
getFunctionContaining
Get a function containing an address.- Parameters:
addr
- address within the function- Returns:
- function containing this address, null otherwise
-
getFunctions
Returns an iterator over all non-external functions in address (entry point) order- Parameters:
forward
- true means to iterate in ascending address order- Returns:
- the iterator
-
getFunctions
Get an iterator over non-external functions starting at an address and ordered by entry address- Parameters:
start
- starting addressforward
- true means to iterate in ascending address order- Returns:
- an iterator over functions.
-
getFunctions
Get an iterator over functions with entry points in the specified address set. Function are ordered based upon entry address.- Parameters:
asv
- address set to iterate overforward
- true means to iterate in ascending address order- Returns:
- an iterator over functions.
-
getFunctionsNoStubs
Returns an iterator over all REAL functions in address (entry point) order (real functions have instructions, and aren't stubs)- Parameters:
forward
- true means to iterate in ascending address order- Returns:
- the iterator
-
getFunctionsNoStubs
Get an iterator over REAL functions starting at an address and ordered by entry address (real functions have instructions, and aren't stubs).- Parameters:
start
- starting addressforward
- true means to iterate in ascending address order- Returns:
- an iterator over functions.
-
getFunctionsNoStubs
Get an iterator over REAL functions with entry points in the specified address set (real functions have instructions, and aren't stubs). Functions are ordered based upon entry address.- Parameters:
asv
- address set to iterate overforward
- true means to iterate in ascending address order- Returns:
- an iterator over functions.
-
getExternalFunctions
FunctionIterator getExternalFunctions()Get an iterator over all external functions. Functions returned have no particular order.- Returns:
- an iterator over external functions
-
isInFunction
Check if this address contains a function.- Parameters:
addr
- address to check- Returns:
- true if this address is contained in a function.
-
getFunctionsOverlapping
Return an iterator over functions that overlap the given address set.- Parameters:
set
- address set of interest- Returns:
- iterator over Functions
-
getReferencedVariable
Attempts to determine which if any of the local functions variables are referenced by the specified reference. In utilizing the firstUseOffset scoping model, negative offsets (relative to the functions entry) are shifted beyond the maximum positive offset within the function. While this does not account for the actual instruction flow, it is hopefully accurate enough for most situations.- Parameters:
instrAddr
- the instruction addressstorageAddr
- the storage addresssize
- varnode size in bytes (1 is assumed if value <= 0)isRead
- true if the reference is a read reference- Returns:
- referenced variable or null if one not found
-
getFunction
Get a Function object by its key- Parameters:
key
- function symbol key- Returns:
- function object or null if not found
-
getFunctionTagManager
FunctionTagManager getFunctionTagManager()Returns the function tag manager- Returns:
- the function tag manager
-
invalidateCache
void invalidateCache(boolean all) Clears all data caches- Specified by:
invalidateCache
in interfaceManagerDB
- Parameters:
all
- if false, some managers may not need to update their cache if they can tell that its not necessary. If this flag is true, then all managers should clear their cache no matter what.
-
moveAddressRange
void moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor) throws CancelledException Move all objects within an address range to a new location- Specified by:
moveAddressRange
in interfaceManagerDB
- Parameters:
fromAddr
- the first address of the range to be movedtoAddr
- the address where to the range is to be movedlength
- the number of addresses to movemonitor
- the task monitor to use in any upgrade operations- Throws:
CancelledException
- if the user cancelled the operation via the task monitor
-