LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
ResourceDialogRegular.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_DIALOG_REGULAR_H
17#define LIEF_PE_RESOURCE_DIALOG_REGULAR_H
18
19#include "LIEF/visibility.h"
21#include "LIEF/errors.hpp"
22#include "LIEF/iterators.hpp"
23#include "LIEF/span.hpp"
24
25namespace LIEF {
26class BinaryStream;
27
28namespace PE {
29
34 public:
36
41 public:
42 Item() = default;
43 Item(const Item&) = default;
44 Item& operator=(const Item&) = default;
45
46 Item(Item&&) = default;
47 Item& operator=(Item&&) = default;
48
50
51 std::string to_string() const override;
52
53 ~Item() override = default;
54 };
55
58 struct font_t {
59 uint16_t point_size = 0;
60 std::u16string name;
61
62 bool is_defined() const {
63 return point_size != 0;
64 }
65
66 operator bool() const {
67 return is_defined();
68 }
69
70 std::string to_string() const;
71
72 LIEF_API friend std::ostream& operator<<(std::ostream& os, const font_t& font) {
73 os << font.to_string();
74 return os;
75 }
76 };
77
78 using items_t = std::vector<Item>;
81
85
88
91
92 static std::unique_ptr<ResourceDialogRegular> create(BinaryStream& stream);
93
94 std::unique_ptr<ResourceDialog> clone() const override {
95 return std::unique_ptr<ResourceDialogRegular>(new ResourceDialogRegular(*this));
96 }
97
98 static bool classof(const ResourceDialog* dialog) {
99 return dialog->type() == ResourceDialog::TYPE::REGULAR;
100 }
101
102 std::string to_string() const override;
103
105 uint32_t nb_items() const {
106 return items_.size();
107 }
108
111 return items_;
112 }
113
115 return items_;
116 }
117
119 void add_item(const Item& item) {
120 items_.push_back(item);
121 }
122
124 const font_t& font() const {
125 return font_;
126 }
127
128 ResourceDialogRegular& font(uint16_t pointsize, std::u16string name) {
129 font_.name = std::move(name);
130 font_.point_size = pointsize;
131 return *this;
132 }
133
135 font_ = std::move(f);
136 return *this;
137 }
138
139 void accept(Visitor& visitor) const override;
140
141 ~ResourceDialogRegular() override = default;
142
143 protected:
144 font_t font_;
145 items_t items_;
146};
147
148}
149}
150
151
152#endif
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:33
This class represents a DLGTEMPLATE item: DLGITEMTEMPLATE.
Definition ResourceDialogRegular.hpp:40
Item & operator=(const Item &)=default
std::string to_string() const override
Item & operator=(Item &&)=default
static result< Item > parse(BinaryStream &stream)
std::vector< Item > items_t
Definition ResourceDialogRegular.hpp:78
~ResourceDialogRegular() override=default
static bool classof(const ResourceDialog *dialog)
Definition ResourceDialogRegular.hpp:98
it_const_items items() const
Definition ResourceDialogRegular.hpp:114
ResourceDialogRegular(const ResourceDialogRegular &)=default
ResourceDialogRegular & font(font_t f)
Definition ResourceDialogRegular.hpp:134
it_items items()
Iterator over the different control items.
Definition ResourceDialogRegular.hpp:110
ref_iterator< items_t & > it_items
Definition ResourceDialogRegular.hpp:79
ResourceDialogRegular & operator=(const ResourceDialogRegular &)=default
void add_item(const Item &item)
Add a new control item to the dialog.
Definition ResourceDialogRegular.hpp:119
std::unique_ptr< ResourceDialog > clone() const override
Definition ResourceDialogRegular.hpp:94
uint32_t nb_items() const
Number of control items.
Definition ResourceDialogRegular.hpp:105
ResourceDialogRegular()
Definition ResourceDialogRegular.hpp:82
ResourceDialogRegular(ResourceDialogRegular &&)=default
const font_t & font() const
Additional font information.
Definition ResourceDialogRegular.hpp:124
std::string to_string() const override
ResourceDialogRegular & font(uint16_t pointsize, std::u16string name)
Definition ResourceDialogRegular.hpp:128
const_ref_iterator< const items_t & > it_const_items
Definition ResourceDialogRegular.hpp:80
void accept(Visitor &visitor) const override
ResourceDialogRegular & operator=(ResourceDialogRegular &&)=default
static std::unique_ptr< ResourceDialogRegular > create(BinaryStream &stream)
This class represents an element of the dialog. It can be for instance, a button, or a caption.
Definition ResourceDialog.hpp:154
TYPE
Enum for discriminating the kind of the Dialog (regular vs extended).
Definition ResourceDialog.hpp:64
@ REGULAR
Definition ResourceDialog.hpp:66
TYPE type() const
Definition ResourceDialog.hpp:333
Definition Visitor.hpp:210
Iterator which returns reference on container's values.
Definition iterators.hpp:46
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
LIEF namespace.
Definition Abstract/Binary.hpp:40
ref_iterator< CT, U, typename decay_t< CT >::const_iterator > const_ref_iterator
Iterator which return const ref on container's values.
Definition iterators.hpp:257
tl::expected< T, lief_errors > result
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:75
This structure represents additional font information that might be embedded at the end of the DLGTEM...
Definition ResourceDialogRegular.hpp:58
bool is_defined() const
Definition ResourceDialogRegular.hpp:62
std::u16string name
Definition ResourceDialogRegular.hpp:60
uint16_t point_size
Definition ResourceDialogRegular.hpp:59
friend std::ostream & operator<<(std::ostream &os, const font_t &font)
Definition ResourceDialogRegular.hpp:72
This structure wraps either an ordinal value (uint16_t) or a string. The ordinal value should refer t...
Definition ResourceDialog.hpp:48
#define LIEF_API
Definition visibility.h:41