LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
ResourceAccelerator.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef LIEF_PE_RESOURCE_ACCELERATOR_H
16#define LIEF_PE_RESOURCE_ACCELERATOR_H
17
18#include <ostream>
19#include <vector>
20
21#include "LIEF/visibility.h"
22
23#include "LIEF/Object.hpp"
24
26#include "LIEF/enums.hpp"
27
28
29namespace LIEF::PE {
31
32namespace details {
33struct pe_resource_acceltableentry;
34}
35
37 friend class ResourcesManager;
38
39 public:
41 enum class FLAGS : uint32_t {
44 VIRTKEY = 0x01,
45
49 NOINVERT = 0x02,
50
53 SHIFT = 0x04,
54
57 CONTROL = 0x08,
58
61 ALT = 0x10,
62
64 END = 0x80,
65 };
66
68 explicit ResourceAccelerator(const details::pe_resource_acceltableentry&);
69
72
75
76 ~ResourceAccelerator() override = default;
77
78 std::vector<FLAGS> flags_list() const;
79
80 const char* ansi_str() const {
82 }
83
85 int16_t flags() const {
86 return flags_;
87 }
88
91 int16_t ansi() const {
92 return ansi_;
93 }
94
96 uint16_t id() const {
97 return id_;
98 }
99
102 int16_t padding() const {
103 return padding_;
104 }
105
107 bool has(FLAGS flag) const {
108 return (flags_ & (int16_t)flag) != 0;
109 }
110
112 flags_ |= (int16_t)flag;
113 return *this;
114 }
115
117 flags_ &= ~(int16_t)flag;
118 return *this;
119 }
120
121 void accept(Visitor& visitor) const override;
122
123 LIEF_API friend std::ostream& operator<<(std::ostream& os,
124 const ResourceAccelerator& acc);
125
126 private:
127 int16_t flags_ = 0;
128 int16_t ansi_ = 0;
129 uint16_t id_ = 0;
130 int16_t padding_ = 0;
131};
132
134
135}
136
137
139#endif
ResourceAccelerator(const details::pe_resource_acceltableentry &)
const char * ansi_str() const
Definition ResourceAccelerator.hpp:80
int16_t ansi() const
An ANSI character value or a virtual-key code that identifies the accelerator key.
Definition ResourceAccelerator.hpp:91
ResourceAccelerator & add(FLAGS flag)
Definition ResourceAccelerator.hpp:111
ResourceAccelerator & operator=(ResourceAccelerator &&)=default
ResourceAccelerator & operator=(const ResourceAccelerator &)=default
ResourceAccelerator & remove(FLAGS flag)
Definition ResourceAccelerator.hpp:116
ResourceAccelerator(ResourceAccelerator &&)=default
uint16_t id() const
An identifier for the keyboard accelerator.
Definition ResourceAccelerator.hpp:96
std::vector< FLAGS > flags_list() const
~ResourceAccelerator() override=default
int16_t flags() const
Describe the keyboard accelerator characteristics.
Definition ResourceAccelerator.hpp:85
friend class ResourcesManager
Definition ResourceAccelerator.hpp:37
FLAGS
From: https://docs.microsoft.com/en-us/windows/win32/menurc/acceltableentry.
Definition ResourceAccelerator.hpp:41
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:107
int16_t padding() const
The number of bytes inserted to ensure that the structure is aligned on a DWORD boundary.
Definition ResourceAccelerator.hpp:102
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:37
Definition Visitor.hpp:211
#define ENABLE_BITMASK_OPERATORS(X)
Definition enums.hpp:23
const char * to_string(lief_errors err)
Definition DataDirectory.hpp:37
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:31
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:24
@ SHIFT
Definition AcceleratorCodes.hpp:35
@ CONTROL
Definition AcceleratorCodes.hpp:36
#define LIEF_API
Definition visibility.h:44