|
decompiler 1.0.0
|
An injection payload built by the SLEIGH engine. More...
#include <inject_sleigh.hh>
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. | |
| InjectParameter & | getInput (int4 i) |
| Get the i-th input parameter. | |
| InjectParameter & | getOutput (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. | |
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< InjectParameter > | inputlist |
| List of input parameters to this payload. | |
| vector< InjectParameter > | output |
| List of output parameters. | |
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.
| 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
| src | is a name or other description of the document to be parsed |
| nm | is the name of the injection |
| tp | is the type of injection |
References ghidra::InjectPayload::paramshift, source, and tpl.
|
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.
| con | is the SLEIGH context established after parsing the injection |
| inputlist | is the list of input parameters specified for the given payload |
| output | is the list of output parameters specified for the given payload |
| source | is 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().
|
virtual |
Decode this payload from a stream.
Implements ghidra::InjectPayload.
Reimplemented in ghidra::InjectPayloadCallfixup, and ghidra::InjectPayloadCallother.
References ghidra::Decoder::closeElement(), decodeBody(), ghidra::InjectPayload::decodePayloadAttributes(), ghidra::InjectPayload::decodePayloadParams(), and ghidra::Decoder::openElement().
|
protected |
Parse the <body> tag.
The content is read as raw p-code source.
| decoder | is 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().
|
inlinevirtual |
Return a string describing the source of the injection (.cspec, prototype model, etc.)
Implements ghidra::InjectPayload.
References source.
Referenced by decodeBody().
|
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.
| context | is the provided InjectConject object |
| emit | is 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.
|
virtual |
Print the p-code ops of the injection to a stream (for debugging)
Implements ghidra::InjectPayload.
References tpl.
|
static |
Set-up operands in the parser state so that they pick up storage locations in InjectContext.
| con | is context for the parser |
| walker | is the parser state |
| inputlist | is the input varnodes as described by the payload |
| output | is the output varnodes as described by the payload |
| source | is 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().