decompiler  1.0.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ghidra::ProtoModelMerged Class Reference

A prototype model made by merging together other models. More...

#include <fspec.hh>

Inheritance diagram for ghidra::ProtoModelMerged:
ghidra::ProtoModel

Public Member Functions

 ProtoModelMerged (Architecture *g)
 Constructor.
 
virtual ~ProtoModelMerged (void)
 Destructor.
 
int4 numModels (void) const
 Get the number of constituent models.
 
ProtoModelgetModel (int4 i) const
 Get the i-th model.
 
void foldIn (ProtoModel *model)
 Fold-in an additional prototype model. More...
 
ProtoModelselectModel (ParamActive *active) const
 Select the best model given a set of trials. More...
 
virtual bool isMerged (void) const
 Is this a merged prototype model.
 
virtual void decode (Decoder &decoder)
 Restore this model from a stream. More...
 
- Public Member Functions inherited from ghidra::ProtoModel
 ProtoModel (Architecture *g)
 Constructor for use with decode() More...
 
 ProtoModel (const string &nm, const ProtoModel &op2)
 Copy constructor changing the name. More...
 
virtual ~ProtoModel (void)
 Destructor.
 
const string & getName (void) const
 Get the name of the prototype model.
 
ArchitecturegetArch (void) const
 Get the owning Architecture.
 
const ProtoModelgetAliasParent (void) const
 Return model this is an alias of (or null)
 
uint4 hasEffect (const Address &addr, int4 size) const
 Determine side-effect of this on the given memory range. More...
 
int4 getExtraPop (void) const
 Get the stack-pointer extrapop for this model.
 
void setExtraPop (int4 ep)
 Set the stack-pointer extrapop.
 
int4 getInjectUponEntry (void) const
 Get the inject uponentry id.
 
int4 getInjectUponReturn (void) const
 Get the inject uponreturn id.
 
bool isCompatible (const ProtoModel *op2) const
 Return true if other given model can be substituted for this. More...
 
void deriveInputMap (ParamActive *active) const
 Given a list of input trials, derive the most likely input prototype. More...
 
void deriveOutputMap (ParamActive *active) const
 Given a list of output trials, derive the most likely output prototype. More...
 
void assignParameterStorage (const vector< Datatype *> &typelist, vector< ParameterPieces > &res, bool ignoreOutputError)
 Calculate input and output storage locations given a function prototype. More...
 
bool checkInputJoin (const Address &hiaddr, int4 hisize, const Address &loaddr, int4 losize) const
 Check if the given two input storage locations can represent a single logical parameter. More...
 
bool checkOutputJoin (const Address &hiaddr, int4 hisize, const Address &loaddr, int4 losize) const
 Check if the given two output storage locations can represent a single logical return value. More...
 
bool checkInputSplit (const Address &loc, int4 size, int4 splitpoint) const
 Check if it makes sense to split a single storage location into two input parameters. More...
 
const RangeListgetLocalRange (void) const
 Get the range of (possible) local stack variables.
 
const RangeListgetParamRange (void) const
 Get the range of (possible) stack parameters.
 
vector< EffectRecord >::const_iterator effectBegin (void) const
 Get an iterator to the first EffectRecord.
 
vector< EffectRecord >::const_iterator effectEnd (void) const
 Get an iterator to the last EffectRecord.
 
vector< VarnodeData >::const_iterator trashBegin (void) const
 Get an iterator to the first likelytrash.
 
vector< VarnodeData >::const_iterator trashEnd (void) const
 Get an iterator to the last likelytrash.
 
int4 characterizeAsInputParam (const Address &loc, int4 size) const
 Characterize whether the given range overlaps parameter storage. More...
 
int4 characterizeAsOutput (const Address &loc, int4 size) const
 Characterize whether the given range overlaps output storage. More...
 
bool possibleInputParam (const Address &loc, int4 size) const
 Does the given storage location make sense as an input parameter. More...
 
bool possibleOutputParam (const Address &loc, int4 size) const
 Does the given storage location make sense as a return value. More...
 
bool possibleInputParamWithSlot (const Address &loc, int4 size, int4 &slot, int4 &slotsize) const
 Pass-back the slot and slot size for the given storage location as an input parameter. More...
 
bool possibleOutputParamWithSlot (const Address &loc, int4 size, int4 &slot, int4 &slotsize) const
 Pass-back the slot and slot size for the given storage location as a return value. More...
 
bool unjustifiedInputParam (const Address &loc, int4 size, VarnodeData &res) const
 Check if the given storage location looks like an unjustified input parameter. More...
 
