LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
ResourceDirectory.hpp
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 <string>
20#include <list>
21
22#include "LIEF/visibility.h"
23
24#include "LIEF/PE/enums.hpp"
25#include "LIEF/PE/ResourceNode.hpp"
26
27namespace LIEF {
28namespace PE {
29
30class Parser;
31class Builder;
32
33namespace details {
34struct pe_resource_directory_table;
35}
36
37class LIEF_API ResourceDirectory : public ResourceNode {
38
39 friend class Parser;
40 friend class Builder;
41
42 public:
44 ResourceDirectory(const details::pe_resource_directory_table& header);
45
47 ResourceDirectory& operator=(ResourceDirectory other);
48
49 void swap(ResourceDirectory& other);
50
51 ~ResourceDirectory() override;
52
53 std::unique_ptr<ResourceNode> clone() const override {
54 return std::unique_ptr<ResourceNode>(new ResourceDirectory{*this});
55 }
56
59 uint32_t characteristics() const;
60
63 uint32_t time_date_stamp() const;
64
66 uint16_t major_version() const;
67
69 uint16_t minor_version() const;
70
75 uint16_t numberof_name_entries() const;
76
80 uint16_t numberof_id_entries() const;
81
82 void characteristics(uint32_t characteristics);
83 void time_date_stamp(uint32_t time_date_stamp);
84 void major_version(uint16_t major_version);
85 void minor_version(uint16_t minor_version);
86 void numberof_name_entries(uint16_t numberof_name_entries);
87 void numberof_id_entries(uint16_t numberof_id_entries);
88
89 static bool classof(const ResourceNode* node) {
90 return node->is_directory();
91 }
92
93 void accept(Visitor& visitor) const override;
94
95
96 LIEF_API friend std::ostream& operator<<(std::ostream& os, const ResourceDirectory& directory);
97
98 private:
99 uint32_t characteristics_ = 0;
100 uint32_t timeDateStamp_ = 0;
101 uint16_t majorVersion_ = 0;
102 uint16_t minorVersion_ = 0;
103 uint16_t numberOfNameEntries_ = 0;
104 uint16_t numberOfIDEntries_ = 0;
105
106};
107}
108}
109#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:37
uint16_t minor_version() const
The minor version number, set by the user.
uint16_t numberof_id_entries() const
The number of directory entries immediately following the Name entries that use numeric IDs for Type,...
uint16_t major_version() const
The major version number, set by the user.
uint16_t numberof_name_entries() const
The number of directory entries immediately following the table that use strings to identify Type,...
uint32_t characteristics() const
Resource characteristics. This field is reserved for future use. It is currently set to zero.
uint32_t time_date_stamp() const
The time that the resource data was created by the resource compiler.
Class which represents a Node in the resource tree.
Definition ResourceNode.hpp:38
bool is_directory() const
True if the current entry is a ResourceDirectory.
Definition Visitor.hpp:219
LIEF namespace.
Definition Abstract/Binary.hpp:32