decompiler  1.0.0
Public Types | Public Member Functions | List of all members
ghidra::ParamList Class Referenceabstract

#include <fspec.hh>

Inheritance diagram for ghidra::ParamList:
ghidra::ParamListStandard ghidra::ParamListMerged ghidra::ParamListRegister ghidra::ParamListRegisterOut ghidra::ParamListStandardOut

Public Types

enum  {
  p_standard, p_standard_out, p_register, p_register_out,
  p_merged
}
 

Public Member Functions

virtual ~ParamList (void)
 Destructor.
 
virtual uint4 getType (void) const =0
 Get the type of parameter list.
 
virtual void assignMap (const vector< Datatype *> &proto, TypeFactory &typefactory, vector< ParameterPieces > &res) const =0
 Given list of data-types, map the list positions to storage locations. More...
 
virtual void fillinMap (ParamActive *active) const =0
 Given an unordered list of storage locations, calculate a function prototype. More...
 
virtual bool checkJoin (const Address &hiaddr, int4 hisize, const Address &loaddr, int4 losize) const =0
 Check if the given two storage locations can represent a single logical parameter. More...
 
virtual bool checkSplit (const Address &loc, int4 size, int4 splitpoint) const =0
 Check if it makes sense to split a single storage location into two parameters. More...
 
virtual int4 characterizeAsParam (const Address &loc, int4 size) const =0
 Characterize whether the given range overlaps parameter storage. More...
 
virtual bool possibleParam (const Address &loc, int4 size) const =0
 Does the given storage location make sense as a parameter. More...
 
virtual bool possibleParamWithSlot (const Address &loc, int4 size, int4 &slot, int4 &slotsize) const =0
 Pass-back the slot and slot size for the given storage location as a parameter. More...
 
virtual bool getBiggestContainedParam (const Address &loc, int4 size, VarnodeData &res) const =0
 Pass-back the biggest parameter contained within the given range. More...
 
virtual bool unjustifiedContainer (const Address &loc, int4 size, VarnodeData &res) const =0
 Check if the given storage location looks like an unjustified parameter. More...
 
virtual OpCode assumedExtension (const Address &addr, int4 size, VarnodeData &res) const =0
 Get the type of extension and containing parameter for the given storage. More...
 
virtual AddrSpacegetSpacebase (void) const =0
 Get the address space associated with any stack based parameters in this list. More...
 
virtual void getRangeList (AddrSpace *spc, RangeList &res) const =0
 For a given address space, collect all the parameter locations within that space. More...
 
virtual int4 getMaxDelay (void) const =0
 Return the maximum heritage delay across all possible parameters. More...
 
virtual void decode (Decoder &decoder, vector< EffectRecord > &effectlist, bool normalstack)=0
 Restore the model from an <input> or <output> element in the stream. More...
 
virtual ParamListclone (void) const =0
 Clone this parameter list model.
 

Detailed Description

A group of ParamEntry objects that form a complete set for passing parameters in one direction (either input or output). The main tasks this class must perform are:

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
p_standard 

Standard input parameter model.

p_standard_out 

Standard output (return value) model.

p_register 

Unordered parameter passing locations model.

p_register_out 

Multiple possible return value locations model.

p_merged 

A merged model (multiple models merged together)

Member Function Documentation

◆ assignMap()

virtual void ghidra::ParamList::assignMap ( const vector< Datatype *> &  proto,
TypeFactory typefactory,
vector< ParameterPieces > &  res 
) const
pure virtual

Given list of data-types, map the list positions to storage locations.

If we know the function prototype, recover how parameters are actually stored using the model.

Parameters
protois the ordered list of data-types
typefactoryis the TypeFactory (for constructing pointers)
reswill contain the storage locations corresponding to the datatypes

Implemented in ghidra::ParamListMerged, ghidra::ParamListStandardOut, ghidra::ParamListRegisterOut, and ghidra::ParamListStandard.

◆ assumedExtension()

virtual OpCode ghidra::ParamList::assumedExtension ( const Address addr,
int4  size,
VarnodeData res 
) const
pure virtual

