|
Ghidra 11.4.2
Ghidra internal decompiler documentation.
|
An abstract Emulate class using a MemoryState object as the backing machine state. More...
#include <emulate.hh>
Public Member Functions | |
| EmulateMemory (MemoryState *mem) | |
| Construct given a memory state. | |
| MemoryState * | getMemoryState (void) const |
| Get the emulator's memory state. | |
Public Member Functions inherited from ghidra::Emulate | |
| Emulate (void) | |
| generic emulator constructor | |
| void | setHalt (bool val) |
| Set the halt state of the emulator. | |
| bool | getHalt (void) const |
| Get the halt state of the emulator. | |
| virtual void | setExecuteAddress (const Address &addr)=0 |
| Set the address of the next instruction to emulate. | |
| virtual Address | getExecuteAddress (void) const =0 |
| Get the address of the current instruction being executed. | |
| void | executeCurrentOp (void) |
| Do a single pcode op step. | |
Protected Member Functions | |
| virtual void | executeUnary (void) |
| Execute a unary arithmetic/logical operation. | |
| virtual void | executeBinary (void) |
| Execute a binary arithmetic/logical operation. | |
| virtual void | executeLoad (void) |
| Standard behavior for a p-code LOAD. | |
| virtual void | executeStore (void) |
| Standard behavior for a p-code STORE. | |
| virtual void | executeBranch (void) |
| Standard behavior for a BRANCH. | |
| virtual bool | executeCbranch (void) |
| Check if the conditional of a CBRANCH is true. | |
| virtual void | executeBranchind (void) |
| Standard behavior for a BRANCHIND. | |
| virtual void | executeCall (void) |
| Standard behavior for a p-code CALL. | |
| virtual void | executeCallind (void) |
| Standard behavior for a CALLIND. | |
| virtual void | executeCallother (void) |
| Standard behavior for a user-defined p-code op. | |
| virtual void | executeMultiequal (void) |
| Standard behavior for a MULTIEQUAL (phi-node) | |
| virtual void | executeIndirect (void) |
| Standard behavior for an INDIRECT op. | |
| virtual void | executeSegmentOp (void) |
| Behavior for a SEGMENTOP. | |
| virtual void | executeCpoolRef (void) |
| Standard behavior for a CPOOLREF (constant pool reference) op. | |
| virtual void | executeNew (void) |
| Standard behavior for (low-level) NEW op. | |
Protected Member Functions inherited from ghidra::Emulate | |
| virtual void | fallthruOp (void)=0 |
| Standard p-code fall-thru semantics. | |
Protected Attributes | |
| MemoryState * | memstate |
| The memory state of the emulator. | |
| PcodeOpRaw * | currentOp |
| Current op to execute. | |
Protected Attributes inherited from ghidra::Emulate | |
| bool | emu_halted |
| Set to true if the emulator is halted. | |
| OpBehavior * | currentBehave |
| Behavior of the next op to execute. | |
An abstract Emulate class using a MemoryState object as the backing machine state.
Most p-code operations are implemented using the MemoryState to fetch and store values. Control-flow is implemented partially in that setExecuteAddress() is called to indicate which instruction is being executed. The derived class must provide
The following p-code operations are stubbed out and will throw an exception: CALLOTHER, MULTIEQUAL, INDIRECT, CPOOLREF, SEGMENTOP, and NEW. Of course the derived class can override these.
|
protectedvirtual |
Execute a binary arithmetic/logical operation.
Implements ghidra::Emulate.
References ghidra::Emulate::currentBehave, currentOp, ghidra::OpBehavior::evaluateBinary(), ghidra::PcodeOpRaw::getInput(), ghidra::PcodeOpRaw::getOutput(), ghidra::MemoryState::getValue(), memstate, ghidra::MemoryState::setValue(), and ghidra::VarnodeData::size.
|
protectedvirtual |
Standard behavior for a BRANCH.
This routine performs a standard p-code BRANCH operation on the memory state. This same routine is used for CBRANCH operations if the condition has evaluated to true.
Implements ghidra::Emulate.
Reimplemented in ghidra::EmulatePcodeCache.
References currentOp, ghidra::VarnodeData::getAddr(), ghidra::PcodeOpRaw::getInput(), and ghidra::Emulate::setExecuteAddress().
|
protectedvirtual |
Standard behavior for a BRANCHIND.
Implements ghidra::Emulate.
References currentOp, ghidra::PcodeOpRaw::getAddr(), ghidra::PcodeOpRaw::getInput(), ghidra::Address::getSpace(), ghidra::MemoryState::getValue(), memstate, and ghidra::Emulate::setExecuteAddress().
|
protectedvirtual |
Standard behavior for a p-code CALL.
Implements ghidra::Emulate.
References currentOp, ghidra::VarnodeData::getAddr(), ghidra::PcodeOpRaw::getInput(), and ghidra::Emulate::setExecuteAddress().
|
protectedvirtual |
Standard behavior for a CALLIND.
Implements ghidra::Emulate.
References currentOp, ghidra::PcodeOpRaw::getAddr(), ghidra::PcodeOpRaw::getInput(), ghidra::Address::getSpace(), ghidra::MemoryState::getValue(), memstate, and ghidra::Emulate::setExecuteAddress().
|
protectedvirtual |
Standard behavior for a user-defined p-code op.
Implements ghidra::Emulate.
Reimplemented in ghidra::EmulatePcodeCache.
|
protectedvirtual |
Check if the conditional of a CBRANCH is true.
This routine only checks if the condition for a p-code CBRANCH is true. It does not perform the actual branch.
Implements ghidra::Emulate.
References currentOp, ghidra::PcodeOpRaw::getInput(), ghidra::MemoryState::getValue(), and memstate.
|
protectedvirtual |
Standard behavior for a CPOOLREF (constant pool reference) op.
Implements ghidra::Emulate.
|
protectedvirtual |
Standard behavior for an INDIRECT op.
Implements ghidra::Emulate.
|
protectedvirtual |
Standard behavior for a p-code LOAD.
Implements ghidra::Emulate.
References ghidra::AddrSpace::addressToByte(), currentOp, ghidra::PcodeOpRaw::getInput(), ghidra::PcodeOpRaw::getOutput(), ghidra::VarnodeData::getSpaceFromConst(), ghidra::MemoryState::getValue(), ghidra::AddrSpace::getWordSize(), memstate, ghidra::MemoryState::setValue(), and ghidra::VarnodeData::size.
|
protectedvirtual |
Standard behavior for a MULTIEQUAL (phi-node)
Implements ghidra::Emulate.
|
protectedvirtual |
Standard behavior for (low-level) NEW op.
Implements ghidra::Emulate.
|
protectedvirtual |
Behavior for a SEGMENTOP.
Implements ghidra::Emulate.
|
protectedvirtual |
Standard behavior for a p-code STORE.
Implements ghidra::Emulate.
References ghidra::AddrSpace::addressToByte(), currentOp, ghidra::PcodeOpRaw::getInput(), ghidra::VarnodeData::getSpaceFromConst(), ghidra::MemoryState::getValue(), ghidra::AddrSpace::getWordSize(), memstate, ghidra::MemoryState::setValue(), and ghidra::VarnodeData::size.
|
protectedvirtual |
Execute a unary arithmetic/logical operation.
Implements ghidra::Emulate.
References ghidra::Emulate::currentBehave, currentOp, ghidra::OpBehavior::evaluateUnary(), ghidra::PcodeOpRaw::getInput(), ghidra::PcodeOpRaw::getOutput(), ghidra::MemoryState::getValue(), memstate, ghidra::MemoryState::setValue(), and ghidra::VarnodeData::size.
|
inline |
Get the emulator's memory state.
References memstate.