retdec
Public Member Functions | Protected Attributes | Private Attributes | List of all members
retdec::fileformat::FileFormat Class Referenceabstract

#include <file_format.h>

Inheritance diagram for retdec::fileformat::FileFormat:
Inheritance graph
[legend]
Collaboration diagram for retdec::fileformat::FileFormat:
Collaboration graph
[legend]

Public Member Functions

 FileFormat (const std::string &pathToFile, LoadFlags loadFlags=LoadFlags::NONE)
 
 FileFormat (std::istream &inputStream, LoadFlags loadFlags=LoadFlags::NONE)
 
 FileFormat (const std::uint8_t *data, std::size_t size, LoadFlags loadFlags=LoadFlags::NONE)
 
virtual ~FileFormat ()
 
const LoaderErrorInfogetLoaderErrorInfo () const
 
Other methods
void initArchitecture (Architecture arch, retdec::utils::Endianness endian=retdec::utils::Endianness::UNKNOWN, std::size_t bytesPerWord=4, retdec::common::Address entryPoint=retdec::common::Address::Undefined, retdec::common::Address sectionVMA=retdec::common::Address::Undefined)
 
void loadStrings ()
 
void loadStrings (StringType type, std::size_t charSize)
 
void loadStrings (StringType type, std::size_t charSize, const SecSeg *secSeg)
 
void loadImpHash ()
 
void loadExpHash ()
 
void loadResourceIconHash ()
 
bool isInValidState () const
 
LoadFlags getLoadFlags () const
 
Auxiliary offset detection methods
const SectiongetSectionFromOffset (unsigned long long offset) const
 
const SegmentgetSegmentFromOffset (unsigned long long offset) const
 
const SecSeggetSectionOrSegmentFromOffset (unsigned long long offset) const
 
bool haveSectionOrSegmentOnOffset (unsigned long long offset) const
 
bool haveDataOnOffset (unsigned long long offset) const
 
Auxiliary address detection methods
const SectiongetSectionFromAddress (unsigned long long address) const
 
const SegmentgetSegmentFromAddress (unsigned long long address) const
 
const SecSeggetSectionOrSegmentFromAddress (unsigned long long address) const
 
bool haveSectionOrSegmentOnAddress (unsigned long long address) const
 
bool haveDataOnAddress (unsigned long long address) const
 
bool haveReadOnlyDataOnAddress (unsigned long long address) const
 Test if there are some read-only data on provided address – address belongs to some read-only section or segment. More...
 
Byte value storage methods
virtual std::size_t getNibbleLength () const override
 
virtual std::size_t getByteLength () const override
 
virtual std::size_t getWordLength () const override
 
virtual std::size_t getNumberOfNibblesInByte () const override
 
Detection methods
bool isX86 () const
 
bool isX86_64 () const
 
bool isX86OrX86_64 () const
 
bool isArm () const
 
bool isPowerPc () const
 
bool isMips () const
 
bool isUnknownArch () const
 
bool isPe () const
 
bool isElf () const
 
bool isCoff () const
 
bool isMacho () const
 
bool isIntelHex () const
 
bool isRawData () const
 
bool isUnknownFormat () const
 
bool isWindowsDriver () const
 
bool hasCrc32 () const
 
bool hasMd5 () const
 
bool hasSha256 () const
 
bool hasSectionTableCrc32 () const
 
bool hasSectionTableMd5 () const
 
bool hasSectionTableSha256 () const
 
std::string getCrc32 () const
 
std::string getMd5 () const
 
std::string getSha256 () const
 
std::string getSectionTableCrc32 () const
 
std::string getSectionTableMd5 () const
 
std::string getSectionTableSha256 () const
 
std::string getPathToFile () const
 
Format getFileFormat () const
 
std::size_t getNumberOfSections () const
 
std::size_t getNumberOfSegments () const
 
std::size_t getNumberOfSymbolTables () const
 
std::size_t getNumberOfRelocationTables () const
 
std::size_t getNumberOfDynamicTables () const
 
std::size_t getFileLength () const
 
std::size_t getLoadedFileLength () const
 
std::size_t getOverlaySize () const
 
bool getOverlayEntropy (double &res) const
 
std::size_t nibblesFromBytes (std::size_t bytes) const
 
std::size_t bytesFromNibbles (std::size_t nibbles) const
 
std::size_t bytesFromNibblesRounded (std::size_t nibbles) const
 
bool getOffsetFromAddress (unsigned long long &result, unsigned long long address) const
 
bool getAddressFromOffset (unsigned long long &result, unsigned long long offset) const
 
bool getBytes (std::vector< std::uint8_t > &result, unsigned long long offset, unsigned long long numberOfBytes) const
 
bool getEpBytes (std::vector< std::uint8_t > &result, unsigned long long numberOfBytes) const
 
bool getHexBytes (std::string &result, unsigned long long offset, unsigned long long numberOfBytes) const
 
bool getHexEpBytes (std::string &result, unsigned long long numberOfBytes) const
 
bool getHexBytesFromEnd (std::string &result, unsigned long long numberOfBytes) const
 
bool getString (std::string &result, unsigned long long offset, unsigned long long numberOfBytes) const
 
bool getStringFromEnd (std::string &result, unsigned long long numberOfBytes) const
 
bool isObjectStretchedOverSections (std::size_t addr, std::size_t size) const
 
const SectiongetEpSection ()
 
const SectiongetSection (const std::string &secName) const
 
const SectiongetSection (unsigned long long secIndex) const
 
const SectiongetLastSection () const
 
const SectiongetLastButOneSection () const
 
const SegmentgetEpSegment ()
 
const SegmentgetSegment (const std::string &segName) const
 
const SegmentgetSegment (unsigned long long segIndex) const
 
const SegmentgetLastSegment () const
 
const SegmentgetLastButOneSegment () const
 
const SymbolTablegetSymbolTable (unsigned long long tabIndex) const
 
const RelocationTablegetRelocationTable (unsigned long long tabIndex) const
 
const DynamicTablegetDynamicTable (unsigned long long tabIndex) const
 
const ImportTablegetImportTable () const
 
const ExportTablegetExportTable () const
 
const ResourceTablegetResourceTable () const
 
const ResourceTreegetResourceTree () const
 
const RichHeadergetRichHeader () const
 
const PdbInfogetPdbInfo () const
 
const CertificateTablegetCertificateTable () const
 
const TlsInfogetTlsInfo () const
 
const ElfCoreInfogetElfCoreInfo () const
 
const SymbolgetSymbol (const std::string &name) const
 
const SymbolgetSymbol (unsigned long long address) const
 
const RelocationgetRelocation (const std::string &name) const
 
const RelocationgetRelocation (unsigned long long address) const
 
const ImportgetImport (const std::string &name) const
 
const ImportgetImport (unsigned long long address) const
 
const ExportgetExport (const std::string &name) const
 
const ExportgetExport (unsigned long long address) const
 
const ResourcegetManifestResource () const
 
const ResourcegetVersionResource () const
 
bool isSignaturePresent () const
 
bool isSignatureVerified () const
 
const retdec::common::RangeContainer< std::uint64_t > & getNonDecodableAddressRanges () const
 
Containers
const std::vector< Section * > & getSections () const
 
const std::vector< Section * > getSections (std::initializer_list< std::string > secs) const
 
const std::vector< Segment * > & getSegments () const
 
const std::vector< Segment * > getSegments (std::initializer_list< std::string > segs) const
 
const std::vector< SymbolTable * > & getSymbolTables () const
 
const std::vector< RelocationTable * > & getRelocationTables () const
 
const std::vector< DynamicTable * > & getDynamicTables () const
 
const std::vector< unsigned char > & getBytes () const
 
const std::vector< unsigned char > & getLoadedBytes () const
 
const unsigned char * getBytesData () const
 
const unsigned char * getLoadedBytesData () const
 
const std::vector< String > & getStrings () const
 
const std::vector< ElfNoteSecSeg > & getElfNoteSecSegs () const
 
const std::set< std::uint64_t > & getUnknownRelocations () const
 
const std::vector< std::pair< std::string, std::string > > & getAnomalies () const
 
Address interpretation methods
virtual bool getXByte (std::uint64_t address, std::uint64_t x, std::uint64_t &res, retdec::utils::Endianness e=retdec::utils::Endianness::UNKNOWN) const override
 
virtual bool getXBytes (std::uint64_t address, std::uint64_t x, std::vector< std::uint8_t > &res) const override
 
virtual bool setXByte (std::uint64_t address, std::uint64_t x, std::uint64_t val, retdec::utils::Endianness e=retdec::utils::Endianness::UNKNOWN) override
 
virtual bool setXBytes (std::uint64_t address, const std::vector< std::uint8_t > &val) override
 
bool isPointer (unsigned long long address, std::uint64_t *pointer=nullptr) const
 
Offset interpretation methods
bool get1ByteOffset (std::uint64_t offset, std::uint64_t &res, retdec::utils::Endianness e=retdec::utils::Endianness::UNKNOWN) const
 
