decompiler
1.0.0
|
All storage/state for a pcode machine. More...
#include <memstate.hh>
Public Member Functions | |
MemoryState (Translate *t) | |
A constructor for MemoryState. More... | |
Translate * | getTranslate (void) const |
Get the Translate object. More... | |
void | setMemoryBank (MemoryBank *bank) |
Map a memory bank into the state. More... | |
MemoryBank * | getMemoryBank (AddrSpace *spc) const |
Get a memory bank associated with a particular space. More... | |
void | setValue (AddrSpace *spc, uintb off, int4 size, uintb cval) |
Set a value on the memory state. More... | |
uintb | getValue (AddrSpace *spc, uintb off, int4 size) const |
Retrieve a memory value from the memory state. More... | |
void | setValue (const string &nm, uintb cval) |
Set a value on a named register in the memory state. More... | |
uintb | getValue (const string &nm) const |
Retrieve a value from a named register in the memory state. More... | |
void | setValue (const VarnodeData *vn, uintb cval) |
Set value on a given varnode. More... | |
uintb | getValue (const VarnodeData *vn) const |
Get a value from a varnode. More... | |
void | getChunk (uint1 *res, AddrSpace *spc, uintb off, int4 size) const |
Get a chunk of data from memory state. More... | |
void | setChunk (const uint1 *val, AddrSpace *spc, uintb off, int4 size) |
Set a chunk of data from memory state. More... | |
Protected Attributes | |
Translate * | trans |
Architecture information about memory spaces. | |
vector< MemoryBank * > | memspace |
Memory banks associated with each address space. | |
All storage/state for a pcode machine.
Every piece of information in a pcode machine is representable as a triple (AddrSpace,offset,size). This class allows getting and setting of all state information of this form.
|
inline |
A constructor for MemoryState.
The MemoryState needs a Translate object in order to be able to convert register names into varnodes
t | is the translator |
void ghidra::MemoryState::getChunk | ( | uint1 * | res, |
AddrSpace * | spc, | ||
uintb | off, | ||
int4 | size | ||
) | const |
Get a chunk of data from memory state.
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
res | is a pointer to the result buffer for storing retrieved bytes |
spc | is the desired address space |
off | is the starting offset of the byte range being queried |
size | is the number of bytes being queried |
References ghidra::MemoryBank::getChunk(), and ghidra::AddrSpace::getName().
MemoryBank * ghidra::MemoryState::getMemoryBank | ( | AddrSpace * | spc | ) | const |
Get a memory bank associated with a particular space.
Any MemoryBank that has been registered with this MemoryState can be retrieved via this method if the MemoryBank's associated address space is known.
spc | is the address space of the desired MemoryBank |
References ghidra::AddrSpace::getIndex().
|
inline |
uintb ghidra::MemoryState::getValue | ( | AddrSpace * | spc, |
uintb | off, | ||
int4 | size | ||
) | const |
Retrieve a memory value from the memory state.
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.
spc | is the address space being queried |
off | is the offset of the value being queried |
size | is the number of bytes to query |
References ghidra::AddrSpace::getName(), ghidra::AddrSpace::getType(), ghidra::MemoryBank::getValue(), and ghidra::IPTR_CONSTANT.
uintb ghidra::MemoryState::getValue | ( | const string & | nm | ) | const |
Retrieve a value from a named register in the memory state.
This is a convenience method for reading registers by name. Any register name known to the Translate object 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.
nm | is the name of the register |
References ghidra::MemoryBank::getValue().
|
inline |
Get a value from a varnode.
A convenience method for reading a value directly from a varnode rather than querying for the offset and space
vn | is a pointer to the varnode to be read |
References ghidra::MemoryBank::getValue(), ghidra::VarnodeData::offset, ghidra::VarnodeData::size, and ghidra::VarnodeData::space.
void ghidra::MemoryState::setChunk | ( | const uint1 * | val, |
AddrSpace * | spc, | ||
uintb | off, | ||
int4 | size | ||
) |
Set a chunk of data from memory state.
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.
val | is a pointer to the byte values to be written into the MemoryState |
spc | is the address space being written |
off | is the starting offset of the range being written |
size | is the number of bytes to write |
References ghidra::AddrSpace::getName(), and ghidra::MemoryBank::setChunk().
void ghidra::MemoryState::setMemoryBank | ( | MemoryBank * | bank | ) |
Map a memory bank into the state.
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
bank | is a pointer to the MemoryBank to be registered |
References ghidra::AddrSpace::getIndex(), and ghidra::MemoryBank::getSpace().
void ghidra::MemoryState::setValue | ( | AddrSpace * | spc, |
uintb | off, | ||
int4 | size, | ||
uintb | cval | ||
) |
Set a value on the memory state.
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.
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 |
References ghidra::AddrSpace::getName(), and ghidra::MemoryBank::setValue().
void ghidra::MemoryState::setValue | ( | const string & | nm, |
uintb | cval | ||
) |
Set a value on a named register in the memory state.
This is a convenience method for setting registers by name. Any register name known to the Translate object 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.
nm | is the name of the register |
cval | is the value to write to the register |
References ghidra::MemoryBank::setValue().
|
inline |
Set value on a given varnode.
A convenience method for setting a value directly on a varnode rather than breaking out the components
vn | is a pointer to the varnode to be written |
cval | is the value to write into the varnode |
References ghidra::VarnodeData::offset, ghidra::MemoryBank::setValue(), ghidra::VarnodeData::size, and ghidra::VarnodeData::space.