Class SegmentedAddress

java.lang.Object
ghidra.program.model.address.GenericAddress
ghidra.program.model.address.SegmentedAddress
All Implemented Interfaces:
Address, Comparable<Address>

public class SegmentedAddress extends GenericAddress
Address class for dealing with (intel) segmented addresses. The class itself is agnostic about the mapping from segmented encoding to flat address offset, it uses the SegmentedAddressSpace to perform this mapping. So the same class can be used to represent either a real-mode address or a protected-mode address. The class uses the underlying offset field to hold the flat encoding.
  • Method Details

    • getSegment

      public int getSegment()
      Returns the segment value
      Returns:
      int the segment value
    • getSegmentOffset

      public int getSegmentOffset()
      Returns the offset within the segment.
      Returns:
      the offset value
    • normalize

      public SegmentedAddress normalize(int seg)
      Returns a new address that is equivalent to this address using the given segment number.
      Parameters:
      seg - the seqment value to normalize to.
      Returns:
      the new address
    • getNewAddress

      public Address getNewAddress(long byteOffset)
      Return a new segmented address. An attempt is made to normalize to this addresses segment.
      Specified by:
      getNewAddress in interface Address
      Overrides:
      getNewAddress in class GenericAddress
      Parameters:
      byteOffset - the byte offset for the new address.
      Returns:
      the new Address.
      See Also:
    • getNewAddress

      public Address getNewAddress(long addrOffset, boolean isAddressableWordOffset) throws AddressOutOfBoundsException
      Description copied from interface: Address
      Returns a new address in this address's space with the given offset.

      NOTE: for those spaces with an addressable unit size other than 1, the address returned may not correspond to an addressable unit/word boundary if a byte-offset is specified.

      Specified by:
      getNewAddress in interface Address
      Overrides:
      getNewAddress in class GenericAddress
      Parameters:
      addrOffset - the offset for the new address.
      isAddressableWordOffset - if true the specified offset is an addressable unit/word offset, otherwise offset is a byte offset. See AddressSpace#getAddressableUnitSize() to understand the distinction (i.e., wordOffset = byteOffset * addressableUnitSize).
      Returns:
      address with given offset
      Throws:
      AddressOutOfBoundsException - if the offset is less than 0 or greater than the max offset allowed for this space.
    • getNewTruncatedAddress

      public Address getNewTruncatedAddress(long addrOffset, boolean isAddressableWordOffset) throws AddressOutOfBoundsException
      Description copied from interface: Address
      Returns a new address in this address's space with the given offset. The specified offset will be truncated within the space and will not throw an exception.

      NOTE: for those spaces with an addressable unit size other than 1, the address returned may not correspond to a word boundary (addressable unit) if a byte-offset is specified.

      Specified by:
      getNewTruncatedAddress in interface Address
      Overrides:
      getNewTruncatedAddress in class GenericAddress
      Parameters:
      addrOffset - the offset for the new address.
      isAddressableWordOffset - if true the specified offset is an addressable unit/word offset, otherwise offset is a byte offset. See AddressSpace#getAddressableUnitSize() to understand the distinction (i.e., wordOffset = byteOffset * addressableUnitSize).
      Returns:
      address with given byte offset truncated to the physical space size
      Throws:
      AddressOutOfBoundsException
    • toString

      public String toString(String prefix)
      Description copied from interface: Address
      Returns a String representation of the address using the given string as a prefix. Equivalent of prefix + ":" + toString(false)
      Specified by:
      toString in interface Address
      Overrides:
      toString in class GenericAddress
      Parameters:
      prefix - the string to prepend to the address string.
      Returns:
      the string
      See Also:
    • getPhysicalAddress

      public Address getPhysicalAddress()
      Description copied from interface: Address
      Returns the physical Address that corresponds to this Address.
      Specified by:
      getPhysicalAddress in interface Address
      Overrides:
      getPhysicalAddress in class GenericAddress
      Returns:
      address in a physical space corresponding to this address.
      See Also:
    • toString

      public String toString(boolean showAddressSpace, int minNumDigits)
      Description copied from interface: Address
      Returns a String representation that may include the address space name and may or may not pad the address with leading zeros.
      Specified by:
      toString in interface Address
      Overrides:
      toString in class GenericAddress
      Parameters:
      showAddressSpace - if true, the addressSpace name will be prepended to the address string.
      minNumDigits - specifies the minimum number of digits to use. If the address space size is less that minNumDigits, the address will be padded to the address space size. If the address space size is larger that minNumDigits, the address will be displayed with as many digits as necessary, but will contain leading zeros to make the address string have at least minNumDigits.
      Returns:
      the address as a String.