Package ghidra.trace.util

# Interface MemoryAdapter

All Superinterfaces:
  `AddressSetView`, `Iterable<AddressRange>`, `Memory`

All Known Implementing Classes:
  `AbstractDBTraceProgramViewMemory`, `DBTraceProgramViewMemory`

public interface MemoryAdapter extends Memory

- ## Field Summary

  ### Fields inherited from interface ghidra.program.model.mem.Memory

  `GBYTE, GBYTE_SHIFT_FACTOR, MAX_BINARY_SIZE, MAX_BINARY_SIZE_GB, MAX_BLOCK_SIZE, MAX_BLOCK_SIZE_GB`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default byte`
  `getByte(Address addr)`
  Get byte at addr.
  `default int`
  `getBytes(Address addr, byte[] dest)`
  Get dest.length number of bytes starting at the given address.
  `default int`
  `getInt(Address addr)`
  Get the int at addr.
  `default int`
  `getInt(Address addr, boolean bigEndian)`
  Get the int at addr using the specified endian order.
  `default int`
  `getInts(Address addr, int[] dest)`
  Get dest.length number of ints starting at the given address.
  `default int`
  `getInts(Address addr, int[] dest, int dIndex, int nElem)`
  Get dest.length number of ints starting at the given address.
  `default int`
  `getInts(Address addr, int[] dest, int dIndex, int nElem, boolean bigEndian)`
  Get dest.length number of ints starting at the given address.
  `default long`
  `getLong(Address addr)`
  Get the long at addr.
  `default long`
  `getLong(Address addr, boolean bigEndian)`
  Get the long at addr in the specified endian order.
  `default int`
  `getLongs(Address addr, long[] dest)`
  Get dest.length number of longs starting at the given address.
  `default int`
  `getLongs(Address addr, long[] dest, int dIndex, int nElem)`
  Get dest.length number of longs starting at the given address.
  `default int`
  `getLongs(Address addr, long[] dest, int dIndex, int nElem, boolean bigEndian)`
  Get dest.length number of longs starting at the given address.
  `default short`
  `getShort(Address addr)`
  Get the short at addr.
  `default short`
  `getShort(Address addr, boolean bigEndian)`
  Get the short at addr using the specified endian order.
  `default int`
  `getShorts(Address addr, short[] dest)`
  Get dest.length number of shorts starting at the given address.
  `default int`
  `getShorts(Address addr, short[] dest, int dIndex, int nElem)`
  Get dest.length number of shorts starting at the given address.
  `default int`
  `getShorts(Address addr, short[] dest, int dIndex, int nElem, boolean bigEndian)`
  Get dest.length number of shorts starting at the given address.
  `default ByteBuffer`
  `mustRead(Address addr, int length, boolean bigEndian)`
  `default void`
  `setByte(Address addr, byte value)`
  Write byte at addr.
  `default void`
  `setBytes(Address addr, byte[] source)`
  Write size bytes from values at addr.
  `default void`
  `setInt(Address addr, int value)`
  Write int at addr in the default endian order.
  `default void`
  `setInt(Address addr, int value, boolean bigEndian)`
  Write int at addr in the specified endian order.
  `default void`
  `setLong(Address addr, long value)`
  Write long at addr in the default endian order.
  `default void`
  `setLong(Address addr, long value, boolean bigEndian)`
  Write long at addr in the specified endian order.
  `default void`
  `setShort(Address addr, short value)`
  Write short at addr in default endian order.
  `default void`
  `setShort(Address addr, short value, boolean bigEndian)`
  Write short at addr in the specified endian order.

  ### Methods inherited from interface ghidra.program.model.address.AddressSetView

  `contains, contains, contains, findFirstAddressInCommon, getAddressCountBefore, getAddresses, getAddresses, getAddressRanges, getAddressRanges, getAddressRanges, getFirstRange, getLastRange, getMaxAddress, getMinAddress, getNumAddresses, getNumAddressRanges, getRangeContaining, hasSameAddresses, intersect, intersectRange, intersects, intersects, isEmpty, iterator, iterator, iterator, spliterator, spliterator, spliterator, stream, stream, stream, subtract, union, xor`

  ### Methods inherited from interface java.lang.Iterable

  `forEach`

  ### Methods inherited from interface ghidra.program.model.mem.Memory

  `convertToInitialized, convertToUninitialized, createBitMappedBlock, createBlock, createByteMappedBlock, createByteMappedBlock, createFileBytes, createInitializedBlock, createInitializedBlock, createInitializedBlock, createUninitializedBlock, deleteFileBytes, findBytes, findBytes, getAddressSourceInfo, getAllFileBytes, getAllInitializedAddressSet, getBlock, getBlock, getBlocks, getBytes, getExecuteSet, getInitializedAddressSet, getLoadedAndInitializedAddressSet, getProgram, getSize, isBigEndian, isExternalBlockAddress, join, locateAddressesForFileBytesOffset, locateAddressesForFileOffset, moveBlock, removeBlock, setBytes, split`

- ## Method Details

  - ### mustRead

    default ByteBuffer mustRead(Address addr, int length, boolean bigEndian) throws MemoryAccessException
    Throws:
      `MemoryAccessException`

  - ### getBytes

    default int getBytes(Address addr, byte[] dest) throws MemoryAccessException
    Description copied from interface: `Memory`
    Get dest.length number of bytes starting at the given address.
    Specified by:
      `getBytes` in interface `Memory`
    Parameters:
      `addr` - the starting Address.
      `dest` - the byte array to populate.
    Returns:
      the number of bytes put into dest. May be less than dest.length if the requested number extends beyond available memory.
    Throws:
      `MemoryAccessException` - if the starting address is not contained in any memory block.

  - ### getByte

    default byte getByte(Address addr) throws MemoryAccessException
    Description copied from interface: `Memory`
    Get byte at addr.
    Specified by:
      `getByte` in interface `Memory`
    Parameters:
      `addr` - the Address of the byte.
    Returns:
      the byte.
    Throws:
      `MemoryAccessException` - if the address is not contained in any memory block.

  - ### getShort

    default short getShort(Address addr) throws MemoryAccessException
    Description copied from interface: `Memory`
    Get the short at addr.
    Specified by:
      `getShort` in interface `Memory`
    Parameters:
      `addr` - the Address where the short starts.
    Returns:
      the short.
    Throws:
      `MemoryAccessException` - if not all needed bytes are contained in initialized memory.

  - ### getShort

    default short getShort(Address addr, boolean bigEndian) throws MemoryAccessException
    Description copied from interface: `Memory`
    Get the short at addr using the specified endian order.
    Specified by:
      `getShort` in interface `Memory`
    Parameters:
      `addr` - the Address where the short starts.
      `bigEndian` - true means to get the short in bigEndian order
    Returns:
      the short.
    Throws:
      `MemoryAccessException` - if not all needed bytes are contained in initialized memory.

  - ### getShorts

    default int getShorts(Address addr, short[] dest) throws MemoryAccessException
    Description copied from interface: `Memory`
    Get dest.length number of shorts starting at the given address.
    Specified by:
      `getShorts` in interface `Memory`
    Parameters:
      `addr` - the starting Address.
      `dest` - the short array to populate.
    Returns:
      the number of shorts put into dest. May be less than dest.length if the requested number extends beyond available memory. If the number of retrievable bytes is odd, the final byte will be discarded.
    Throws:
      `MemoryAccessException` - if not all needed bytes are contained in initialized memory.

  - ### getShorts

    default int getShorts(Address addr, short[] dest, int dIndex, int nElem) throws MemoryAccessException
    Description copied from interface: `Memory`
    Get dest.length number of shorts starting at the given address.
    Specified by:
      `getShorts` in interface `Memory`
    Parameters:
      `addr` - the starting Address.
      `dest` - the short array to populate.
      `dIndex` - the offset into dest to place the shorts.
      `nElem` - the number of shorts to get.
    Returns:
      the number of shorts put into dest. May be less than dest.length if the requested number extends beyond available memory. If the number of retrievable bytes is odd, the final byte will be discarded.
    Throws:
      `MemoryAccessException` - if not all needed bytes are contained in initialized memory.

  - ### getShorts

    default int getShorts(Address addr, short[] dest, int dIndex, int nElem, boolean bigEndian) throws MemoryAccessException
    Description copied from interface: `Memory`
    Get dest.length number of shorts starting at the given address.
    Specified by:
      `getShorts` in interface `Memory`
    Parameters:
      `addr` - the starting Address.
      `dest` - the short array to populate.
      `dIndex` - the offset into dest to place the shorts.
      `nElem` - the number of shorts to get.
      `bigEndian` - true means to get the shorts in bigEndian order
    Returns:
      the number of shorts put into dest. May be less than dest.length if the requested number extends beyond available memory. If the number of retrievable bytes is odd, the final byte will be discarded.
    Throws:
      `MemoryAccessException` - if not all needed bytes are contained in initialized memory.

  - ### getInt

    default int getInt(Address addr) throws MemoryAccessException
    Description copied from interface: `Memory`
    Get the int at addr.
    Specified by:
      `getInt` in interface `Memory`
    Parameters:
      `addr` - the Address where the int starts.
    Returns:
      the int.
    Throws:
      `MemoryAccessException` - if not all needed bytes are contained in initialized memory.

  - ### getInt

    default int getInt(Address addr, boolean bigEndian) throws MemoryAccessException
    Description copied from interface: `Memory`
    Get the int at addr using the specified endian order.
    Specified by:
      `getInt` in interface `Memory`
    Parameters:
      `addr` - the Address where the int starts.
      `bigEndian` - true means to get the int in big endian order
    Returns:
      the int.
    Throws:
      `MemoryAccessException` - if not all needed bytes are contained in initialized memory.

  - ### getInts

    default int getInts(Address addr, int[] dest) throws MemoryAccessException
    Description copied from interface: `Memory`
    Get dest.length number of ints starting at the given address.
    Specified by:
      `getInts` in interface `Memory`
    Parameters:
      `addr` - the starting Address.
      `dest` - the int array to populate.
    Returns:
      the number of ints put into dest. May be less than dest.length if the requested number extends beyond available memory. If the number of retrievable bytes is not 0 mod 4, the final byte(s) will be discarded.
    Throws:
      `MemoryAccessException` - if the starting address is not contained in any memory block.

  - ### getInts

    default int getInts(Address addr, int[] dest, int dIndex, int nElem) throws MemoryAccessException
    Description copied from interface: `Memory`
    Get dest.length number of ints starting at the given address.
    Specified by:
      `getInts` in interface `Memory`
    Parameters:
      `addr` - the starting Address.
      `dest` - the int array to populate.
      `dIndex` - the offset into dest to place the ints.
      `nElem` - the number of ints to get.
    Returns:
      the number of ints put into dest. May be less than dest.length if the requested number extends beyond available memory. If the number of retrievable bytes is not 0 mod 4, the final byte(s) will be discarded.
    Throws:
      `MemoryAccessException` - if not all needed bytes are contained in initialized memory.

  - ### getInts

    default int getInts(Address addr, int[] dest, int dIndex, int nElem, boolean bigEndian) throws MemoryAccessException
    Description copied from interface: `Memory`
    Get dest.length number of ints starting at the given address.
    Specified by:
      `getInts` in interface `Memory`
    Parameters:
      `addr` - the starting Address.
      `dest` - the int array to populate.
      `dIndex` - the offset into dest to place the ints.
      `nElem` - the number of ints to get.
      `bigEndian` - true means to get the ints in bigEndian order
    Returns:
      the number of ints put into dest. May be less than dest.length if the requested number extends beyond available memory. If the number of retrievable bytes is not 0 mod 4, the final byte(s) will be discarded.
    Throws:
      `MemoryAccessException` - if not all needed bytes are contained in initialized memory.

  - ### getLong

    default long getLong(Address addr) throws MemoryAccessException
    Description copied from interface: `Memory`
    Get the long at addr.
    Specified by:
      `getLong` in interface `Memory`
    Parameters:
      `addr` - the Address where the long starts.
    Returns:
      the long.
    Throws:
      `MemoryAccessException` - if not all needed bytes are contained in initialized memory.

  - ### getLong

    default long getLong(Address addr, boolean bigEndian) throws MemoryAccessException
    Description copied from interface: `Memory`
    Get the long at addr in the specified endian order.
    Specified by:
      `getLong` in interface `Memory`
    Parameters:
      `addr` - the Address where the long starts.
      `bigEndian` - true means to get the long in big endian order
    Returns:
      the long.
    Throws:
      `MemoryAccessException` - if not all needed bytes are contained in initialized memory.

  - ### getLongs

    default int getLongs(Address addr, long[] dest) throws MemoryAccessException
    Description copied from interface: `Memory`
    Get dest.length number of longs starting at the given address.
    Specified by:
      `getLongs` in interface `Memory`
    Parameters:
      `addr` - the starting Address.
      `dest` - the long array to populate.
    Returns:
      the number of longs put into dest. May be less than dest.length if the requested number extends beyond available memory. If the number of retrievable bytes is not 0 mod 8, the final byte(s) will be discarded.
    Throws:
      `MemoryAccessException` - if not all needed bytes are contained in initialized memory.

  - ### getLongs

    default int getLongs(Address addr, long[] dest, int dIndex, int nElem) throws MemoryAccessException
    Description copied from interface: `Memory`
    Get dest.length number of longs starting at the given address.
    Specified by:
      `getLongs` in interface `Memory`
    Parameters:
      `addr` - the starting Address.
      `dest` - the long array to populate.
      `dIndex` - the offset into dest to place the longs.
      `nElem` - the number of longs to get.
    Returns:
      the number of longs put into dest. May be less than dest.length if the requested number extends beyond available memory. If the number of retrievable bytes is not 0 mod 8, the final byte(s) will be discarded.
    Throws:
      `MemoryAccessException` - if not all needed bytes are contained in initialized memory.

  - ### getLongs

    default int getLongs(Address addr, long[] dest, int dIndex, int nElem, boolean bigEndian) throws MemoryAccessException
    Description copied from interface: `Memory`
    Get dest.length number of longs starting at the given address.
    Specified by:
      `getLongs` in interface `Memory`
    Parameters:
      `addr` - the starting Address.
      `dest` - the long array to populate.
      `dIndex` - the offset into dest to place the longs.
      `nElem` - the number of longs to get.
      `bigEndian` - true means to get the longs in bigEndian order
    Returns:
      the number of longs put into dest. May be less than dest.length if the requested number extends beyond available memory. If the number of retrievable bytes is not 0 mod 8, the final byte(s) will be discarded.
    Throws:
      `MemoryAccessException` - if not all needed bytes are contained in initialized memory.

  - ### setBytes

    default void setBytes(Address addr, byte[] source) throws MemoryAccessException
    Description copied from interface: `Memory`
    Write size bytes from values at addr.
    Specified by:
      `setBytes` in interface `Memory`
    Parameters:
      `addr` - the starting Address.
      `source` - the bytes to write.
    Throws:
      `MemoryAccessException` - if writing is not allowed.

  - ### setByte

    default void setByte(Address addr, byte value) throws MemoryAccessException
    Description copied from interface: `Memory`
    Write byte at addr.
    Specified by:
      `setByte` in interface `Memory`
    Parameters:
      `addr` - the Address of the byte.
      `value` - the data to write.
    Throws:
      `MemoryAccessException` - if writing is not allowed.

  - ### setShort

    default void setShort(Address addr, short value) throws MemoryAccessException
    Description copied from interface: `Memory`
    Write short at addr in default endian order.
    Specified by:
      `setShort` in interface `Memory`
    Parameters:
      `addr` - the Address of the short.
      `value` - the data to write.
    Throws:
      `MemoryAccessException` - if writing is not allowed.

  - ### setShort

    default void setShort(Address addr, short value, boolean bigEndian) throws MemoryAccessException
    Description copied from interface: `Memory`
    Write short at addr in the specified endian order.
    Specified by:
      `setShort` in interface `Memory`
    Parameters:
      `addr` - the Address of the short.
      `value` - the data to write.
      `bigEndian` - true means to write short in big endian order
    Throws:
      `MemoryAccessException` - if writing is not allowed.

  - ### setInt

    default void setInt(Address addr, int value) throws MemoryAccessException
    Description copied from interface: `Memory`
    Write int at addr in the default endian order.
    Specified by:
      `setInt` in interface `Memory`
    Parameters:
      `addr` - the Address of the int.
      `value` - the data to write.
    Throws:
      `MemoryAccessException` - if writing is not allowed.

  - ### setInt

    default void setInt(Address addr, int value, boolean bigEndian) throws MemoryAccessException
    Description copied from interface: `Memory`
    Write int at addr in the specified endian order.
    Specified by:
      `setInt` in interface `Memory`
    Parameters:
      `addr` - the Address of the int.
      `value` - the data to write.
      `bigEndian` - true means to write the short in bigEndian order
    Throws:
      `MemoryAccessException` - if writing is not allowed.

  - ### setLong

    default void setLong(Address addr, long value) throws MemoryAccessException
    Description copied from interface: `Memory`
    Write long at addr in the default endian order.
    Specified by:
      `setLong` in interface `Memory`
    Parameters:
      `addr` - the Address of the long.
      `value` - the data to write.
    Throws:
      `MemoryAccessException` - if writing is not allowed.

  - ### setLong

    default void setLong(Address addr, long value, boolean bigEndian) throws MemoryAccessException
    Description copied from interface: `Memory`
    Write long at addr in the specified endian order.
    Specified by:
      `setLong` in interface `Memory`
    Parameters:
      `addr` - the Address of the long.
      `value` - the data to write.
      `bigEndian` - true means to write the long in bigEndian order
    Throws:
      `MemoryAccessException` - if writing is not allowed.