LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
ResourceVar.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2025 R. Thomas
2 * Copyright 2017 - 2025 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_VAR_H
17#define LIEF_PE_RESOURCE_VAR_H
18#include <ostream>
19#include <vector>
20
21#include "LIEF/visibility.h"
22#include "LIEF/errors.hpp"
23
24namespace LIEF {
25class BinaryStream;
26namespace PE {
34 public: using values_t = std::vector<uint32_t>;
37
38 static result<ResourceVar> parse(BinaryStream& stream);
39
40 ResourceVar() = default;
41
42 ResourceVar(const ResourceVar&) = default;
43 ResourceVar& operator=(const ResourceVar&) = default;
44
45 ResourceVar(ResourceVar&&) = default;
46 ResourceVar& operator=(ResourceVar&&) = default;
47
48 ~ResourceVar() = default;
49 const std::u16string& key() const {
52 return key_;
53 }
54 uint16_t type() const {
59 return type_;
60 }
61 std::string key_u8() const;
64 const values_t& values() const {
72 return values_;
73 }
74
75 values_t& values() {
76 return values_;
77 }
78
79 ResourceVar& key(std::u16string key) {
80 key_ = std::move(key);
81 return *this;
82 }
83
84 ResourceVar& type(uint16_t ty) {
85 type_ = ty;
86 return *this;
87 }
88
89 void add_value(uint32_t val) {
90 values_.push_back(val);
91 }
92
93 LIEF_API friend
94 std::ostream& operator<<(std::ostream& os, const ResourceVar& entry);
95
96 private:
97 uint16_t type_ = 0;
98 std::u16string key_;
99 values_t values_;
100};
101}
102}
103
104#endif
LIEF::BinaryStream
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:33
LIEF::PE::ResourceVar
This class represents an element of the ResourceVarFileInfo structure It typically contains a list of...
Definition ResourceVar.hpp:33
LIEF::PE::ResourceVar::operator=
ResourceVar & operator=(const ResourceVar &)=default
LIEF::PE::ResourceVar::ResourceVar
ResourceVar(const ResourceVar &)=default
LIEF::PE::ResourceVar::operator<<
friend std::ostream & operator<<(std::ostream &os, const ResourceVar &entry)
LIEF::PE::ResourceVar::key
ResourceVar & key(std::u16string key)
Definition ResourceVar.hpp:79
LIEF::PE::ResourceVar::type
ResourceVar & type(uint16_t ty)
Definition ResourceVar.hpp:84
LIEF::PE::ResourceVar::parse
static result< ResourceVar > parse(BinaryStream &stream)
LIEF::PE::ResourceVar::values
values_t & values()
Definition ResourceVar.hpp:75
LIEF::PE::ResourceVar::key_u8
std::string key_u8() const
The key as an utf8 string.
LIEF::PE::ResourceVar::type
uint16_t type() const
The type of data in the version resource:
Definition ResourceVar.hpp:58
LIEF::PE::ResourceVar::ResourceVar
ResourceVar(ResourceVar &&)=default
LIEF::PE::ResourceVar::key
const std::u16string & key() const
The Unicode string L"Translation"
Definition ResourceVar.hpp:51
LIEF::PE::ResourceVar::~ResourceVar
~ResourceVar()=default
LIEF::PE::ResourceVar::add_value
void add_value(uint32_t val)
Definition ResourceVar.hpp:89
LIEF::PE::ResourceVar::values
const values_t & values() const
Return the translation values.
Definition ResourceVar.hpp:71
LIEF::PE::ResourceVar::ResourceVar
ResourceVar()=default
LIEF::PE::ResourceVar::operator=
ResourceVar & operator=(ResourceVar &&)=default
errors.hpp
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