File: pyResourceDialog.cpp

package info (click to toggle)
lief 0.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 16,036 kB
  • sloc: cpp: 76,013; python: 6,167; ansic: 3,355; pascal: 404; sh: 98; makefile: 32
file content (166 lines) | stat: -rw-r--r-- 6,263 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/* Copyright 2017 R. Thomas
 * Copyright 2017 Quarkslab
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include "pyPE.hpp"

#include "LIEF/PE/hash.hpp"
#include "LIEF/PE/resources/ResourceDialog.hpp"

#include <string>
#include <sstream>


namespace LIEF {
namespace PE {

template<class T>
using getter_t = T (ResourceDialog::*)(void) const;

template<class T>
using setter_t = void (ResourceDialog::*)(T);


template<>
void create<ResourceDialog>(py::module& m) {
  py::class_<ResourceDialog, LIEF::Object>(m, "ResourceDialog")

    .def_property_readonly("is_extended",
        &ResourceDialog::is_extended,
        "``True`` if the dialog is an extended one")

    .def_property_readonly("version",
        &ResourceDialog::version,
        "The version number of the extended dialog box template. This member must be set to 1.")

    .def_property_readonly("signature",
        &ResourceDialog::signature,
        "Indicates whether a template is an extended dialog box template:\n\n"
        "* ``0xFFFF``: Extended dialog box template\n"
        "* Other value: Standard dialog box template")

    .def_property_readonly("help_id",
        &ResourceDialog::version,
        "The help context identifier for the dialog box window")

    .def_property_readonly("x",
        static_cast<getter_t<int16_t>>(&ResourceDialog::x),
        "The x-coordinate, in dialog box units, of the upper-left corner of the dialog box.")

    .def_property_readonly("y",
        static_cast<getter_t<int16_t>>(&ResourceDialog::y),
        "The y-coordinate, in dialog box units, of the upper-left corner of the dialog box.")

    .def_property_readonly("cx",
        static_cast<getter_t<int16_t>>(&ResourceDialog::cx),
        "The width, in dialog box units, of the dialog box.")

    .def_property_readonly("cy",
        static_cast<getter_t<int16_t>>(&ResourceDialog::cy),
        "The height, in dialog box units, of the dialog box.")

    .def_property_readonly("title",
        static_cast<getter_t<const std::u16string&>>(&ResourceDialog::title),
        "The title of the dialog box")

    .def_property_readonly("typeface",
        static_cast<getter_t<const std::u16string&>>(&ResourceDialog::typeface),
        "The name of the typeface for the font")

    .def_property_readonly("weight",
        static_cast<getter_t<uint16_t>>(&ResourceDialog::weight),
        "The weight of the font")

    .def_property_readonly("point_size",
        static_cast<getter_t<uint16_t>>(&ResourceDialog::point_size),
        "The point size of the font to use for the text in the dialog box and its controls.")

    .def_property_readonly("charset",
        static_cast<getter_t<uint8_t>>(&ResourceDialog::charset),
        "The character set to be used")

    .def_property_readonly("style_list",
        &ResourceDialog::style_list,
        "Return list of " RST_CLASS_REF(lief.PE.WINDOW_STYLES) " associated with the "
        ":attr:`~lief.PE.ResourceDialog.style` member")

    .def_property_readonly("dialogbox_style_list",
        &ResourceDialog::dialogbox_style_list,
        "Return list of " RST_CLASS_REF(lief.PE.DIALOG_BOX_STYLES) " associated with the "
        ":attr:`~lief.PE.ResourceDialog.style` member")

    .def_property_readonly("extended_style_list",
        &ResourceDialog::dialogbox_style_list,
        "Return list of " RST_CLASS_REF(lief.PE.EXTENDED_WINDOW_STYLES) " associated with the "
        ":attr:`~lief.PE.ResourceDialog.extended_style` member")

    .def_property_readonly("style",
        &ResourceDialog::extended_style,
        "The style of the dialog box. This member can be a combination of " RST_CLASS_REF(lief.PE.WINDOW_STYLES)         " and " RST_CLASS_REF(lief.PE.DIALOG_BOX_STYLES) "")

    .def_property_readonly("extended_style",
        &ResourceDialog::extended_style,
        "The extended windows styles (" RST_CLASS_REF(lief.PE.EXTENDED_WINDOW_STYLES) ")")

    .def_property_readonly("items",
        &ResourceDialog::items,
        "Iterator on the controls (" RST_CLASS_REF(lief.PE.ResourceDialogItem) ") that define the Dialog (Button, Label...)")

    .def("has_style",
        &ResourceDialog::has_style,
        "Check if the :attr:`~lief.PE.ResourceDialog.style` member has the given "
        "" RST_CLASS_REF(lief.PE.WINDOW_STYLES) "",
        "style"_a)

    .def("has_dialogbox_style",
        &ResourceDialog::has_dialogbox_style,
        "Check if the :attr:`~lief.PE.ResourceDialog.style` member has the given "
        "" RST_CLASS_REF(lief.PE.DIALOG_BOX_STYLES) "",
        "style"_a)

    .def("has_extended_style",
        &ResourceDialog::has_extended_style,
        "Check if the :attr:`~lief.PE.ResourceDialog.extended_style` member has the given "
        "" RST_CLASS_REF(lief.PE.EXTENDED_WINDOW_STYLES) "",
        "style"_a)

    .def_property("lang",
        static_cast<getter_t<RESOURCE_LANGS>>(&ResourceDialog::lang),
        static_cast<setter_t<RESOURCE_LANGS>>(&ResourceDialog::lang),
        "Primary " RST_CLASS_REF(lief.PE.RESOURCE_LANGS) " associated with the dialog")

    .def_property("sub_lang",
        static_cast<getter_t<RESOURCE_SUBLANGS>>(&ResourceDialog::sub_lang),
        static_cast<setter_t<RESOURCE_SUBLANGS>>(&ResourceDialog::sub_lang),
        "Secondary " RST_CLASS_REF(lief.PE.RESOURCE_SUBLANGS) " associated with the dialog")

    .def("__eq__", &ResourceDialog::operator==)
    .def("__ne__", &ResourceDialog::operator!=)
    .def("__hash__",
        [] (const ResourceDialog& dialog) {
          return Hash::hash(dialog);
        })

    .def("__str__",
        [] (const ResourceDialog& dialog) {
          std::ostringstream stream;
          stream << dialog;
          std::string str = stream.str();
          return str;
        });
}

}
}