OpCode assumedInputExtension (const Address &addr, int4 size, VarnodeData &res) const
 Get the type of extension and containing input parameter for the given storage. More...
 
OpCode assumedOutputExtension (const Address &addr, int4 size, VarnodeData &res) const
 Get the type of extension and containing return value location for the given storage. More...
 
bool getBiggestContainedInputParam (const Address &loc, int4 size, VarnodeData &res) const
 Pass-back the biggest input parameter contained within the given range. More...
 
bool getBiggestContainedOutput (const Address &loc, int4 size, VarnodeData &res) const
 Pass-back the biggest possible output parameter contained within the given range. More...
 
AddrSpacegetSpacebase (void) const
 Get the stack space associated with this model.
 
bool isStackGrowsNegative (void) const
 Return true if the stack grows toward smaller addresses.
 
bool hasThisPointer (void) const
 Is this a model for (non-static) class methods.
 
bool isConstructor (void) const
 Is this model for class constructors.
 
bool printInDecl (void) const
 Return true if name should be printed in function declarations.
 
void setPrintInDecl (bool val)
 Set whether this name should be printed in function declarations.
 
int4 getMaxInputDelay (void) const
 Return the maximum heritage delay across all possible input parameters. More...
 
int4 getMaxOutputDelay (void) const
 Return the maximum heritage delay across all possible return values. More...
 
virtual bool isUnknown (void) const
 Is this an unrecognized prototype model.
 

Private Member Functions

void intersectEffects (const vector< EffectRecord > &efflist)
 Fold EffectRecords into this model. More...
 
void intersectLikelyTrash (const vector< VarnodeData > &trashlist)
 Fold likelytrash locations into this model. More...
 

Private Attributes

vector< ProtoModel * > modellist
 Constituent models being merged.
 

Additional Inherited Members

- Public Types inherited from ghidra::ProtoModel
enum  { extrapop_unknown = 0x8000 }
 
- Static Public Member Functions inherited from ghidra::ProtoModel
static uint4 lookupEffect (const vector< EffectRecord > &efflist, const Address &addr, int4 size)
 Look up an effect from the given EffectRecord list. More...
 
static int4 lookupRecord (const vector< EffectRecord > &efflist, int4 listSize, const Address &addr, int4 size)
 Look up a particular EffectRecord from a given list by its Address and size. More...
 

Detailed Description

A prototype model made by merging together other models.

This model serves as a placeholder for multiple models, when the exact model hasn't been immediately determined. At the time of active parameter recovery the correct model is selected for the given set of trials from among the constituent prototype models used to build this, by calling the method selectModel(). Up to this time, this serves as a merged form of the models so that all potential parameter trials will be included in the analysis. The parameter recovery for the output part of the model is currently limited, so the constituent models must all share the same output model, and this part is not currently merged.

Member Function Documentation

◆ decode()

void ghidra::ProtoModelMerged::decode ( Decoder decoder)
virtual

Restore this model from a stream.

Parse details about this model from a <prototype> element

Parameters
decoderis the stream decoder

Reimplemented from ghidra::ProtoModel.

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

◆ foldIn()

void ghidra::ProtoModelMerged::foldIn ( ProtoModel model)

◆ intersectEffects()

void ghidra::ProtoModelMerged::intersectEffects ( const vector< EffectRecord > &  efflist)
private

Fold EffectRecords into this model.

The EffectRecord lists are intersected. Anything in this that is not also in the given EffectRecord list is removed.

Parameters
efflistis the given EffectRecord list

References ghidra::EffectRecord::compareByAddress().

◆ intersectLikelyTrash()

void ghidra::ProtoModelMerged::intersectLikelyTrash ( const vector< VarnodeData > &  trashlist)
private

Fold likelytrash locations into this model.

The likely-trash locations are intersected. Anything in this that is not also in the given likely-trash list is removed.

Parameters
trashlistis the given likely-trash list

◆ selectModel()

ProtoModel * ghidra::ProtoModelMerged::selectModel ( ParamActive active) const

Select the best model given a set of trials.

The model that best matches the given set of input parameter trials is returned. This method currently uses the ScoreProtoModel object to score the different prototype models.

Parameters
activeis the set of parameter trials
Returns
the prototype model that scores the best

References ghidra::ScoreProtoModel::addParameter(), ghidra::ScoreProtoModel::doScore(), ghidra::ParamActive::getNumTrials(), ghidra::ScoreProtoModel::getScore(), and ghidra::ParamActive::getTrial().

Referenced by ghidra::FuncProto::resolveModel().


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