retdec
Private Types | Private Member Functions | Private Attributes | List of all members
retdec::fileformat::ResourceTable Class Reference

#include <resource_table.h>

Collaboration diagram for retdec::fileformat::ResourceTable:
Collaboration graph
[legend]

Public Member Functions

Getters
std::size_t getNumberOfResources () const
 
std::size_t getNumberOfLanguages () const
 
std::size_t getNumberOfStrings () const
 
std::size_t getSizeInFile () const
 
std::size_t getLoadedSize () const
 
const ResourcegetResource (std::size_t rIndex) const
 
const std::pair< std::string, std::string > * getLanguage (std::size_t rIndex) const
 
const std::pair< std::string, std::string > * getString (std::size_t rIndex) const
 
const ResourcegetResourceWithName (const std::string &rName) const
 
const ResourcegetResourceWithName (std::size_t rId) const
 
const ResourcegetResourceWithType (const std::string &rType) const
 
const ResourcegetResourceWithType (std::size_t rId) const
 
const ResourcegetResourceWithLanguage (const std::string &rLan) const
 
const ResourcegetResourceWithLanguage (std::size_t rId) const
 
const std::string & getResourceIconhashCrc32 () const
 
const std::string & getResourceIconhashMd5 () const
 
const std::string & getResourceIconhashSha256 () const
 
const std::string & getResourceIconPerceptualAvgHash () const
 
const ResourceIconGroupgetPriorResourceIconGroup () const
 
Iterators
resourcesIterator begin () const
 
resourcesIterator end () const
 
Other methods
void computeIconHashes ()
 
void parseVersionInfoResources ()
 
void clear ()
 
void addResource (std::unique_ptr< Resource > &&newResource)
 
void addResourceVersion (Resource *ver)
 
void addResourceIcon (ResourceIcon *icon)
 
void addResourceIconGroup (ResourceIconGroup *iGroup)
 
void linkResourceIconGroups ()
 
bool hasResources () const
 
bool hasResourceWithName (const std::string &rName) const
 
bool hasResourceWithName (std::size_t rId) const
 
bool hasResourceWithType (const std::string &rType) const
 
bool hasResourceWithType (std::size_t rId) const
 
bool hasResourceWithLanguage (const std::string &rLan) const
 
bool hasResourceWithLanguage (std::size_t rId) const
 
void dump (std::string &dumpTable) const
 

Private Types

using resourcesIterator = std::vector< std::unique_ptr< Resource > >::const_iterator
 

Private Member Functions

std::string computePerceptualAvgHash (const ResourceIcon &icon) const
 
bool parseVersionInfo (const std::vector< std::uint8_t > &bytes)
 
bool parseVersionInfoChild (const std::vector< std::uint8_t > &bytes, std::size_t &offset)
 
bool parseVarFileInfoChild (const std::vector< std::uint8_t > &bytes, std::size_t &offset)
 
bool parseStringFileInfoChild (const std::vector< std::uint8_t > &bytes, std::size_t &offset)
 
bool parseVarString (const std::vector< std::uint8_t > &bytes, std::size_t &offset)
 

Private Attributes

std::vector< std::unique_ptr< Resource > > table
 stored resources More...
 
std::vector< Resource * > resourceVersions
 version info resources More...
 
std::vector< ResourceIconGroup * > iconGroups
 icon groups More...
 
std::vector< ResourceIcon * > icons
 icons More...
 
std::vector< std::pair< std::string, std::string > > languages
 supported languages, LCID and code page More...
 
std::vector< std::pair< std::string, std::string > > strings
 version info strings More...
 
std::string iconHashCrc32
 iconhash CRC32 More...
 
std::string iconHashMd5
 iconhash MD5 More...
 
std::string iconHashSha256
 iconhash SHA256 More...
 
std::string iconPerceptualAvgHash
 icon perceptual hash AvgHash More...
 

