LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
ResourceVarFileInfo.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_FILE_INFO_H
17#define LIEF_PE_RESOURCE_VAR_FILE_INFO_H
18#include <ostream>
19#include <cstdint>
20#include <vector>
21
22#include "LIEF/visibility.h"
23#include "LIEF/Object.hpp"
24#include "LIEF/errors.hpp"
25#include "LIEF/iterators.hpp"
27
28namespace LIEF {
29class BinaryStream;
30namespace PE {
31class LIEF_API ResourceVarFileInfo : public Object {
40 public:
41 using vars_t = std::vector<ResourceVar>;
42
43 using it_vars = ref_iterator<vars_t&>;
44 using it_const_vars = const_ref_iterator<const vars_t&>;
45
46 static result<ResourceVarFileInfo> parse(BinaryStream& stream);
47
49
50 ResourceVarFileInfo(const ResourceVarFileInfo&) = default;
51 ResourceVarFileInfo& operator=(const ResourceVarFileInfo&) = default;
52
53 ResourceVarFileInfo(ResourceVarFileInfo&&) = default;
54 ResourceVarFileInfo& operator=(ResourceVarFileInfo&&) = default;
55
56 ~ResourceVarFileInfo() override = default;
57 uint16_t type() const {
62 return type_;
63 }
64 const std::u16string& key() const {
67 return key_;
68 }
69 std::string key_u8() const;
72 it_vars vars() {
75 return vars_;
76 }
77
78 it_const_vars vars() const {
79 return vars_;
80 }
81
82 ResourceVarFileInfo& type(uint16_t type) {
83 type_ = type;
84 return *this;
85 }
86
87 ResourceVarFileInfo& key(std::u16string key) {
88 key_ = std::move(key);
89 return *this;
90 }
91
92 void add_var(ResourceVar var) {
93 vars_.push_back(std::move(var));
94 }
95
96 void accept(Visitor& visitor) const override;
97
98 LIEF_API friend
99 std::ostream& operator<<(std::ostream& os, const ResourceVarFileInfo& entry);
100
101 private:
102 uint16_t type_ = 0;
103 std::u16string key_;
104 vars_t vars_;
105};
106}
107}
108
109#endif
Object.hpp
ResourceVar.hpp
LIEF::BinaryStream
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:33
LIEF::PE::ResourceVarFileInfo
Representation of the VarFileInfo structure.
Definition ResourceVarFileInfo.hpp:39
LIEF::PE::ResourceVarFileInfo::type
ResourceVarFileInfo & type(uint16_t type)
Definition ResourceVarFileInfo.hpp:82
LIEF::PE::ResourceVarFileInfo::parse
static result< ResourceVarFileInfo > parse(BinaryStream &stream)
LIEF::PE::ResourceVarFileInfo::operator<<
friend std::ostream & operator<<(std::ostream &os, const ResourceVarFileInfo &entry)
LIEF::PE::ResourceVarFileInfo::key
const std::u16string & key() const
Signature of the structure. Must be the unicode string "VarFileInfo".
Definition ResourceVarFileInfo.hpp:66
LIEF::PE::ResourceVarFileInfo::type
uint16_t type() const
The type of data in the version resource.
Definition ResourceVarFileInfo.hpp:61
LIEF::PE::ResourceVarFileInfo::accept
void accept(Visitor &visitor) const override
LIEF::PE::ResourceVarFileInfo::vars
it_const_vars vars() const
Definition ResourceVarFileInfo.hpp:78
LIEF::PE::ResourceVarFileInfo::ResourceVarFileInfo
ResourceVarFileInfo()=default
LIEF::PE::ResourceVarFileInfo::key_u8
std::string key_u8() const
Key as an utf8 string.
LIEF::PE::ResourceVarFileInfo::key
ResourceVarFileInfo & key(std::u16string key)
Definition ResourceVarFileInfo.hpp:87
LIEF::PE::ResourceVarFileInfo::vars
it_vars vars()
Iterator over the embedded variables associated to the structure.
Definition ResourceVarFileInfo.hpp:74
LIEF::PE::ResourceVarFileInfo::operator=
ResourceVarFileInfo & operator=(ResourceVarFileInfo &&)=default
LIEF::PE::ResourceVarFileInfo::operator=
ResourceVarFileInfo & operator=(const ResourceVarFileInfo &)=default
LIEF::PE::ResourceVarFileInfo::add_var
void add_var(ResourceVar var)
Definition ResourceVarFileInfo.hpp:92
LIEF::PE::ResourceVarFileInfo::ResourceVarFileInfo
ResourceVarFileInfo(ResourceVarFileInfo &&)=default
LIEF::PE::ResourceVarFileInfo::~ResourceVarFileInfo
~ResourceVarFileInfo() override=default
LIEF::PE::ResourceVarFileInfo::ResourceVarFileInfo
ResourceVarFileInfo(const ResourceVarFileInfo &)=default
errors.hpp
iterators.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