LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
ResourceDialogExtended.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 * Copyright 2017 - 2026 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_EXTENDED_H
17#define LIEF_PE_RESOURCE_DIALOG_EXTENDED_H
18
19#include "LIEF/visibility.h"
21#include "LIEF/errors.hpp"
22#include "LIEF/iterators.hpp"
23
24namespace LIEF {
25class BinaryStream;
26
27namespace PE {
28
33 public:
38 public:
39 Item() = default;
40 Item(const Item&) = default;
41 Item& operator=(const Item&) = default;
42
43 Item(Item&&) = default;
44 Item& operator=(Item&&) = default;
45
47
48 std::string to_string() const override;
49
53 uint32_t help_id() const {
54 return help_id_;
55 }
56
57 Item& help_id(uint32_t value) {
58 help_id_ = value;
59 return *this;
60 }
61
62 ~Item() override = default;
63
64 protected:
65 uint32_t help_id_ = 0;
66 };
67
72 uint16_t point_size = 0;
73
75 uint16_t weight = 0;
76
78 bool italic = false;
79
81 uint8_t charset = false;
82
84 std::u16string typeface;
85
86 bool is_defined() const {
87 return point_size != 0 || weight != 0;
88 }
89
90 operator bool() const {
91 return is_defined();
92 }
93
94 std::string to_string() const;
95
96 LIEF_API friend std::ostream& operator<<(std::ostream& os,
97 const font_t& font) {
98 os << font.to_string();
99 return os;
100 }
101 };
102
103 using items_t = std::vector<Item>;
106
109
112
115
116 static std::unique_ptr<ResourceDialogExtended> create(BinaryStream& stream);
117
118 std::unique_ptr<ResourceDialog> clone() const override {
119 return std::unique_ptr<ResourceDialogExtended>(
120 new ResourceDialogExtended(*this)
121 );
122 }
123
124 static bool classof(const ResourceDialog* dialog) {
125 return dialog->type() == ResourceDialog::TYPE::EXTENDED;
126 }
127
128 void accept(Visitor& visitor) const override;
129
130 std::string to_string() const override;
131
132 ~ResourceDialogExtended() override = default;
133
136 uint16_t version() const {
137 return version_;
138 }
139
143 uint16_t signature() const {
144 return signature_;
145 }
146
150 uint32_t help_id() const {
151 return help_id_;
152 }
153
156 return items_;
157 }
158
160 return items_;
161 }
162
164 void add_item(const Item& item) {
165 items_.push_back(item);
166 }
167
169 version_ = value;
170 return *this;
171 }
172
174 signature_ = value;
175 return *this;
176 }
177
179 help_id_ = value;
180 return *this;
181 }
182
184 const font_t& font() const {
185 return font_;
186 }
187
188 ResourceDialogExtended& font(uint16_t point_size, uint16_t weight, bool italic,
189 uint8_t charset, std::u16string typeface) {
190 font_.point_size = point_size;
191 font_.weight = weight;
192 font_.italic = italic;
193 font_.charset = charset;
194 font_.typeface = std::move(typeface);
195 return *this;
196 }
197
199 font_ = std::move(f);
200 return *this;
201 }
202
203 protected:
204 uint16_t version_ = 0;
205 uint16_t signature_ = 0;
206 uint32_t help_id_ = 0;
207 font_t font_;
208 items_t items_;
209};
210
211}
212}
213
214
215#endif
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:33
This class represents a DLGTEMPLATEEX item (DLGITEMTEMPLATEEX).
Definition ResourceDialogExtended.hpp:37
Item & operator=(const Item &)=default
static result< Item > parse(BinaryStream &stream)
std::string to_string() const override
uint32_t help_id() const
The help context identifier for the control. When the system sends a WM_HELP message,...
Definition ResourceDialogExtended.hpp:53
Item & operator=(Item &&)=default
Item & help_id(uint32_t value)
Definition ResourceDialogExtended.hpp:57
std::vector< Item > items_t
Definition ResourceDialogExtended.hpp:103
ResourceDialogExtended(ResourceDialogExtended &&)=default
uint16_t version() const
The version number of the extended dialog box template. This member must be set to 1.
Definition ResourceDialogExtended.hpp:136
void add_item(const Item &item)
Add a new control item to the dialog.
Definition ResourceDialogExtended.hpp:164
ResourceDialogExtended & font(font_t f)
Definition ResourceDialogExtended.hpp:198
uint16_t signature() const
Indicates whether a template is an extended dialog box template. If signature is 0xFFFF,...
Definition ResourceDialogExtended.hpp:143
ResourceDialogExtended & help_id(uint32_t value)
Definition ResourceDialogExtended.hpp:178
static std::unique_ptr< ResourceDialogExtended > create(BinaryStream &stream)
ResourceDialogExtended & signature(uint16_t value)
Definition ResourceDialogExtended.hpp:173
~ResourceDialogExtended() override=default
ResourceDialogExtended & font(uint16_t point_size, uint16_t weight, bool italic, uint8_t charset, std::u16string typeface)
Definition ResourceDialogExtended.hpp:188
const font_t & font() const
Additional font information.
Definition ResourceDialogExtended.hpp:184
ResourceDialogExtended & version(uint16_t value)
Definition ResourceDialogExtended.hpp:168
std::unique_ptr< ResourceDialog > clone() const override
Definition ResourceDialogExtended.hpp:118
void accept(Visitor &visitor) const override
ResourceDialogExtended(const ResourceDialogExtended &)=default
static bool classof(const ResourceDialog *dialog)
Definition ResourceDialogExtended.hpp:124
ResourceDialogExtended & operator=(const ResourceDialogExtended &)=default
it_const_items items() const
Definition ResourceDialogExtended.hpp:159
ref_iterator< items_t & > it_items
Definition ResourceDialogExtended.hpp:104
std::string to_string() const override
it_items items()
Iterator over the control items of this dialog box.
Definition ResourceDialogExtended.hpp:155
uint32_t help_id() const
The help context identifier for the dialog box window. When the system sends a WM_HELP message,...
Definition ResourceDialogExtended.hpp:150
const_ref_iterator< const items_t & > it_const_items
Definition ResourceDialogExtended.hpp:105
ResourceDialogExtended()
Definition ResourceDialogExtended.hpp:107
ResourceDialogExtended & operator=(ResourceDialogExtended &&)=default
This class represents an element of the dialog. It can be for instance, a button, or a caption.
Definition ResourceDialog.hpp:159
TYPE
Enum for discriminating the kind of the Dialog (regular vs extended).
Definition ResourceDialog.hpp:65
@ EXTENDED
Definition ResourceDialog.hpp:68
TYPE type() const
Definition ResourceDialog.hpp:360
Definition Visitor.hpp:212
Iterator which returns reference on container's values.
Definition iterators.hpp:45
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:77
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:286
Font information for the font to use for the text in the dialog box and its controls.
Definition ResourceDialogExtended.hpp:70
bool is_defined() const
Definition ResourceDialogExtended.hpp:86
uint16_t point_size
The point size of the font.
Definition ResourceDialogExtended.hpp:72
std::u16string typeface
The name of the typeface for the font.
Definition ResourceDialogExtended.hpp:84
friend std::ostream & operator<<(std::ostream &os, const font_t &font)
Definition ResourceDialogExtended.hpp:96
uint8_t charset
The character set to be used.
Definition ResourceDialogExtended.hpp:81
uint16_t weight
The weight of the font.
Definition ResourceDialogExtended.hpp:75
bool italic
Indicates whether the font is italic.
Definition ResourceDialogExtended.hpp:78
#define LIEF_API
Definition visibility.h:43