LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
LIEF::PE::ResourceNode Class Referenceabstract

Class which represents a Node in the resource tree. More...

#include <ResourceNode.hpp>

Inheritance diagram for LIEF::PE::ResourceNode:
Collaboration diagram for LIEF::PE::ResourceNode:

Public Types

enum class  TYPE { UNKNOWN = 0 , DATA , DIRECTORY }
 Enum that identifies the type of a node in the resource tree. More...
 
using childs_t = std::vector<std::unique_ptr<ResourceNode>>
 
using it_childs = ref_iterator<childs_t&, ResourceNode*>
 
using it_const_childs = const_ref_iterator<const childs_t&, ResourceNode*>
 
- Public Types inherited from LIEF::Object
template<class T >
using output_t = add_pointer_t<decay_t<T>>
 
template<class T >
using output_const_t = add_pointer_t<add_const_t<decay_t<T>>>
 

Public Member Functions

 ResourceNode (const ResourceNode &other)
 
ResourceNodeoperator= (const ResourceNode &other)
 
 ResourceNode (ResourceNode &&other)=default
 
ResourceNodeoperator= (ResourceNode &&other)=default
 
void swap (ResourceNode &other)
 
 ~ResourceNode () override
 
virtual std::unique_ptr< ResourceNodeclone () const =0
 
uint32_t id () const
 Integer that identifies the Type, Name, or Language ID of the entry depending on its depth in the tree.
 
const std::u16string & name () const
 Name of the entry (if any)
 
std::string utf8_name () const
 UTF-8 representation of the name()
 
it_childs childs ()
 Iterator on node's children.
 
it_const_childs childs () const
 
bool has_name () const
 True if the entry uses a name as ID
 
uint32_t depth () const
 Current depth of the Node in the resource tree.
 
bool is_directory () const
 True if the current entry is a ResourceDirectory.
 
bool is_data () const
 True if the current entry is a ResourceData.
 
void id (uint32_t id)
 
void name (const std::string &name)
 
void name (std::u16string name)
 
ResourceNodeadd_child (std::unique_ptr< ResourceNode > child)
 Add a new child to the current node, taking the ownership of the provided unique_ptr
 
ResourceNodeadd_child (const ResourceNode &child)
 Add a new child to the current node.
 
void delete_child (uint32_t id)
 Delete the node with the given id
 
void delete_child (const ResourceNode &node)
 Delete the given node from the node's children.
 
void accept (Visitor &visitor) const override
 
template<class T >
const Tcast () const
 
template<class T >
Tcast ()
 
std::string to_string () const
 
void push_child (std::unique_ptr< ResourceNode > node)
 
- Public Member Functions inherited from LIEF::Object
 Object ()
 
 Object (const Object &other)
 
Objectoperator= (const Object &other)
 
template<class T >
output_t< T > as ()
 
template<class T >
output_const_t< T > as () const
 
virtual bool operator== (const Object &other) const
 
virtual bool operator!= (const Object &other) const
 
virtual ~Object ()
 

Static Public Member Functions

static std::unique_ptr< ResourceNodeparse (BinaryStream &stream, uint64_t rva)
 Parse the resource tree from the provided BinaryStream stream and with the original RVA provided in the second parameter.
 
static std::unique_ptr< ResourceNodeparse (const uint8_t *buffer, size_t size, uint64_t rva)
 Parse the resource tree from the provided buffer referenced by a pointer and the size. The second parameter is the RVA where the resource is (or was) located.
 
static std::unique_ptr< ResourceNodeparse (const std::vector< uint8_t > &buffer, uint64_t rva)
 See doc from other parse functions.
 
static std::unique_ptr< ResourceNodeparse (span< const uint8_t > buffer, uint64_t rva)
 See doc from other parse functions.
 
static std::unique_ptr< ResourceNodeparse (BinaryStream &stream, const Binary &bin)
 

Detailed Description

Class which represents a Node in the resource tree.

Member Typedef Documentation

◆ childs_t

using LIEF::PE::ResourceNode::childs_t = std::vector<std::unique_ptr<ResourceNode>>

◆ it_childs

◆ it_const_childs

Member Enumeration Documentation

◆ TYPE

enum class LIEF::PE::ResourceNode::TYPE
strong

Enum that identifies the type of a node in the resource tree.

Enumerator
UNKNOWN 
DATA 
DIRECTORY 

Constructor & Destructor Documentation

◆ ResourceNode() [1/2]

LIEF::PE::ResourceNode::ResourceNode ( const ResourceNode & other)

◆ ResourceNode() [2/2]

LIEF::PE::ResourceNode::ResourceNode ( ResourceNode && other)
default

◆ ~ResourceNode()

LIEF::PE::ResourceNode::~ResourceNode ( )
override

Member Function Documentation

◆ accept()

void LIEF::PE::ResourceNode::accept ( Visitor & visitor) const
overridevirtual

Implements LIEF::Object.

