19 #ifndef __PCODEINJECT__ 20 #define __PCODEINJECT__ 42 uint4
getSize(
void)
const {
return size; }
65 virtual void clear(
void) { inputlist.clear(); output.clear(); }
70 virtual void saveXml(ostream &s)
const=0;
82 CALLOTHERFIXUP_TYPE = 2,
83 CALLMECHANISM_TYPE = 3,
84 EXECUTABLEPCODE_TYPE = 4
94 static void readParameter(
const Element *el,
string &name,uint4 &size);
95 void orderParameters(
void);
97 InjectPayload(
const string &nm,int4 tp) { name=nm; type=tp; paramshift=0; dynamic =
false; incidentalCopy =
false; }
118 virtual void restoreXml(
const Element *el);
119 virtual void printTemplate(ostream &s)
const=0;
122 virtual string getSource(
void)
const=0;
139 vector<uintb> inputList;
140 vector<uintb> outputList;
147 uintb evaluate(
const vector<uintb> &input);
175 void registerCallFixup(
const string &fixupName,int4 injectid);
176 void registerCallOtherFixup(
const string &fixupName,int4 injectid);
177 void registerCallMechanism(
const string &fixupName,int4 injectid);
178 void registerExeScript(
const string &scriptName,int4 injectid);
188 virtual int4 allocateInject(
const string &sourceName,
const string &name,int4 type)=0;
196 virtual void registerInject(int4 injectid)=0;
201 int4 getPayloadId(int4 type,
const string &nm)
const;
203 string getCallFixupName(int4 injectid)
const;
204 string getCallOtherTarget(int4 injectid)
const;
205 string getCallMechanismName(int4 injectid)
const;
206 int4 restoreXmlInject(
const string &src,
const string &nm,int4 tp,
const Element *el);
222 virtual int4 manualCallFixup(
const string &name,
const string &snippetstring)=0;
233 virtual int4 manualCallOtherFixup(
const string &name,
const string &outname,
const vector<string> &inname,
234 const string &snippet)=0;
248 virtual const vector<OpBehavior *> &getBehaviors(
void)=0;
Context needed to emit a p-code injection as a full set of p-code operations.
Definition: pcodeinject.hh:56
vector< InjectPayload * > injection
Registered injections.
Definition: pcodeinject.hh:166
Address baseaddr
Address of instruction causing inject.
Definition: pcodeinject.hh:59
A collection of p-code injection payloads.
Definition: pcodeinject.hh:162
Abstract class for emitting pcode to an application.
Definition: translate.hh:76
A snippet of p-code that can be executed outside of normal analysis.
Definition: pcodeinject.hh:134
int4 getType(void) const
Return the type of injection (CALLFIXUP_TYPE, CALLOTHERFIXUP_TYPE, etc.)
Definition: pcodeinject.hh:121
int4 sizeOutput(void) const
Return the number of output parameters.
Definition: pcodeinject.hh:102
An input or output parameter to a p-code injection payload.
Definition: pcodeinject.hh:33
vector< InjectParameter > inputlist
List of input parameters to this payload.
Definition: pcodeinject.hh:92
vector< string > callFixupNames
Map from injectid to call-fixup name.
Definition: pcodeinject.hh:171
virtual void restoreDebug(const Element *el)
A method for reading in p-code generated externally for use in debugging.
Definition: pcodeinject.hh:214
uint4 getSize(void) const
Get the size of the parameter in bytes.
Definition: pcodeinject.hh:42
vector< string > callOtherTarget
Map from injectid to callother-fixup target-op name.
Definition: pcodeinject.hh:172
vector< VarnodeData > inputlist
Storage location for input parameters.
Definition: pcodeinject.hh:62
bool incidentalCopy
True if injected COPYs are considered incidental.
Definition: pcodeinject.hh:90
InjectParameter & getInput(int4 i)
Get the i-th input parameter.
Definition: pcodeinject.hh:103
An active container for a set of p-code operations that can be injected into data-flow.
Definition: pcodeinject.hh:78
int4 getIndex(void) const
Get the assigned index.
Definition: pcodeinject.hh:41
uintb getUniqueBase(void) const
Get the (current) offset for building temporary registers.
Definition: pcodeinject.hh:200
int4 paramshift
Number of parameters shifted in the original call.
Definition: pcodeinject.hh:91
map< string, int4 > callOtherFixupMap
Map of registered callother-fixup names to injection id.
Definition: pcodeinject.hh:168
string name
Formal name of the payload.
Definition: pcodeinject.hh:87
map< string, int4 > scriptMap
Map of registered script names to ExecutablePcode id.
Definition: pcodeinject.hh:170
int4 getParamShift(void) const
Get the number of parameters shifted.
Definition: pcodeinject.hh:98
InjectParameter(const string &nm, uint4 sz)
Constructor.
Definition: pcodeinject.hh:39
Architecture * glb
The Architecture to which the injection payloads apply.
Definition: pcodeinject.hh:164
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
int4 type
Type of this payload: CALLFIXUP_TYPE, CALLOTHERFIXUP_TYPE, etc.
Definition: pcodeinject.hh:88
Manager for all the major decompiler subsystems.
Definition: architecture.hh:117
bool dynamic
True if the injection is generated dynamically.
Definition: pcodeinject.hh:89
bool isIncidentalCopy(void) const
Return true if any injected COPY is considered incidental.
Definition: pcodeinject.hh:100
virtual void clear(void)
Release resources (from last injection)
Definition: pcodeinject.hh:65
vector< string > scriptNames
Map from injectid to script name.
Definition: pcodeinject.hh:174
map< string, int4 > callMechFixupMap
Map of registered mechanism names to injection id.
Definition: pcodeinject.hh:169
An XML element. A node in the DOM tree.
Definition: xml.hh:150
uintb tempbase
Offset within unique space for allocating temporaries within a payload.
Definition: pcodeinject.hh:165
map< string, int4 > callFixupMap
Map of registered call-fixup names to injection id.
Definition: pcodeinject.hh:167
PcodeInjectLibrary(Architecture *g, uintb tmpbase)
Constructor.
Definition: pcodeinject.hh:198
Architecture * glb
Architecture associated with the injection.
Definition: pcodeinject.hh:58
vector< InjectParameter > output
List of output parameters.
Definition: pcodeinject.hh:93
const string & getName(void) const
Get the parameter name.
Definition: pcodeinject.hh:40
vector< string > callMechTarget
Map from injectid to call-mech name.
Definition: pcodeinject.hh:173
string getName(void) const
Return the name of the injection.
Definition: pcodeinject.hh:120
InjectPayload(const string &nm, int4 tp)
Construct for use with restoreXml.
Definition: pcodeinject.hh:97
InjectPayload * getPayload(int4 id) const
Get the InjectPayload by id.
Definition: pcodeinject.hh:202
vector< VarnodeData > output
Storage location for output.
Definition: pcodeinject.hh:63
virtual ~InjectPayload(void)
Destructor.
Definition: pcodeinject.hh:105
int4 sizeInput(void) const
Return the number of input parameters.
Definition: pcodeinject.hh:101
Emulate a snippet of PcodeOps out of a functional context.
Definition: emulateutil.hh:111
bool isDynamic(void) const
Return true if p-code in the injection is generated dynamically.
Definition: pcodeinject.hh:99
(Lightweight) emulation interface for executing PcodeOp objects within a syntax tree or for executing...
InjectParameter & getOutput(int4 i)
Get the i-th output parameter.
Definition: pcodeinject.hh:104
Address nextaddr
Address of following instruction.
Definition: pcodeinject.hh:60
virtual ~InjectContext(void)
Destructor.
Definition: pcodeinject.hh:64
Address calladdr
If the instruction being injected is a call, this is the address being called.
Definition: pcodeinject.hh:61
virtual string getSource(void) const
Return a string describing the source of the injection (.cspec, prototype model, etc.)
Definition: pcodeinject.hh:146