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

ResourceNodes represent the nodes in the resource tree. More...

#include <ResourceDirectory.h>

Inheritance diagram for PeLib::ResourceNode:
Inheritance graph
[legend]
Collaboration diagram for PeLib::ResourceNode:
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 ResourceNode. More...
 
unsigned int getNumberOfChildren () const
 Returns the node's number of children. More...
 
ResourceChildaddChild ()
 Adds another child to node. More...
 
ResourceChildgetChild (std::size_t uiIndex)
 Returns a node's child. More...
 
const ResourceChildgetChild (std::size_t uiIndex) const
 
void removeChild (unsigned int uiIndex)
 Removes a node's child. More...
 
std::string getChildName (unsigned int uiIndex) const
 Returns the name of one of the node's children. More...
 
std::uint32_t getOffsetToChildName (unsigned int uiIndex) const
 Returns the Name value of one of the node's children. More...
 
std::uint32_t getOffsetToChildData (unsigned int uiIndex) const
 Returns the OffsetToData value of one of the node's children. More...
 
void setChildName (unsigned int uiIndex, const std::string &strNewName)
 Sets the name of one of the node's children. More...
 
void setOffsetToChildName (unsigned int uiIndex, std::uint32_t dwNewOffset)
 Sets the Name value of one of the node's children. More...
 
void setOffsetToChildData (unsigned int uiIndex, std::uint32_t dwNewOffset)
 Sets the OffsetToData value of one of the node's children. More...
 
std::uint32_t getCharacteristics () const
 Returns the node's Characteristics value. More...
 
std::uint32_t getTimeDateStamp () const
 Returns the node's TimeDateStamp value. More...
 
std::uint16_t getMajorVersion () const
 Returns the node's MajorVersion value. More...
 
std::uint16_t getMinorVersion () const
 Returns the node's MinorVersion value. More...
 
std::uint16_t getNumberOfNamedEntries () const
 Returns the node's NumberOfNamedEntries value. More...
 
std::uint16_t getNumberOfIdEntries () const
 Returns the node's NumberOfIdEntries value. More...
 
void setCharacteristics (std::uint32_t value)
 Sets the node's Characteristics value. More...
 
void setTimeDateStamp (std::uint32_t value)
 Sets the node's TimeDateStamp value. More...
 
void setMajorVersion (std::uint16_t value)
 Sets the node's MajorVersion value. More...
 
void setMinorVersion (std::uint16_t value)
 Sets the node's MinorVersion value. More...
 
void setNumberOfNamedEntries (std::uint16_t value)
 Sets the node's NumberOfNamedEntries value. More...
 
void setNumberOfIdEntries (std::uint16_t value)
 Sets the node's NumberOfIdEntries value. More...
 
 ResourceNode ()
 Returns the size of a resource node. More...
 
virtual ~ResourceNode () 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)
 Reads the next resource node. More...
 
void rebuild (OutputBuffer &, unsigned int uiOffset, unsigned int uiRva, const std::string &) const
 Writes the next resource node 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< ResourceChildchildren
 The node's children. More...
 
PELIB_IMAGE_RESOURCE_DIRECTORY header
 The node's header. Equivalent to IMAGE_RESOURCE_DIRECTORY from the Win32 API. 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

ResourceNodes represent the nodes in the resource tree.

Constructor & Destructor Documentation

◆ ResourceNode()

PeLib::ResourceNode::ResourceNode ( )

Returns the size of a resource node.

Constructor

◆ ~ResourceNode()

PeLib::ResourceNode::~ResourceNode ( )
overridevirtual

Destructor.

Member Function Documentation

◆ addChild()

ResourceChild * PeLib::ResourceNode::addChild ( )

Adds another child to node.

Adds another child to the current node.

Returns
Newly created ResourceChild.

◆ getCharacteristics()

std::uint32_t PeLib::ResourceNode::getCharacteristics ( ) const

Returns the node's Characteristics value.

Returns the Characteristics value of the node.

Returns
Characteristics value of the node.

◆ getChild() [1/2]

ResourceChild * PeLib::ResourceNode::getChild ( std::size_t  uiIndex)

Returns a node's child.

Returns a node's child.

Parameters
uiIndexIndex of the child.
Returns
The child identified by uiIndex.

◆ getChild() [2/2]

const ResourceChild * PeLib::ResourceNode::getChild ( std::size_t  uiIndex) const

Returns a node's child.

Parameters
uiIndexIndex of the child.
Returns
The child identified by uiIndex.

◆ getChildName()

std::string PeLib::ResourceNode::getChildName ( unsigned int  uiIndex) const

Returns the name of one of the node's children.

Returns the name of a child.

Parameters
uiIndexIndex of the child.
Returns
Either the name of the specified child or an empty string.

◆ getMajorVersion()

std::uint16_t PeLib::ResourceNode::getMajorVersion ( ) const

Returns the node's MajorVersion value.

Returns the MajorVersion value of the node.

Returns
MajorVersion value of the node.

◆ getMinorVersion()

std::uint16_t PeLib::ResourceNode::getMinorVersion ( ) const

Returns the node's MinorVersion value.

Returns the MinorVersion value of the node.

Returns
MinorVersion value of the node.

◆ getNumberOfChildren()

unsigned int PeLib::ResourceNode::getNumberOfChildren ( ) const

Returns the node's number of children.

Returns the number of children of the current node. Note that this number is the number of defined children, not the value from the header.

Returns
Number of node's children.

◆ getNumberOfIdEntries()

std::uint16_t PeLib::ResourceNode::getNumberOfIdEntries ( ) const