bool get2ByteOffset (std::uint64_t offset, std::uint64_t &res, retdec::utils::Endianness e=retdec::utils::Endianness::UNKNOWN) const
 
bool get4ByteOffset (std::uint64_t offset, std::uint64_t &res, retdec::utils::Endianness e=retdec::utils::Endianness::UNKNOWN) const
 
bool get8ByteOffset (std::uint64_t offset, std::uint64_t &res, retdec::utils::Endianness e=retdec::utils::Endianness::UNKNOWN) const
 
bool get10ByteOffset (std::uint64_t offset, long double &res) const
 
bool getXByteOffset (std::uint64_t offset, std::uint64_t x, std::uint64_t &res, retdec::utils::Endianness e=retdec::utils::Endianness::UNKNOWN) const
 
bool getXBytesOffset (std::uint64_t offset, std::uint64_t x, std::vector< std::uint8_t > &res) const
 
bool getWordOffset (std::uint64_t offset, std::uint64_t &res, retdec::utils::Endianness e=retdec::utils::Endianness::UNKNOWN) const
 
bool getNTBSOffset (std::uint64_t offset, std::string &res, std::size_t size=0) const
 
bool getNTWSOffset (std::uint64_t offset, std::size_t width, std::vector< std::uint64_t > &res) const
 
Virtual detection methods
virtual std::string getFileFormatName () const
 
virtual std::size_t getDeclaredFileLength () const
 
virtual bool areSectionsValid () const
 
Pure virtual detection methods
virtual bool isObjectFile () const =0
 
virtual bool isDll () const =0
 
virtual bool isExecutable () const =0
 
virtual bool getMachineCode (unsigned long long &result) const =0
 
virtual bool getAbiVersion (unsigned long long &result) const =0
 
virtual bool getImageBaseAddress (unsigned long long &imageBase) const =0
 
virtual bool getEpAddress (unsigned long long &result) const =0
 
virtual bool getEpOffset (unsigned long long &epOffset) const =0
 
virtual Architecture getTargetArchitecture () const =0
 
virtual std::size_t getDeclaredNumberOfSections () const =0
 
virtual std::size_t getDeclaredNumberOfSegments () const =0
 
virtual std::size_t getSectionTableOffset () const =0
 
virtual std::size_t getSectionTableEntrySize () const =0
 
virtual std::size_t getSegmentTableOffset () const =0
 
virtual std::size_t getSegmentTableEntrySize () const =0
 
Dump methods
void dump ()
 
void dump (std::string &dumpFile)
 
void dumpRegionsValidity ()
 
void dumpRegionsValidity (std::string &dumpStr)
 
void dumpResourceTree ()
 
void dumpResourceTree (std::string &dumpStr)
 
- Public Member Functions inherited from retdec::utils::ByteValueStorage
 ByteValueStorage ()=default
 
virtual ~ByteValueStorage ()=default
 
virtual Endianness getEndianness () const =0
 
virtual std::size_t getBytesPerWord () const =0
 
virtual bool hasMixedEndianForDouble () const =0
 
Endianness getInverseEndianness () const
 
bool isLittleEndian () const
 
bool isBigEndian () const
 
bool isUnknownEndian () const
 
bool hexToBig (std::string &str) const
 
bool hexToLittle (std::string &str) const
 
bool bitsToBig (std::string &str) const
 
bool bitsToLittle (std::string &str) const
 
bool bitsToBig (std::vector< unsigned char > &values) const
 
bool bitsToLittle (std::vector< unsigned char > &values) const
 
bool get1Byte (std::uint64_t address, std::uint64_t &res, Endianness e=Endianness::UNKNOWN) const
 
bool get2Byte (std::uint64_t address, std::uint64_t &res, Endianness e=Endianness::UNKNOWN) const
 
bool get4Byte (std::uint64_t address, std::uint64_t &res, Endianness e=Endianness::UNKNOWN) const
 
bool get8Byte (std::uint64_t address, std::uint64_t &res, Endianness e=Endianness::UNKNOWN) const
 
bool get10Byte (std::uint64_t address, long double &res) const
 
bool getWord (std::uint64_t address, std::uint64_t &res, Endianness e=Endianness::UNKNOWN) const
 
bool getFloat (std::uint64_t address, float &res) const
 
bool getDouble (std::uint64_t address, double &res) const
 
bool set1Byte (std::uint64_t address, std::uint64_t val, Endianness e=Endianness::UNKNOWN)
 
bool set2Byte (std::uint64_t address, std::uint64_t val, Endianness e=Endianness::UNKNOWN)
 
bool set4Byte (std::uint64_t address, std::uint64_t val, Endianness e=Endianness::UNKNOWN)
 
bool set8Byte (std::uint64_t address, std::uint64_t val, Endianness e=Endianness::UNKNOWN)
 
bool set10Byte (std::uint64_t address, long double val)
 
bool setWord (std::uint64_t address, std::uint64_t val, Endianness e=Endianness::UNKNOWN)
 
bool setFloat (std::uint64_t address, float val)
 
bool setDouble (std::uint64_t address, double val)
 
bool getXByteArray (std::uint64_t address, std::uint64_t x, std::vector< std::uint64_t > &res, std::size_t size, Endianness e=Endianness::UNKNOWN) const
 
bool get1ByteArray (std::uint64_t address, std::vector< std::uint64_t > &res, std::size_t size, Endianness e=Endianness::UNKNOWN) const
 
bool get2ByteArray (std::uint64_t address, std::vector< std::uint64_t > &res, std::size_t size, Endianness e=Endianness::UNKNOWN) const
 
bool get4ByteArray (std::uint64_t address, std::vector< std::uint64_t > &res, std::size_t size, Endianness e=Endianness::UNKNOWN) const
 
bool get8ByteArray (std::uint64_t address, std::vector< std::uint64_t > &res, std::size_t size, Endianness e=Endianness::UNKNOWN) const
 
bool get10ByteArray (std::uint64_t address, std::vector< long double > &res, std::size_t size) const
 
bool getWordArray (std::uint64_t address, std::vector< std::uint64_t > &res, std::size_t, Endianness e=Endianness::UNKNOWN) const
 
bool getFloatArray (std::uint64_t address, std::vector< float > &res, std::size_t size) const
 
bool getDoubleArray (std::uint64_t address, std::vector< double > &res, std::size_t size) const
 
bool getNTBS (std::uint64_t address, std::string &res, std::size_t size=0) const
 
bool getNTWS (std::uint64_t address, std::size_t width, std::vector< std::uint64_t > &res) const
 
bool getNTWSNice (std::uint64_t address, std::size_t width, std::vector< std::uint64_t > &res) const
 

Protected Member Functions

Clear methods
void clear ()
 
Protected detection methods
void computeSectionTableHashes ()
 
Setters
void setLoadedBytes (std::vector< unsigned char > *lBytes)
 
- Protected Member Functions inherited from retdec::utils::ByteValueStorage
bool createValueFromBytes (const std::vector< std::uint8_t > &data, std::uint64_t &value, Endianness endian, std::uint64_t offset=0, std::uint64_t size=0) const
 
bool createBytesFromValue (std::uint64_t data, std::uint64_t x, std::vector< std::uint8_t > &value, Endianness endian) const
 
bool get10ByteImpl (const std::vector< std::uint8_t > &data, long double &res) const
 
bool getFloatImpl (const std::vector< std::uint8_t > &data, float &res) const
 
bool getDoubleImpl (const std::vector< std::uint8_t > &data, double &res) const
 
bool getNTBSImpl (const GetNByteFn &get1ByteFn, std::uint64_t address, std::string &res, std::size_t size) const
 
bool getNTWSImpl (const GetXByteFn &getXByteFn, std::uint64_t address, std::size_t width, std::vector< std::uint64_t > &res) const
 
bool getNTWSNiceImpl (const GetXByteFn &getXByteFn, std::uint64_t address, std::size_t width, std::vector< std::uint64_t > &res) const
 

Protected Attributes

std::string crc32
 CRC32 of file content. More...
 
std::string md5
 MD5 of file content. More...
 
std::string sha256
 SHA256 of file content. More...
 
std::string sectionCrc32
 CRC32 of section table. More...
 
std::string sectionMd5
 MD5 of section table. More...
 
std::string sectionSha256
 SHA256 of section table. More...
 
std::string filePath
 name of input file More...
 
std::istream & fileStream
 stream representation of input file More...
 
std::vector< Section * > sections
 file sections More...
 
std::vector< Segment * > segments
 file segments More...
 
std::vector< SymbolTable * > symbolTables
 symbol tables More...
 
std::vector< RelocationTable * > relocationTables
 relocation tables More...
 
std::vector< DynamicTable * > dynamicTables
 tables with dynamic records More...
 
std::vector< unsigned char > bytes
 content of file as bytes More...
 
std::vector< Stringstrings
 detected strings More...
 
std::vector< ElfNoteSecSegnoteSecSegs
 note sections or segemnts found in ELF file More...
 
