LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
ResourceData.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_DATA_H
17#define LIEF_PE_RESOURCE_DATA_H
18
19#include <vector>
20
21#include "LIEF/visibility.h"
23#include "LIEF/span.hpp"
24
25namespace LIEF {
26namespace PE {
27
28class Parser;
29class Builder;
30
33
34 friend class Parser;
35 friend class Builder;
36
37 public:
41 ResourceData(std::vector<uint8_t> content, uint32_t code_page) :
43 content_(std::move(content)),
44 code_page_(code_page)
45 {}
46
47 ResourceData(const ResourceData& other) = default;
48 ResourceData& operator=(const ResourceData& other) = default;
49 void swap(ResourceData& other) noexcept;
50
51 ~ResourceData() override = default;
52
53 std::unique_ptr<ResourceNode> clone() const override {
54 return std::unique_ptr<ResourceNode>{new ResourceData{*this}};
55 }
56
59 uint32_t code_page() const {
60 return code_page_;
61 }
62
65 return content_;
66 }
68 return content_;
69 }
70
72 uint32_t reserved() const {
73 return reserved_;
74 }
75
79 uint32_t offset() const {
80 return offset_;
81 }
82
83 void code_page(uint32_t code_page) {
84 code_page_ = code_page;
85 }
86
87 void content(std::vector<uint8_t> content) {
88 content_ = std::move(content);
89 }
90
91 void reserved(uint32_t value) {
92 reserved_ = value;
93 }
94
95 static bool classof(const ResourceNode* node) {
96 return node->is_data();
97 }
98
99 void accept(Visitor& visitor) const override;
100
101 LIEF_API friend std::ostream& operator<<(std::ostream& os, const ResourceData& data);
102
103 private:
104 std::vector<uint8_t> content_;
105 uint32_t code_page_ = 0;
106 uint32_t reserved_ = 0;
107 uint32_t offset_ = 0;
108
109};
110
111} // namespace PE
112} // namepsace LIEF
113#endif /* RESOURCEDATA_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
Class which represents a Data Node in the PE resources tree.
Definition ResourceData.hpp:32
ResourceData(std::vector< uint8_t > content, uint32_t code_page)
Definition ResourceData.hpp:41
span< uint8_t > content()
Definition ResourceData.hpp:67
ResourceData()
Definition ResourceData.hpp:38
ResourceData & operator=(const ResourceData &other)=default
friend std::ostream & operator<<(std::ostream &os, const ResourceData &data)
uint32_t offset() const
Offset of the content within the resource.
Definition ResourceData.hpp:79
std::unique_ptr< ResourceNode > clone() const override
Definition ResourceData.hpp:53
uint32_t reserved() const
Reserved value. Should be 0
Definition ResourceData.hpp:72
void code_page(uint32_t code_page)
Definition ResourceData.hpp:83
void accept(Visitor &visitor) const override
void reserved(uint32_t value)
Definition ResourceData.hpp:91
static bool classof(const ResourceNode *node)
Definition ResourceData.hpp:95
span< const uint8_t > content() const
Resource content.
Definition ResourceData.hpp:64
uint32_t code_page() const
Return the code page that is used to decode code point values within the resource data....
Definition ResourceData.hpp:59
ResourceData(const ResourceData &other)=default
~ResourceData() override=default
void swap(ResourceData &other) noexcept
void content(std::vector< uint8_t > content)
Definition ResourceData.hpp:87
Class which represents a Node in the resource tree.
Definition ResourceNode.hpp:36
bool is_data() const
True if the current entry is a ResourceData.
Definition ResourceNode.hpp:112
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
tcb::span< ElementType, Extent > span
Definition span.hpp:22
#define LIEF_API
Definition visibility.h:41