Get the type of extension and containing parameter for the given storage.

If the given storage is properly contained within a normal parameter and the model typically extends a small value into the full container, pass back the full container and the type of extension.

Parameters
addris the starting address of the given storage
sizeis the number of bytes in the given storage
resis the parameter storage to pass back
Returns
the extension operator (INT_ZEXT INT_SEXT) or INT_COPY if there is no extension. INT_PIECE indicates the extension is determined by the specific prototype.

Implemented in ghidra::ParamListStandard.

Referenced by ghidra::ProtoModel::assumedInputExtension(), and ghidra::ProtoModel::assumedOutputExtension().

◆ characterizeAsParam()

virtual int4 ghidra::ParamList::characterizeAsParam ( const Address loc,
int4  size 
) const
pure virtual

Characterize whether the given range overlaps parameter storage.

Does the range naturally fit inside a potential parameter entry from this list or does it contain a parameter entry. Return one of four enumerations indicating this characterization:

  • no_containment - there is no containment between the range and any parameter in this list
  • contains_unjustified - at least one parameter contains the range
  • contains_justified - at least one parameter contains this range as its least significant bytes
  • contained_by - no parameter contains this range, but the range contains at least one parameter
    Parameters
    locis the starting address of the given range
    sizeis the number of bytes in the given range
    Returns
    the characterization code

Implemented in ghidra::ParamListStandard.

Referenced by ghidra::ProtoModel::characterizeAsInputParam(), and ghidra::ProtoModel::characterizeAsOutput().

◆ checkJoin()

virtual bool ghidra::ParamList::checkJoin ( const Address hiaddr,
int4  hisize,
const Address loaddr,
int4  losize 
) const
pure virtual

Check if the given two storage locations can represent a single logical parameter.

Within the conventions of this model, do the two (hi/lo) locations represent consecutive parameter locations that can be replaced by a single logical parameter.

Parameters
hiaddris the address of the most significant part of the value
hisizeis the size of the most significant part in bytes
loaddris the address of the least significant part of the value
losizeis the size of the least significant part in bytes
Returns
true if the two pieces can be joined

Implemented in ghidra::ParamListStandard.

Referenced by ghidra::ProtoModel::checkInputJoin(), and ghidra::ProtoModel::checkOutputJoin().

◆ checkSplit()

virtual bool ghidra::ParamList::checkSplit ( const Address loc,
int4  size,
int4  splitpoint 
) const
pure virtual

Check if it makes sense to split a single storage location into two parameters.

A storage location and split point is provided, implying two new storage locations. Does this model allow these locations to be considered parameters.

Parameters
locis the starting address of provided storage location
sizeis the size of the location in bytes
splitpointis the number of bytes to consider in the first (in address order) piece
Returns
true if the storage location can be split

Implemented in ghidra::ParamListStandard.

Referenced by ghidra::ProtoModel::checkInputSplit().

◆ decode()

virtual void ghidra::ParamList::decode ( Decoder decoder,
vector< EffectRecord > &  effectlist,
bool  normalstack 
)
pure virtual

Restore the model from an <input> or <output> element in the stream.

Parameters
decoderis the stream decoder
effectlistis a container collecting EffectRecords across all parameters
normalstackis true if parameters are pushed on the stack in the normal order

Implemented in ghidra::ParamListStandardOut, and ghidra::ParamListStandard.

◆ fillinMap()

virtual void ghidra::ParamList::fillinMap ( ParamActive active) const
pure virtual

Given an unordered list of storage locations, calculate a function prototype.

A list of input (or output) trials is given, which may have holes, invalid inputs etc. Decide on the formal ordered parameter list. Trials within the ParamActive are added, removed, or reordered as needed.

Parameters
activeis the given list of trials

Implemented in ghidra::ParamListMerged, ghidra::ParamListRegister, ghidra::ParamListRegisterOut, and ghidra::ParamListStandard.