Returns the node's NumberOfIdEntries value.

Returns the NumberOfIdEntries value of the node.

Returns
NumberOfIdEntries value of the node.

◆ getNumberOfNamedEntries()

std::uint16_t PeLib::ResourceNode::getNumberOfNamedEntries ( ) const

Returns the node's NumberOfNamedEntries value.

Returns the NumberOfNamedEntries value of the node.

Returns
NumberOfNamedEntries value of the node.

◆ getOffsetToChildData()

std::uint32_t PeLib::ResourceNode::getOffsetToChildData ( unsigned int  uiIndex) const

Returns the OffsetToData value of one of the node's children.

Returns the OffsetToData value of a child.

Parameters
uiIndexIndex of the child.
Returns
OffsetToData value of a child.

◆ getOffsetToChildName()

std::uint32_t PeLib::ResourceNode::getOffsetToChildName ( unsigned int  uiIndex) const

Returns the Name value of one of the node's children.

Returns the Name value of a child.

Parameters
uiIndexIndex of the child.
Returns
Name value of a child.

◆ getTimeDateStamp()

std::uint32_t PeLib::ResourceNode::getTimeDateStamp ( ) const

Returns the node's TimeDateStamp value.

Returns the TimeDateStamp value of the node.

Returns
TimeDateStamp value of the node.

◆ isLeaf()

bool PeLib::ResourceNode::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 false.

Implements PeLib::ResourceElement.

◆ makeValid()

void PeLib::ResourceNode::makeValid ( )
virtual

Corrects erroneous values in the ResourceNode.

Sorts the node's children and corrects the node's header.

Implements PeLib::ResourceElement.

◆ read()

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

Reads the next resource node.

Reads the next resource node from the input file.

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

Implements PeLib::ResourceElement.

◆ rebuild()

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

Writes the next resource node into the OutputBuffer.

Rebuilds the current resource node.

Parameters
obBufferOutputBuffer where the rebuilt resource node is stored.
uiOffsetOffset of the resource node inside the resource directory.
uiRvaRVA of the resource directory.
padUsed for debugging.

Implements PeLib::ResourceElement.

◆ recalculate()

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

Recalculates the tree for different RVA.

Recalculates the current node and child nodes 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.

◆ removeChild()

void PeLib::ResourceNode::removeChild ( unsigned int  uiIndex)

Removes a node's child.

Removes a child from the current node.

Parameters
uiIndexIndex of the child.

◆ setCharacteristics()

void PeLib::ResourceNode::setCharacteristics ( std::uint32_t  value)

Sets the node's Characteristics value.

Sets the Characteristics value of the node.

Parameters
valueNew Characteristics value of the node.

◆ setChildName()

void PeLib::ResourceNode::setChildName ( unsigned int  uiIndex,
const std::string &  strNewName 
)

Sets the name of one of the node's children.

Sets the name of a child.

Parameters
uiIndexIndex of the child.
strNewNameNew name of the resource.

◆ setMajorVersion()

void PeLib::ResourceNode::setMajorVersion ( std::uint16_t  value)

Sets the node's MajorVersion value.

Sets the MajorVersion value of the node.

Parameters
valueNew MajorVersion value of the node.

◆ setMinorVersion()

void PeLib::ResourceNode::setMinorVersion ( std::uint16_t  value)

Sets the node's MinorVersion value.

Sets the MinorVersion value of the node.

Parameters
valueNew MinorVersion value of the node.

◆ setNumberOfIdEntries()

void PeLib::ResourceNode::setNumberOfIdEntries ( std::uint16_t  value)

Sets the node's NumberOfIdEntries value.

Sets the NumberOfIdEntries value of the node.

Parameters
valueNew NumberOfIdEntries value of the node.

◆ setNumberOfNamedEntries()

void PeLib::ResourceNode::setNumberOfNamedEntries ( std::uint16_t  value)

Sets the node's NumberOfNamedEntries value.

Sets the NumberOfNamedEntries value of the node.

Parameters
valueNew NumberOfNamedEntries value of the node.

◆ setOffsetToChildData()

void PeLib::ResourceNode::setOffsetToChildData ( unsigned int  uiIndex,
std::uint32_t  dwNewOffset 
)

Sets the OffsetToData value of one of the node's children.

Sets the OffsetToData value of a child.

Parameters
uiIndexIndex of the child.
dwNewOffsetNew OffsetToData value of the resource.

◆ setOffsetToChildName()

void PeLib::ResourceNode::setOffsetToChildName ( unsigned int  uiIndex,
std::uint32_t  dwNewOffset 
)

Sets the Name value of one of the node's children.

Sets the Name value of a child.

Parameters
uiIndexIndex of the child.
dwNewOffsetNew Name value of the resource.

◆ setTimeDateStamp()

void PeLib::ResourceNode::setTimeDateStamp ( std::uint32_t  value)

Sets the node's TimeDateStamp value.

Sets the TimeDateStamp value of the node.

Parameters
valueNew TimeDateStamp value of the node.

Friends And Related Function Documentation

◆ fixNumberOfEntries

template<typename T >
friend struct fixNumberOfEntries
friend

◆ ResourceChild

friend class ResourceChild
friend

◆ ResourceDirectory

Member Data Documentation

◆ children

std::vector<ResourceChild> PeLib::ResourceNode::children
private

The node's children.

◆ header

PELIB_IMAGE_RESOURCE_DIRECTORY PeLib::ResourceNode::header
private

The node's header. Equivalent to IMAGE_RESOURCE_DIRECTORY from the Win32 API.


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