Package ghidra.program.model.listing
Interface FunctionManager
-
- All Known Implementing Classes:
FunctionManagerDB
public interface FunctionManager
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description FunctioncreateFunction(java.lang.String name, Address entryPoint, AddressSetView body, SourceType source)Create a function with the given body at entry point within the global namespace.FunctioncreateFunction(java.lang.String name, Namespace nameSpace, Address entryPoint, AddressSetView body, SourceType source)Create a function with the given body at entry point.FunctioncreateThunkFunction(java.lang.String name, Namespace nameSpace, Address entryPoint, AddressSetView body, Function thunkedFunction, SourceType source)Create a thunk function with the given body at entry point.voiddeleteAddressRange(Address startAddr, Address endAddr, TaskMonitor monitor)PrototypeModelgetCallingConvention(java.lang.String name)Gets the prototype model of the calling convention with the specified name in this program.java.util.List<java.lang.String>getCallingConventionNames()Gets the names associated with each of the current calling conventions associated with this program.PrototypeModel[]getCallingConventions()Gets all the calling convention prototype models in this program that have names.PrototypeModelgetDefaultCallingConvention()Gets the default calling convention's prototype model in this program.FunctionIteratorgetExternalFunctions()Get an iterator over all external functions.FunctiongetFunction(long key)Get a Function object by its keyFunctiongetFunctionAt(Address entryPoint)Get the function at entryPoint.FunctiongetFunctionContaining(Address addr)Get a function containing an address.intgetFunctionCount()Returns the total number of functions in the program including external functions.FunctionIteratorgetFunctions(boolean forward)Returns an iterator over all non-external functions in address (entry point) order.FunctionIteratorgetFunctions(Address start, boolean foward)Get an iterator over non-external functions starting at an address and ordered by entry address.FunctionIteratorgetFunctions(AddressSetView asv, boolean forward)Get an iterator over functions with entry points in the specified address set.FunctionIteratorgetFunctionsNoStubs(boolean forward)Returns an iterator over all REAL functions in address (entry point) order (real functions have instructions, and aren't stubs).FunctionIteratorgetFunctionsNoStubs(Address start, boolean foward)Get an iterator over REAL functions starting at an address and ordered by entry address (real functions have instructions, and aren't stubs).FunctionIteratorgetFunctionsNoStubs(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).java.util.Iterator<Function>getFunctionsOverlapping(AddressSetView set)Return an iterator over functions that overlap the given address set.ProgramgetProgram()FunctiongetReferencedFunction(Address address)Get the function which resides at the specified address or is referenced from the specified address.VariablegetReferencedVariable(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.voidinvalidateCache(boolean all)booleanisInFunction(Address addr)Check if this address contains a function.voidmoveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor)voidprogramReady(int openMode, int currentRevision, TaskMonitor monitor)booleanremoveFunction(Address entryPoint)Remove a function defined at entryPoint.voidsetProgram(ProgramDB program)
-
-
-
Method Detail
-
getProgram
Program getProgram()
-
getCallingConventionNames
java.util.List<java.lang.String> getCallingConventionNames()
Gets the names associated with each of the current calling conventions associated with this program. Within the exception of "unknown", all of these calling convention names should have a PrototypeModel.- 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
PrototypeModel getCallingConvention(java.lang.String name)
Gets the prototype model of the calling convention with the specified name in this program.- Returns:
- the named function calling convention prototype model or null.
-
getCallingConventions
PrototypeModel[] getCallingConventions()
Gets all the calling convention prototype models in this program that have names.- Returns:
- the function calling convention prototype models.
-
createFunction
Function createFunction(java.lang.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 charactersDuplicateNameException- if a function with the given name already existsOverlappingFunctionException- if the address set of the body overlaps an existing function
-
createFunction
Function createFunction(java.lang.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 charactersDuplicateNameException- if a function with the given name already existsOverlappingFunctionException- if the address set of the body overlaps an existing function
-
createThunkFunction
Function createThunkFunction(java.lang.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.
-
removeFunction
boolean removeFunction(Address entryPoint)
Remove a function defined at entryPoint.
-
getFunctionAt
Function getFunctionAt(Address entryPoint)
Get the function at entryPoint.- Returns:
- null if there is no function at entryPoint.
-
getReferencedFunction
Function getReferencedFunction(Address address)
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
Function getFunctionContaining(Address addr)
Get a function containing an address.- Parameters:
addr- address within the function- Returns:
- function containing this address, null otherwise
-
getFunctions
FunctionIterator getFunctions(boolean forward)
Returns an iterator over all non-external functions in address (entry point) order.- Parameters:
forward- true means to iterate in ascending address order
-
getFunctions
FunctionIterator getFunctions(Address start, boolean foward)
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
FunctionIterator getFunctions(AddressSetView asv, boolean forward)
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
FunctionIterator getFunctionsNoStubs(boolean forward)
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
-
getFunctionsNoStubs
FunctionIterator getFunctionsNoStubs(Address start, boolean foward)
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
FunctionIterator 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). 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
boolean isInFunction(Address addr)
Check if this address contains a function.- Parameters:
addr- address to check- Returns:
- true if this address is contained in a function.
-
moveAddressRange
void moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor) throws CancelledException
-
deleteAddressRange
void deleteAddressRange(Address startAddr, Address endAddr, TaskMonitor monitor) throws CancelledException
-
setProgram
void setProgram(ProgramDB program)
-
programReady
void programReady(int openMode, int currentRevision, TaskMonitor monitor) throws java.io.IOException, CancelledException- Parameters:
currentRevision- TODO- Throws:
java.io.IOExceptionCancelledException- See Also:
ManagerDB.programReady(int, int, ghidra.util.task.TaskMonitor)
-
invalidateCache
void invalidateCache(boolean all)
-
getFunctionsOverlapping
java.util.Iterator<Function> getFunctionsOverlapping(AddressSetView set)
Return an iterator over functions that overlap the given address set.- Parameters:
set- address set of interest- Returns:
- iterator over Functions
-
getReferencedVariable
Variable getReferencedVariable(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. 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-storageAddr-size- varnode size in bytes (1 is assumed if value <= 0)isRead-- Returns:
- referenced variable or null if one not found
-
getFunction
Function getFunction(long key)
Get a Function object by its key- Parameters:
key- function symbol key- Returns:
- function object or null if not found
-
-