retdec
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
retdec::llvmir2hll::APICallSeqData Class Reference

A storage of intermediate data when finding sequences of API calls. More...

#include <api_call_seq_data.h>

Collaboration diagram for retdec::llvmir2hll::APICallSeqData:
Collaboration graph
[legend]

Public Member Functions

 APICallSeqData (const APICallInfoSeq &info)
 Constructs data from the given information. More...
 
 APICallSeqData (const APICallSeqData &data)
 Constructs data from data. More...
 
APICallSeqDataoperator= (const APICallSeqData &data)
 Assigns data into the current data. More...
 
bool operator== (const APICallSeqData &other) const
 Returns true if this data equal the other data, false otherwise. More...
 
bool operator!= (const APICallSeqData &other) const
 Returns true if this data differ from the other data, false otherwise. More...
 
bool matches (ShPtr< CallExpr > call) const
 Returns true if call matches the currently set API call information, false otherwise. More...
 
void apply (ShPtr< Statement > stmt, ShPtr< CallExpr > call)
 Applies call that occur in stmt. More...
 
bool patternIsComplete () const
 Returns true if the pattern is complete, false otherwise. More...
 
ShPtr< PatterngetPattern () const
 Returns the current version of the built pattern. More...
 
bool atEnd () const
 Returns true if all the API call information passed to the constructor have been matched, false otherwise. More...
 

Private Types

using BindIdValueMap = std::map< std::string, ShPtr< Expression > >
 Mapping of a bind ID into the bound value. More...
 

Private Member Functions

bool funcNameMatches (ShPtr< Expression > calledExpr) const
 Checks that the function called in calledExpr is the one we expect. More...
 
bool argsMatch (ShPtr< CallExpr > call) const
 Checks that all the bound parameters from the API call info match the values in call. More...
 
bool valuesMatch (ShPtr< Value > value1, ShPtr< Value > value2) const
 Checks whether value1 is structurally equal to value2. More...
 
void addToPattern (ShPtr< Statement > stmt, ShPtr< CallExpr > call)
 Adds a new piece of information into the currently built pattern. More...
 
void advanceToNextInfo ()
 Advances to the next information in allInfos. More...
 
void bindValues (ShPtr< Statement > stmt, ShPtr< CallExpr > call)
 Binds values from call that appear in stmt. More...
 
void bindValueFromReturnValue (ShPtr< Statement > stmt, ShPtr< CallExpr > call)
 Binds the value returned from call (if any). More...
 
void bindValuesFromArgs (ShPtr< CallExpr > call)
 Binds the values from the arguments of call. More...
 

Private Attributes

const APICallInfoSeqallInfos
 Sequence of API call information that we are looking for. More...
 
const APICallInfocurrInfo
 Pointer to the current information from allInfos. More...
 
APICallInfoSeq::iterator currInfoIter
 Iterator to the current information in allInfos. More...
 
BindIdValueMap boundValues
 Mapping of a bind ID into the bound value. More...
 
ShPtr< StmtsPatternpattern
 Pattern that is being built. More...
 

Detailed Description

A storage of intermediate data when finding sequences of API calls.

Member Typedef Documentation

◆ BindIdValueMap

using retdec::llvmir2hll::APICallSeqData::BindIdValueMap = std::map<std::string, ShPtr<Expression> >
private

Mapping of a bind ID into the bound value.

Constructor & Destructor Documentation

◆ APICallSeqData() [1/2]

retdec::llvmir2hll::APICallSeqData::APICallSeqData ( const APICallInfoSeq info)

Constructs data from the given information.

It starts with the first information in info and an empty pattern.

Preconditions
  • info is non-empty

◆ APICallSeqData() [2/2]

retdec::llvmir2hll::APICallSeqData::APICallSeqData ( const APICallSeqData data)

Constructs data from data.

Member Function Documentation

◆ addToPattern()

void retdec::llvmir2hll::APICallSeqData::addToPattern ( ShPtr< Statement stmt,
ShPtr< CallExpr call 
)
private