std::set< std::uint64_t > unknownRelocs
 unknown relocations More...
 
ImportTableimportTable
 table of imports More...
 
ExportTableexportTable
 table of exports More...
 
ResourceTableresourceTable
 table of resources More...
 
ResourceTreeresourceTree
 structure of resource tree More...
 
RichHeaderrichHeader
 rich header More...
 
PdbInfopdbInfo
 information about related PDB debug file More...
 
CertificateTablecertificateTable
 table of certificates More...
 
TlsInfotlsInfo
 thread-local information More...
 
ElfCoreInfoelfCoreInfo
 information about core file structures More...
 
Format fileFormat
 format of input file More...
 
LoaderErrorInfo _ldrErrInfo
 loader error (e.g. Windows loader error for PE files) More...
 
bool stateIsValid
 internal state of instance More...
 
std::vector< std::pair< std::size_t, std::size_t > > secHashInfo
 information for calculation of section table hash More...
 
std::optional< bool > signatureVerified
 indicates whether the signature is present and also verified More...
 
retdec::common::RangeContainer< std::uint64_t > nonDecodableRanges
 Address ranges which should not be decoded for instructions. More...
 
std::vector< std::pair< std::string, std::string > > anomalies
 file format anomalies More...
 

Private Member Functions

Initialization methods
void init ()
 
void initStream ()
 
Pure virtual initialization methods
virtual std::size_t initSectionTableHashOffsets ()=0
 
- Private Member Functions inherited from retdec::utils::NonCopyable
 NonCopyable (const NonCopyable &)=delete
 
NonCopyableoperator= (const NonCopyable &)=delete
 
 NonCopyable ()=default
 
 ~NonCopyable ()=default
 

Private Attributes

byte_array_buffer auxBuff
 auxiliary input buffer More...
 
std::ifstream auxFStream
 auxiliary input file stream More...
 
std::istream auxIStream
 auxiliary input stream More...
 
std::vector< unsigned char > * loadedBytes
 reference to serialized content of input file More...
 
LoadFlags loadFlags
 load flags for configurable file loading More...
 

Additional Inherited Members

- Protected Types inherited from retdec::utils::ByteValueStorage
using GetNByteFn = std::function< bool(std::uint64_t, std::uint64_t &, Endianness)>
 
using GetXByteFn = std::function< bool(std::uint64_t, std::uint64_t, std::uint64_t &, Endianness)>
 

Detailed Description

FileFormat - abstract class for parsing files

Constructor & Destructor Documentation

◆ FileFormat() [1/3]

retdec::fileformat::FileFormat::FileFormat ( const std::string &  pathToFile,
LoadFlags  loadFlags = LoadFlags::NONE 
)

Constructor

Parameters
pathToFilePath to input file
loadFlagsLoad flags

◆ FileFormat() [2/3]

retdec::fileformat::FileFormat::FileFormat ( std::istream &  inputStream,
LoadFlags  loadFlags = LoadFlags::NONE 
)

Constructor

Parameters
inputStreamStream which represents input file
loadFlagsLoad flags

◆ FileFormat() [3/3]

retdec::fileformat::FileFormat::FileFormat ( const std::uint8_t *  data,
std::size_t  size,
LoadFlags  loadFlags = LoadFlags::NONE 
)

Constructor

Parameters
dataInput data.
sizeInput data size.
loadFlagsLoad flags

◆ ~FileFormat()

retdec::fileformat::FileFormat::~FileFormat ( )
virtual

Destructor

Member Function Documentation

◆ areSectionsValid()

bool retdec::fileformat::FileFormat::areSectionsValid ( ) const
virtual

Determine if loaded sections are OK to use for decompilation purposes. We want at least one valid section which may hold code.

Returns
true if sections are to be used, false otherwise (use segments).

Reimplemented in retdec::fileformat::RawDataFormat, retdec::fileformat::PeFormat, retdec::fileformat::MachOFormat, retdec::fileformat::IntelHexFormat, retdec::fileformat::ElfFormat, and retdec::fileformat::CoffFormat.

◆ bytesFromNibbles()

std::size_t retdec::fileformat::FileFormat::bytesFromNibbles ( std::size_t  nibbles) const

Count number of bytes from number of nibbles

Parameters
nibblesNumber of nibbles
Returns
Number of bytes

◆ bytesFromNibblesRounded()

std::size_t retdec::fileformat::FileFormat::bytesFromNibblesRounded ( std::size_t  nibbles) const

Count number of bytes from number of nibbles and round up

Parameters
nibblesNumber of nibbles
Returns
Number of bytes rounded up

◆ clear()

void retdec::fileformat::FileFormat::clear ( )
protected

Clear all internal structures

◆ computeSectionTableHashes()

void retdec::fileformat::FileFormat::computeSectionTableHashes ( )
protected

Compute hashes of section table. This method must be called after sections are loaded.

◆ dump() [1/2]

void retdec::fileformat::FileFormat::dump ( )

Dump information about input file on standard output

◆ dump() [2/2]

void retdec::fileformat::FileFormat::dump ( std::string &  dumpFile)

Dump information about input file

Parameters
dumpFileInto this parameter is stored dump of input file in an LLVM style

◆ dumpRegionsValidity() [1/2]

void retdec::fileformat::FileFormat::dumpRegionsValidity ( )

Dump information about validity of sections and segments on standard output

◆ dumpRegionsValidity() [2/2]

void retdec::fileformat::FileFormat::dumpRegionsValidity ( std::string &  dumpStr)

Dump information about validity of sections and segments

Parameters
dumpStrParameter for store the dump in LLVM format

◆ dumpResourceTree() [1/2]

void retdec::fileformat::FileFormat::dumpResourceTree ( )

Dump information about structure of resource tree on standard output

◆ dumpResourceTree() [2/2]

void retdec::fileformat::FileFormat::dumpResourceTree ( std::string &  dumpStr)

◆ get10ByteOffset()

bool retdec::fileformat::FileFormat::get10ByteOffset ( std::uint64_t  offset,
long double &  res 
) const

Get long double from the specified offset If system has 80-bit (10 - byte) long double, copy data directly. Else convert 80-bit (10 - byte) long double into 64-bit (8 - uint8_t) double.

Parameters
offsetOffset to get double from
resResult double
Returns
Status of operation (true if all is OK, false otherwise)

◆ get1ByteOffset()

bool retdec::fileformat::FileFormat::get1ByteOffset ( std::uint64_t  offset,
std::uint64_t &  res,
retdec::utils::Endianness  e = retdec::utils::Endianness::UNKNOWN 
) const

Get integer (1B) located at provided offset using the specified endian or default file endian

Parameters
offsetOffset to get integer from
resResult integer
eEndian - if specified it is forced, otherwise file's endian is used
Returns
Status of operation (true if all is OK, false otherwise)

◆ get2ByteOffset()

bool retdec::fileformat::FileFormat::get2ByteOffset ( std::uint64_t  offset,
std::uint64_t &  res,
retdec::utils::Endianness  e = retdec::utils::Endianness::UNKNOWN 
) const

Get integer (2B) located at provided offset using the specified endian or default file endian

Parameters
offsetOffset to get integer from
resResult integer
eEndian - if specified it is forced, otherwise file's endian is used
Returns
Status of operation (true if all is OK, false otherwise)

◆ get4ByteOffset()

bool retdec::fileformat::FileFormat::get4ByteOffset ( std::uint64_t  offset,
std::uint64_t &  res,
retdec::utils::Endianness  e = retdec::utils::Endianness::UNKNOWN 
) const

Get integer (4B) located at provided offset using the specified endian or default file endian

Parameters
offsetOffset to get integer from
resResult integer
eEndian - if specified it is forced, otherwise file's endian is used
Returns
Status of operation (true if all is OK, false otherwise)

◆ get8ByteOffset()

bool retdec::fileformat::FileFormat::get8ByteOffset ( std::uint64_t  offset,
std::uint64_t &  res,
retdec::utils::Endianness  e = retdec::utils::Endianness::UNKNOWN 
) const

Get integer (8B) located at provided offset using the specified endian or default file endian

Parameters
offsetOffset to get integer from
resResult integer
eEndian - if specified it is forced, otherwise file's endian is used
Returns
Status of operation (true if all is OK, false otherwise)

◆ getAbiVersion()

bool retdec::fileformat::FileFormat::getAbiVersion ( unsigned long long &  result) const
pure virtual

Get file format-dependent version of used ABI

Parameters
resultParameter for store the result
Returns
true if method went OK, false otherwise

Implemented in retdec::fileformat::RawDataFormat, retdec::fileformat::PeFormat, retdec::fileformat::MachOFormat, retdec::fileformat::IntelHexFormat, retdec::fileformat::ElfFormat, and retdec::fileformat::CoffFormat.

◆ getAddressFromOffset()

bool retdec::fileformat::FileFormat::getAddressFromOffset ( unsigned long long &  result,
unsigned long long  offset 
) const

Convert offset to address

Parameters
resultInto this parameter is stored resulted address
offsetOffset for conversion
Returns
true if offset was successfully converted to address, false otherwise

