Interface MemoryState

All Known Implementing Classes:
AbstractMemoryState, AdaptedMemoryState, DefaultMemoryState

public interface MemoryState
  • Method Summary

    Modifier and Type
    Method
    Description
    getBigInteger(AddressSpace spc, long off, int size, boolean signed)
    This is the main interface for reading values from the MemoryState.
    A convenience method for reading a value directly from a register rather than querying for the offset and space
    getBigInteger(Varnode vn, boolean signed)
    A convenience method for reading a value directly from a varnode rather than querying for the offset and space
    This is a convenience method for reading registers by name.
    int
    getChunk(byte[] res, AddressSpace spc, long off, int size, boolean stopOnUnintialized)
    This is the main interface for reading a range of bytes from the MemorySate.
    Any MemoryBank that has been registered with this MemoryState can be retrieved via this method if the MemoryBank's associated address space is known.
    long
    getValue(AddressSpace spc, long off, int size)
    This is the main interface for reading values from the MemoryState.
    long
    A convenience method for reading a value directly from a register rather than querying for the offset and space
    long
    A convenience method for reading a value directly from a varnode rather than querying for the offset and space
    long
    This is a convenience method for reading registers by name.
    void
    setChunk(byte[] val, AddressSpace spc, long off, int size)
    This is the main interface for setting values for a range of bytes in the MemoryState.
    void
    setInitialized(boolean initialized, AddressSpace spc, long off, int size)
    This is the main interface for setting the initialization status for a range of bytes in the MemoryState.
    void
    MemoryBanks associated with specific address spaces must be registers with this MemoryState via this method.
    void
    setValue(AddressSpace spc, long off, int size, long cval)
    This is the main interface for writing values to the MemoryState.
    void
    setValue(AddressSpace spc, long off, int size, BigInteger cval)
    This is the main interface for writing values to the MemoryState.
    void
    setValue(Register reg, long cval)
    A convenience method for setting a value directly on a register rather than breaking out the components
    void
    A convenience method for setting a value directly on a register rather than breaking out the components
    void
    setValue(Varnode vn, long cval)
    A convenience method for setting a value directly on a varnode rather than breaking out the components
    void
    A convenience method for setting a value directly on a varnode rather than breaking out the components
    void
    setValue(String nm, long cval)
    This is a convenience method for setting registers by name.
    void
    This is a convenience method for setting registers by name.
  • Method Details

    • setMemoryBank

      void setMemoryBank(MemoryBank bank)
      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

      MemoryBank getMemoryBank(AddressSpace spc)
      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.
    • setValue

      void setValue(Varnode vn, long cval)
      A convenience method for setting a value directly on a varnode rather than breaking out the components
      Parameters:
      vn - the varnode location to be written
      cval - the value to write into the varnode location
    • setValue

      void setValue(Register reg, long cval)
      A convenience method for setting a value directly on a register rather than breaking out the components
      Parameters:
      reg - the register location to be written
      cval - the value to write into the register location
    • setValue

      void setValue(String nm, long cval)
      This is a convenience method for setting registers by name. Any register name known to the language can be used as a write location. The associated address space, offset, and size is looked up and automatically passed to the main setValue routine.
      Parameters:
      nm - is the name of the register
      cval - is the value to write to the register
    • setValue

      void setValue(AddressSpace spc, long off, int size, long cval)
      This is the main interface for writing values to the MemoryState. If there is no registered MemoryBank for the desired address space, or if there is some other error, an exception is thrown.
      Parameters:
      spc - is the address space to write to
      off - is the offset where the value should be written
      size - is the number of bytes to be written
      cval - is the value to be written
    • getValue

      long getValue(Varnode vn)
      A convenience method for reading a value directly from a varnode rather than querying for the offset and space
      Parameters:
      vn - the varnode location to be read
      Returns:
      the value read from the varnode location
    • getValue

      long getValue(Register reg)
      A convenience method for reading a value directly from a register rather than querying for the offset and space
      Parameters:
      reg - the register location to be read
      Returns:
      the value read from the register location
    • getValue

      long getValue(String nm)
      This is a convenience method for reading registers by name. any register name known to the language can be used as a read location. The associated address space, offset, and size is looked up and automatically passed to the main getValue routine.
      Parameters:
      nm - is the name of the register
      Returns:
      the value associated with that register
    • getValue

      long getValue(AddressSpace spc, long off, int size)
      This is the main interface for reading values from the MemoryState. If there is no registered MemoryBank for the desired address space, or if there is some other error, an exception is thrown.
      Parameters:
      spc - is the address space being queried
      off - is the offset of the value being queried
      size - is the number of bytes to query
      Returns:
      the queried value
    • setValue

      void setValue(Varnode vn, BigInteger cval)
      A convenience method for setting a value directly on a varnode rather than breaking out the components
      Parameters:
      vn - the varnode location to be written
      cval - the value to write into the varnode location
    • setValue

      void setValue(Register reg, BigInteger cval)
      A convenience method for setting a value directly on a register rather than breaking out the components
      Parameters:
      reg - the register location to be written
      cval - the value to write into the register location
    • setValue

      void setValue(String nm, BigInteger cval)
      This is a convenience method for setting registers by name. Any register name known to the language can be used as a write location. The associated address space, offset, and size is looked up and automatically passed to the main setValue routine.
      Parameters:
      nm - is the name of the register
      cval - is the value to write to the register
    • setValue

      void setValue(AddressSpace spc, long off, int size, BigInteger cval)
      This is the main interface for writing values to the MemoryState. If there is no registered MemoryBank for the desired address space, or if there is some other error, an exception is thrown.
      Parameters:
      spc - is the address space to write to
      off - is the offset where the value should be written
      size - is the number of bytes to be written
      cval - is the value to be written
    • getBigInteger

      BigInteger getBigInteger(Varnode vn, boolean signed)
      A convenience method for reading a value directly from a varnode rather than querying for the offset and space
      Parameters:
      vn - the varnode location to be read
      signed - true if signed value should be returned, false for unsigned value
      Returns:
      the unsigned value read from the varnode location
    • getBigInteger

      BigInteger getBigInteger(Register reg)
      A convenience method for reading a value directly from a register rather than querying for the offset and space
      Parameters:
      reg - the register location to be read
      Returns:
      the unsigned value read from the register location
    • getBigInteger

      BigInteger getBigInteger(String nm)
      This is a convenience method for reading registers by name. any register name known to the language can be used as a read location. The associated address space, offset, and size is looked up and automatically passed to the main getValue routine.
      Parameters:
      nm - is the name of the register
      Returns:
      the unsigned value associated with that register
    • getBigInteger

      BigInteger getBigInteger(AddressSpace spc, long off, int size, boolean signed)
      This is the main interface for reading values from the MemoryState. If there is no registered MemoryBank for the desired address space, or if there is some other error, an exception is thrown.
      Parameters:
      spc - is the address space being queried
      off - is the offset of the value being queried
      size - is the number of bytes to query
      signed - true if signed value should be returned, false for unsigned value
      Returns:
      the queried unsigned value
    • getChunk

      int getChunk(byte[] res, AddressSpace spc, long off, int size, boolean stopOnUnintialized)
      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
      Throws:
      LowlevelError - if spc has not been mapped within this MemoryState or memory fault handler generated error
    • setChunk

      void setChunk(byte[] val, AddressSpace spc, long off, int size)
      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
      Throws:
      LowlevelError - if spc has not been mapped within this MemoryState
    • setInitialized

      void setInitialized(boolean initialized, AddressSpace spc, long off, int size)
      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