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

An injection payload built by the SLEIGH engine. More...

#include <inject_sleigh.hh>

Inheritance diagram for ghidra::InjectPayloadSleigh:
ghidra::InjectPayload ghidra::InjectPayloadCallfixup ghidra::InjectPayloadCallother

Public Member Functions

 InjectPayloadSleigh (const string &src, const string &nm, int4 tp)
 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)
 
virtual string getSource (void) const
 Return a string describing the source of the injection (.cspec, prototype model, etc.)
 
- 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.)
 

Static Public Member Functions

static void checkParameterRestrictions (InjectContextSleigh &con, const vector< InjectParameter > &inputlist, const vector< InjectParameter > &output, const string &source)
 Verify that storage locations passed in -con- match the restrictions set for a given payload.
 
static void setupParameters (InjectContextSleigh &con, ParserWalkerChange &walker, const vector< InjectParameter > &inputlist, const vector< InjectParameter > &output, const string &source)
 Set-up operands in the parser state so that they pick up storage locations in InjectContext.
 

Protected Member Functions

void decodeBody (Decoder &decoder)
 Parse the <body> tag.
 
- 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.
 

Private Attributes

ConstructTpl * tpl
 The VarnodeTpl and OpTpl objects prepared for injection.
 
string parsestring
 SLEIGH syntax describing the injection p-code.
 
string source
 A description of the document containing the SLEIGH syntax.
 

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 }
 
- 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.
 
- 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.
 

Detailed Description

An injection payload built by the SLEIGH engine.

The p-code ops for the injection are described using SLEIGH syntax. This object can hold both the SLEIGH syntax as a string or the p-code templates (VarnodeTpl and OpTpl) that are prepared for emitting the p-code for the injection.

Constructor & Destructor Documentation

◆ InjectPayloadSleigh()

ghidra::InjectPayloadSleigh::InjectPayloadSleigh ( const string &  src,
const string &  nm,
int4  tp 
)

Constructor for use with decode.

Create an empty payload in preparation for parsing the injection from a stream

Parameters
srcis a name or other description of the document to be parsed
nmis the name of the injection
tpis the type of injection

References ghidra::InjectPayload::paramshift, source, and tpl.

Member Function Documentation

◆ checkParameterRestrictions()

void ghidra::InjectPayloadSleigh::checkParameterRestrictions ( InjectContextSleigh con,
const vector< InjectParameter > &  inputlist,
const vector< InjectParameter > &  output,
const string &  source 
)
static

Verify that storage locations passed in -con- match the restrictions set for a given payload.

If the parsed injection does not match the restrictions, an exception is thrown.

Parameters
conis the SLEIGH context established after parsing the injection
inputlistis the list of input parameters specified for the given payload
outputis the list of output parameters specified for the given payload
sourceis a description or name for the payload document

References ghidra::InjectContext::inputlist, ghidra::InjectPayload::inputlist, ghidra::InjectContext::output, ghidra::InjectPayload::output, and source.

Referenced by setupParameters().

◆ decode()

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

◆ decodeBody()

void ghidra::InjectPayloadSleigh::decodeBody ( Decoder decoder)
protected

Parse the <body> tag.

The content is read as raw p-code source.

Parameters
decoderis the stream decoder

References ghidra::Decoder::closeElement(), ghidra::InjectPayload::dynamic, getSource(), ghidra::Decoder::openElement(), parsestring, and ghidra::Decoder::readString().

Referenced by decode(), ghidra::InjectPayloadCallfixup::decode(), and ghidra::InjectPayloadCallother::decode().

◆ getSource()

virtual string ghidra::InjectPayloadSleigh::getSource ( void  ) const
inlinevirtual

Return a string describing the source of the injection (.cspec, prototype model, etc.)

Implements ghidra::InjectPayload.

References source.

Referenced by decodeBody().

◆ inject()

void ghidra::InjectPayloadSleigh::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::AddrSpaceManager::getUniqueSpace(), ghidra::InjectContext::glb, ghidra::InjectPayload::inputlist, ghidra::InjectContext::nextaddr, ghidra::InjectPayload::output, ghidra::InjectContextSleigh::pos, ghidra::PcodeCacher::resolveRelatives(), setupParameters(), source, and tpl.

◆ printTemplate()

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

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

Implements ghidra::InjectPayload.

References tpl.

◆ setupParameters()

void ghidra::InjectPayloadSleigh::setupParameters ( InjectContextSleigh con,
ParserWalkerChange &  walker,
const vector< InjectParameter > &  inputlist,
const vector< InjectParameter > &  output,
const string &  source 
)
static

Set-up operands in the parser state so that they pick up storage locations in InjectContext.

Parameters
conis context for the parser
walkeris the parser state
inputlistis the input varnodes as described by the payload
outputis the output varnodes as described by the payload
sourceis a description or name of the payload document

References checkParameterRestrictions(), ghidra::InjectContext::inputlist, ghidra::InjectPayload::inputlist, ghidra::VarnodeData::offset, ghidra::InjectContext::output, ghidra::InjectPayload::output, ghidra::VarnodeData::size, source, and ghidra::VarnodeData::space.

Referenced by inject(), and ghidra::ExecutablePcodeSleigh::inject().


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