decompiler  1.0.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
EmulatePcodeOp Class Referenceabstract

Emulation based on (existing) PcodeOps and Varnodes. More...

#include <emulateutil.hh>

Inheritance diagram for EmulatePcodeOp:
Emulate EmulateFunction

Public Member Functions

 EmulatePcodeOp (Architecture *g)
 Constructor. More...
 
void setCurrentOp (PcodeOp *op)
 Establish the current PcodeOp being emulated. More...
 
virtual Address getExecuteAddress (void) const
 Get the address of the current instruction being executed.
 
virtual void setVarnodeValue (Varnode *vn, uintb val)=0
 Given a specific Varnode, set the given value for it in the current machine state. More...
 
virtual uintb getVarnodeValue (Varnode *vn) const =0
 Given a specific Varnode, retrieve the current value for it from the machine state. More...
 
- Public Member Functions inherited from Emulate
 Emulate (void)
 generic emulator constructor
 
void setHalt (bool val)
 Set the halt state of the emulator. More...
 
bool getHalt (void) const
 Get the halt state of the emulator. More...
 
virtual void setExecuteAddress (const Address &addr)=0
 Set the address of the next instruction to emulate.
 
void executeCurrentOp (void)
 Do a single pcode op step. More...
 

Protected Member Functions

virtual uintb getLoadImageValue (AddrSpace *spc, uintb offset, int4 sz) const
 Pull a value from the load-image given a specific address. More...
 
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 bool executeCbranch (void)
 Check if the conditional of a CBRANCH is true. More...
 
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 Emulate
virtual void executeBranch (void)=0
 Standard behavior for a BRANCH. More...
 
virtual void executeBranchind (void)=0
 Standard behavior for a BRANCHIND.
 
virtual void executeCall (void)=0
 Standard behavior for a p-code CALL.
 
virtual void executeCallind (void)=0
 Standard behavior for a CALLIND.
 
virtual void executeCallother (void)=0
 Standard behavior for a user-defined p-code op.
 
virtual void fallthruOp (void)=0
 Standard p-code fall-thru semantics.
 

Protected Attributes

Architectureglb
 The underlying Architecture for the program being emulated.
 
PcodeOpcurrentOp
 Current PcodeOp being executed.
 
PcodeOplastOp
 Last PcodeOp that was executed.
 
- Protected Attributes inherited from Emulate
bool emu_halted
 Set to true if the emulator is halted.
 
OpBehaviorcurrentBehave
 Behavior of the next op to execute.
 

Detailed Description

Emulation based on (existing) PcodeOps and Varnodes.

This is still an abstract class. It does most of the work of emulating p-code using PcodeOp and Varnode objects (as opposed to PcodeOpRaw and VarnodeData). This class leaves implementation of control-flow to the derived class. This class implements most operations by going through new virtual methods:

The default executeLoad() implementation pulls values from the underlying LoadImage object. The following p-code ops are provided NULL implementations, as some tasks don't need hard emulation of them:

Constructor & Destructor Documentation

◆ EmulatePcodeOp()

EmulatePcodeOp::EmulatePcodeOp ( Architecture g)

Constructor.

Parameters
gis the Architecture providing the LoadImage

References currentOp, glb, and lastOp.

Member Function Documentation

◆ executeCbranch()

bool EmulatePcodeOp::executeCbranch ( void  )
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.

Returns
the boolean state indicated by the condition

Implements Emulate.

References currentOp, PcodeOp::getIn(), getVarnodeValue(), and PcodeOp::isBooleanFlip().

◆ getLoadImageValue()

uintb EmulatePcodeOp::getLoadImageValue ( AddrSpace spc,
uintb  offset,
int4  sz 
) const
protectedvirtual

Pull a value from the load-image given a specific address.

A contiguous chunk of memory is pulled from the load-image and returned as a constant value, respecting the endianess of the address space. The default implementation of this method pulls the value directly from the LoadImage object.

Parameters
spcis the address space to pull the value from
offsetis the starting address offset (from within the space) to pull the value from
szis the number of bytes to pull from memory
Returns
indicated bytes arranged as a constant value

References byte_swap(), calc_mask(), glb, AddrSpace::isBigEndian(), Architecture::loader, and LoadImage::loadFill().

Referenced by executeLoad(), and EmulateFunction::getVarnodeValue().

◆ getVarnodeValue()

virtual uintb EmulatePcodeOp::getVarnodeValue ( Varnode vn) const
pure virtual

Given a specific Varnode, retrieve the current value for it from the machine state.

This is the placeholder internal operation for obtaining a Varnode value during emulation. The value is loaded using the Varnode as the address and storage size.

Parameters
vnis the specific Varnode
Returns
the corresponding value from the machine state

Implemented in EmulateFunction.

Referenced by executeBinary(), executeCbranch(), executeIndirect(), executeLoad(), executeMultiequal(), executeSegmentOp(), and executeUnary().

◆ setCurrentOp()

void EmulatePcodeOp::setCurrentOp ( PcodeOp op)
inline

Establish the current PcodeOp being emulated.

Parameters
opis the PcodeOp that will next be executed via executeCurrentOp()

References Emulate::currentBehave, currentOp, TypeOp::getBehavior(), and PcodeOp::getOpcode().

◆ setVarnodeValue()

virtual void EmulatePcodeOp::setVarnodeValue ( Varnode vn,
uintb  val 
)
pure virtual

Given a specific Varnode, set the given value for it in the current machine state.

This is the placeholder internal operation for setting a Varnode value during emulation. The value is stored using the Varnode as the address and storage size.

Parameters
vnis the specific Varnode
valis the constant value to store

Implemented in EmulateFunction.

Referenced by executeBinary(), executeIndirect(), executeLoad(), executeMultiequal(), executeSegmentOp(), and executeUnary().


The documentation for this class was generated from the following files: