Package ghidra.program.model.mem

# Interface LiveMemoryHandler

public interface LiveMemoryHandler
Live memory handler interface.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addLiveMemoryListener(LiveMemoryListener listener)`
  Adds a LiveMemoryListener to this handler.
  `void`
  `clearCache()`
  Called when the memory map is re-initializing.
  `byte`
  `getByte(Address addr)`
  Gets the byte at the given address.
  `int`
  `getBytes(Address address, byte[] buffer, int startIndex, int size)`
  Get the bytes at the given address and size and put them into the destination buffer.
  `void`
  `putByte(Address address, byte value)`
  Writes the given byte value to the address in memory.
  `int`
  `putBytes(Address address, byte[] source, int startIndex, int size)`
  Writes the given bytes to memory starting at the given address.
  `void`
  `removeLiveMemoryListener(LiveMemoryListener listener)`
  Removes the LiveMemoryListener from this handler.

- ## Method Details

  - ### clearCache

    void clearCache()
    Called when the memory map is re-initializing. Usually after an undo or redo.

  - ### getByte

    byte getByte(Address addr) throws MemoryAccessException
    Gets the byte at the given address.
    Parameters:
      `addr` - the address of the byte to be retrieved
    Returns:
      the byte at the given address.
    Throws:
      `MemoryAccessException` - if the byte can't be read.

  - ### getBytes

    int getBytes(Address address, byte[] buffer, int startIndex, int size) throws MemoryAccessException
    Get the bytes at the given address and size and put them into the destination buffer.
    Parameters:
      `address` - the address of the first byte to be retrieved.
      `buffer` - the byte buffer in which to place the bytes.
      `startIndex` - the starting index in the buffer to put the first byte.
      `size` - the number of bytes to retrieve and put in the buffer.
    Returns:
      the number of bytes placed into the given buffer.
    Throws:
      `MemoryAccessException` - if the bytes can't be read.

  - ### putByte

    void putByte(Address address, byte value) throws MemoryAccessException
    Writes the given byte value to the address in memory.
    Parameters:
      `address` - the address whose byte is to be updated to the new value.
      `value` - the value to set at the given address.
    Throws:
      `MemoryAccessException` - if the value can not be written to the memory.

  - ### putBytes

    int putBytes(Address address, byte[] source, int startIndex, int size) throws MemoryAccessException
    Writes the given bytes to memory starting at the given address.
    Parameters:
      `address` - the address in memory to write the bytes.
      `source` - the buffer containing the byte values to be written to memory.
      `startIndex` - the starting index in the buffer to get byte values.
      `size` - the number of bytes to write to memory.
    Returns:
      the number of bytes written to memory.
    Throws:
      `MemoryAccessException` - if the bytes can't be written to memory.

  - ### addLiveMemoryListener

    void addLiveMemoryListener(LiveMemoryListener listener)
    Adds a LiveMemoryListener to this handler. The listener will be notified when memory bytes change.
    Parameters:
      `listener` - the listener to be notified of memory byte value changes.

  - ### removeLiveMemoryListener

    void removeLiveMemoryListener(LiveMemoryListener listener)
    Removes the LiveMemoryListener from this handler.
    Parameters:
      `listener` - the listener to be removed.