Detailed Description

Table of resources

Member Typedef Documentation

◆ resourcesIterator

using retdec::fileformat::ResourceTable::resourcesIterator = std::vector<std::unique_ptr<Resource> >::const_iterator
private

Member Function Documentation

◆ addResource()

void retdec::fileformat::ResourceTable::addResource ( std::unique_ptr< Resource > &&  newResource)

Add resource

Parameters
newResourceResource which will be added

◆ addResourceIcon()

void retdec::fileformat::ResourceTable::addResourceIcon ( ResourceIcon icon)

Add icon

Parameters
iconIcon which will be added

◆ addResourceIconGroup()

void retdec::fileformat::ResourceTable::addResourceIconGroup ( ResourceIconGroup iGroup)

Add icon group

Parameters
iGroupIcon group which will be added

◆ addResourceVersion()

void retdec::fileformat::ResourceTable::addResourceVersion ( Resource ver)

Add version resource

Parameters
verVersion resource which will be added

◆ begin()

ResourceTable::resourcesIterator retdec::fileformat::ResourceTable::begin ( ) const

Get begin iterator

Returns
Begin iterator

◆ clear()

void retdec::fileformat::ResourceTable::clear ( )

Delete all records from table

◆ computeIconHashes()

void retdec::fileformat::ResourceTable::computeIconHashes ( )

Compute icon hashes - CRC32, MD5, SHA256.

◆ computePerceptualAvgHash()

std::string retdec::fileformat::ResourceTable::computePerceptualAvgHash ( const ResourceIcon icon) const
private

Compute icon perceptual hashes

Parameters
iconIcon to compute the hash of
Returns
Perceptual hash as AvgHash

◆ dump()

void retdec::fileformat::ResourceTable::dump ( std::string &  dumpTable) const

Dump information about all resources in table

Parameters
dumpTableInto this parameter is stored dump of table in an LLVM style

◆ end()

ResourceTable::resourcesIterator retdec::fileformat::ResourceTable::end ( ) const

Get end iterator

Returns
End iterator

◆ getLanguage()

const std::pair< std::string, std::string > * retdec::fileformat::ResourceTable::getLanguage ( std::size_t  rIndex) const

Get selected language

Parameters
rIndexIndex of selected language (indexed from 0)
Returns
Pointer to selected language or nullptr if language index is invalid

◆ getLoadedSize()

std::size_t retdec::fileformat::ResourceTable::getLoadedSize ( ) const

Get total loaded size of resources

Returns
Total loaded size of resources

◆ getNumberOfLanguages()

std::size_t retdec::fileformat::ResourceTable::getNumberOfLanguages ( ) const

Get number of supported languages

Returns
Number of supported languages

◆ getNumberOfResources()

std::size_t retdec::fileformat::ResourceTable::getNumberOfResources ( ) const

Get number of stored resources

Returns
Number of stored resources

◆ getNumberOfStrings()

std::size_t retdec::fileformat::ResourceTable::getNumberOfStrings ( ) const

Get number of strings

Returns
Number of strings

◆ getPriorResourceIconGroup()

const ResourceIconGroup * retdec::fileformat::ResourceTable::getPriorResourceIconGroup ( ) const

Get prior icon group

Returns
Prior icon group

◆ getResource()

const Resource * retdec::fileformat::ResourceTable::getResource ( std::size_t  rIndex) const

Get selected resource

Parameters
rIndexIndex of selected resource (indexed from 0)
Returns
Pointer to selected resource or nullptr if resource index is invalid

◆ getResourceIconhashCrc32()

const std::string & retdec::fileformat::ResourceTable::getResourceIconhashCrc32 ( ) const

Get iconhash as CRC32

Returns
Iconhash as CRC32

◆ getResourceIconhashMd5()

const std::string & retdec::fileformat::ResourceTable::getResourceIconhashMd5 ( ) const

Get iconhash as MD5

