#include <search.h>
|
| Search (retdec::fileformat::FileFormat &fileParser) |
|
|
bool | isFileLoaded () const |
|
bool | isFileSupported () const |
|
|
const std::string & | getNibbles () const |
|
const std::string & | getPlainString () const |
|
|
const RelativeJump * | getRelativeJump (std::size_t fileOffset, std::size_t shift, std::int64_t &moveSize) const |
|
|
unsigned long long | countImpNibbles (const std::string &signPattern) const |
|
unsigned long long | findUnslashedSignature (const std::string &signPattern, std::size_t startOffset, std::size_t stopOffset) const |
|
unsigned long long | findSlashedSignature (const std::string &signPattern, std::size_t startOffset, std::size_t stopOffset) const |
|
unsigned long long | exactComparison (const std::string &signPattern, std::size_t fileOffset, std::size_t shift=0) const |
|
bool | countSimilarity (const std::string &signPattern, Similarity &sim, std::size_t fileOffset, std::size_t shift=0) const |
|
bool | areaSimilarity (const std::string &signPattern, Similarity &sim, std::size_t startOffset, std::size_t stopOffset) const |
|
|
bool | hasString (const std::string &str) const |
|
bool | hasString (const std::string &str, std::size_t fileOffset) const |
|
bool | hasString (const std::string &str, std::size_t startOffset, std::size_t stopOffset) const |
|
bool | hasStringInSection (const std::string &str, const retdec::fileformat::Section *section) const |
|
bool | hasStringInSection (const std::string &str, std::size_t sectionIndex) const |
|
bool | hasStringInSection (const std::string &str, const std::string §ionName) const |
|
|
bool | createSignature (std::string &pattern, std::size_t fileOffset, std::size_t size) const |
|
◆ Search()
Constructor
- Parameters
-
fileParser | Parser of input file |
◆ areaSimilarity()
bool retdec::cpdetect::Search::areaSimilarity |
( |
const std::string & |
signPattern, |
|
|
Similarity & |
sim, |
|
|
std::size_t |
startOffset, |
|
|
std::size_t |
stopOffset |
|
) |
| const |
Count the most similar similarity in area
- Parameters
-
signPattern | Signature pattern |
sim | Structure for save similarity |
startOffset | Start offset in file (in bytes) |
stopOffset | Stop offset in file (in bytes) |
- Returns
true
if function went OK, false
otherwise
If function return false
, sim is left unchanged
◆ bytesFromNibbles()
std::size_t retdec::cpdetect::Search::bytesFromNibbles |
( |
std::size_t |
nNibbles | ) |
const |
|
private |
Count number of bytes from number of nibbles
- Parameters
-
nNibbles | Number of nibbles |
- Returns
- Number of bytes
◆ countImpNibbles()
unsigned long long retdec::cpdetect::Search::countImpNibbles |
( |
const std::string & |
signPattern | ) |
const |
Count number of significant nibbles in signature pattern
- Parameters
-
- Returns
- Number of significant nibbles in signature pattern
◆ countSimilarity()
bool retdec::cpdetect::Search::countSimilarity |
( |
const std::string & |
signPattern, |
|
|
Similarity & |
sim, |
|
|
std::size_t |
fileOffset, |
|
|
std::size_t |
shift = 0 |
|
) |
| const |
Count similarity as count of agree nibbles and count of valuable nibbles in signature
- Parameters
-
signPattern | Signature pattern |
sim | Structure for save similarity |
fileOffset | Offset in file |
shift | Relative shift in nibbles from fileOffset |
- Returns
true
if function went OK, false
otherwise
If function return false
, sim is left unchanged
◆ createSignature()
bool retdec::cpdetect::Search::createSignature |
( |
std::string & |
pattern, |
|
|
std::size_t |
fileOffset, |
|
|
std::size_t |
size |
|
) |
| const |
Create signature from specified offset
- Parameters
-
pattern | Into this parameter is stored resulted signature |
fileOffset | Start offset in file (in bytes) |
size | Desired length of signature (in bytes, slashes are also considered as one byte during creation of signature) |
- Returns
true
if signature was successfully created, false
otherwise
◆ exactComparison()
unsigned long long retdec::cpdetect::Search::exactComparison |
( |
const std::string & |
signPattern, |
|
|
std::size_t |
fileOffset, |
|
|
std::size_t |
shift = 0 |
|
) |
| const |
Try find signature signPattern at specified offset
- Parameters
-
signPattern | Signature pattern |
fileOffset | Offset in file |
shift | Relative shift in nibbles from fileOffset |
- Returns
- Number of significant nibbles of signature or 0 if content of file and signature are different
◆ findSlashedSignature()
unsigned long long retdec::cpdetect::Search::findSlashedSignature |
( |
const std::string & |
signPattern, |
|
|
std::size_t |
startOffset, |
|
|
std::size_t |
stopOffset |
|
) |
| const |
Search if there is a slash(es) containing pattern in selected area
- Parameters
-
signPattern | Signature pattern |
startOffset | Start offset in file (in bytes) |
stopOffset | Stop offset in file (in bytes) |
- Returns
- If pattern is not present in area return 0, else return number of patterns significant nibbles
◆ findUnslashedSignature()
unsigned long long retdec::cpdetect::Search::findUnslashedSignature |
( |
const std::string & |
signPattern, |
|
|
std::size_t |
startOffset, |
|
|
std::size_t |
stopOffset |
|
) |
| const |
Method tells if there is the pattern in selected area of file. Unable for slashed signatures
- Parameters
-
signPattern | Signature pattern |
startOffset | Start offset in file (in bytes) |
stopOffset | Stop offset in file (in bytes) |
- Returns
- If pattern is present in area return number of patterns significant nibbles, else return 0
◆ getNibbles()
const std::string & retdec::cpdetect::Search::getNibbles |
( |
| ) |
const |
Get content of file in hexadecimal string representation
- Returns
- Content of file in hexadecimal string representation
◆ getPlainString()
const std::string & retdec::cpdetect::Search::getPlainString |
( |
| ) |
const |
Get content of file as plain string
- Returns
- Content of file as plain string
◆ getRelativeJump()
const Search::RelativeJump * retdec::cpdetect::Search::getRelativeJump |
( |
std::size_t |
fileOffset, |
|
|
std::size_t |
shift, |
|
|
std::int64_t & |
moveSize |
|
) |
| const |
Check if relative jump is present on offset fileOffset
- Parameters
-
fileOffset | Byte offset in file |
shift | Relative shift in nibbles from fileOffset |
moveSize | Into this parameter is stored number of nibbles of which will jump or zero if nullptr is returned |
- Returns
- Pointer to the description of detected jump of
nullptr
if jump is not detected
◆ hasString() [1/3]
bool retdec::cpdetect::Search::hasString |
( |
const std::string & |
str | ) |
const |
Check if file contains specified substring
- Parameters
-
- Returns
true
if file contains str, false
otherwise
◆ hasString() [2/3]
bool retdec::cpdetect::Search::hasString |
( |
const std::string & |
str, |
|
|
std::size_t |
fileOffset |
|
) |
| const |
Check if file has substring str on specified offset
- Parameters
-
str | Coveted substring |
fileOffset | Offset in file |
- Returns
true
if file has str on offset fileOffset, false
otherwise
◆ hasString() [3/3]
bool retdec::cpdetect::Search::hasString |
( |
const std::string & |
str, |
|
|
std::size_t |
startOffset, |
|
|
std::size_t |
stopOffset |
|
) |
| const |
Check if file contains string in selected area of file
- Parameters
-
str | Coveted string |
startOffset | Start offset in file (in bytes) |
stopOffset | Stop offset in file (in bytes) |
- Returns
true
if string is present in selected area of file, false
otherwise
◆ hasStringInSection() [1/3]
Check if file contains string in selected section
- Parameters
-
str | Coveted string |
section | Selected section |
- Returns
true
if string is present in selected section, false
otherwise
◆ hasStringInSection() [2/3]
bool retdec::cpdetect::Search::hasStringInSection |
( |
const std::string & |
str, |
|
|
const std::string & |
sectionName |
|
) |
| const |
Check if file contains string in selected section
- Parameters
-
str | Coveted string |
sectionName | Name of selected section |
- Returns
true
if string is present in selected section, false
otherwise
◆ hasStringInSection() [3/3]
bool retdec::cpdetect::Search::hasStringInSection |
( |
const std::string & |
str, |
|
|
std::size_t |
sectionIndex |
|
) |
| const |
Check if file contains string in selected section
- Parameters
-
str | Coveted string |
sectionIndex | Index of selected section (indexed from 0) |
- Returns
true
if string is present in selected section, false
otherwise
◆ haveSlashes()
bool retdec::cpdetect::Search::haveSlashes |
( |
| ) |
const |
|
private |
Check is some slashes are defined for target architecture of input file
- Returns
true
if at least one slash pattern is defined for target architecture of input file, false
otherwise
◆ isFileLoaded()
bool retdec::cpdetect::Search::isFileLoaded |
( |
| ) |
const |
Check if input file was successfully loaded
- Returns
true
if file was successfully loaded, false
otherwise
◆ isFileSupported()
bool retdec::cpdetect::Search::isFileSupported |
( |
| ) |
const |
Check if input file is supported for search
- Returns
true
if input file is supported for search, false
otherwise
◆ nibblesFromBytes()
std::size_t retdec::cpdetect::Search::nibblesFromBytes |
( |
std::size_t |
nBytes | ) |
const |
|
private |
Count number of nibbles from number of bytes
- Parameters
-
- Returns
- Number of nibbles
◆ averageSlashLen
std::size_t retdec::cpdetect::Search::averageSlashLen |
|
private |
average length of one slash representation
◆ fileLoaded
bool retdec::cpdetect::Search::fileLoaded |
|
private |
true
if file was successfully loaded, false
otherwise
◆ fileSupported
bool retdec::cpdetect::Search::fileSupported |
|
private |
true
if search of patterns is supported for input file, false
otherwise
◆ jumps
representation of supported relative jumps
◆ nibbles
std::string retdec::cpdetect::Search::nibbles |
|
private |
content of file in hexadecimal string representation
◆ parser
◆ plain
std::string retdec::cpdetect::Search::plain |
|
private |
content of file as plain string
The documentation for this class was generated from the following files:
- /var/cache/acbs/build/acbs.6bu6osb6/retdec/include/retdec/cpdetect/search.h
- /var/cache/acbs/build/acbs.6bu6osb6/retdec/src/cpdetect/search.cpp