Referenced by ghidra::ProtoModel::deriveInputMap(), and ghidra::ProtoModel::deriveOutputMap().

◆ getBiggestContainedParam()

virtual bool ghidra::ParamList::getBiggestContainedParam ( const Address loc,
int4  size,
VarnodeData res 
) const
pure virtual

Pass-back the biggest parameter contained within the given range.

Parameters
locis the starting address of the given range
sizeis the number of bytes in the range
reswill hold the parameter storage description being passed back
Returns
true if there is at least one parameter contained in the range

Implemented in ghidra::ParamListStandard.

Referenced by ghidra::ProtoModel::getBiggestContainedInputParam(), and ghidra::ProtoModel::getBiggestContainedOutput().

◆ getMaxDelay()

virtual int4 ghidra::ParamList::getMaxDelay ( void  ) const
pure virtual

Return the maximum heritage delay across all possible parameters.

Depending on the address space, data-flow for a parameter may not be available until extra transform passes have completed. This method returns the number of passes that must occur before we can guarantee that all parameters have data-flow info.

Returns
the maximum number of passes across all parameters in this model

Implemented in ghidra::ParamListStandard.

Referenced by ghidra::ProtoModel::getMaxInputDelay(), and ghidra::ProtoModel::getMaxOutputDelay().

◆ getRangeList()

virtual void ghidra::ParamList::getRangeList ( AddrSpace spc,
RangeList res 
) const
pure virtual

For a given address space, collect all the parameter locations within that space.

Pass back the memory ranges for any parameter that is stored in the given address space.

Parameters
spcis the given address space
reswill hold the set of matching memory ranges

Implemented in ghidra::ParamListStandard.

◆ getSpacebase()

virtual AddrSpace* ghidra::ParamList::getSpacebase ( void  ) const
pure virtual

Get the address space associated with any stack based parameters in this list.

Returns
the stack address space, if this models parameters passed on the stack, NULL otherwise

Implemented in ghidra::ParamListStandard.

Referenced by ghidra::ProtoModel::getSpacebase().

◆ possibleParam()

virtual bool ghidra::ParamList::possibleParam ( const Address loc,
int4  size 
) const
pure virtual

Does the given storage location make sense as a parameter.

Within this model, decide if the storage location can be considered a parameter.

Parameters
locis the starting address of the storage location
sizeis the number of bytes in the storage location
Returns
true if the location can be a parameter

Implemented in ghidra::ParamListRegisterOut, and ghidra::ParamListStandard.

Referenced by ghidra::ProtoModel::possibleInputParam(), and ghidra::ProtoModel::possibleOutputParam().

◆ possibleParamWithSlot()

virtual bool ghidra::ParamList::possibleParamWithSlot ( const Address loc,
int4  size,
int4 &  slot,
int4 &  slotsize 
) const
pure virtual

Pass-back the slot and slot size for the given storage location as a parameter.

This checks if the given storage location acts as a parameter in this model and passes back the number of slots that it occupies.

Parameters
locis the starting address of the storage location
sizeis the number of bytes in the storage location
slotif the slot number to pass back
slotsizeis the number of consumed slots to pass back
Returns
true if the location can be a parameter

Implemented in ghidra::ParamListStandard.

Referenced by ghidra::ProtoModel::possibleInputParamWithSlot(), and ghidra::ProtoModel::possibleOutputParamWithSlot().

◆ unjustifiedContainer()

virtual bool ghidra::ParamList::unjustifiedContainer ( const Address loc,
int4  size,
VarnodeData res 
) const
pure virtual

Check if the given storage location looks like an unjustified parameter.

The storage for a value may be contained in a normal parameter location but be unjustified within that container, i.e. the least significant bytes are not being used. If this is the case, pass back the full parameter location and return true.

Parameters
locis the starting address of the given storage
sizeis the number of bytes in the given storage
resis the full parameter storage to pass back
Returns
true if the given storage is unjustified within its parameter container

Implemented in ghidra::ParamListStandard.

Referenced by ghidra::ProtoModel::unjustifiedInputParam().


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