Returns
Iconhash as MD5

◆ getResourceIconhashSha256()

const std::string & retdec::fileformat::ResourceTable::getResourceIconhashSha256 ( ) const

Get iconhash as SHA256

Returns
Iconhash as SHA256

◆ getResourceIconPerceptualAvgHash()

const std::string & retdec::fileformat::ResourceTable::getResourceIconPerceptualAvgHash ( ) const

Get icon perceptual hash as AvgHash

Returns
Icon perceptual hash as AvgHash

◆ getResourceWithLanguage() [1/2]

const Resource * retdec::fileformat::ResourceTable::getResourceWithLanguage ( const std::string &  rLan) const

Get resource by language

Parameters
rLanLanguage of the resource to get
Returns
Pointer to resource with the specified language or nullptr if such resource not found

◆ getResourceWithLanguage() [2/2]

const Resource * retdec::fileformat::ResourceTable::getResourceWithLanguage ( std::size_t  rId) const

Get resource by language ID

Parameters
rIdLanguage ID of the resource to get
Returns
Pointer to resource with specified language ID or nullptr if such resource not found

◆ getResourceWithName() [1/2]

const Resource * retdec::fileformat::ResourceTable::getResourceWithName ( const std::string &  rName) const

Get resource by name

Parameters
rNameName of the resource to get
Returns
Pointer to resource with the specified name or nullptr if such resource not found

◆ getResourceWithName() [2/2]

const Resource * retdec::fileformat::ResourceTable::getResourceWithName ( std::size_t  rId) const

Get resource by name ID

Parameters
rIdName ID of the resource to get
Returns
Pointer to resource with specified name ID or nullptr if such resource not found

◆ getResourceWithType() [1/2]

const Resource * retdec::fileformat::ResourceTable::getResourceWithType ( const std::string &  rType) const

Get resource by type

Parameters
rTypeType of the resource to get
Returns
Pointer to resource with the specified type or nullptr if such resource not found

◆ getResourceWithType() [2/2]

const Resource * retdec::fileformat::ResourceTable::getResourceWithType ( std::size_t  rId) const

Get resource by type ID

Parameters
rIdType ID of the resource to get
Returns
Pointer to resource with specified type ID or nullptr if such resource not found

◆ getSizeInFile()

std::size_t retdec::fileformat::ResourceTable::getSizeInFile ( ) const

Get total declared size of resources

Returns
Total declared size of resources

◆ getString()

const std::pair< std::string, std::string > * retdec::fileformat::ResourceTable::getString ( std::size_t  rIndex) const

Get selected string

Parameters
rIndexIndex of selected string (indexed from 0)
Returns
Pointer to selected string or nullptr if string index is invalid

◆ hasResources()

bool retdec::fileformat::ResourceTable::hasResources ( ) const

Find out if there are any resources

Returns
true if there are some resources, false otherwise

◆ hasResourceWithLanguage() [1/2]

bool retdec::fileformat::ResourceTable::hasResourceWithLanguage ( const std::string &  rLan) const

Check if resource with language rLan exists

Parameters
rLanLanguage of resource
Returns
true if has resource with language rLan, false otherwise

◆ hasResourceWithLanguage() [2/2]

bool retdec::fileformat::ResourceTable::hasResourceWithLanguage ( std::size_t  rId) const

Check if resource with language ID rId exists

Parameters
rIdLanguage ID of resource
Returns
true if has resource with language ID rId, false otherwise

◆ hasResourceWithName() [1/2]

bool retdec::fileformat::ResourceTable::hasResourceWithName ( const std::string &  rName) const

Check if resource with name rName exists

Parameters
rNameName of resource
Returns
true if has resource with name rName, false otherwise

◆ hasResourceWithName() [2/2]

bool retdec::fileformat::ResourceTable::hasResourceWithName ( std::size_t  rId) const

Check if resource with name ID rId exists

