Package ghidra.app.cmd.function
Class CreateThunkFunctionCmd
- java.lang.Object
-
- ghidra.framework.cmd.BackgroundCommand
-
- ghidra.app.cmd.function.CreateThunkFunctionCmd
-
- All Implemented Interfaces:
Command
public class CreateThunkFunctionCmd extends BackgroundCommand
Command for creating a thunk function at an address.
-
-
Constructor Summary
Constructors Constructor Description CreateThunkFunctionCmd(Address entry, boolean checkForSideEffects)
Constructs a new command for creating a thunk function that can compute the function this function is thunking to.CreateThunkFunctionCmd(Address entry, AddressSetView body, Address referencedFunctionAddr)
Constructs a new command for creating a thunk function.CreateThunkFunctionCmd(Address entry, AddressSetView body, Address referencedFunctionAddr, java.util.List<Address> referringThunkAddresses)
Constructs a new command for creating a thunk function.CreateThunkFunctionCmd(Address entry, AddressSetView body, Symbol referencedSymbol)
Constructs a new command for creating a thunk function.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
applyTo(DomainObject obj, TaskMonitor monitor)
Method called when this command is to apply changes to the given domain object.Function
getReferencedFunction()
static Address
getThunkedAddr(Program program, Address entry)
if the code starting at entry is a thunk, return the thunked addess if known.static Address
getThunkedAddr(Program program, Address entry, boolean checkForSideEffects)
Get the address that this function would thunk if it is a valid thunkFunction
getThunkFunction()
static boolean
isThunk(Program program, Function func)
Check if this is a Thunking function.-
Methods inherited from class ghidra.framework.cmd.BackgroundCommand
applyTo, canCancel, dispose, getName, getStatusMsg, hasProgress, isModal, setStatusMsg, taskCompleted, toString
-
-
-
-
Constructor Detail
-
CreateThunkFunctionCmd
public CreateThunkFunctionCmd(Address entry, AddressSetView body, Address referencedFunctionAddr, java.util.List<Address> referringThunkAddresses)
Constructs a new command for creating a thunk function.- Parameters:
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. If null, and entry corresponds to an existing function, that function will be converted to a thunk, otherwise an error will result.referencedFunctionAddr
- the function address to which this thunk refers. If no function exists at that specified referencedFunctionAddr one will be created per the following scheme:- If referencedFunctionAddr is not contained within a memory block, an external function will
be created (a check will be done to look for an previously defined external location) - If referencedFunctionAddr corresponds to an instruction, a new function will be
created at that address.
- If referencedFunctionAddr is not contained within a memory block, an external function will
-
CreateThunkFunctionCmd
public CreateThunkFunctionCmd(Address entry, AddressSetView body, Address referencedFunctionAddr)
Constructs a new command for creating a thunk function.- Parameters:
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. If null, and entry corresponds to an existing function, that function will be converted to a thunk, otherwise an error will result.referencedFunctionAddr
- the function address to which this thunk refers. If no function exists at that specified referencedFunctionAddr one will be created per the following scheme:- If referencedFunctionAddr is not contained within a memory block, an external function will
be created (a check will be done to look for an previously defined external location) - If referencedFunctionAddr corresponds to an instruction, a new function will be
created at that address.
- If referencedFunctionAddr is not contained within a memory block, an external function will
-
CreateThunkFunctionCmd
public CreateThunkFunctionCmd(Address entry, AddressSetView body, Symbol referencedSymbol)
Constructs a new command for creating a thunk function.- Parameters:
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. If null, and entry corresponds to an existing function, that function will be converted to a thunk, otherwise an error will result.referencedSymbol
- the symbol which identifies the intended function to which this thunk refers. If no function exists at that specified referencedSymbol location, one will be created per the following scheme:- If referencedFunctionAddr is not contained within a memory block, an external function will
be created (a check will be done to look for an previously defined external location) - If referencedFunctionAddr corresponds to an instruction, a new function will be
created at that address. - If referencedSymbol corresponds to an external CODE symbol, it will be converted to an
external FUNCTION
- If referencedFunctionAddr is not contained within a memory block, an external function will
-
CreateThunkFunctionCmd
public CreateThunkFunctionCmd(Address entry, boolean checkForSideEffects)
Constructs a new command for creating a thunk function that can compute the function this function is thunking to.- Parameters:
entry
- entry point address for the function to be created.checkForSideEffects
- true to check for side-effects that indicate it is not a pure thunk. The body may be computed. References to the thunked to function may be created. If no function exists at the location being thunked, it will be created based on the above rules.
-
-
Method Detail
-
applyTo
public boolean applyTo(DomainObject obj, TaskMonitor monitor)
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
- Parameters:
obj
- domain object that will be affected by the commandmonitor
- monitor to show progress of the command- Returns:
- true if the command applied successfully
-
getThunkFunction
public Function getThunkFunction()
- Returns:
- function if create command was successful
-
getReferencedFunction
public Function getReferencedFunction()
- Returns:
- the function referenced by the newly created thunk function is command was successful
-
getThunkedAddr
public static Address getThunkedAddr(Program program, Address entry)
if the code starting at entry is a thunk, return the thunked addess if known.- Parameters:
program
- code resides inentry
- start of the code- Returns:
- the function address, Address.NO_ADDRESS if thunk but unknonw addr, null otherwise
-
getThunkedAddr
public static Address getThunkedAddr(Program program, Address entry, boolean checkForSideEffects)
Get the address that this function would thunk if it is a valid thunk- Parameters:
program
-entry
- location to check for a thunkcheckForSideEffects
- true if there should be no extra registers affected- Returns:
- address that the thunk thunks,Address.NO_ADDRESS if thunk but unknown addr, null otherwise
-
-