Ghidra Decompiler Analysis Engine
Public Member Functions | List of all members
PcodeInjectLibraryGhidra Class Reference

A p-code injection library that uses a Ghidra client to generate/compile the injection p-code. More...

#include <inject_ghidra.hh>

Inheritance diagram for PcodeInjectLibraryGhidra:
Inheritance graph
[legend]
Collaboration diagram for PcodeInjectLibraryGhidra:
Collaboration graph
[legend]

Public Member Functions

 PcodeInjectLibraryGhidra (ArchitectureGhidra *ghi)
 Constructor.
 
virtual int4 manualCallFixup (const string &name, const string &snippet)
 Manually add a call-fixup payload given a compilable snippet of p-code source. More...
 
virtual int4 manualCallOtherFixup (const string &name, const string &outname, const vector< string > &inname, const string &snippet)
 Manually add a callother-fixup payload given a compilable snippet of p-code source. More...
 
virtual InjectContextgetCachedContext (void)
 Retrieve a reusable context object for this library. More...
 
virtual const vector< OpBehavior * > & getBehaviors (void)
 Get the array of op-code behaviors for initializing and emulator. More...
 
- Public Member Functions inherited from PcodeInjectLibrary
virtual ~PcodeInjectLibrary (void)
 Destructor.
 
int4 getPayloadId (int4 type, const string &nm) const
 Map name and type to the payload id. More...
 
string getCallFixupName (int4 injectid) const
 Get the call-fixup name associated with an id. More...
 
string getCallOtherTarget (int4 injectid) const
 Get the callother-fixup name associated with an id. More...
 
string getCallMechanismName (int4 injectid) const
 Get the call mechanism name associated with an id. More...
 
int4 restoreXmlInject (const string &src, const string &nm, int4 tp, const Element *el)
 Read in and register an injection payload from an XML stream. More...
 
virtual void restoreDebug (const Element *el)
 A method for reading in p-code generated externally for use in debugging. More...
 

Additional Inherited Members

- Protected Member Functions inherited from PcodeInjectLibrary
void registerCallFixup (const string &fixupName, int4 injectid)
 Map a call-fixup name to a payload id. More...
 
void registerCallOtherFixup (const string &fixupName, int4 injectid)
 Map a callother-fixup name to a payload id. More...
 
void registerCallMechanism (const string &fixupName, int4 injectid)
 Map a call mechanism name to a payload id. More...
 
void registerExeScript (const string &scriptName, int4 injectid)
 Map a p-code script name to a payload id. More...
 
- Protected Attributes inherited from PcodeInjectLibrary
Architectureglb
 The Architecture to which the injection payloads apply.
 
uintb tempbase
 Offset within unique space for allocating temporaries within a payload.
 
vector< InjectPayload * > injection
 Registered injections.
 
map< string, int4 > callFixupMap
 Map of registered call-fixup names to injection id.
 
map< string, int4 > callOtherFixupMap
 Map of registered callother-fixup names to injection id.
 
map< string, int4 > callMechFixupMap
 Map of registered mechanism names to injection id.
 
map< string, int4 > scriptMap
 Map of registered script names to ExecutablePcode id.
 
vector< string > callFixupNames
 Map from injectid to call-fixup name.
 
vector< string > callOtherTarget
 Map from injectid to callother-fixup target-op name.
 
vector< string > callMechTarget
 Map from injectid to call-mech name.
 
vector< string > scriptNames
 Map from injectid to script name.
 

Detailed Description

A p-code injection library that uses a Ghidra client to generate/compile the injection p-code.

The InjectPayload objects produced by this library are just placeholders (see InjectPayloadGhidra). At the time of injection, final p-code is generated by the Ghidra client.

Member Function Documentation

◆ getBehaviors()

const vector< OpBehavior * > & PcodeInjectLibraryGhidra::getBehaviors ( void  )
virtual

Get the array of op-code behaviors for initializing and emulator.

Behaviors are pulled from the underlying architecture in order to initialize the Emulate object which services the p-code script payloads.

Returns
the array of OpBehavior objects indexed by op-code

Implements PcodeInjectLibrary.

◆ getCachedContext()

virtual InjectContext& PcodeInjectLibraryGhidra::getCachedContext ( void  )
inlinevirtual

Retrieve a reusable context object for this library.

The object returned by this method gets passed to the payload inject() method. The clear() method must be called between uses.

Returns
the cached context object

Implements PcodeInjectLibrary.

◆ manualCallFixup()

int4 PcodeInjectLibraryGhidra::manualCallFixup ( const string &  name,
const string &  snippetstring 
)
virtual

Manually add a call-fixup payload given a compilable snippet of p-code source.

The snippet is compiled immediately to produce the payload.

Parameters
nameis the formal name of the new payload
snippetstringis the compilable snippet of p-code source
Returns
the id of the new payload

Implements PcodeInjectLibrary.

◆ manualCallOtherFixup()

int4 PcodeInjectLibraryGhidra::manualCallOtherFixup ( const string &  name,
const string &  outname,
const vector< string > &  inname,
const string &  snippet 
)
virtual

Manually add a callother-fixup payload given a compilable snippet of p-code source.

The snippet is compiled immediately to produce the payload. Symbol names for input and output parameters must be provided to the compiler.

Parameters
nameis the formal name of the new payload
outnameis the name of the output symbol
innameis the ordered list of input symbol names
snippetis the compilable snippet of p-code source
Returns
the id of the new payload

Implements PcodeInjectLibrary.


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