Parameters
rIdName ID of resource
Returns
true if has resource with name ID rId, false otherwise

◆ hasResourceWithType() [1/2]

bool retdec::fileformat::ResourceTable::hasResourceWithType ( const std::string &  rType) const

Check if resource with type rType exists

Parameters
rTypeType of resource
Returns
true if has resource with type rType, false otherwise

◆ hasResourceWithType() [2/2]

bool retdec::fileformat::ResourceTable::hasResourceWithType ( std::size_t  rId) const

Check if resource with type ID rId exists

Parameters
rIdType ID of resource
Returns
true if has resource with type ID rId, false otherwise

◆ linkResourceIconGroups()

void retdec::fileformat::ResourceTable::linkResourceIconGroups ( )

Link resource icon group with referenced icons and set icon properties

◆ parseStringFileInfoChild()

bool retdec::fileformat::ResourceTable::parseStringFileInfoChild ( const std::vector< std::uint8_t > &  bytes,
std::size_t &  offset 
)
private

Parse StringFileInfo child

Parameters
bytesResource bytes
offsetOffset to structure
Returns
true if parsing was successful, false otherwise

◆ parseVarFileInfoChild()

bool retdec::fileformat::ResourceTable::parseVarFileInfoChild ( const std::vector< std::uint8_t > &  bytes,
std::size_t &  offset 
)
private

Parse VarFileInfo structure

Parameters
bytesResource bytes
offsetOffset to structure
Returns
true if parsing was successful, false otherwise

◆ parseVarString()

bool retdec::fileformat::ResourceTable::parseVarString ( const std::vector< std::uint8_t > &  bytes,
std::size_t &  offset 
)
private

Parse var string

Parameters
bytesResource bytes
offsetOffset to structure
Returns
true if parsing was successful, false otherwise

◆ parseVersionInfo()

bool retdec::fileformat::ResourceTable::parseVersionInfo ( const std::vector< std::uint8_t > &  bytes)
private

Parse version information

Parameters
bytesResource bytes
Returns
true if parsing was successful, false otherwise

◆ parseVersionInfoChild()

bool retdec::fileformat::ResourceTable::parseVersionInfoChild ( const std::vector< std::uint8_t > &  bytes,
std::size_t &  offset 
)
private

Parse Version Info child

Parameters
bytesResource bytes
offsetOffset to Version Info Child structure
Returns
true if parsing was successful, false otherwise

◆ parseVersionInfoResources()

void retdec::fileformat::ResourceTable::parseVersionInfoResources ( )

Parse all version information resources

Member Data Documentation

◆ iconGroups

std::vector<ResourceIconGroup *> retdec::fileformat::ResourceTable::iconGroups
private

icon groups

◆ iconHashCrc32

std::string retdec::fileformat::ResourceTable::iconHashCrc32
private

iconhash CRC32

◆ iconHashMd5

std::string retdec::fileformat::ResourceTable::iconHashMd5
private

iconhash MD5

◆ iconHashSha256

std::string retdec::fileformat::ResourceTable::iconHashSha256
private

iconhash SHA256

◆ iconPerceptualAvgHash

std::string retdec::fileformat::ResourceTable::iconPerceptualAvgHash
private

icon perceptual hash AvgHash

◆ icons

std::vector<ResourceIcon *> retdec::fileformat::ResourceTable::icons
private

icons

◆ languages

std::vector<std::pair<std::string, std::string> > retdec::fileformat::ResourceTable::languages
private

supported languages, LCID and code page

◆ resourceVersions

std::vector<Resource *> retdec::fileformat::ResourceTable::resourceVersions
private

version info resources

◆ strings

std::vector<std::pair<std::string, std::string> > retdec::fileformat::ResourceTable::strings
private

version info strings

◆ table

std::vector<std::unique_ptr<Resource> > retdec::fileformat::ResourceTable::table
private

stored resources


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