16#ifndef LIEF_PE_RESOURCE_DIALOG_H
17#define LIEF_PE_RESOURCE_DIALOG_H
45 using dialogs_t = std::vector<std::unique_ptr<ResourceDialog>>;
55 return ordinal || !
string.empty();
58 operator bool()
const {
82 SETFOREGROUND = 0x0200,
85 NOFAILCREATE = 0x0010,
90 SHELLFONT = SETFONT | FIXEDSYS,
97 OVERLAPPED = 0x00000000,
100 MINIMIZE = 0x20000000,
101 VISIBLE = 0x10000000,
102 DISABLED = 0x08000000,
103 CLIPSIBLINGS = 0x04000000,
104 CLIPCHILDREN = 0x02000000,
105 MAXIMIZE = 0x01000000,
106 CAPTION = 0x00C00000,
108 DLGFRAME = 0x00400000,
109 VSCROLL = 0x00200000,
110 HSCROLL = 0x00100000,
111 SYSMENU = 0x00080000,
112 THICKFRAME = 0x00040000,
114 TABSTOP = 0x00010000,
122 DLGMODALFRAME = 0x00000001,
123 NOPARENTNOTIFY = 0x00000004,
124 TOPMOST = 0x00000008,
125 ACCEPTFILES = 0x00000010,
126 TRANSPARENT_STY = 0x00000020,
127 MDICHILD = 0x00000040,
128 TOOLWINDOW = 0x00000080,
129 WINDOWEDGE = 0x00000100,
130 CLIENTEDGE = 0x00000200,
131 CONTEXTHELP = 0x00000400,
135 RTLREADING = 0x00002000,
136 LEFTSCROLLBAR = 0x00004000,
138 CONTROLPARENT = 0x00010000,
139 STATICEDGE = 0x00020000,
140 APPWINDOW = 0x00040000,
149 NOMOVEY = 0x00000002,
151 NORESIZE = 0x00000004,
152 NOPARENTALIGN = 0x00000008,
153 ADJUSTABLE = 0x00000020,
154 NODIVIDER = 0x00000040,
158 NOMOVEX = VERT | NOMOVEY,
198 return extended_style_;
208 return (style_ & (uint32_t)
style) != 0;
213 return (style_ & (uint32_t)
style) != 0;
252 extended_style_ = value;
284 class_.string = std::move(
title);
290 class_.ordinal = ord;
295 title_.string = std::move(value);
301 title_.ordinal = ord;
321 return creation_data_;
325 return creation_data_;
339 uint32_t extended_style_ = 0;
350 std::vector<uint8_t> creation_data_;
367 virtual std::unique_ptr<ResourceDialog>
clone()
const = 0;
384 return extended_style_;
415 extended_style_ = value;
437 menu_.string = std::move(
title);
448 window_class_.string = std::move(
title);
454 window_class_.ordinal = ord;
459 title_ = std::move(value);
467 return (style_ & (uint32_t)
style) != 0;
472 return (style_ & (uint32_t)
style) != 0;
477 return (extended_style_ & (uint32_t)
style) != 0;
505 return window_class_;
517 static_assert(std::is_base_of<ResourceDialog, T>::value,
518 "Require ResourceDialog inheritance");
519 if (T::classof(
this)) {
520 return static_cast<const T*
>(
this);
541 TYPE type_ = TYPE::UNKNOWN;
544 uint32_t extended_style_ = 0;
551 ordinal_or_str_t menu_;
552 ordinal_or_str_t window_class_;
554 std::u16string title_;
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:35
Class which represents a Data Node in the PE resources tree.
Definition ResourceData.hpp:34
This class represents an element of the dialog. It can be for instance, a button, or a caption.
Definition ResourceDialog.hpp:168
const ordinal_or_str_t & clazz() const
Window class of the control. This can be either: a string that specifies the name of a registered win...
Definition ResourceDialog.hpp:308
Item & cy(int16_t value)
Definition ResourceDialog.hpp:268
Item & y(int16_t value)
Definition ResourceDialog.hpp:260
friend std::ostream & operator<<(std::ostream &os, const Item &item)
Definition ResourceDialog.hpp:332
Item & cx(int16_t value)
Definition ResourceDialog.hpp:264
bool has(WINDOW_STYLES style) const
Check if this item has the given WINDOW_STYLES.
Definition ResourceDialog.hpp:207
WINDOW_CLASS
Definition ResourceDialog.hpp:177
const ordinal_or_str_t & title() const
Title of the item which can be either: a string that specifies the initial text or an ordinal value o...
Definition ResourceDialog.hpp:315
Item & extended_style(uint32_t value)
Definition ResourceDialog.hpp:251
span< uint8_t > creation_data()
Definition ResourceDialog.hpp:324
virtual std::string to_string() const =0
Item & title(uint16_t ord)
Definition ResourceDialog.hpp:300
Item & operator=(Item &&)=default
int32_t id() const
The control identifier.
Definition ResourceDialog.hpp:202
Item(const Item &)=default
span< const uint8_t > creation_data() const
Creation data that is passed to the control's window procedure.
Definition ResourceDialog.hpp:320
uint32_t style() const
The style of the control. This can be a combination of WINDOW_STYLES or CONTROL_STYLES.
Definition ResourceDialog.hpp:188
std::vector< WINDOW_STYLES > window_styles() const
List of WINDOW_STYLES used by this item.
Item & clazz(uint16_t ord)
Definition ResourceDialog.hpp:289
int16_t cx() const
The width, in dialog box units, of the control.
Definition ResourceDialog.hpp:237
bool has(CONTROL_STYLES style) const
Check if this item has the given CONTROL_STYLES.
Definition ResourceDialog.hpp:212
uint32_t extended_style() const
The extended styles for a window. This member is not used to create controls in dialog boxes,...
Definition ResourceDialog.hpp:197
Item & style(uint32_t value)
Definition ResourceDialog.hpp:246
int16_t cy() const
The height, in dialog box units, of the control.
Definition ResourceDialog.hpp:242
Item & operator=(const Item &)=default
Item & x(int16_t value)
Definition ResourceDialog.hpp:256
Item & data(std::vector< uint8_t > creation_data)
Definition ResourceDialog.hpp:278
std::vector< CONTROL_STYLES > control_styles() const
List of CONTROL_STYLES used by this item.
Item & id(int32_t value)
Definition ResourceDialog.hpp:273
int16_t y() const
The y-coordinate, in dialog box units, of the upper-left corner of the control. This coordinate is al...
Definition ResourceDialog.hpp:232
Item & title(std::u16string value)
Definition ResourceDialog.hpp:294
int16_t x() const
The x-coordinate, in dialog box units, of the upper-left corner of the control. This coordinate is al...
Definition ResourceDialog.hpp:225
Item & clazz(std::u16string title)
Definition ResourceDialog.hpp:283
This class is the base class for either a regular (legacy) Dialog or an extended Dialog....
Definition ResourceDialog.hpp:43
ResourceDialog & window_class(std::u16string title)
Definition ResourceDialog.hpp:447
virtual std::string to_string() const =0
std::vector< WINDOW_STYLES > windows_styles_list() const
List of WINDOW_STYLES used by this dialog.
CONTROL_STYLES
From: https://learn.microsoft.com/en-us/windows/win32/controls/common-control-styles.
Definition ResourceDialog.hpp:146
WINDOW_EXTENDED_STYLES
From https://docs.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles.
Definition ResourceDialog.hpp:120
ResourceDialog(ResourceDialog &&)=default
static dialogs_t parse(const ResourceData &node)
Parse dialogs from the given resource data node.
ResourceDialog & window_class(uint16_t ord)
Definition ResourceDialog.hpp:453
ResourceDialog(const ResourceDialog &)=default
const T * as() const
Helper to downcast a ResourceDialog into a ResourceDialogRegular or a ResourceDialogExtended.
Definition ResourceDialog.hpp:516
ResourceDialog & title(std::u16string value)
Definition ResourceDialog.hpp:458
ResourceDialog & title(const std::string &title)
friend std::ostream & operator<<(std::ostream &os, const ResourceDialog &dialog)
Definition ResourceDialog.hpp:525
ResourceDialog & menu(std::u16string title)
Definition ResourceDialog.hpp:436
DIALOG_STYLES
From: https://learn.microsoft.com/en-us/windows/win32/dlgbox/dialog-box-styles.
Definition ResourceDialog.hpp:74
int16_t cx() const
The width, in dialog box units, of the dialog box.
Definition ResourceDialog.hpp:400
bool has(WINDOW_EXTENDED_STYLES style) const
Check if the dialog uses the given extended window style.
Definition ResourceDialog.hpp:476
uint32_t style() const
The style of the dialog box. This member can be a combination of window style values (such as WINDOW_...
Definition ResourceDialog.hpp:376
virtual std::unique_ptr< ResourceDialog > clone() const =0
bool has(WINDOW_STYLES style) const
Check if the dialog uses the given window style.
Definition ResourceDialog.hpp:471
ResourceDialog & menu(uint16_t ord)
Definition ResourceDialog.hpp:442
ResourceDialog & extended_style(uint32_t value)
Definition ResourceDialog.hpp:414
ResourceDialog & operator=(ResourceDialog &&)=default
ResourceDialog & y(int16_t value)
Definition ResourceDialog.hpp:423
ResourceDialog & cx(int16_t value)
Definition ResourceDialog.hpp:427
TYPE
Enum for discriminating the kind of the Dialog (regular vs extended).
Definition ResourceDialog.hpp:66
const ordinal_or_str_t & menu() const
ordinal or name value of a menu resource.
Definition ResourceDialog.hpp:498
ResourceDialog & style(uint32_t value)
Definition ResourceDialog.hpp:409
uint32_t extended_style() const
The extended styles for a window. This member is not used to create dialog boxes, but applications th...
Definition ResourceDialog.hpp:383
std::vector< std::unique_ptr< ResourceDialog > > dialogs_t
Definition ResourceDialog.hpp:45
bool has(DIALOG_STYLES style) const
Check if the dialog uses the given dialog style.
Definition ResourceDialog.hpp:466
WINDOW_STYLES
From: https://docs.microsoft.com/en-us/windows/win32/winmsg/window-styles.
Definition ResourceDialog.hpp:95
int16_t x() const
The x-coordinate, in dialog box units, of the upper-left corner of the dialog box.
Definition ResourceDialog.hpp:389
ResourceDialog & x(int16_t value)
Definition ResourceDialog.hpp:419
ResourceDialog & operator=(const ResourceDialog &)=default
std::vector< WINDOW_EXTENDED_STYLES > windows_ext_styles_list() const
List of WINDOW_EXTENDED_STYLES used by this dialog.
std::string title_utf8() const
title of the dialog box
ResourceDialog & cy(int16_t value)
Definition ResourceDialog.hpp:431
virtual ~ResourceDialog()=default
int16_t y() const
The y-coordinate, in dialog box units, of the upper-left corner of the dialog box.
Definition ResourceDialog.hpp:395
int16_t cy() const
The height, in dialog box units, of the dialog box.
Definition ResourceDialog.hpp:405
static dialogs_t parse(const uint8_t *buffer, size_t size)
const ordinal_or_str_t & window_class() const
ordinal of a predefined system window class or name of a registered window class
Definition ResourceDialog.hpp:504
const std::u16string & title() const
title of the dialog box
Definition ResourceDialog.hpp:490
TYPE type() const
Definition ResourceDialog.hpp:369
std::vector< DIALOG_STYLES > styles_list() const
List of DIALOG_STYLES used by this dialog.
ResourceDialog(TYPE ty)
Definition ResourceDialog.hpp:364
Opaque structure that is used by LIEF to avoid writing result<void> f(...). Instead,...
Definition errors.hpp:119
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:79
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
#define ENABLE_BITMASK_OPERATORS(X)
Definition enums.hpp:24
@ not_found
Definition errors.hpp:26
tl::unexpected< lief_errors > make_error_code(lief_errors e)
Create a standard error code from lief_errors.
Definition errors.hpp:55
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
const char * to_string(CODE_PAGES e)
@ RIGHT
Definition AcceleratorCodes.hpp:59
@ LEFT
Definition AcceleratorCodes.hpp:57
@ T
Definition AcceleratorCodes.hpp:97
@ CONTROL
Definition AcceleratorCodes.hpp:37
LIEF namespace.
Definition Abstract/Binary.hpp:41
tcb::span< ElementType, Extent > span
Definition span.hpp:22
This structure wraps either an ordinal value (uint16_t) or a string. The ordinal value should refer t...
Definition ResourceDialog.hpp:50
std::string to_string() const
bool is_defined() const
Definition ResourceDialog.hpp:54
std::u16string string
Definition ResourceDialog.hpp:52
result< uint16_t > ordinal
Definition ResourceDialog.hpp:51
#define LIEF_API
Definition visibility.h:45