LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
ResourceDirectory.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2024 R. Thomas
2 * Copyright 2017 - 2024 Quarkslab
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef LIEF_PE_RESOURCE_DIRECTORY_H
17#define LIEF_PE_RESOURCE_DIRECTORY_H
18
19#include "LIEF/visibility.h"
20
22
23namespace LIEF {
24namespace PE {
25
26class Parser;
27class Builder;
28
29namespace details {
30struct pe_resource_directory_table;
31}
32
34
35 friend class Parser;
36 friend class Builder;
37
38 public:
40 ResourceNode(ResourceNode::TYPE::DIRECTORY)
41 {}
42 ResourceDirectory(const details::pe_resource_directory_table& header);
43
44 ResourceDirectory(const ResourceDirectory& other) = default;
45 ResourceDirectory& operator=(const ResourceDirectory& other) = default;
46
47 void swap(ResourceDirectory& other) noexcept;
48
49 ~ResourceDirectory() override = default;
50
51 std::unique_ptr<ResourceNode> clone() const override {
52 return std::unique_ptr<ResourceNode>(new ResourceDirectory{*this});
53 }
54 uint32_t characteristics() const {
58 return characteristics_;
59 }
60 uint32_t time_date_stamp() const {
64 return timedatestamp_;
65 }
66 uint16_t major_version() const {
69 return majorversion_;
70 }
71 uint16_t minor_version() const {
74 return minorversion_;
75 }
76 uint16_t numberof_name_entries() const {
81 return numberof_name_entries_;
82 }
83 uint16_t numberof_id_entries() const {
88 return numberof_id_entries_;
89 }
90
91 void characteristics(uint32_t characteristics) {
92 characteristics_ = characteristics;
93 }
94 void time_date_stamp(uint32_t time_date_stamp) {
95 timedatestamp_ = time_date_stamp;
96 }
97 void major_version(uint16_t major_version) {
98 majorversion_ = major_version;
99 }
100 void minor_version(uint16_t minor_version) {
101 minorversion_ = minor_version;
102 }
103 void numberof_name_entries(uint16_t numberof_name_entries) {
104 numberof_name_entries_ = numberof_name_entries;
105 }
106 void numberof_id_entries(uint16_t numberof_id_entries) {
107 numberof_id_entries_ = numberof_id_entries;
108 }
109
110 static bool classof(const ResourceNode* node) {
111 return node->is_directory();
112 }
113
114 void accept(Visitor& visitor) const override;
115
116 LIEF_API friend std::ostream& operator<<(std::ostream& os, const ResourceDirectory& directory);
117
118 private:
119 uint32_t characteristics_ = 0;
120 uint32_t timedatestamp_ = 0;
121 uint16_t majorversion_ = 0;
122 uint16_t minorversion_ = 0;
123 uint16_t numberof_name_entries_ = 0;
124 uint16_t numberof_id_entries_ = 0;
125
126};
127}
128}
129#endif /* RESOURCEDIRECTORY_H */
ResourceNode.hpp
LIEF::PE::Builder
Class that is used to rebuild a raw PE binary from a PE::Binary object.
Definition PE/Builder.hpp:45
LIEF::PE::Parser
Main interface to parse PE binaries. In particular the static functions: Parser::parse should be used...
Definition PE/Parser.hpp:47
LIEF::PE::ResourceDirectory
Definition ResourceDirectory.hpp:33
LIEF::PE::ResourceDirectory::major_version
void major_version(uint16_t major_version)
Definition ResourceDirectory.hpp:97
LIEF::PE::ResourceDirectory::characteristics
void characteristics(uint32_t characteristics)
Definition ResourceDirectory.hpp:91
LIEF::PE::ResourceDirectory::minor_version
uint16_t minor_version() const
The minor version number, set by the user.
Definition ResourceDirectory.hpp:73
LIEF::PE::ResourceDirectory::ResourceDirectory
ResourceDirectory()
Definition ResourceDirectory.hpp:39
LIEF::PE::ResourceDirectory::~ResourceDirectory
~ResourceDirectory() override=default
LIEF::PE::ResourceDirectory::operator=
ResourceDirectory & operator=(const ResourceDirectory &other)=default
LIEF::PE::ResourceDirectory::minor_version
void minor_version(uint16_t minor_version)
Definition ResourceDirectory.hpp:100
LIEF::PE::ResourceDirectory::numberof_id_entries
uint16_t numberof_id_entries() const
The number of directory entries immediately following the Name entries that use numeric IDs for Type,...
Definition ResourceDirectory.hpp:87
LIEF::PE::ResourceDirectory::major_version
uint16_t major_version() const
The major version number, set by the user.
Definition ResourceDirectory.hpp:68
LIEF::PE::ResourceDirectory::ResourceDirectory
ResourceDirectory(const details::pe_resource_directory_table &header)
LIEF::PE::ResourceDirectory::numberof_name_entries
uint16_t numberof_name_entries() const
The number of directory entries immediately following the table that use strings to identify Type,...
Definition ResourceDirectory.hpp:80
LIEF::PE::ResourceDirectory::numberof_name_entries
void numberof_name_entries(uint16_t numberof_name_entries)
Definition ResourceDirectory.hpp:103
LIEF::PE::ResourceDirectory::classof
static bool classof(const ResourceNode *node)
Definition ResourceDirectory.hpp:110
LIEF::PE::ResourceDirectory::accept
void accept(Visitor &visitor) const override
LIEF::PE::ResourceDirectory::time_date_stamp
void time_date_stamp(uint32_t time_date_stamp)
Definition ResourceDirectory.hpp:94
LIEF::PE::ResourceDirectory::swap
void swap(ResourceDirectory &other) noexcept
LIEF::PE::ResourceDirectory::operator<<
friend std::ostream & operator<<(std::ostream &os, const ResourceDirectory &directory)
LIEF::PE::ResourceDirectory::numberof_id_entries
void numberof_id_entries(uint16_t numberof_id_entries)
Definition ResourceDirectory.hpp:106
LIEF::PE::ResourceDirectory::ResourceDirectory
ResourceDirectory(const ResourceDirectory &other)=default
LIEF::PE::ResourceDirectory::characteristics
uint32_t characteristics() const
Resource characteristics. This field is reserved for future use. It is currently set to zero.
Definition ResourceDirectory.hpp:57
LIEF::PE::ResourceDirectory::time_date_stamp
uint32_t time_date_stamp() const
The time that the resource data was created by the resource compiler.
Definition ResourceDirectory.hpp:63
LIEF::PE::ResourceDirectory::clone
std::unique_ptr< ResourceNode > clone() const override
Definition ResourceDirectory.hpp:51
LIEF::PE::ResourceNode
Class which represents a Node in the resource tree.
Definition ResourceNode.hpp:36
LIEF::PE::ResourceNode::is_directory
bool is_directory() const
True if the current entry is a ResourceDirectory.
Definition ResourceNode.hpp:101
LIEF::PE::details
Definition CodeIntegrity.hpp:26
LIEF::PE
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:36
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41