Package ghidra.program.model.mem

# Interface MemoryBlockSourceInfo

public interface MemoryBlockSourceInfo
Describes the source of bytes for a memory block.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `contains(Address address)`
  Returns true if this SourceInfo object applies to the given address;
  `default boolean`
  `containsFileOffset(long fileOffset)`
  Determine if this block source contains the specified file offset.
  `Optional<ByteMappingScheme>`
  `getByteMappingScheme()`
  Returns an `Optional` `ByteMappingScheme` employed if this is a byte-mapped memory block.
  `String`
  `getDescription()`
  Returns a description of this SourceInfo object.
  `Optional<FileBytes>`
  `getFileBytes()`
  Returns an `Optional` `FileBytes` object if a FileBytes object is the byte source for this SourceInfo.
  `long`
  `getFileBytesOffset()`
  Returns the offset into the underlying `FileBytes` object where this sub-block starts getting its bytes from or -1 if this sub-block does not have an associated `FileBytes` or a complex bit/byte-mapping is used.
  `long`
  `getFileBytesOffset(Address address)`
  Returns the offset into the `FileBytes` object for the given address or -1 if this sub-block if address is out of range or this sub-block does not have an associated `FileBytes`, or a complex bit/byte-mapping is used.
  `long`
  `getLength()`
  Returns the length of this block byte source.
  `Optional<AddressRange>`
  `getMappedRange()`
  Returns an `Optional` `AddressRange` for the mapped addresses if this is a mapped memory block (bit mapped or byte mapped).
  `Address`
  `getMaxAddress()`
  Returns the end address where this byte source is mapped.
  `MemoryBlock`
  `getMemoryBlock()`
  Returns the containing Memory Block
  `Address`
  `getMinAddress()`
  Returns the start address where this byte source is mapped.
  `default Address`
  `locateAddressForFileOffset(long fileOffset)`
  Get the Address within this sub-block which corresponds to the specified file offset.

- ## Method Details

  - ### getLength

    long getLength()
    Returns the length of this block byte source.
    Returns:
      the length of this block byte source.

  - ### getMinAddress

    Address getMinAddress()
    Returns the start address where this byte source is mapped.
    Returns:
      the start address where this byte source is mapped.

  - ### getMaxAddress

    Address getMaxAddress()
    Returns the end address where this byte source is mapped.
    Returns:
      the end address where this byte source is mapped.

  - ### getDescription

    String getDescription()
    Returns a description of this SourceInfo object.
    Returns:
      a description of this SourceInfo object.

  - ### getFileBytes

    Optional<FileBytes> getFileBytes()
    Returns an `Optional` `FileBytes` object if a FileBytes object is the byte source for this SourceInfo. Otherwise, the Optional will be empty.
    Returns:
      the `FileBytes` object if it is the byte source for this section

  - ### getFileBytesOffset

    long getFileBytesOffset()
    Returns the offset into the underlying `FileBytes` object where this sub-block starts getting its bytes from or -1 if this sub-block does not have an associated `FileBytes` or a complex bit/byte-mapping is used.
    Returns:
      the offset into the `FileBytes` object where this section starts getting its bytes.

  - ### getFileBytesOffset

    long getFileBytesOffset(Address address)
    Returns the offset into the `FileBytes` object for the given address or -1 if this sub-block if address is out of range or this sub-block does not have an associated `FileBytes`, or a complex bit/byte-mapping is used.
    Parameters:
      `address` - the address for which to get an offset into the `FileBytes` object.
    Returns:
      the offset into the `FileBytes` object for the given address.

  - ### getMappedRange

    Optional<AddressRange> getMappedRange()
    Returns an `Optional` `AddressRange` for the mapped addresses if this is a mapped memory block (bit mapped or byte mapped). Otherwise, the Optional is empty.
    Returns:
      an `Optional` `AddressRange` for the mapped addresses if this is a mapped memory block

  - ### getByteMappingScheme

    Optional<ByteMappingScheme> getByteMappingScheme()
    Returns an `Optional` `ByteMappingScheme` employed if this is a byte-mapped memory block. Otherwise, the Optional is empty.
    Returns:
      an `Optional` `ByteMappingScheme` employed if this is a byte-mapped memory block.

  - ### getMemoryBlock

    MemoryBlock getMemoryBlock()
    Returns the containing Memory Block
    Returns:
      the containing Memory Block

  - ### contains

    boolean contains(Address address)
    Returns true if this SourceInfo object applies to the given address;
    Parameters:
      `address` - the address to test if this is its SourceInfo
    Returns:
      true if this SourceInfo object applies to the given address;

  - ### containsFileOffset

    default boolean containsFileOffset(long fileOffset)
    Determine if this block source contains the specified file offset.
    Parameters:
      `fileOffset` - file offset within underlying FileBytes (if applicable) within the loaded range associated with this source info.
    Returns:
      true if file offset is within the loaded range of the corresponding FileBytes, else false if method is not supported by the sub-block type (e.g., bit/byte-mapped sub-block).

  - ### locateAddressForFileOffset

    default Address locateAddressForFileOffset(long fileOffset)
    Get the Address within this sub-block which corresponds to the specified file offset.
    Parameters:
      `fileOffset` - file offset
    Returns:
      `Address` within this sub-block or null if file offset is out of range or method is not supported by the sub-block type (e.g., bit/byte-mapped sub-block).