decompiler  1.0.0
Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
InjectPayload Class Referenceabstract

An active container for a set of p-code operations that can be injected into data-flow. More...

#include <pcodeinject.hh>

Inheritance diagram for InjectPayload:
ExecutablePcode InjectPayloadGhidra ExecutablePcodeGhidra InjectCallfixupGhidra InjectCallotherGhidra

Public Types

enum  { CALLFIXUP_TYPE = 1, CALLOTHERFIXUP_TYPE = 2, CALLMECHANISM_TYPE = 3, EXECUTABLEPCODE_TYPE = 4 }
 

Public Member Functions

 InjectPayload (const string &nm, int4 tp)
 Construct for use with restoreXml.
 
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.
 
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.
 
virtual void inject (InjectContext &context, PcodeEmit &emit) const =0
 
virtual void restoreXml (const Element *el)
 Restore this payload from an XML stream. More...
 
virtual void printTemplate (ostream &s) const =0
 Print the p-code ops of the injection to a stream (for debugging)
 
string getName (void) const
 Return the name of the injection.
 
int4 getType (void) const
 Return the type of injection (CALLFIXUP_TYPE, CALLOTHERFIXUP_TYPE, etc.)
 
virtual string getSource (void) const =0
 Return a string describing the source of the injection (.cspec, prototype model, etc.)
 

Protected Member Functions

void orderParameters (void)
 Assign an index to parameters. More...
 

Static Protected Member Functions

static void readParameter (const Element *el, string &name, uint4 &size)
 Read in an <input> or <output> XML tag describing an injection parameter. More...
 

Protected Attributes

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.
 
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 active container for a set of p-code operations that can be injected into data-flow.

This is an abstract base class. Derived classes manage details of how the p-code is stored. The methods provide access to the input/output parameter information, and the main injection is performed with inject().

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
CALLFIXUP_TYPE 

Injection that replaces a CALL.

CALLOTHERFIXUP_TYPE 

Injection that replaces a user-defined p-code op, CALLOTHER.

CALLMECHANISM_TYPE 

Injection to patch up data-flow around the caller/callee boundary.

EXECUTABLEPCODE_TYPE 

Injection running as a stand-alone p-code script.

Member Function Documentation

◆ inject()

virtual void InjectPayload::inject ( InjectContext context,
PcodeEmit emit 
) const
pure 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

Implemented in ExecutablePcodeGhidra, and InjectPayloadGhidra.

Referenced by ExecutablePcode::build(), FlowInfo::doInjection(), and Funcdata::doLiveInject().

◆ orderParameters()

void InjectPayload::orderParameters ( void  )
protected

Assign an index to parameters.

Input and output parameters are assigned a unique index.

References inputlist, and output.

Referenced by restoreXml().

◆ readParameter()

void InjectPayload::readParameter ( const Element el,
string &  name,
uint4 &  size 
)
staticprotected

Read in an <input> or <output> XML tag describing an injection parameter.

Parameters
elis the XML element
nameis used to pass back the parameter name
sizeis used to pass back the parameter size

References name.

Referenced by restoreXml().

◆ restoreXml()

void InjectPayload::restoreXml ( const Element el)
virtual

Restore this payload from an XML stream.

The base class version of this method restores from a <pcode> tag. Derived classes may restore from a parent tag and then invoke the base class method.

Parameters
elis the XML element

Reimplemented in ExecutablePcodeGhidra, InjectCallotherGhidra, InjectCallfixupGhidra, and InjectPayloadGhidra.

References dynamic, inputlist, orderParameters(), output, paramshift, and readParameter().

Referenced by InjectCallotherGhidra::restoreXml(), ExecutablePcodeGhidra::restoreXml(), and PcodeInjectLibrary::restoreXmlInject().


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