If method returns false, result is left unchanged

◆ getAnomalies()

const std::vector< std::pair< std::string, std::string > > & retdec::fileformat::FileFormat::getAnomalies ( ) const

Get all anomalies

Returns
Reference to anomalies

◆ getByteLength()

std::size_t retdec::fileformat::FileFormat::getByteLength ( ) const
overridevirtual

Get number of bits in one byte

Returns
Number of bits in one byte
Note
This assumes architectures with 8-bit bytes and may break if some exotic architecture is encountered.

Implements retdec::utils::ByteValueStorage.

Reimplemented in retdec::fileformat::RawDataFormat.

◆ getBytes() [1/2]

const std::vector< unsigned char > & retdec::fileformat::FileFormat::getBytes ( ) const

Get content of input file as bytes

Returns
Content of input file as bytes

◆ getBytes() [2/2]

bool retdec::fileformat::FileFormat::getBytes ( std::vector< std::uint8_t > &  result,
unsigned long long  offset,
unsigned long long  numberOfBytes 
) const

Get bytes from entry point

Parameters
resultRead bytes
offsetStart offset for read
numberOfBytesNumber of bytes for read
Returns
Status of operation (true if all is OK)

◆ getBytesData()

const unsigned char * retdec::fileformat::FileFormat::getBytesData ( ) const

Get content of input file as constant pointer to bytes

Returns
Content of input file as constant pointer to bytes

◆ getCertificateTable()

const CertificateTable * retdec::fileformat::FileFormat::getCertificateTable ( ) const

Get information about certificate table

Returns
Pointer to certificate table or nullptr if file has no certificates

◆ getCrc32()

std::string retdec::fileformat::FileFormat::getCrc32 ( ) const

Get CRC32

Returns
CRC32 of file content

◆ getDeclaredFileLength()

std::size_t retdec::fileformat::FileFormat::getDeclaredFileLength ( ) const
virtual

Get declared length of file. This length may be shorter or longer than real length of file.

Returns
Declared length of file

This method takes into account only offset and size of each file section and segment. This is not valid for some file formats (e.g. ELF, PE, COFF), therefore, this method is virtual and can be replaced in subclass.

Reimplemented in retdec::fileformat::RawDataFormat, retdec::fileformat::PeFormat, retdec::fileformat::IntelHexFormat, retdec::fileformat::ElfFormat, and retdec::fileformat::CoffFormat.

◆ getDeclaredNumberOfSections()

std::size_t retdec::fileformat::FileFormat::getDeclaredNumberOfSections ( ) const
pure virtual

Get declared number of sections. This number may be different than real number of sections in file

Returns
Declared number of sections

Implemented in retdec::fileformat::RawDataFormat, retdec::fileformat::PeFormat, retdec::fileformat::MachOFormat, retdec::fileformat::IntelHexFormat, retdec::fileformat::ElfFormat, and retdec::fileformat::CoffFormat.

◆ getDeclaredNumberOfSegments()

std::size_t retdec::fileformat::FileFormat::getDeclaredNumberOfSegments ( ) const
pure virtual

Get declared number of segments. This number may be different than real number of segments in file

Returns
Declared number of segments

Implemented in retdec::fileformat::RawDataFormat, retdec::fileformat::PeFormat, retdec::fileformat::MachOFormat, retdec::fileformat::IntelHexFormat, retdec::fileformat::ElfFormat, and retdec::fileformat::CoffFormat.

◆ getDynamicTable()

const DynamicTable * retdec::fileformat::FileFormat::getDynamicTable ( unsigned long long  tabIndex) const

Get information about dynamic table

Parameters
tabIndexIndex of selected dynamic table (indexed from 0)
Returns
Pointer to dynamic table or nullptr if index of table is invalid

◆ getDynamicTables()

const std::vector< DynamicTable * > & retdec::fileformat::FileFormat::getDynamicTables ( ) const

Get all dynamic tables

Returns
Reference to dynamic tables

◆ getElfCoreInfo()

const ElfCoreInfo * retdec::fileformat::FileFormat::getElfCoreInfo ( ) const

Get information about ELF core file

Returns
Pointer to ELF core info of nullptr if file has no certificates

◆ getElfNoteSecSegs()

const std::vector< ElfNoteSecSeg > & retdec::fileformat::FileFormat::getElfNoteSecSegs ( ) const

Get all detected notes

Returns
Reference to notes

◆ getEpAddress()

bool retdec::fileformat::FileFormat::getEpAddress ( unsigned long long &  result) const
pure virtual

Get virtual address of entry point

Parameters
resultParameter for store the result
Returns
true if file has entry point and entry point address is successfully detected, false otherwise

If file has no associated entry point, result is left unchanged.

If file has entry point but detection of entry point address is failed, instance method isInValidState() returns false after its invocation.

Implemented in retdec::fileformat::RawDataFormat, retdec::fileformat::PeFormat, retdec::fileformat::MachOFormat, retdec::fileformat::IntelHexFormat, retdec::fileformat::ElfFormat, and retdec::fileformat::CoffFormat.

◆ getEpBytes()

bool retdec::fileformat::FileFormat::getEpBytes ( std::vector< std::uint8_t > &  result,
unsigned long long  numberOfBytes 
) const

Get bytes from entry point

Parameters
resultRead bytes
numberOfBytesNumber of bytes for read
Returns
Status of operation (true if all is OK)

If file has no entry point or entry point has not detected, method returns false

If file has entry point but detection of entry point offset is failed or an error occurs while reading bytes from file, instance method isInValidState() returns false after its invocation.

◆ getEpOffset()

bool retdec::fileformat::FileFormat::getEpOffset ( unsigned long long &  epOffset) const
pure virtual

Get offset of entry point

Parameters
epOffsetInto this parameter the resulting number is stored
Returns
true if file has entry point and entry point offset is successfully detected, false otherwise

If file has no associated entry point, epOffset is left unchanged.

If file has entry point but detection of entry point offset is failed, instance method isInValidState() returns false after its invocation.

Implemented in retdec::fileformat::RawDataFormat, retdec::fileformat::PeFormat, retdec::fileformat::MachOFormat, retdec::fileformat::IntelHexFormat, retdec::fileformat::ElfFormat, and retdec::fileformat::CoffFormat.

◆ getEpSection()

const Section * retdec::fileformat::FileFormat::getEpSection ( )

Get information about section containing entry point

Returns
Pointer to EP section if file has entry point and EP section was detected, nullptr otherwise

◆ getEpSegment()

const Segment * retdec::fileformat::FileFormat::getEpSegment ( )

Get information about segment containing entry point

Returns
Pointer to EP segment if file has entry point and EP segment was detected, nullptr otherwise

◆ getExport() [1/2]

const Export * retdec::fileformat::FileFormat::getExport ( const std::string &  name) const

Get export with name name

Parameters
nameName of export to get
Returns
Pointer to export with name name or nullptr if such export is not found

◆ getExport() [2/2]

const Export * retdec::fileformat::FileFormat::getExport ( unsigned long long  address) const

Get export on address address

Parameters
addressAddress of export to get
Returns
Pointer to export with address address or nullptr if such export is not found

◆ getExportTable()

const ExportTable * retdec::fileformat::FileFormat::getExportTable ( ) const

Get information about export table

Returns
Pointer to export table or nullptr if file has no exports

◆ getFileFormat()

Format retdec::fileformat::FileFormat::getFileFormat ( ) const

Get file format

Returns
File format of input file
Return values
Format::UNDETECTABLEInstance is not in consistent state (file format cannot be unambiguously determined)

◆ getFileFormatName()

std::string retdec::fileformat::FileFormat::getFileFormatName ( ) const
virtual

Get name of file format as string

Returns
Name of file format in which is input file

Reimplemented in retdec::fileformat::MachOFormat.

◆ getFileLength()

std::size_t retdec::fileformat::FileFormat::getFileLength ( ) const

Get real length of file. This lenght may be shorter or longer than declared length of file.

Returns
Real length of input file

◆ getHexBytes()

bool retdec::fileformat::FileFormat::getHexBytes ( std::string &  result,
unsigned long long  offset,
unsigned long long  numberOfBytes 
) const

Get bytes from specified offset in hexadecimal string representation

Parameters
resultRead bytes in hexadecimal string representation
offsetStart offset for read
numberOfBytesNumber of bytes for read
Returns
Status of operation (true if all is OK)

◆ getHexBytesFromEnd()

bool retdec::fileformat::FileFormat::getHexBytesFromEnd ( std::string &  result,
unsigned long long  numberOfBytes 
) const

Get bytes from end of file in hexadecimal string representation

Parameters
resultParameter for store the result
numberOfBytesNumber of bytes for read
Returns
true if operation went OK, false otherwise

If length of file is smaller than numberOfBytes, as many bytes as possible are read.

◆ getHexEpBytes()

bool retdec::fileformat::FileFormat::getHexEpBytes ( std::string &  result,
unsigned long long  numberOfBytes 
) const

