Package ghidra.program.model.address
Class SegmentedAddress
- java.lang.Object
-
- ghidra.program.model.address.GenericAddress
-
- ghidra.program.model.address.SegmentedAddress
-
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.
-
-
Field Summary
-
Fields inherited from class ghidra.program.model.address.GenericAddress
addrSpace, offset, zeros
-
Fields inherited from interface ghidra.program.model.address.Address
EXT_FROM_ADDRESS, NO_ADDRESS, SEPARATOR_CHAR
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Address
getNewAddress(long byteOffset)
Return a new segmented address.Address
getNewAddress(long addrOffset, boolean isAddressableWordOffset)
Returns a new address in this address's space with the given offset.Address
getNewTruncatedAddress(long addrOffset, boolean isAddressableWordOffset)
Returns a new address in this address's space with the given offset.Address
getPhysicalAddress()
Returns the physical Address that corresponds to this Address.int
getSegment()
Returns the segment valueint
getSegmentOffset()
Returns the offset within the segment.SegmentedAddress
normalize(int seg)
Returns a new address that is equivalent to this address using the given segment number.java.lang.String
toString(boolean showAddressSpace, int minNumDigits)
Returns a String representation that may include the address space name and may or may not pad the address with leading zeros.java.lang.String
toString(java.lang.String prefix)
Returns a String representation of the address using the given string as a prefix.-
Methods inherited from class ghidra.program.model.address.GenericAddress
add, addNoWrap, addNoWrap, addWrap, addWrapSpace, compareTo, equals, getAddress, getAddressableWordOffset, getAddressSpace, getOffset, getOffsetAsBigInteger, getPointerSize, getSize, getUnsignedOffset, hashCode, hasSameAddressSpace, isConstantAddress, isExternalAddress, isHashAddress, isLoadedMemoryAddress, isMemoryAddress, isNonLoadedMemoryAddress, isRegisterAddress, isStackAddress, isSuccessor, isUniqueAddress, isVariableAddress, next, previous, subtract, subtract, subtractNoWrap, subtractWrap, subtractWrapSpace, toString, toString, toString
-
-
-
-
Method Detail
-
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 interfaceAddress
- Overrides:
getNewAddress
in classGenericAddress
- Parameters:
byteOffset
- the byte offset for the new address.- Returns:
- the new Address.
- See Also:
Address.getNewAddress(long)
-
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 interfaceAddress
- Overrides:
getNewAddress
in classGenericAddress
- 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. SeeAddressSpace#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 interfaceAddress
- Overrides:
getNewTruncatedAddress
in classGenericAddress
- 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. SeeAddressSpace#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 java.lang.String toString(java.lang.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 interfaceAddress
- Overrides:
toString
in classGenericAddress
- Parameters:
prefix
- the string to prepend to the address string.- See Also:
Address.toString(String)
-
getPhysicalAddress
public Address getPhysicalAddress()
Description copied from interface:Address
Returns the physical Address that corresponds to this Address.- Specified by:
getPhysicalAddress
in interfaceAddress
- Overrides:
getPhysicalAddress
in classGenericAddress
- Returns:
- address in a physical space corresponding to this address.
- See Also:
Address.getPhysicalAddress()
-
toString
public java.lang.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 interfaceAddress
- Overrides:
toString
in classGenericAddress
- 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.
-
-