Adds a new piece of information into the currently built pattern.

◆ advanceToNextInfo()

void retdec::llvmir2hll::APICallSeqData::advanceToNextInfo ( )
private

Advances to the next information in allInfos.

◆ apply()

void retdec::llvmir2hll::APICallSeqData::apply ( ShPtr< Statement stmt,
ShPtr< CallExpr call 
)

Applies call that occur in stmt.

In a greater detail, this function adds the information to the currently build pattern, binds values occurring in call, and advances to the next API call information.

Note: This function should be called only after matches() returned true.

◆ argsMatch()

bool retdec::llvmir2hll::APICallSeqData::argsMatch ( ShPtr< CallExpr call) const
private

Checks that all the bound parameters from the API call info match the values in call.

◆ atEnd()

bool retdec::llvmir2hll::APICallSeqData::atEnd ( ) const

Returns true if all the API call information passed to the constructor have been matched, false otherwise.

◆ bindValueFromReturnValue()

void retdec::llvmir2hll::APICallSeqData::bindValueFromReturnValue ( ShPtr< Statement stmt,
ShPtr< CallExpr call 
)
private

Binds the value returned from call (if any).

◆ bindValues()

void retdec::llvmir2hll::APICallSeqData::bindValues ( ShPtr< Statement stmt,
ShPtr< CallExpr call 
)
private

Binds values from call that appear in stmt.

◆ bindValuesFromArgs()

void retdec::llvmir2hll::APICallSeqData::bindValuesFromArgs ( ShPtr< CallExpr call)
private

Binds the values from the arguments of call.

◆ funcNameMatches()

bool retdec::llvmir2hll::APICallSeqData::funcNameMatches ( ShPtr< Expression calledExpr) const
private

Checks that the function called in calledExpr is the one we expect.

◆ getPattern()

ShPtr< Pattern > retdec::llvmir2hll::APICallSeqData::getPattern ( ) const

Returns the current version of the built pattern.

This functions returns a complete pattern only if patternIsComplete() returns true. Otherwise, it returns a partially build pattern.

◆ matches()

bool retdec::llvmir2hll::APICallSeqData::matches ( ShPtr< CallExpr call) const

Returns true if call matches the currently set API call information, false otherwise.

◆ operator!=()

bool retdec::llvmir2hll::APICallSeqData::operator!= ( const APICallSeqData other) const

Returns true if this data differ from the other data, false otherwise.

◆ operator=()

APICallSeqData & retdec::llvmir2hll::APICallSeqData::operator= ( const APICallSeqData data)

Assigns data into the current data.

◆ operator==()

bool retdec::llvmir2hll::APICallSeqData::operator== ( const APICallSeqData other) const

Returns true if this data equal the other data, false otherwise.

◆ patternIsComplete()

bool retdec::llvmir2hll::APICallSeqData::patternIsComplete ( ) const

Returns true if the pattern is complete, false otherwise.

A pattern is complete if all API call information has been successfully matched.

◆ valuesMatch()

bool retdec::llvmir2hll::APICallSeqData::valuesMatch ( ShPtr< Value value1,
ShPtr< Value value2 
) const
private

Checks whether value1 is structurally equal to value2.

Structurally equal means that they may have different addresses, but they hold the same data.

Member Data Documentation

◆ allInfos

const APICallInfoSeq& retdec::llvmir2hll::APICallSeqData::allInfos
private

Sequence of API call information that we are looking for.

◆ boundValues

BindIdValueMap retdec::llvmir2hll::APICallSeqData::boundValues
private

Mapping of a bind ID into the bound value.

◆ currInfo

const APICallInfo* retdec::llvmir2hll::APICallSeqData::currInfo
private

Pointer to the current information from allInfos.

◆ currInfoIter

APICallInfoSeq::iterator retdec::llvmir2hll::APICallSeqData::currInfoIter
private

Iterator to the current information in allInfos.

◆ pattern

ShPtr<StmtsPattern> retdec::llvmir2hll::APICallSeqData::pattern
private

Pattern that is being built.


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