Get bytes from entry point in hexadecimal string representation

Parameters
resultRead bytes in hexadecimal string representation
numberOfBytesNumber of bytes for read
Returns
Status of operation (true if all is OK)

If file has no entry point or entry point has not detected, method returns false

If file has entry point but detection of entry point offset is failed or an error occurs while reading bytes from file, instance method isInValidState() returns false after its invocation.

◆ getImageBaseAddress()

bool retdec::fileformat::FileFormat::getImageBaseAddress ( unsigned long long &  imageBase) const
pure virtual

Get image base address of file

Parameters
imageBaseInto this parameter the resulting number is stored
Returns
true if file has image base address and this address was successfully detected, false otherwise

If file has no image base, imageBase is left unchanged

Implemented in retdec::fileformat::RawDataFormat, retdec::fileformat::PeFormat, retdec::fileformat::MachOFormat, retdec::fileformat::IntelHexFormat, retdec::fileformat::ElfFormat, and retdec::fileformat::CoffFormat.

◆ getImport() [1/2]

const Import * retdec::fileformat::FileFormat::getImport ( const std::string &  name) const

Get import with name name

Parameters
nameName of import to get
Returns
Pointer to import with name name or nullptr if such import is not found

◆ getImport() [2/2]

const Import * retdec::fileformat::FileFormat::getImport ( unsigned long long  address) const

Get import on address address

Parameters
addressAddress of import to get
Returns
Pointer to import with address address or nullptr if such import is not found

◆ getImportTable()

const ImportTable * retdec::fileformat::FileFormat::getImportTable ( ) const

Get information about import table

Returns
Pointer to import table or nullptr if file has no imports

◆ getLastButOneSection()

const Section * retdec::fileformat::FileFormat::getLastButOneSection ( ) const

Get information about last but one section

Returns
Pointer to last but one section or nullptr if section is not detected

◆ getLastButOneSegment()

const Segment * retdec::fileformat::FileFormat::getLastButOneSegment ( ) const

Get information about last but one segment

Returns
Pointer to last but one segment or nullptr if segment is not detected

◆ getLastSection()

const Section * retdec::fileformat::FileFormat::getLastSection ( ) const

Get information about last section

Returns
Pointer to last section or nullptr if section is not detected

◆ getLastSegment()

const Segment * retdec::fileformat::FileFormat::getLastSegment ( ) const

Get information about last segment

Returns
Pointer to last segment or nullptr if segment is not detected

◆ getLoadedBytes()

const std::vector< unsigned char > & retdec::fileformat::FileFormat::getLoadedBytes ( ) const

Get serialized loaded content of input file as bytes

Returns
Serialized content of input file as bytes

◆ getLoadedBytesData()

const unsigned char * retdec::fileformat::FileFormat::getLoadedBytesData ( ) const

Get serialized loaded content of input file as constant pointer to bytes

Returns
Serialized content of input file as constant pointer to bytes

◆ getLoadedFileLength()

std::size_t retdec::fileformat::FileFormat::getLoadedFileLength ( ) const

Get real length of serialized content of input file.

Returns
Real length of serialized content of input file

◆ getLoaderErrorInfo()

const LoaderErrorInfo & retdec::fileformat::FileFormat::getLoaderErrorInfo ( ) const

Get reference to the loader error info

Returns
The LoaderErrorInfo structire

◆ getLoadFlags()

LoadFlags retdec::fileformat::FileFormat::getLoadFlags ( ) const

Getter for load flags.

Returns
Load flags.

◆ getMachineCode()

bool retdec::fileformat::FileFormat::getMachineCode ( unsigned long long &  result) const
pure virtual

Get file format-dependent number representing code of target architecture of file

Parameters
resultParameter for store the result
Returns
true if method went OK, false otherwise

Implemented in retdec::fileformat::RawDataFormat, retdec::fileformat::PeFormat, retdec::fileformat::MachOFormat, retdec::fileformat::IntelHexFormat, retdec::fileformat::ElfFormat, and retdec::fileformat::CoffFormat.

◆ getManifestResource()

const Resource * retdec::fileformat::FileFormat::getManifestResource ( ) const

Get resource that represents side-by-side assembly manifest

Returns
Pointer to manifest resource or nullptr if such resource is not found

◆ getMd5()

std::string retdec::fileformat::FileFormat::getMd5 ( ) const

Get MD5

Returns
MD5 of file content

◆ getNibbleLength()

std::size_t retdec::fileformat::FileFormat::getNibbleLength ( ) const
overridevirtual

Get number of bits in one nibble

Returns
Number of bits in one nibble
Note
This assumes architectures with 8-bit bytes and may break if some exotic architecture is encountered.

Implements retdec::utils::ByteValueStorage.

◆ getNonDecodableAddressRanges()

const retdec::common::RangeContainer< std::uint64_t > & retdec::fileformat::FileFormat::getNonDecodableAddressRanges ( ) const

Get non-decodable address ranges.

Returns
Non-decodable address ranges.

◆ getNTBSOffset()

bool retdec::fileformat::FileFormat::getNTBSOffset ( std::uint64_t  offset,
std::string &  res,
std::size_t  size = 0 
) const

Get NTBS (null-terminated byte string) from specified offset

Parameters
offsetOffset to get string from
resResult string
sizeRequested size of string (if size is zero, read until zero byte)
Returns
Status of operation (true if all is OK, false otherwise)

◆ getNTWSOffset()

bool retdec::fileformat::FileFormat::getNTWSOffset ( std::uint64_t  offset,
std::size_t  width,
std::vector< std::uint64_t > &  res 
) const

Get NTWS (null-terminated wide string) from specified offset

Parameters
offsetOffset to get string from
widthByte width of one character
resResult character array
Returns
Status of operation (true if all is OK, false otherwise)

◆ getNumberOfDynamicTables()

std::size_t retdec::fileformat::FileFormat::getNumberOfDynamicTables ( ) const

Get number of dynamic tables in file

Returns
Number ofo dynamic tables in file

◆ getNumberOfNibblesInByte()

std::size_t retdec::fileformat::FileFormat::getNumberOfNibblesInByte ( ) const
overridevirtual

Get number of nibbles in one byte

Returns
Number of nibbles in one byte or zero if this feature is not supported for target architecture of input file.

Supported architectures are defined as enumeration type Architecture.

Implements retdec::utils::ByteValueStorage.

◆ getNumberOfRelocationTables()

std::size_t retdec::fileformat::FileFormat::getNumberOfRelocationTables ( ) const

Get number of relocation tables in file

Returns
Number of relocation tables in file

◆ getNumberOfSections()

std::size_t retdec::fileformat::FileFormat::getNumberOfSections ( ) const

Get number of sections in file

Returns
Number of sections in file

◆ getNumberOfSegments()

std::size_t retdec::fileformat::FileFormat::getNumberOfSegments ( ) const

Get number of segments in file

Returns
Number of segments in file

◆ getNumberOfSymbolTables()

std::size_t retdec::fileformat::FileFormat::getNumberOfSymbolTables ( ) const

Get number of symbol tables in file

Returns
Number of symbol tables in file

◆ getOffsetFromAddress()

bool retdec::fileformat::FileFormat::getOffsetFromAddress ( unsigned long long &  result,
unsigned long long  address 
) const

Convert address to offset

Parameters
resultInto this parameter is stored resulted offset
addressAddress for conversion
Returns
true if address was successfully converted to offset, false otherwise

If method returns false, result is left unchanged

◆ getOverlayEntropy()

bool retdec::fileformat::FileFormat::getOverlayEntropy ( double &  res) const

Get overlay data entropy

Parameters
resVariable to store the result to
Returns
true if entropy calculation succeeded, false otherwise

◆ getOverlaySize()

std::size_t retdec::fileformat::FileFormat::getOverlaySize ( ) const

Get size of overlay. This may be zero. If size of overlay is non-zero, overlay starts at offset which is identical with result of method getDeclaredFileLength().

Returns
Size of overlay

◆ getPathToFile()

std::string retdec::fileformat::FileFormat::getPathToFile ( ) const

Get path to input file

Returns
Path to input file

◆ getPdbInfo()

const PdbInfo * retdec::fileformat::FileFormat::getPdbInfo ( ) const

Get information about related PDB file

Returns
Pointer to information about related PDB file or nullptr if file has no such information

◆ getRelocation() [1/2]

const Relocation * retdec::fileformat::FileFormat::getRelocation ( const std::string &  name) const

Get relocation with name name

Parameters
nameName of relocation to get
Returns
Pointer to relocation with name name or nullptr if such relocation is not found

◆ getRelocation() [2/2]

const Relocation * retdec::fileformat::FileFormat::getRelocation ( unsigned long long  address) const

Get relocation with address address

Parameters
addressAddress of relocation to get
Returns
Pointer to relocation with address address or nullptr if such relocation is not found

◆ getRelocationTable()

const RelocationTable * retdec::fileformat::FileFormat::getRelocationTable ( unsigned long long  tabIndex) const

Get information about relocation table

