Package ghidra.pcode.memstate
Interface MemoryState
- All Known Implementing Classes:
AbstractMemoryState
,AdaptedMemoryState
,DefaultMemoryState
public interface MemoryState
-
Method Summary
Modifier and TypeMethodDescriptiongetBigInteger
(AddressSpace spc, long off, int size, boolean signed) This is the main interface for reading values from the MemoryState.getBigInteger
(Register reg) A convenience method for reading a value directly from a register rather than querying for the offset and spacegetBigInteger
(Varnode vn, boolean signed) A convenience method for reading a value directly from a varnode rather than querying for the offset and spacegetBigInteger
(String nm) 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 spacelong
A convenience method for reading a value directly from a varnode rather than querying for the offset and spacelong
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
setMemoryBank
(MemoryBank bank) 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
A convenience method for setting a value directly on a register rather than breaking out the componentsvoid
setValue
(Register reg, BigInteger cval) A convenience method for setting a value directly on a register rather than breaking out the componentsvoid
A convenience method for setting a value directly on a varnode rather than breaking out the componentsvoid
setValue
(Varnode vn, BigInteger cval) A convenience method for setting a value directly on a varnode rather than breaking out the componentsvoid
This is a convenience method for setting registers by name.void
setValue
(String nm, BigInteger cval) This is a convenience method for setting registers by name.
-
Method Details
-
setMemoryBank
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
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
A convenience method for setting a value directly on a varnode rather than breaking out the components- Parameters:
vn
- the varnode location to be writtencval
- the value to write into the varnode location
-
setValue
A convenience method for setting a value directly on a register rather than breaking out the components- Parameters:
reg
- the register location to be writtencval
- the value to write into the register location
-
setValue
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 registercval
- is the value to write to the register
-
setValue
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 tooff
- is the offset where the value should be writtensize
- is the number of bytes to be writtencval
- is the value to be written
-
getValue
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
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
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
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 queriedoff
- is the offset of the value being queriedsize
- is the number of bytes to query- Returns:
- the queried value
-
setValue
A convenience method for setting a value directly on a varnode rather than breaking out the components- Parameters:
vn
- the varnode location to be writtencval
- the value to write into the varnode location
-
setValue
A convenience method for setting a value directly on a register rather than breaking out the components- Parameters:
reg
- the register location to be writtencval
- the value to write into the register location
-
setValue
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 registercval
- is the value to write to the register
-
setValue
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 tooff
- is the offset where the value should be writtensize
- is the number of bytes to be writtencval
- is the value to be written
-
getBigInteger
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 readsigned
- true if signed value should be returned, false for unsigned value- Returns:
- the unsigned value read from the varnode location
-
getBigInteger
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
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
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 queriedoff
- is the offset of the value being queriedsize
- is the number of bytes to querysigned
- true if signed value should be returned, false for unsigned value- Returns:
- the queried unsigned value
-
getChunk
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 bytesspc
- the desired address spaceoff
- the starting offset of the byte range being readsize
- the number of bytes being readstopOnUnintialized
- 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
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 MemoryStatespc
- the address space being writtenoff
- the starting offset of the range being writtensize
- the number of bytes to write- Throws:
LowlevelError
- if spc has not been mapped within this MemoryState
-
setInitialized
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 notspc
- the address space being writtenoff
- the starting offset of the range being writtensize
- the number of bytes to write
-