retdec
Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
PeLib::ResourceLeaf Class Reference

ResourceLeafs represent the leafs of the resource tree: The actual resources. More...

#include <ResourceDirectory.h>

Inheritance diagram for PeLib::ResourceLeaf:
Inheritance graph
[legend]
Collaboration diagram for PeLib::ResourceLeaf:
Collaboration graph
[legend]

Public Member Functions

bool isLeaf () const
 Indicates if the resource element is a leaf or a node. More...
 
void makeValid ()
 Corrects erroneous values in the ResourceLeaf. More...
 
std::vector< std::uint8_t > getData () const
 Returns the resource data of this resource leaf. More...
 
void setData (const std::vector< std::uint8_t > &vData)
 Sets the resource data of this resource leaf. More...
 
std::uint32_t getOffsetToData () const
 Returns the OffsetToData value of this resource leaf. More...
 
std::uint32_t getSize () const
 Returns the Size value of this resource leaf. More...
 
std::uint32_t getCodePage () const
 Returns the CodePage value of this resource leaf. More...
 
std::uint32_t getReserved () const
 Returns the Reserved value of this resource leaf. More...
 
void setOffsetToData (std::uint32_t dwValue)
 Sets the OffsetToData value of this resource leaf. More...
 
void setSize (std::uint32_t dwValue)
 Sets the Size value of this resource leaf. More...
 
void setCodePage (std::uint32_t dwValue)
 Sets the CodePage value of this resource leaf. More...
 
void setReserved (std::uint32_t dwValue)
 Sets the Reserved value of this resource leaf. More...
 
 ResourceLeaf ()
 Constructor. More...
 
virtual ~ResourceLeaf () override
 Destructor. More...
 
- Public Member Functions inherited from PeLib::ResourceElement
unsigned int getElementRva () const
 Returns the RVA of the element in the file. More...
 
 ResourceElement ()
 Returns the size of a resource element. More...
 
virtual ~ResourceElement ()
 Necessary virtual destructor. More...
 

Protected Member Functions

int read (ImageLoader &imageLoader, std::uint32_t uiRsrcRva, std::uint32_t uiOffset, std::uint32_t sizeOfImage, ResourceDirectory *resDir)
 
void rebuild (OutputBuffer &, unsigned int uiOffset, unsigned int uiRva, const std::string &) const
 Writes the next resource leaf into the OutputBuffer. More...
 
virtual void recalculate (unsigned int &uiCurrentOffset, unsigned int uiNewRva) override
 Recalculates the tree for different RVA. More...
 

Private Attributes

std::vector< std::uint8_t > m_data
 The resource data. More...
 
PELIB_IMAGE_RESOURCE_DATA_ENTRY entry
 PeLib equivalent of the Win32 structure IMAGE_RESOURCE_DATA_ENTRY. More...
 

Friends

class ResourceChild
 
class ResourceDirectory
 
template<typename T >
struct fixNumberOfEntries
 

Additional Inherited Members

- Protected Attributes inherited from PeLib::ResourceElement
unsigned int uiElementRva
 Stores RVA of the resource element in the file. More...
 

Detailed Description

ResourceLeafs represent the leafs of the resource tree: The actual resources.

Constructor & Destructor Documentation

◆ ResourceLeaf()

PeLib::ResourceLeaf::ResourceLeaf ( )

Constructor.

◆ ~ResourceLeaf()

PeLib::ResourceLeaf::~ResourceLeaf ( )
overridevirtual

Destructor.

Member Function Documentation

◆ getCodePage()

std::uint32_t PeLib::ResourceLeaf::getCodePage ( ) const

Returns the CodePage value of this resource leaf.

Returns the leaf's CodePage value.

Returns
The leaf's CodePage value.

◆ getData()

std::vector< std::uint8_t > PeLib::ResourceLeaf::getData ( ) const

Returns the resource data of this resource leaf.

Reads the next resource leaf from the InputBuffer. Returns the size of a resource lead.

Returns a vector that contains the raw data of a resource leaf.

Returns
Raw data of the resource.

◆ getOffsetToData()

std::uint32_t PeLib::ResourceLeaf::getOffsetToData ( ) const

Returns the OffsetToData value of this resource leaf.

Returns the leaf's OffsetToData value. That's the RVA where the raw data of the resource can be found.

Returns
The leaf's OffsetToData value.

