LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
ResourceData.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_DATA_H
17#define LIEF_PE_RESOURCE_DATA_H
18
19#include <vector>
20
21#include "LIEF/visibility.h"
22#include "LIEF/PE/ResourceNode.hpp"
23#include "LIEF/span.hpp"
24
25namespace LIEF {
26namespace PE {
27
28class Parser;
29class Builder;
30
32class LIEF_API ResourceData : public ResourceNode {
33
34 friend class Parser;
35 friend class Builder;
36
37 public:
39 ResourceData(std::vector<uint8_t> content, uint32_t code_page);
40
41 ResourceData(const ResourceData& other);
42 ResourceData& operator=(ResourceData other);
43 void swap(ResourceData& other);
44
45 ~ResourceData() override;
46
47 std::unique_ptr<ResourceNode> clone() const override {
48 return std::unique_ptr<ResourceNode>{new ResourceData{*this}};
49 }
50
53 uint32_t code_page() const;
54
56 span<const uint8_t> content() const;
57 span<uint8_t> content();
58
60 uint32_t reserved() const;
61
65 uint32_t offset() const;
66
67 void code_page(uint32_t code_page);
68 void content(const std::vector<uint8_t>& content);
69 void reserved(uint32_t value);
70
71 static bool classof(const ResourceNode* node) {
72 return node->is_data();
73 }
74
75 void accept(Visitor& visitor) const override;
76
77
78 LIEF_API friend std::ostream& operator<<(std::ostream& os, const ResourceData& data);
79
80 private:
81 std::vector<uint8_t> content_;
82 uint32_t code_page_ = 0;
83 uint32_t reserved_ = 0;
84 uint32_t offset_ = 0;
85
86};
87
88} // namespace PE
89} // namepsace LIEF
90#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
uint32_t offset() const
Offset of the content within the resource.
uint32_t reserved() const
Reserved value. Should be 0
span< const uint8_t > content() const
Resource content.
uint32_t code_page() const
Return the code page that is used to decode code point values within the resource data....
Class which represents a Node in the resource tree.
Definition ResourceNode.hpp:38
bool is_data() const
True if the current entry is a ResourceData.
Definition Visitor.hpp:219
LIEF namespace.
Definition Abstract/Binary.hpp:32