Class AdaptedMemoryState<T>

java.lang.Object
ghidra.pcode.memstate.AbstractMemoryState
ghidra.app.emulator.AdaptedMemoryState<T>
Type Parameters:
T - the type of values in the wrapped state. This matters not to EmulatorHelper, so long as AdaptedMemoryState can be made concrete.
All Implemented Interfaces:
MemoryState

public class AdaptedMemoryState<T> extends AbstractMemoryState
An implementation of MemoryState which wraps a newer PcodeExecutorState.

This is a transitional component used internally by the AdaptedEmulator. It is also used in the ModifiedPcodeThread, which is part of the newer PcodeEmulator system, as a means of incorporating EmulateInstructionStateModifier, which is part of the older EmulatorHelper system. This class will be removed once both conditions are met:

  1. An equivalent state modification system is developed for the PcodeEmulator system, and each EmulateInstructionStateModifier is ported to it.
  2. The AdaptedEmulator class is removed.

Guidance for the use of this class is the same as AdaptedEmulator.

  • Constructor Details

  • Method Details

    • setMemoryBank

      public void setMemoryBank(MemoryBank bank)
      Description copied from interface: MemoryState
      MemoryBanks associated with specific address spaces must be registers with this MemoryState via this method. Each address space that will be used during emulation must be registered separately. The MemoryState object does not assume responsibility for freeing the MemoryBank.
      Parameters:
      bank - is a pointer to the MemoryBank to be registered
    • getMemoryBank

      public MemoryBank getMemoryBank(AddressSpace spc)
      Description copied from interface: MemoryState
      Any MemoryBank that has been registered with this MemoryState can be retrieved via this method if the MemoryBank's associated address space is known.
      Parameters:
      spc - is the address space of the desired MemoryBank
      Returns:
      the MemoryBank or null if no bank is associated with spc.
    • getChunk

      public int getChunk(byte[] res, AddressSpace spc, long off, int size, boolean stopOnUnintialized)
      Description copied from interface: MemoryState
      This is the main interface for reading a range of bytes from the MemorySate. The MemoryBank associated with the address space of the query is looked up and the request is forwarded to the getChunk method on the MemoryBank. If there is no registered MemoryBank or some other error, an exception is thrown. All getLongValue methods utilize this method to read the bytes from the appropriate memory bank.
      Parameters:
      res - the result buffer for storing retrieved bytes
      spc - the desired address space
      off - the starting offset of the byte range being read
      size - the number of bytes being read
      stopOnUnintialized - if true a partial read is permitted and returned size may be smaller than size requested
      Returns:
      number of bytes actually read
    • setChunk

      public void setChunk(byte[] val, AddressSpace spc, long off, int size)
      Description copied from interface: MemoryState
      This is the main interface for setting values for a range of bytes in the MemoryState. The MemoryBank associated with the desired address space is looked up and the write is forwarded to the setChunk method on the MemoryBank. If there is no registered MemoryBank or some other error, an exception is throw. All setValue methods utilize this method to read the bytes from the appropriate memory bank.
      Parameters:
      val - the byte values to be written into the MemoryState
      spc - the address space being written
      off - the starting offset of the range being written
      size - the number of bytes to write
    • setInitialized

      public void setInitialized(boolean initialized, AddressSpace spc, long off, int size)
      Description copied from interface: MemoryState
      This is the main interface for setting the initialization status for a range of bytes in the MemoryState. The MemoryBank associated with the desired address space is looked up and the write is forwarded to the setInitialized method on the MemoryBank. If there is no registered MemoryBank or some other error, an exception is throw. All setValue methods utilize this method to read the bytes from the appropriate memory bank.
      Parameters:
      initialized - indicates if range should be marked as initialized or not
      spc - the address space being written
      off - the starting offset of the range being written
      size - the number of bytes to write