Parameters
tabIndexIndex of selected relocation table (indexed from 0)
Returns
Pointer to relocation table or nullptr if index of table is invalid

◆ getRelocationTables()

const std::vector< RelocationTable * > & retdec::fileformat::FileFormat::getRelocationTables ( ) const

Get all relocation tables

Returns
Reference to relocation tables

◆ getResourceTable()

const ResourceTable * retdec::fileformat::FileFormat::getResourceTable ( ) const

Get information about resources

Returns
Pointer to resource table or nullptr if file has no resources

◆ getResourceTree()

const ResourceTree * retdec::fileformat::FileFormat::getResourceTree ( ) const

Get information about structure of resource tree

Returns
Pointer to resource tree or nullptr if file has no resources

◆ getRichHeader()

const RichHeader * retdec::fileformat::FileFormat::getRichHeader ( ) const

Get information about rich header

Returns
Pointer to rich header or nullptr if file has no rich header

◆ getSection() [1/2]

const Section * retdec::fileformat::FileFormat::getSection ( const std::string &  secName) const

Get information about section with name secName

Parameters
secNameName of section
Returns
Pointer to section or nullptr if section was not found

If file has more sections with name equal to secName, then is returned first such section.

◆ getSection() [2/2]

const Section * retdec::fileformat::FileFormat::getSection ( unsigned long long  secIndex) const

Get information about section with index secIndex

Parameters
secIndexIndex of section (indexed from 0)
Returns
Pointer to section or nullptr if section was not detected

◆ getSectionFromAddress()

const Section * retdec::fileformat::FileFormat::getSectionFromAddress ( unsigned long long  address) const

Get section which is located at address address

Parameters
addressAddress in memory
Returns
Pointer to section which is located at address address or nullptr if there is no such section

◆ getSectionFromOffset()

const Section * retdec::fileformat::FileFormat::getSectionFromOffset ( unsigned long long  offset) const

Get section which is located at offset offset

Parameters
offsetOffset in file
Returns
Pointer to section which is located at offset offset or nullptr if there is no such section

◆ getSectionOrSegmentFromAddress()

const SecSeg * retdec::fileformat::FileFormat::getSectionOrSegmentFromAddress ( unsigned long long  address) const

Get section (preferentially) or segment (if no section) which is located at address address

Parameters
addressAddress in memory
Returns
Pointer to section or segment which is located at address address or nullptr if there is no such section or segment

◆ getSectionOrSegmentFromOffset()

const SecSeg * retdec::fileformat::FileFormat::getSectionOrSegmentFromOffset ( unsigned long long  offset) const

Get section (preferentially) or segment (if no section) which is located at offset offset

Parameters
offsetOffset in file
Returns
Pointer to section or segment which is located at offset offset or nullptr if there is no such section or segment

◆ getSections() [1/2]

const std::vector< Section * > & retdec::fileformat::FileFormat::getSections ( ) const

Get all sections

Returns
Reference to sections

◆ getSections() [2/2]

const std::vector< Section * > retdec::fileformat::FileFormat::getSections ( std::initializer_list< std::string >  secs) const

Get selected sections

Parameters
secsNames of selected sections
Returns
Selected sections

◆ getSectionTableCrc32()

std::string retdec::fileformat::FileFormat::getSectionTableCrc32 ( ) const

Get section table CRC32

Returns
CRC32 of section table

◆ getSectionTableEntrySize()

std::size_t retdec::fileformat::FileFormat::getSectionTableEntrySize ( ) const
pure virtual

Get size of one record in section table or zero if section table does not exist

Returns
Size of one record in section table

Implemented in retdec::fileformat::RawDataFormat, retdec::fileformat::PeFormat, retdec::fileformat::MachOFormat, retdec::fileformat::IntelHexFormat, retdec::fileformat::ElfFormat, and retdec::fileformat::CoffFormat.

◆ getSectionTableMd5()

std::string retdec::fileformat::FileFormat::getSectionTableMd5 ( ) const

Get section table MD5

Returns
MD5 of section table

◆ getSectionTableOffset()

std::size_t retdec::fileformat::FileFormat::getSectionTableOffset ( ) const
pure virtual

◆ getSectionTableSha256()

std::string retdec::fileformat::FileFormat::getSectionTableSha256 ( ) const

Get section table SHA256

Returns
SHA256 of section table

◆ getSegment() [1/2]

const Segment * retdec::fileformat::FileFormat::getSegment ( const std::string &  segName) const

Get information about segment with name segName

Parameters
segNameName of segment
Returns
Pointer to segment or nullptr if segment was not found

If file has more segments with name equal to segName, then is returned first such segment.

◆ getSegment() [2/2]

const Segment * retdec::fileformat::FileFormat::getSegment ( unsigned long long  segIndex) const

Get information about segment with index segIndex

Parameters
segIndexIndex of segment (indexed from 0)
Returns
Pointer to segment or nullptr if segment was not detected

◆ getSegmentFromAddress()

const Segment * retdec::fileformat::FileFormat::getSegmentFromAddress ( unsigned long long  address) const

Get segment which is located at address address

Parameters
addressAddress in memory
Returns
Pointer to segment which is located at address address or nullptr if there is no such segment

◆ getSegmentFromOffset()

const Segment * retdec::fileformat::FileFormat::getSegmentFromOffset ( unsigned long long  offset) const

Get segment which is located at offset offset

Parameters
offsetOffset in file
Returns
Pointer to segment which is located at offset offset or nullptr if there is no such segment

◆ getSegments() [1/2]

const std::vector< Segment * > & retdec::fileformat::FileFormat::getSegments ( ) const

Get all segments

Returns
Reference to segments

◆ getSegments() [2/2]

const std::vector< Segment * > retdec::fileformat::FileFormat::getSegments ( std::initializer_list< std::string >  segs) const

Get selected segments

Parameters
segsName of selected segments
Returns
Selected segments

◆ getSegmentTableEntrySize()

std::size_t retdec::fileformat::FileFormat::getSegmentTableEntrySize ( ) const
pure virtual

Get size of one record in segment table or zero if segment table does not exist

Returns
Size of one record in segment table

Implemented in retdec::fileformat::RawDataFormat, retdec::fileformat::PeFormat, retdec::fileformat::MachOFormat, retdec::fileformat::IntelHexFormat, retdec::fileformat::ElfFormat, and retdec::fileformat::CoffFormat.

◆ getSegmentTableOffset()

std::size_t retdec::fileformat::FileFormat::getSegmentTableOffset ( ) const
pure virtual

◆ getSha256()

std::string retdec::fileformat::FileFormat::getSha256 ( ) const

Get SHA256

Returns
SHA256 of file content

◆ getString()

bool retdec::fileformat::FileFormat::getString ( std::string &  result,
unsigned long long  offset,
unsigned long long  numberOfBytes 
) const

Get bytes from specified offset as plain string

Parameters
resultParameter for store the result
offsetStart offset for read
numberOfBytesNumber of bytes for read
Returns
Status of operation (true if all is OK)

◆ getStringFromEnd()

bool retdec::fileformat::FileFormat::getStringFromEnd ( std::string &  result,
unsigned long long  numberOfBytes 
) const

Get bytes from end of file as plain string

Parameters
resultParameter for store the result
numberOfBytesNumber of bytes for read
Returns
true if operation went OK, false otherwise

If length of file is smaller than numberOfBytes, as many bytes as possible are read.

◆ getStrings()

const std::vector< String > & retdec::fileformat::FileFormat::getStrings ( ) const

Get all detected strings

Returns
Reference to strings

◆ getSymbol() [1/2]

const Symbol * retdec::fileformat::FileFormat::getSymbol ( const std::string &  name) const

Get symbol with name name

Parameters
nameName of symbol to get
Returns
Pointer to symbol with name name or nullptr if such symbol is not found

◆ getSymbol() [2/2]

const Symbol * retdec::fileformat::FileFormat::getSymbol ( unsigned long long  address) const

Get symbol with address address

Parameters
addressAddress of symbol to get
Returns
Pointer to symbol with address address or nullptr if such symbol is not found

◆ getSymbolTable()

const SymbolTable * retdec::fileformat::FileFormat::getSymbolTable ( unsigned long long  tabIndex) const

Get information about symbol table

Parameters
tabIndexIndex of selected symbol table (indexed from 0)
Returns
Pointer to symbol table or nullptr if index of table is invalid

◆ getSymbolTables()

const std::vector< SymbolTable * > & retdec::fileformat::FileFormat::getSymbolTables ( ) const

Get all symbol tables

Returns
Reference to symbol tables

◆ getTargetArchitecture()

Architecture retdec::fileformat::FileFormat::getTargetArchitecture ( ) const
pure virtual

◆ getTlsInfo()

const TlsInfo * retdec::fileformat::FileFormat::getTlsInfo ( ) const

Get information about TLS

Returns
Pointer to TLS information or nullptr if file has no certificates

◆ getUnknownRelocations()

const std::set< std::uint64_t > & retdec::fileformat::FileFormat::getUnknownRelocations ( ) const

