LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
ResourceAccelerator.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_ACCELERATOR_H
17#define LIEF_PE_RESOURCE_ACCELERATOR_H
18
19#include <string>
20#include <ostream>
21#include <vector>
22
23#include "LIEF/visibility.h"
24
25#include "LIEF/Object.hpp"
26
28#include "LIEF/enums.hpp"
29
30namespace LIEF {
31namespace PE {
33
34namespace details {
35struct pe_resource_acceltableentry;
36}
37
39 friend class ResourcesManager;
40 public:
41
43 enum class FLAGS : uint32_t {
46 VIRTKEY = 0x01,
47
51 NOINVERT = 0x02,
52
55 SHIFT = 0x04,
56
59 CONTROL = 0x08,
60
63 ALT = 0x10,
64
66 END = 0x80,
67 };
68
70 explicit ResourceAccelerator(const details::pe_resource_acceltableentry&);
71
74
77
78 ~ResourceAccelerator() override = default;
79
80 std::vector<FLAGS> flags_list() const;
81
82 const char* ansi_str() const {
84 }
85
87 int16_t flags() const {
88 return flags_;
89 }
90
93 int16_t ansi() const {
94 return ansi_;
95 }
96
98 uint16_t id() const {
99 return id_;
100 }
101
104 int16_t padding() const {
105 return padding_;
106 }
107
109 bool has(FLAGS flag) const {
110 return (flags_ & (int16_t)flag) != 0;
111 }
112
114 flags_ |= (int16_t)flag;
115 return *this;
116 }
117
119 flags_ &= ~(int16_t)flag;
120 return *this;
121 }
122
123 void accept(Visitor& visitor) const override;
124
125 LIEF_API friend std::ostream& operator<<(std::ostream& os, const ResourceAccelerator& acc);
126
127 private:
128 int16_t flags_ = 0;
129 int16_t ansi_ = 0;
130 uint16_t id_ = 0;
131 int16_t padding_ = 0;
132};
133
135
136}
137}
138
140#endif
ResourceAccelerator(const details::pe_resource_acceltableentry &)
const char * ansi_str() const
Definition ResourceAccelerator.hpp:82
int16_t ansi() const
An ANSI character value or a virtual-key code that identifies the accelerator key.
Definition ResourceAccelerator.hpp:93
ResourceAccelerator & add(FLAGS flag)
Definition ResourceAccelerator.hpp:113
ResourceAccelerator & operator=(ResourceAccelerator &&)=default
ResourceAccelerator & operator=(const ResourceAccelerator &)=default
ResourceAccelerator & remove(FLAGS flag)
Definition ResourceAccelerator.hpp:118
ResourceAccelerator(ResourceAccelerator &&)=default
uint16_t id() const
An identifier for the keyboard accelerator.
Definition ResourceAccelerator.hpp:98
std::vector< FLAGS > flags_list() const
~ResourceAccelerator() override=default
int16_t flags() const
Describe the keyboard accelerator characteristics.
Definition ResourceAccelerator.hpp:87
friend class ResourcesManager
Definition ResourceAccelerator.hpp:39
FLAGS
From: https://docs.microsoft.com/en-us/windows/win32/menurc/acceltableentry.
Definition ResourceAccelerator.hpp:43
@ SHIFT
The accelerator is activated only if the user presses the SHIFT key. This flag applies only to virtua...
Definition ResourceAccelerator.hpp:55
@ VIRTKEY
The accelerator key is a virtual-key code. If this flag is not specified, the accelerator key is assu...
Definition ResourceAccelerator.hpp:46
@ NOINVERT
A menu item on the menu bar is not highlighted when an accelerator is used. This attribute is obsolet...
Definition ResourceAccelerator.hpp:51
@ END
The entry is last in an accelerator table.
Definition ResourceAccelerator.hpp:66
@ CONTROL
The accelerator is activated only if the user presses the CTRL key. This flag applies only to virtual...
Definition ResourceAccelerator.hpp:59
@ ALT
The accelerator is activated only if the user presses the ALT key. This flag applies only to virtual ...
Definition ResourceAccelerator.hpp:63
ResourceAccelerator(const ResourceAccelerator &)=default
void accept(Visitor &visitor) const override
bool has(FLAGS flag) const
Whether the entry has the given flag.
Definition ResourceAccelerator.hpp:109
int16_t padding() const
The number of bytes inserted to ensure that the structure is aligned on a DWORD boundary.
Definition ResourceAccelerator.hpp:104
friend std::ostream & operator<<(std::ostream &os, const ResourceAccelerator &acc)
The Resource Manager provides an enhanced API to manipulate the resource tree.
Definition ResourcesManager.hpp:38
Definition Visitor.hpp:210
#define ENABLE_BITMASK_OPERATORS(X)
Definition enums.hpp:24
const char * to_string(lief_errors err)
Definition DataDirectory.hpp:37
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
const char * to_string(CODE_PAGES e)
ACCELERATOR_CODES
From https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes.
Definition AcceleratorCodes.hpp:25
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:41