LIEF: Library to Instrument Executable Formats Version 0.17.0
|
Loading...
Searching...
No Matches
Go to the documentation of this file.
16#ifndef LIEF_PE_RESOURCES_MANAGER_H
17#define LIEF_PE_RESOURCES_MANAGER_H
68 using dialogs_t = ResourceDialog::dialogs_t;
69 using it_const_dialogs = const_ref_iterator<const dialogs_t&, const ResourceDialog*>;
71 using icons_t = std::vector<ResourceIcon>;
72 using it_const_icons = const_ref_iterator<icons_t>;
74 using accelerators_t = std::vector<ResourceAccelerator>;
75 using it_const_accelerators = const_ref_iterator<accelerators_t>;
79 std::u16string string;
85 return !
string.empty();
88 operator bool()
const {
93 std::ostream&
operator<<(std::ostream& os,
const string_entry_t& str)
95 os << std::to_string(str.
id) <<
", " << str.
string_u8();
100 using strings_table_t = std::vector<string_entry_t>;
109 resources_(other.resources_)
113 ResourcesManager&
operator=(
const ResourcesManager& other) {
114 if (&other !=
this) {
115 Object::operator=(other);
116 resources_ = other.resources_;
123 ResourcesManager&
operator=(ResourcesManager&&) =
default;
130 return const_cast<ResourceNode*
>(
131 static_cast<const ResourcesManager*
>(
this)->get_node_type(type));
140 return get_node_type(type) !=
nullptr;
145 return get_node_type(TYPE::MANIFEST) !=
nullptr;
151 void manifest(
const std::string& manifest);
158 return get_node_type(TYPE::VERSION) !=
nullptr;
160 std::vector<ResourceVersion>
version()
const;
166 return get_node_type(TYPE::ICON) !=
nullptr &&
167 get_node_type(TYPE::GROUP_ICON) !=
nullptr;
169 it_const_icons
icons()
const;
172 void add_icon(
const ResourceIcon& icon);
176 void change_icon(
const ResourceIcon& original,
const ResourceIcon& newone);
180 return get_node_type(TYPE::DIALOG) !=
nullptr;
182 it_const_dialogs
dialogs()
const;
188 return get_node_type(TYPE::STRING) !=
nullptr;
196 return get_node_type(TYPE::HTML) !=
nullptr;
198 std::vector<std::string>
html()
const;
204 return get_node_type(TYPE::ACCELERATOR) !=
nullptr;
209 std::string
print(uint32_t depth = 0)
const;
213 void accept(Visitor& visitor)
const override;
218 void print_tree(
const ResourceNode& node, std::ostringstream& stream,
219 uint32_t current_depth, uint32_t max_depth,
220 const ResourceNode* parent =
nullptr,
221 std::string header =
"",
bool is_last =
false)
const;
222 ResourceNode* resources_ =
nullptr;
223 mutable dialogs_t dialogs_;
Class which represents a Node in the resource tree.
Definition ResourceNode.hpp:45
The Resource Manager provides an enhanced API to manipulate the resource tree.
Definition ResourcesManager.hpp:38
void add_icon(const ResourceIcon &icon)
Add an icon to the resources.
bool has_version() const
true if resources a LIEF::PE::ResourceVersion
Definition ResourcesManager.hpp:157
bool has_html() const
true if the resources contain html
Definition ResourcesManager.hpp:195
std::vector< ResourceVersion > version() const
Return a list of verison info (VS_VERSIONINFO).
it_const_accelerators accelerator() const
Return the list of the accelerator in the resource.
it_const_dialogs dialogs() const
Return the list of the dialogs present in the resource.
ResourceNode * get_node_type(TYPE type)
Return the ResourceNode associated with the given TYPE or a nullptr if not found;.
Definition ResourcesManager.hpp:129
bool has_type(TYPE type) const
true if the resource has the given TYPE node
Definition ResourcesManager.hpp:139
~ResourcesManager() override=default
bool has_icons() const
true if resources contain a LIEF::PE::ResourceIcon
Definition ResourcesManager.hpp:165
bool has_manifest() const
true if resources contain the Manifest element
Definition ResourcesManager.hpp:144
std::string print(uint32_t depth=0) const
Print the resource tree to the given depth.
void change_icon(const ResourceIcon &original, const ResourceIcon &newone)
ResourcesManager(ResourceNode &rsrc)
Definition ResourcesManager.hpp:103
std::vector< TYPE > get_types() const
List of TYPE present in the resources.
it_const_icons icons() const
Return the list of the icons present in the resources.
TYPE
The different types of resources From https://learn.microsoft.com/en-us/windows/win32/menurc/resource...
Definition ResourcesManager.hpp:43
bool has_string_table() const
true if the resources contain a string table
Definition ResourcesManager.hpp:187
std::string manifest() const
Return the manifest as a std::string or an empty string if not found or corrupted.
ResourcesManager(const ResourcesManager &other)
Definition ResourcesManager.hpp:107
bool has_accelerator() const
true if the resources contain accelerator info
Definition ResourcesManager.hpp:203
friend std::ostream & operator<<(std::ostream &os, const ResourcesManager &m)
ResourcesManager & operator=(ResourcesManager &&)=default
bool has_dialogs() const
true if resources contain dialogs
Definition ResourcesManager.hpp:179
strings_table_t string_table() const
Return the list of the strings embedded in the string table (RT_STRING)
const ResourceNode * get_node_type(TYPE type) const
void accept(Visitor &visitor) const override
ResourcesManager & operator=(const ResourcesManager &other)
Definition ResourcesManager.hpp:113
ResourcesManager()=delete
std::vector< std::string > html() const
Return the list of the html resources.
ResourcesManager(ResourcesManager &&)=default
void manifest(const std::string &manifest)
Change or set the manifest. If the manifest node path does not exist, all required nodes are created.
Definition VectorStream.hpp:29
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
@ MENU
Definition AcceleratorCodes.hpp:38
const char * to_string(AuxiliaryWeakExternal::CHARACTERISTICS e)
LIEF namespace.
Definition Abstract/Binary.hpp:36
std::string string_u8() const
friend std::ostream & operator<<(std::ostream &os, const string_entry_t &str)
Definition ResourcesManager.hpp:93
bool is_defined() const
Definition ResourcesManager.hpp:84
uint32_t id
Definition ResourcesManager.hpp:80
#define LIEF_API
Definition visibility.h:41