◆ getVersionResource()

const Resource * retdec::fileformat::FileFormat::getVersionResource ( ) const

Get resource that represents version information

Returns
Pointer to version resource or nullptr if such resource is not found

◆ getWordLength()

std::size_t retdec::fileformat::FileFormat::getWordLength ( ) const
overridevirtual

Get number of bits in one word

Returns
Number of bits in one word or zero if this feature is not supported for target architecture of input file.

Supported architectures are defined as enumeration type Architecture.

Implements retdec::utils::ByteValueStorage.

◆ getWordOffset()

bool retdec::fileformat::FileFormat::getWordOffset ( std::uint64_t  offset,
std::uint64_t &  res,
retdec::utils::Endianness  e = retdec::utils::Endianness::UNKNOWN 
) const

Get word located at provided offset using the specified endian or default file endian

Parameters
offsetOffset to get integer from
resResult integer
eEndian - if specified it is forced, otherwise file's endian is used
Returns
Status of operation (true if all is OK, false otherwise)

◆ getXByte()

bool retdec::fileformat::FileFormat::getXByte ( std::uint64_t  address,
std::uint64_t  x,
std::uint64_t &  res,
retdec::utils::Endianness  e = retdec::utils::Endianness::UNKNOWN 
) const
overridevirtual

Get integer (x bytes) located at provided address using the specified endian or default file endian

Parameters
addressAddress to get integer from
xNumber of bytes for conversion
resResult integer
eEndian - if specified it is forced, otherwise file's endian is used
Returns
Status of operation (true if all is OK, false otherwise)

Implements retdec::utils::ByteValueStorage.

◆ getXByteOffset()

bool retdec::fileformat::FileFormat::getXByteOffset ( std::uint64_t  offset,
std::uint64_t  x,
std::uint64_t &  res,
retdec::utils::Endianness  e = retdec::utils::Endianness::UNKNOWN 
) const

Get integer (x bytes) located at provided offset using the specified endian or default file endian

Parameters
offsetOffset to get integer from
xNumber of bytes for conversion
resResult integer
eEndian - if specified it is forced, otherwise file's endian is used
Returns
Status of operation (true if all is OK, false otherwise)

◆ getXBytes()

bool retdec::fileformat::FileFormat::getXBytes ( std::uint64_t  address,
std::uint64_t  x,
std::vector< std::uint8_t > &  res 
) const
overridevirtual

Get x bytes long byte array from specified address

Parameters
addressAddress to get array from
xNumber of bytes for get
resResult array
Returns
Status of operation (true if all is OK, false otherwise)

Implements retdec::utils::ByteValueStorage.

◆ getXBytesOffset()

bool retdec::fileformat::FileFormat::getXBytesOffset ( std::uint64_t  offset,
std::uint64_t  x,
std::vector< std::uint8_t > &  res 
) const

Get x bytes long byte array from specified offset

Parameters
offsetOffset to get array from
xNumber of bytes for get
resResult array
Returns
Status of operation (true if all is OK, false otherwise)

◆ hasCrc32()

bool retdec::fileformat::FileFormat::hasCrc32 ( ) const

Check if CRC32 was computed

Returns
true if CRC32 was computed, false otherwise

◆ hasMd5()

bool retdec::fileformat::FileFormat::hasMd5 ( ) const

Check if MD5 was computed

Returns
true if MD5 was computed, false otherwise

◆ hasSectionTableCrc32()

bool retdec::fileformat::FileFormat::hasSectionTableCrc32 ( ) const

Check if CRC32 of section table was computed

Returns
true if CRC32 of section table was computed, false otherwise

◆ hasSectionTableMd5()

bool retdec::fileformat::FileFormat::hasSectionTableMd5 ( ) const

Check if MD5 of section table was computed

Returns
true if MD5 of section table was computed, false otherwise

◆ hasSectionTableSha256()

bool retdec::fileformat::FileFormat::hasSectionTableSha256 ( ) const

Check if SHA256 of section table was computed

Returns
true if SHA256 of section table was computed, false otherwise

◆ hasSha256()

bool retdec::fileformat::FileFormat::hasSha256 ( ) const

Check if SHA256 was computed

Returns
true if SHA256 was computed, false otherwise

◆ haveDataOnAddress()

bool retdec::fileformat::FileFormat::haveDataOnAddress ( unsigned long long  address) const

Test if there are some data on provided address – address belongs to some section or segment

Parameters
addressAddress to test
Returns
true if there are data for address, false otherwise
Note
This will return false if address is in BSS section.

◆ haveDataOnOffset()

bool retdec::fileformat::FileFormat::haveDataOnOffset ( unsigned long long  offset) const

Test if there are some data on provided offset – offset belongs to some section or segment.

Parameters
offsetOffset to test
Returns
true if there are data for offset, false otherwise
Note
This will return false if offset is in BSS section.

◆ haveReadOnlyDataOnAddress()

bool retdec::fileformat::FileFormat::haveReadOnlyDataOnAddress ( unsigned long long  address) const

Test if there are some read-only data on provided address – address belongs to some read-only section or segment.

Parameters
addressAddress to test
Returns
True if there are read-only data for address, false otherwise
Note
This will return false if address is in BSS or debug section.

◆ haveSectionOrSegmentOnAddress()

bool retdec::fileformat::FileFormat::haveSectionOrSegmentOnAddress ( unsigned long long  address) const

Test if the given address in valid section or segment

Parameters
addressAddress to test
Returns
true if address is valid, false otherwise

◆ haveSectionOrSegmentOnOffset()

bool retdec::fileformat::FileFormat::haveSectionOrSegmentOnOffset ( unsigned long long  offset) const

Test if the given offset in valid section or segment

Parameters
offsetOffset to test
Returns
true if offset is valid, false otherwise

◆ init()

void retdec::fileformat::FileFormat::init ( )
private

Init internal structures

◆ initArchitecture()

void retdec::fileformat::FileFormat::initArchitecture ( Architecture  arch,
retdec::utils::Endianness  endian = retdec::utils::Endianness::UNKNOWN,
std::size_t  bytesPerWord = 4,
retdec::common::Address  entryPoint = retdec::common::Address::Undefined,
retdec::common::Address  sectionVMA = retdec::common::Address::Undefined 
)

If fileformat is Intel HEX or raw binary then it does not contain critical information like architecture, endianness or std::uint16_t size. However, fileformat users expect it to contain this information. Therefore, this method needs to be called to set these critical information.

◆ initSectionTableHashOffsets()

std::size_t retdec::fileformat::FileFormat::initSectionTableHashOffsets ( )
privatepure virtual

Init offsets for calculation of section table hashes

Returns
Number of offsets in offsets vector after initialization

Implemented in retdec::fileformat::RawDataFormat, retdec::fileformat::PeFormat, retdec::fileformat::MachOFormat, retdec::fileformat::IntelHexFormat, retdec::fileformat::ElfFormat, and retdec::fileformat::CoffFormat.

◆ initStream()

void retdec::fileformat::FileFormat::initStream ( )
private

Initialize internal state of member fileStream

◆ isArm()

bool retdec::fileformat::FileFormat::isArm ( ) const

Find out if target architecture is ARM

Returns
true if target architecture is ARM, false otherwise

◆ isCoff()

bool retdec::fileformat::FileFormat::isCoff ( ) const

Find out if file format is COFF

Returns
true if file format is COFF, false otherwise

◆ isDll()

bool retdec::fileformat::FileFormat::isDll ( ) const
pure virtual

◆ isElf()

bool retdec::fileformat::FileFormat::isElf ( ) const

Find out if file format is ELF

Returns
true if file format is ELF, false otherwise

◆ isExecutable()

bool retdec::fileformat::FileFormat::isExecutable ( ) const
pure virtual

◆ isIntelHex()

bool retdec::fileformat::FileFormat::isIntelHex ( ) const

Find out if file format is Intel HEX

Returns
true if file format is Intel HEX, false otherwise

◆ isInValidState()

bool retdec::fileformat::FileFormat::isInValidState ( ) const

Getter for state of instance

Returns
true if all is OK, false otherwise

◆ isMacho()

bool retdec::fileformat::FileFormat::isMacho ( ) const

Find out if file format is Macho

Returns
true if file format is Macho, false otherwise

◆ isMips()

bool retdec::fileformat::FileFormat::isMips ( ) const

Find out if target architecture is MIPS

Returns
true if target architecture is MIPS, false otherwise

◆ isObjectFile()

bool retdec::fileformat::FileFormat::isObjectFile ( ) const
pure virtual

◆ isObjectStretchedOverSections()

bool retdec::fileformat::FileFormat::isObjectStretchedOverSections ( std::size_t  addr,
std::size_t  size 
) const

Find out if object is stretched over multiple sections

Parameters
addrAddres of object
sizeObject size
Returns
true if object is stretched over multiple sections, false otherwise

◆ isPe()

bool retdec::fileformat::FileFormat::isPe ( ) const

Find out if file format is PE

Returns
true if file format is PE, false otherwise

