Ghidra 11.3.2
Ghidra internal decompiler documentation.
Loading...
Searching...
No Matches
ghidra::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 ghidra::InjectPayload:
[legend]
Collaboration diagram for ghidra::InjectPayload:
[legend]

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 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.
 
virtual void inject (InjectContext &context, PcodeEmit &emit) const =0
 
virtual void decode (Decoder &decoder)=0
 Decode this payload from a stream.
 
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.
 
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

static void decodeParameter (Decoder &decoder, string &name, uint4 &size)
 Parse an <input> or <output> element describing an injection parameter.
 

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

◆ decode()

virtual void ghidra::InjectPayload::decode ( Decoder decoder)
pure virtual

◆ decodeParameter()

void ghidra::InjectPayload::decodeParameter ( Decoder decoder,
string &  name,
uint4 &  size 
)
staticprotected

Parse an <input> or <output> element describing an injection parameter.

Parameters
decoderis the stream decoder
nameis used to pass back the parameter name
sizeis used to pass back the parameter size

References ghidra::Decoder::closeElement(), ghidra::Decoder::getNextAttributeId(), name, ghidra::Decoder::openElement(), ghidra::Decoder::readString(), and ghidra::Decoder::readUnsignedInteger().

Referenced by decodePayloadParams().

◆ decodePayloadAttributes()

void ghidra::InjectPayload::decodePayloadAttributes ( Decoder decoder)
protected

Parse the attributes of the current <pcode> tag.

The <pcode> element must be current and already opened.

Parameters
decoderis the stream decoder

References dynamic, ghidra::Decoder::getNextAttributeId(), incidentalCopy, name, paramshift, ghidra::Decoder::readBool(), ghidra::Decoder::readSignedInteger(), and ghidra::Decoder::readString().

Referenced by ghidra::InjectPayloadGhidra::decode(), ghidra::InjectCallotherGhidra::decode(), and ghidra::ExecutablePcodeGhidra::decode().

◆ decodePayloadParams()

void ghidra::InjectPayload::decodePayloadParams ( Decoder decoder)
protected

Parse any <input> or <output> children of current <pcode> tag.

Elements are processed until the first child that isn't an <input> or <output> tag is encountered. The <pcode> element must be current and already opened.

Parameters
decoderis the stream decoder

References decodeParameter(), inputlist, orderParameters(), output, and ghidra::Decoder::peekElement().

Referenced by ghidra::InjectCallotherGhidra::decode(), and ghidra::ExecutablePcodeGhidra::decode().

◆ getSource()

virtual string ghidra::InjectPayload::getSource ( void  ) const
pure virtual

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

Implemented in ghidra::ExecutablePcode, and ghidra::InjectPayloadGhidra.

◆ inject()

virtual void ghidra::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 ghidra::InjectPayloadGhidra, and ghidra::ExecutablePcodeGhidra.

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

◆ orderParameters()

void ghidra::InjectPayload::orderParameters ( void  )
protected

Assign an index to parameters.

Input and output parameters are assigned a unique index.

References inputlist, and output.

Referenced by decodePayloadParams().

◆ printTemplate()

virtual void ghidra::InjectPayload::printTemplate ( ostream &  s) const
pure virtual

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

Implemented in ghidra::InjectPayloadGhidra, and ghidra::ExecutablePcodeGhidra.


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