Class CreateThunkFunctionCmd

  • All Implemented Interfaces:
    Command

    public class CreateThunkFunctionCmd
    extends BackgroundCommand
    Command for creating a thunk function at an address.
    • 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.
      • 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.
      • 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
      • 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 class BackgroundCommand
        Parameters:
        obj - domain object that will be affected by the command
        monitor - 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 in
        entry - 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 thunk
        checkForSideEffects - 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
      • isThunk

        public static boolean isThunk​(Program program,
                                      Function func)
        Check if this is a Thunking function.
        Returns:
        true if this is a function thunking another.