retdec
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
retdec::unpacker::Signature Class Reference

#include <signature.h>

Collaboration diagram for retdec::unpacker::Signature:
Collaboration graph
[legend]

Classes

class  Byte
 
class  MatchSettings
 

Public Member Functions

 Signature ()=delete
 
 Signature (const std::initializer_list< Signature::Byte > &initList)
 
 Signature (const Signature &signature)
 
virtual ~Signature ()=default
 
uint64_t getSize () const
 
uint64_t getCaptureSize () const
 
bool match (const MatchSettings &settings, retdec::loader::Image *file) const
 
bool match (const MatchSettings &settings, const retdec::utils::DynamicBuffer &data) const
 
bool match (const MatchSettings &settings, retdec::loader::Image *file, retdec::utils::DynamicBuffer &capturedData) const
 
bool match (const MatchSettings &settings, const retdec::utils::DynamicBuffer &data, retdec::utils::DynamicBuffer &capturedData) const
 
Signatureoperator= (const std::initializer_list< Signature::Byte > &initList)
 

Private Member Functions

Signatureoperator= (const Signature &)
 
bool searchMatchImpl (const std::vector< uint8_t > &bytesToMatch, uint64_t offset, uint64_t maxSearchDist, retdec::utils::DynamicBuffer *captureBuffer) const
 
int64_t matchImpl (const std::vector< uint8_t > &bytesToMatch, uint64_t offset, retdec::utils::DynamicBuffer *captureBuffer) const
 

Private Attributes

std::vector< Signature::Byte_buffer
 Signature bytes buffer. More...
 

Detailed Description

Class for storing the signatures that can be matched against another file or another DynamicBuffer. Signature can contains three type of bytes

  1. Exact byte values
  2. Wildcard
  3. Capture

Exact byte values are equal to the expected byte value that should be at the specific position in the matched data. Wildcard can specify the bytes that can have any value but are still matched as equal. Capture bytes are same as wildcard bytes but they are also put into the capture buffer and can be later obtained from the caller.

Signatures can also be specified for per-bit-matching, not only per-byte-matching. The expected value and wildcard bits are distinguished using wildcard mask in Signature::Byte class.

Signature matching on files is being done only on section or segment that contains entry point.

Constructor & Destructor Documentation

◆ Signature() [1/3]

retdec::unpacker::Signature::Signature ( )
delete

◆ Signature() [2/3]

retdec::unpacker::Signature::Signature ( const std::initializer_list< Signature::Byte > &  initList)

Initializer list constructor.

Parameters
initListInitializer list containing Signature::Byte objects.

◆ Signature() [3/3]

retdec::unpacker::Signature::Signature ( const Signature signature)

Copy constructor.

Parameters
signatureAnother signature.

◆ ~Signature()

virtual retdec::unpacker::Signature::~Signature ( )
virtualdefault

Member Function Documentation

◆ getCaptureSize()

uint64_t retdec::unpacker::Signature::getCaptureSize ( ) const

Returns the number of bytes in the signature that has Signature::Byte::Type::CAPTURE type.

Returns
Number of capture bytes.

◆ getSize()

uint64_t retdec::unpacker::Signature::getSize ( ) const

Returns the number of bytes in the signature.

Returns
Number of bytes in the signature.

◆ match() [1/4]

bool retdec::unpacker::Signature::match ( const MatchSettings settings,
const retdec::utils::DynamicBuffer data 
) const

Matches the signature against the data buffer using the specified settings.

Parameters
settingsMatch settings.
dataInput data buffer.
Returns
True if the signature matched successfuly, otherwise false.

◆ match() [2/4]

bool retdec::unpacker::Signature::match ( const MatchSettings settings,
const retdec::utils::DynamicBuffer data,
retdec::utils::DynamicBuffer capturedData 
) const

Matches the signature against the data buffer using the specified settings and captures all capture bytes into DynamicBuffer.

Parameters
settingsMatch settings.
dataInput data buffer.
capturedDataBuffer where to capture the capture bytes.
Returns
True if the signature matched successfuly, otherwise false.

◆ match() [3/4]

bool retdec::unpacker::Signature::match ( const MatchSettings settings,
retdec::loader::Image file 
) const

Matches the signature against the file using the specified settings. Matching is being done on section or segment which contains entry point.

Parameters
settingsMatch settings.
fileInput file.
Returns
True if the signature matched successfuly, otherwise false.

◆ match() [4/4]

bool retdec::unpacker::Signature::match ( const MatchSettings settings,
retdec::loader::Image file,
retdec::utils::DynamicBuffer capturedData 
) const

Matches the signature against the file using the specified settings and captures all capture bytes into DynamicBuffer. Matching is being done on section or segment which contains entry point.

Parameters
settingsMatch settings.
fileInput file.
capturedDataBuffer where to capture the capture bytes.
Returns
True if the signature matched successfuly, otherwise false.

◆ matchImpl()

int64_t retdec::unpacker::Signature::matchImpl ( const std::vector< uint8_t > &  bytesToMatch,
uint64_t  offset,
retdec::utils::DynamicBuffer captureBuffer 
) const
private

◆ operator=() [1/2]

Signature& retdec::unpacker::Signature::operator= ( const Signature )
private

◆ operator=() [2/2]

Signature & retdec::unpacker::Signature::operator= ( const std::initializer_list< Signature::Byte > &  initList)

Assignment operator allowing initializer list assignment.

Parameters
initListInitializer list containing Signature::Byte objects.
Returns
Newly created Signature object.

◆ searchMatchImpl()

bool retdec::unpacker::Signature::searchMatchImpl ( const std::vector< uint8_t > &  bytesToMatch,
uint64_t  offset,
uint64_t  maxSearchDist,
retdec::utils::DynamicBuffer captureBuffer 
) const
private

Member Data Documentation

◆ _buffer

std::vector<Signature::Byte> retdec::unpacker::Signature::_buffer
private

Signature bytes buffer.


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