◆ isPointer()

bool retdec::fileformat::FileFormat::isPointer ( unsigned long long  address,
std::uint64_t *  pointer = nullptr 
) const

Find out, if there is a pointer (valid address) on the provided address

Parameters
addressAddress to check
[out]pointerIf provided (not nullptr) it is filled with pointer's value on the provided address
Returns
true if pointer on address, false otherwise

◆ isPowerPc()

bool retdec::fileformat::FileFormat::isPowerPc ( ) const

Find out if target architecture is PowerPC

Returns
true if target architecture is PowerPC, false otherwise

◆ isRawData()

bool retdec::fileformat::FileFormat::isRawData ( ) const

Find out if file format is Raw Data

Returns
true if file format is Raw Data, false otherwise

◆ isSignaturePresent()

bool retdec::fileformat::FileFormat::isSignaturePresent ( ) const

Get whether the signature is present in the file

Returns
true if present, otherwise false.

◆ isSignatureVerified()

bool retdec::fileformat::FileFormat::isSignatureVerified ( ) const

Get whether the signature is verified

Returns
true if present, otherwise false.

◆ isUnknownArch()

bool retdec::fileformat::FileFormat::isUnknownArch ( ) const

Find out if target architecture is unknown

Returns
true if target architecture is unknown, false otherwise

◆ isUnknownFormat()

bool retdec::fileformat::FileFormat::isUnknownFormat ( ) const

Find out if file format is unknown

Returns
true if file format is unknown, false otherwise

◆ isWindowsDriver()

bool retdec::fileformat::FileFormat::isWindowsDriver ( ) const

Find out if file is Windows driver

Returns
true if binary is PE windows driver – it imports certain libs, false otherwise

◆ isX86()

bool retdec::fileformat::FileFormat::isX86 ( ) const

Find out if target architecture is x86

Returns
true if target architecture is x86, false otherwise

◆ isX86_64()

bool retdec::fileformat::FileFormat::isX86_64 ( ) const

Find out if target architecture is x86_64

Returns
true if target architecture is x86_64, false otherwise

◆ isX86OrX86_64()

bool retdec::fileformat::FileFormat::isX86OrX86_64 ( ) const

Find out if target architecture is x86 or x86_64

Returns
true if target architecture is x86 or x86_64, false otherwise

◆ loadExpHash()

void retdec::fileformat::FileFormat::loadExpHash ( )

Loads exphash from export table.

◆ loadImpHash()

void retdec::fileformat::FileFormat::loadImpHash ( )

Loads imphash from import table.

◆ loadResourceIconHash()

void retdec::fileformat::FileFormat::loadResourceIconHash ( )

Loads iconhash from resource table.

◆ loadStrings() [1/3]

void retdec::fileformat::FileFormat::loadStrings ( )

Load strings from data sections

◆ loadStrings() [2/3]

void retdec::fileformat::FileFormat::loadStrings ( StringType  type,
std::size_t  charSize 
)

Load strings of specified type and with specified character size.

Parameters
typeType of the strings.
charSizeCharacter size.

◆ loadStrings() [3/3]

void retdec::fileformat::FileFormat::loadStrings ( StringType  type,
std::size_t  charSize,
const SecSeg secSeg 
)

◆ nibblesFromBytes()

std::size_t retdec::fileformat::FileFormat::nibblesFromBytes ( std::size_t  bytes) const

Count number of nibbles from number of bytes

Parameters
bytesNumber of bytes
Returns
Number of nibbles

◆ setLoadedBytes()

void retdec::fileformat::FileFormat::setLoadedBytes ( std::vector< unsigned char > *  lBytes)
protected

Set pointer to loaded serialized bytes of input file. In binary file formats (e.g. ELF, PE, COFF) it is not necessary to call this method. In text file formats (e.g. Intel HEX) it is necessary to call this method.

Parameters
lBytesPointer to serialized bytes

◆ setXByte()

bool retdec::fileformat::FileFormat::setXByte ( std::uint64_t  address,
std::uint64_t  x,
std::uint64_t  val,
retdec::utils::Endianness  e = retdec::utils::Endianness::UNKNOWN 
)
overridevirtual

◆ setXBytes()

bool retdec::fileformat::FileFormat::setXBytes ( std::uint64_t  address,
const std::vector< std::uint8_t > &  val 
)
overridevirtual

Member Data Documentation

◆ _ldrErrInfo

LoaderErrorInfo retdec::fileformat::FileFormat::_ldrErrInfo
protected

loader error (e.g. Windows loader error for PE files)

◆ anomalies

std::vector<std::pair<std::string, std::string> > retdec::fileformat::FileFormat::anomalies
protected

file format anomalies

◆ auxBuff

byte_array_buffer retdec::fileformat::FileFormat::auxBuff
private

auxiliary input buffer

◆ auxFStream

std::ifstream retdec::fileformat::FileFormat::auxFStream
private

auxiliary input file stream

◆ auxIStream

std::istream retdec::fileformat::FileFormat::auxIStream
private

auxiliary input stream

◆ bytes

std::vector<unsigned char> retdec::fileformat::FileFormat::bytes
protected

content of file as bytes

◆ certificateTable

CertificateTable* retdec::fileformat::FileFormat::certificateTable
protected

table of certificates

◆ crc32

std::string retdec::fileformat::FileFormat::crc32
protected

CRC32 of file content.

◆ dynamicTables

std::vector<DynamicTable*> retdec::fileformat::FileFormat::dynamicTables
protected

tables with dynamic records

◆ elfCoreInfo

ElfCoreInfo* retdec::fileformat::FileFormat::elfCoreInfo
protected

information about core file structures

◆ exportTable

ExportTable* retdec::fileformat::FileFormat::exportTable
protected

table of exports

◆ fileFormat

Format retdec::fileformat::FileFormat::fileFormat
protected

format of input file

◆ filePath

std::string retdec::fileformat::FileFormat::filePath
protected

name of input file

◆ fileStream

std::istream& retdec::fileformat::FileFormat::fileStream
protected

stream representation of input file

◆ importTable

ImportTable* retdec::fileformat::FileFormat::importTable
protected

table of imports

◆ loadedBytes

std::vector<unsigned char>* retdec::fileformat::FileFormat::loadedBytes
private

reference to serialized content of input file

◆ loadFlags

LoadFlags retdec::fileformat::FileFormat::loadFlags
private

load flags for configurable file loading

◆ md5

std::string retdec::fileformat::FileFormat::md5
protected

MD5 of file content.

◆ nonDecodableRanges

retdec::common::RangeContainer<std::uint64_t> retdec::fileformat::FileFormat::nonDecodableRanges
protected

Address ranges which should not be decoded for instructions.

◆ noteSecSegs

std::vector<ElfNoteSecSeg> retdec::fileformat::FileFormat::noteSecSegs
protected

note sections or segemnts found in ELF file

◆ pdbInfo

PdbInfo* retdec::fileformat::FileFormat::pdbInfo
protected

information about related PDB debug file

◆ relocationTables

std::vector<RelocationTable*> retdec::fileformat::FileFormat::relocationTables
protected

relocation tables

◆ resourceTable

ResourceTable* retdec::fileformat::FileFormat::resourceTable
protected

table of resources

◆ resourceTree

ResourceTree* retdec::fileformat::FileFormat::resourceTree
protected

structure of resource tree

◆ richHeader

RichHeader* retdec::fileformat::FileFormat::richHeader
protected

rich header

◆ secHashInfo

std::vector<std::pair<std::size_t, std::size_t> > retdec::fileformat::FileFormat::secHashInfo
protected

information for calculation of section table hash

◆ sectionCrc32

std::string retdec::fileformat::FileFormat::sectionCrc32
protected

CRC32 of section table.

◆ sectionMd5

std::string retdec::fileformat::FileFormat::sectionMd5
protected

MD5 of section table.

◆ sections

std::vector<Section*> retdec::fileformat::FileFormat::sections
protected

file sections

◆ sectionSha256

std::string retdec::fileformat::FileFormat::sectionSha256
protected

SHA256 of section table.

◆ segments

std::vector<Segment*> retdec::fileformat::FileFormat::segments
protected

file segments

◆ sha256

std::string retdec::fileformat::FileFormat::sha256
protected

SHA256 of file content.

◆ signatureVerified

std::optional<bool> retdec::fileformat::FileFormat::signatureVerified
protected

indicates whether the signature is present and also verified

◆ stateIsValid

bool retdec::fileformat::FileFormat::stateIsValid
protected

internal state of instance

◆ strings

std::vector<String> retdec::fileformat::FileFormat::strings
protected

detected strings

◆ symbolTables

std::vector<SymbolTable*> retdec::fileformat::FileFormat::symbolTables
protected

symbol tables

◆ tlsInfo

TlsInfo* retdec::fileformat::FileFormat::tlsInfo
protected

thread-local information

◆ unknownRelocs

std::set<std::uint64_t> retdec::fileformat::FileFormat::unknownRelocs
protected

unknown relocations


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