◆ getReserved()

std::uint32_t PeLib::ResourceLeaf::getReserved ( ) const

Returns the Reserved value of this resource leaf.

Returns the leaf's Reserved value.

Returns
The leaf's Reserved value.

◆ getSize()

std::uint32_t PeLib::ResourceLeaf::getSize ( ) const

Returns the Size value of this resource leaf.

Returns the leaf's Size value. That's the size of the raw data of the resource.

Returns
The leaf's Size value.

◆ isLeaf()

bool PeLib::ResourceLeaf::isLeaf ( ) const
virtual

Indicates if the resource element is a leaf or a node.

Checks if a ResourceElement is a leaf or not.

Returns
Always returns true.

Implements PeLib::ResourceElement.

◆ makeValid()

void PeLib::ResourceLeaf::makeValid ( )
virtual

Corrects erroneous values in the ResourceLeaf.

Implements PeLib::ResourceElement.

◆ read()

int PeLib::ResourceLeaf::read ( ImageLoader imageLoader,
std::uint32_t  uiRsrcRva,
std::uint32_t  uiOffset,
std::uint32_t  sizeOfImage,
ResourceDirectory resDir 
)
protectedvirtual

Reads the next resource leaf from the input file.

Parameters
imageLoaderAn image loaded into the ImageLoader parser
uiRsrcRvaRVA of the beginning of the resource directory.
uiOffsetOffset of the resource leaf that's to be read.
sizeOfImageSize of the image.
resDirResource directory.

Implements PeLib::ResourceElement.

◆ rebuild()

void PeLib::ResourceLeaf::rebuild ( OutputBuffer obBuffer,
unsigned int  uiOffset,
unsigned int  uiRva,
const std::string &   
) const
protectedvirtual

Writes the next resource leaf into the OutputBuffer.

Rebuilds the current resource leaf.

Parameters
obBufferOutputBuffer where the rebuilt resource leaf is stored.
uiOffsetOffset of the resource leaf inside the resource directory.
uiRvaRVA of the resource directory.

Implements PeLib::ResourceElement.

◆ recalculate()

void PeLib::ResourceLeaf::recalculate ( unsigned int &  uiCurrentOffset,
unsigned int  uiNewRva 
)
overrideprotectedvirtual

Recalculates the tree for different RVA.

Recalculates the current node for directory with new RVA.

Parameters
uiCurrentOffsetThe current offset of the node in the new directory.
uiNewRvaThe RVA of the new directory.

Implements PeLib::ResourceElement.

◆ setCodePage()

void PeLib::ResourceLeaf::setCodePage ( std::uint32_t  dwValue)

Sets the CodePage value of this resource leaf.

Sets the leaf's CodePage value.

Parameters
dwValueThe leaf's new CodePage value.

◆ setData()

void PeLib::ResourceLeaf::setData ( const std::vector< std::uint8_t > &  vData)

Sets the resource data of this resource leaf.

Overwrites the raw data of a resource.

Parameters
vDataNew data of the resource.

◆ setOffsetToData()

void PeLib::ResourceLeaf::setOffsetToData ( std::uint32_t  dwValue)

Sets the OffsetToData value of this resource leaf.

Sets the leaf's OffsetToData value.

Parameters
dwValueThe leaf's new OffsetToData value.

◆ setReserved()

void PeLib::ResourceLeaf::setReserved ( std::uint32_t  dwValue)

Sets the Reserved value of this resource leaf.

Sets the leaf's Reserved value.

Parameters
dwValueThe leaf's new Reserved value.

◆ setSize()

void PeLib::ResourceLeaf::setSize ( std::uint32_t  dwValue)

Sets the Size value of this resource leaf.

Sets the leaf's Size value.

Parameters
dwValueThe leaf's new Size value.

Friends And Related Function Documentation

◆ fixNumberOfEntries

template<typename T >
friend struct fixNumberOfEntries
friend

◆ ResourceChild

friend class ResourceChild
friend

◆ ResourceDirectory

Member Data Documentation

◆ entry

PELIB_IMAGE_RESOURCE_DATA_ENTRY PeLib::ResourceLeaf::entry
private

PeLib equivalent of the Win32 structure IMAGE_RESOURCE_DATA_ENTRY.

◆ m_data

std::vector<std::uint8_t> PeLib::ResourceLeaf::m_data
private

The resource data.


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