Package ghidra.app.cmd.function
Class CreateFunctionCmd
Command for Creating a function at an address. It will copy off the
parameters used to create the function (Selection or just an address) and
create the function on redo and clear on undo.
-
Constructor Summary
ConstructorDescriptionCreateFunctionCmd
(Address entry) Constructs a new command for creating a function that automatically computes the body of the function.CreateFunctionCmd
(Address entry, boolean findEntryPoint) CreateFunctionCmd
(AddressSetView entries) Constructs a new command for creating functions that automatically computes the body of each function.CreateFunctionCmd
(AddressSetView entries, boolean findEntryPoint) Constructs a new command for creating functions that automatically computes the body of each function.CreateFunctionCmd
(AddressSetView entries, SourceType source) Constructs a new command for creating functions that automatically computes the body of each function.CreateFunctionCmd
(String name, Address entry, AddressSetView body, SourceType source) CreateFunctionCmd
(String name, Address entry, AddressSetView body, SourceType source, boolean findEntryPoint, boolean recreateFunction) Constructs a new command for creating a function.CreateFunctionCmd
(String name, AddressSetView entries, AddressSetView body, SourceType source, boolean findEntryPoint, boolean recreateFunction) Constructs a new command for creating a function. -
Method Summary
Modifier and TypeMethodDescriptionboolean
applyTo
(Program p, TaskMonitor monitor) Method called when this command is to apply changes to the given domain object.static boolean
fixupFunctionBody
(Program program, Function func, TaskMonitor monitor) Recompute function body.static boolean
fixupFunctionBody
(Program program, Instruction start_inst, TaskMonitor monitor) Recompute function body.Returns function if create command was successfulstatic AddressSetView
getFunctionBody
(Program program, Address entry) Find the function body by following all flows other than a call from the entry point.static AddressSetView
getFunctionBody
(Program program, Address entry, boolean includeOtherFunctions, TaskMonitor monitor) static AddressSetView
getFunctionBody
(Program program, Address entry, TaskMonitor monitor) static AddressSetView
getFunctionBody
(TaskMonitor monitor, Program program, Address entry) Find the function body by following all flows other than a call from the entry point.Methods inherited from class ghidra.framework.cmd.BackgroundCommand
applyTo, canCancel, dispose, getName, getStatusMsg, hasProgress, isModal, run, setStatusMsg, taskCompleted, toString
-
Constructor Details
-
CreateFunctionCmd
public CreateFunctionCmd(String name, AddressSetView entries, AddressSetView body, SourceType source, boolean findEntryPoint, boolean recreateFunction) Constructs a new command for creating a function. The default name for a function is the name associated with the current primary symbol which will be removed.- Parameters:
name
- function name or null for default name.entries
- the entry points at which to create functions.body
- set of addresses to associated with the function to be created. The addresses must not already be included in the body of any existing function.source
- the source of this functionfindEntryPoint
- true if the entry point should be computed (entry could be in the middle of a function)recreateFunction
- true if the function body should be recreated even if the function exists.
-
CreateFunctionCmd
public CreateFunctionCmd(String name, Address entry, AddressSetView body, SourceType source, boolean findEntryPoint, boolean recreateFunction) Constructs a new command for creating a function. The default name for a function is the name associated with the current primary symbol which will be removed.- Parameters:
name
- function name or null for default name.entry
- entry point address for the function to be created.body
- set of addresses to associated with the function to be created. The addresses must not already be included in the body of any existing function.source
- the source of this functionfindEntryPoint
- true if the entry point should be computed (entry could be in the middle of a function)recreateFunction
- true if the function body should be recreated even if the function exists.
-
CreateFunctionCmd
Constructs a new command for creating functions that automatically computes the body of each function.- Parameters:
entries
- the entry points at which to create functions.findEntryPoint
- true if entry point is unknown and should be found
-
CreateFunctionCmd
Constructs a new command for creating functions that automatically computes the body of each function.- Parameters:
entries
- the entry points at which to create functions.
-
CreateFunctionCmd
Constructs a new command for creating functions that automatically computes the body of each function.- Parameters:
entries
- the entry points at which to create functions.source
- SourceType for created function
-
CreateFunctionCmd
-
CreateFunctionCmd
Constructs a new command for creating a function that automatically computes the body of the function.- Parameters:
entry
- the entry point at which to create a function.
-
CreateFunctionCmd
-
-
Method Details
-
applyTo
Description copied from class:BackgroundCommand
Method called when this command is to apply changes to the given domain object. A monitor is provided to display status information about the command as it executes in the background.- Specified by:
applyTo
in classBackgroundCommand<Program>
- Parameters:
p
- domain object that will be affected by the commandmonitor
- monitor to show progress of the command- Returns:
- true if the command applied successfully
-
getFunction
Returns function if create command was successful- Returns:
- last new created function, null if failed
-
getFunctionBody
Find the function body by following all flows other than a call from the entry point.- Parameters:
monitor
- task monitorprogram
- the program where the function is being created.entry
- entry point to start tracing flow- Returns:
- AddressSetView address set representing the body of the function
-
getFunctionBody
Find the function body by following all flows other than a call from the entry point.- Parameters:
program
- the program where the function is being created.entry
- entry point to start tracing flow- Returns:
- AddressSetView address set representing the body of the function
-
getFunctionBody
-
getFunctionBody
public static AddressSetView getFunctionBody(Program program, Address entry, boolean includeOtherFunctions, TaskMonitor monitor) -
fixupFunctionBody
public static boolean fixupFunctionBody(Program program, Instruction start_inst, TaskMonitor monitor) throws CancelledException Recompute function body. An open transaction must already exist.- Parameters:
program
- the program the function is in.start_inst
- instruction that is within the function to be fixed up.monitor
- task monitor- Returns:
- true if successful, false if cancelled or unable to fixup function or no function found containing the start address of the indicated instruction
- Throws:
CancelledException
- if the function fixup is cancelled.
-
fixupFunctionBody
public static boolean fixupFunctionBody(Program program, Function func, TaskMonitor monitor) throws CancelledException Recompute function body. An open transaction must already exist.- Parameters:
program
- the program the function is in.func
- the function to be fixed up. A null function will return false.monitor
- task monitor- Returns:
- true if successful, false if unable to fixup function or no function found containing the start address of the indicated instruction
- Throws:
CancelledException
- if the function fixup is cancelled.
-