◆ add_child() [1/2]

ResourceNode & LIEF::PE::ResourceNode::add_child ( const ResourceNode & child)
inline

Add a new child to the current node.

References clone().

◆ add_child() [2/2]

ResourceNode & LIEF::PE::ResourceNode::add_child ( std::unique_ptr< ResourceNode > child)

Add a new child to the current node, taking the ownership of the provided unique_ptr

◆ cast() [1/2]

template<class T >
T * LIEF::PE::ResourceNode::cast ( )
inline

References LIEF::PE::T.

◆ cast() [2/2]

template<class T >
const T * LIEF::PE::ResourceNode::cast ( ) const
inline

References LIEF::PE::T.

◆ childs() [1/2]

it_childs LIEF::PE::ResourceNode::childs ( )
inline

Iterator on node's children.

◆ childs() [2/2]

it_const_childs LIEF::PE::ResourceNode::childs ( ) const
inline

◆ clone()

virtual std::unique_ptr< ResourceNode > LIEF::PE::ResourceNode::clone ( ) const
pure virtual

Implemented in LIEF::PE::ResourceData, and LIEF::PE::ResourceDirectory.

Referenced by add_child().

◆ delete_child() [1/2]

void LIEF::PE::ResourceNode::delete_child ( const ResourceNode & node)

Delete the given node from the node's children.

◆ delete_child() [2/2]

void LIEF::PE::ResourceNode::delete_child ( uint32_t id)

Delete the node with the given id

◆ depth()

uint32_t LIEF::PE::ResourceNode::depth ( ) const
inline

Current depth of the Node in the resource tree.

◆ has_name()

bool LIEF::PE::ResourceNode::has_name ( ) const
inline

True if the entry uses a name as ID

◆ id() [1/2]

uint32_t LIEF::PE::ResourceNode::id ( ) const
inline

Integer that identifies the Type, Name, or Language ID of the entry depending on its depth in the tree.

◆ id() [2/2]

void LIEF::PE::ResourceNode::id ( uint32_t id)
inline

◆ is_data()

bool LIEF::PE::ResourceNode::is_data ( ) const
inline

True if the current entry is a ResourceData.

It can be safely casted with:

const auto* data_node = node.cast<ResourceData>();

Referenced by LIEF::PE::ResourceData::classof().

◆ is_directory()

bool LIEF::PE::ResourceNode::is_directory ( ) const
inline

True if the current entry is a ResourceDirectory.

It can be safely casted with:

const auto* dir_node = node.cast<ResourceDirectory>();

Referenced by LIEF::PE::ResourceDirectory::classof().

◆ name() [1/3]

const std::u16string & LIEF::PE::ResourceNode::name ( ) const
inline

Name of the entry (if any)

◆ name() [2/3]

void LIEF::PE::ResourceNode::name ( const std::string & name)

◆ name() [3/3]

void LIEF::PE::ResourceNode::name ( std::u16string name)
inline

◆ operator=() [1/2]

ResourceNode & LIEF::PE::ResourceNode::operator= ( const ResourceNode & other)

◆ operator=() [2/2]

ResourceNode & LIEF::PE::ResourceNode::operator= ( ResourceNode && other)
default

◆ parse() [1/5]

static std::unique_ptr< ResourceNode > LIEF::PE::ResourceNode::parse ( BinaryStream & stream,
const Binary & bin )
static

◆ parse() [2/5]

static std::unique_ptr< ResourceNode > LIEF::PE::ResourceNode::parse ( BinaryStream & stream,
uint64_t rva )
static

Parse the resource tree from the provided BinaryStream stream and with the original RVA provided in the second parameter.

The RVA value should be come from the DataDirectory::RVA associated with the resource tree.

◆ parse() [3/5]

static std::unique_ptr< ResourceNode > LIEF::PE::ResourceNode::parse ( const std::vector< uint8_t > & buffer,
uint64_t rva )
inlinestatic

See doc from other parse functions.

◆ parse() [4/5]

static std::unique_ptr< ResourceNode > LIEF::PE::ResourceNode::parse ( const uint8_t * buffer,
size_t size,
uint64_t rva )
static

Parse the resource tree from the provided buffer referenced by a pointer and the size. The second parameter is the RVA where the resource is (or was) located.

◆ parse() [5/5]

static std::unique_ptr< ResourceNode > LIEF::PE::ResourceNode::parse ( span< const uint8_t > buffer,
uint64_t rva )
inlinestatic

See doc from other parse functions.

◆ push_child()

void LIEF::PE::ResourceNode::push_child ( std::unique_ptr< ResourceNode > node)
inline

◆ swap()

void LIEF::PE::ResourceNode::swap ( ResourceNode & other)

◆ to_string()

std::string LIEF::PE::ResourceNode::to_string ( ) const
inline

◆ utf8_name()

std::string LIEF::PE::ResourceNode::utf8_name ( ) const

UTF-8 representation of the name()


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