LIEF: Library to Instrument Executable Formats Version 0.15.1
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:
42 ResourceDirectory(const details::pe_resource_directory_table& header);
43
44 ResourceDirectory(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
57 uint32_t characteristics() const {
58 return characteristics_;
59 }
60
63 uint32_t time_date_stamp() const {
64 return timedatestamp_;
65 }
66
68 uint16_t major_version() const {
69 return majorversion_;
70 }
71
73 uint16_t minor_version() const {
74 return minorversion_;
75 }
76
80 uint16_t numberof_name_entries() const {
81 return numberof_name_entries_;
82 }
83
87 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 */
Class that is used to rebuild a raw PE binary from a PE::Binary object.
Definition PE/Builder.hpp:45
Main interface to parse PE binaries. In particular the static functions: Parser::parse should be used...
Definition PE/Parser.hpp:47
Definition ResourceDirectory.hpp:33
void major_version(uint16_t major_version)
Definition ResourceDirectory.hpp:97
void characteristics(uint32_t characteristics)
Definition ResourceDirectory.hpp:91
uint16_t minor_version() const
The minor version number, set by the user.
Definition ResourceDirectory.hpp:73
ResourceDirectory()
Definition ResourceDirectory.hpp:39
~ResourceDirectory() override=default
ResourceDirectory & operator=(const ResourceDirectory &other)=default
void minor_version(uint16_t minor_version)
Definition ResourceDirectory.hpp:100
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
uint16_t major_version() const
The major version number, set by the user.
Definition ResourceDirectory.hpp:68
ResourceDirectory(const details::pe_resource_directory_table &header)
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
void numberof_name_entries(uint16_t numberof_name_entries)
Definition ResourceDirectory.hpp:103
static bool classof(const ResourceNode *node)
Definition ResourceDirectory.hpp:110
void accept(Visitor &visitor) const override
void time_date_stamp(uint32_t time_date_stamp)
Definition ResourceDirectory.hpp:94
void swap(ResourceDirectory &other) noexcept
friend std::ostream & operator<<(std::ostream &os, const ResourceDirectory &directory)
void numberof_id_entries(uint16_t numberof_id_entries)
Definition ResourceDirectory.hpp:106
ResourceDirectory(const ResourceDirectory &other)=default
uint32_t characteristics() const
Resource characteristics. This field is reserved for future use. It is currently set to zero.
Definition ResourceDirectory.hpp:57
uint32_t time_date_stamp() const
The time that the resource data was created by the resource compiler.
Definition ResourceDirectory.hpp:63
std::unique_ptr< ResourceNode > clone() const override
Definition ResourceDirectory.hpp:51
Class which represents a Node in the resource tree.
Definition ResourceNode.hpp:36
bool is_directory() const
True if the current entry is a ResourceDirectory.
Definition ResourceNode.hpp:101
TYPE
Enum that identifies the type of a node in the resource tree.
Definition ResourceNode.hpp:47
Definition Visitor.hpp:224
LIEF namespace.
Definition Abstract/Binary.hpp:32
#define LIEF_API
Definition visibility.h:41