Class CallDepthChangeInfo

java.lang.Object
ghidra.app.cmd.function.CallDepthChangeInfo

public class CallDepthChangeInfo extends Object
Given a function in a program or the start of a function, record information about the change to a stack pointer from a subroutine call. The routine getCallChange() can be called with the address of a call instruction. If the stack could be tracked, the call instruction will return the change in the stack pointer that would result from a call to the function. The computation is based on a set of equations that are generated and solved. Each equation represents the stack change for a given basic flow block or call instruction within the function.
  • Constructor Details

    • CallDepthChangeInfo

      public CallDepthChangeInfo(Function func)
      Construct a new CallDepthChangeInfo object.
      Parameters:
      func - function to examine
    • CallDepthChangeInfo

      public CallDepthChangeInfo(Function func, TaskMonitor monitor) throws CancelledException
      Construct a new CallDepthChangeInfo object.
      Parameters:
      func - function to examine
      monitor - monitor used to cancel the operation
      Throws:
      CancelledException - if the operation was canceled
    • CallDepthChangeInfo

      public CallDepthChangeInfo(Function function, AddressSetView restrictSet, Register frameReg, TaskMonitor monitor) throws CancelledException
      Construct a new CallDepthChangeInfo object.
      Parameters:
      function - function to examine
      restrictSet - set of addresses to restrict flow flowing to.
      frameReg - register that is to have it's depth(value) change tracked
      monitor - monitor used to cancel the operation
      Throws:
      CancelledException - if the operation was canceled
    • CallDepthChangeInfo

      public CallDepthChangeInfo(Program program, Address addr, AddressSetView restrictSet, Register frameReg, TaskMonitor monitor) throws CancelledException
      Construct a new CallDepthChangeInfo object.
      Parameters:
      program - program containing the function to examime
      addr - address within the function to examine
      restrictSet - set of addresses to restrict flow flowing to.
      frameReg - register that is to have it's depth(value) change tracked
      monitor - monitor used to cancel the operation
      Throws:
      CancelledException - if the operation was canceled
  • Method Details

    • getCallChange

      public int getCallChange(Address addr)
    • getDepth

      public int getDepth(Address addr)
    • getInstructionStackDepthChange

      public int getInstructionStackDepthChange(Instruction instr)
      Inspect the instruction and return how it affects the stack depth. If the depth cannot be determined, then return that the stack depth change is unknown.
      Parameters:
      instr - instruction to analyze
      Returns:
      int change to stack depth if it can be determined, Function.UNKNOWN_STACK_DEPTH_CHANGE otherwise.
    • getStackDepthChange

      public static Integer getStackDepthChange(Program program, Address address)
      Gets the stack depth change value that has been set at the indicated address.
      Parameters:
      program - the program to be checked
      address - the program address
      Returns:
      the stack depth change value or null if value has not been set
    • setStackDepthChange

      public static void setStackDepthChange(Program program, Address address, int stackDepthChange) throws DuplicateNameException
      Sets a new value for the stack depth change at the indicated address.
      Parameters:
      program - the program where the value will be set
      address - the program address
      stackDepthChange - the new stack depth change value
      Throws:
      DuplicateNameException - if the property name for stack depth changes conflicted with another property tha has the same name.
    • removeStackDepthChange

      public static boolean removeStackDepthChange(Program program, Address address)
      Removes the value for the stack depth change at the indicated address.
      Parameters:
      program - the program where the value will be removed
      address - the program address
      Returns:
      true if a stack depth change existed at the indicated at the address and it was removed.
    • getStackDepthChanges

      public static AddressIterator getStackDepthChanges(Program program, AddressSetView addressSet)
      Gets an iterator indicating all the addresses that have a stack depth change value specified within a program's indicated address set.
      Parameters:
      program - the program to be checked
      addressSet - the set of addresses to check for a stack depth change value
      Returns:
      the address iterator indicating where stack depth change values have been set
    • getStackPurge

      public int getStackPurge()
    • getStackOffset

      public int getStackOffset(Instruction cu, int opIndex)
    • getSPDepth

      public int getSPDepth(Address addr)
      Parameters:
      addr - the address to get the stack pointer depth at.
      Returns:
      the stack pointer depth at the address.
    • getRegDepth

      public int getRegDepth(Address addr, Register reg)
      Parameters:
      addr - the address to get the register depth at.
      reg - the register to get the depth of.
      Returns:
      the depth of the register at the address.
    • getRegValueRepresentation

      public String getRegValueRepresentation(Address addr, Register reg)
      Parameters:
      addr - the address of the register value to get the representation of.
      reg - the register to get the representation of.
      Returns:
      the string representation of the register value.