decompiler 1.0.0
Public Member Functions | Protected Attributes | Friends | List of all members
ghidra::ExecutablePcodeSleigh Class Reference

A p-code snippet, described by SLEIGH, that can be executed as a script. More...

#include <inject_sleigh.hh>

Inheritance diagram for ghidra::ExecutablePcodeSleigh:
ghidra::ExecutablePcode ghidra::InjectPayload

Public Member Functions

 ExecutablePcodeSleigh (Architecture *g, const string &src, const string &nm)
 Constructor for use with decode.
 
virtual void inject (InjectContext &context, PcodeEmit &emit) const
 
virtual void decode (Decoder &decoder)
 Decode this payload from a stream.
 
virtual void printTemplate (ostream &s) const
 Print the p-code ops of the injection to a stream (for debugging)
 
- Public Member Functions inherited from ghidra::ExecutablePcode
 ExecutablePcode (Architecture *g, const string &src, const string &nm)
 Constructor.
 
virtual string getSource (void) const
 Return a string describing the source of the injection (.cspec, prototype model, etc.)
 
uintb evaluate (const vector< uintb > &input)
 Evaluate the snippet on the given inputs.
 
- Public Member Functions inherited from ghidra::InjectPayload
 InjectPayload (const string &nm, int4 tp)
 Construct for use with decode.
 
int4 getParamShift (void) const
 Get the number of parameters shifted.
 
bool isDynamic (void) const
 Return true if p-code in the injection is generated dynamically.
 
bool isIncidentalCopy (void) const
 Return true if any injected COPY is considered incidental.
 
int4 sizeInput (void) const
 Return the number of input parameters.
 
int4 sizeOutput (void) const
 Return the number of output parameters.
 
InjectParametergetInput (int4 i)
 Get the i-th input parameter.
 
InjectParametergetOutput (int4 i)
 Get the i-th output parameter.
 
virtual ~InjectPayload (void)
 Destructor.
 
string getName (void) const
 Return the name of the injection.
 
int4 getType (void) const
 Return the type of injection (CALLFIXUP_TYPE, CALLOTHERFIXUP_TYPE, etc.)
 

Protected Attributes

string parsestring
 SLEIGH syntax describing the p-code snippet.
 
ConstructTpl * tpl
 Parsed template objects (VarnodeTpl and OpTpl) ready for injection.
 
- Protected Attributes inherited from ghidra::InjectPayload
string name
 Formal name of the payload.
 
int4 type
 Type of this payload: CALLFIXUP_TYPE, CALLOTHERFIXUP_TYPE, etc.
 
bool dynamic
 True if the injection is generated dynamically.
 
bool incidentalCopy
 True if injected COPYs are considered incidental.
 
int4 paramshift
 Number of parameters shifted in the original call.
 
vector< InjectParameterinputlist
 List of input parameters to this payload.
 
vector< InjectParameteroutput
 List of output parameters.
 

Friends

class PcodeInjectLibrarySleigh
 

Additional Inherited Members

- Public Types inherited from ghidra::InjectPayload
enum  { CALLFIXUP_TYPE = 1 , CALLOTHERFIXUP_TYPE = 2 , CALLMECHANISM_TYPE = 3 , EXECUTABLEPCODE_TYPE = 4 }
 
- Protected Member Functions inherited from ghidra::InjectPayload
void orderParameters (void)
 Assign an index to parameters.
 
void decodePayloadAttributes (Decoder &decoder)
 Parse the attributes of the current <pcode> tag.
 
void decodePayloadParams (Decoder &decoder)
 Parse any <input> or <output> children of current <pcode> tag.
 
- Static Protected Member Functions inherited from ghidra::InjectPayload
static void decodeParameter (Decoder &decoder, string &name, uint4 &size)
 Parse an <input> or <output> element describing an injection parameter.
 

Detailed Description

A p-code snippet, described by SLEIGH, that can be executed as a script.

Constructor & Destructor Documentation

◆ ExecutablePcodeSleigh()

ghidra::ExecutablePcodeSleigh::ExecutablePcodeSleigh ( Architecture g,
const string &  src,
const string &  nm 
)

Constructor for use with decode.

Parameters
gis the Architecture owning the script
srcis a description or name of the payload document
nmis the name of the script

References tpl.

Member Function Documentation

◆ decode()

void ghidra::ExecutablePcodeSleigh::decode ( Decoder decoder)
virtual

◆ inject()

void ghidra::ExecutablePcodeSleigh::inject ( InjectContext context,
PcodeEmit emit 
) const
virtual

Perform the injection of this payload into data-flow.

P-code operations representing this payload are copied into the controlling analysis context. The provided PcodeEmit object dictates exactly where the PcodeOp and Varnode objects are inserted and to what container. An InjectContext object specifies how placeholder elements become concrete Varnodes in the appropriate context.

Parameters
contextis the provided InjectConject object
emitis the provovided PcodeEmit object

Implements ghidra::InjectPayload.

References ghidra::InjectContext::baseaddr, ghidra::InjectContextSleigh::cacher, ghidra::InjectContext::calladdr, ghidra::PcodeCacher::clear(), ghidra::PcodeCacher::emit(), ghidra::AddrSpaceManager::getConstantSpace(), ghidra::ExecutablePcode::getSource(), ghidra::AddrSpaceManager::getUniqueSpace(), ghidra::InjectContext::glb, ghidra::InjectPayload::inputlist, ghidra::InjectContext::nextaddr, ghidra::InjectPayload::output, ghidra::InjectContextSleigh::pos, ghidra::PcodeCacher::resolveRelatives(), ghidra::InjectPayloadSleigh::setupParameters(), and tpl.

◆ printTemplate()

void ghidra::ExecutablePcodeSleigh::printTemplate ( ostream &  s) const
virtual

Print the p-code ops of the injection to a stream (for debugging)

Implements ghidra::InjectPayload.

References tpl.


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