LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
ResourceAccelerator.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_ACCELERATOR_H
17#define LIEF_PE_RESOURCE_ACCELERATOR_H
18
19#include <ostream>
20#include <vector>
21
22#include "LIEF/visibility.h"
23
24#include "LIEF/Object.hpp"
25
27#include "LIEF/enums.hpp"
28
29namespace LIEF {
30namespace PE {
32
33namespace details {
34struct pe_resource_acceltableentry;
35}
36
38 friend class ResourcesManager;
39
40 public:
42 enum class FLAGS : uint32_t {
45 VIRTKEY = 0x01,
46
50 NOINVERT = 0x02,
51
54 SHIFT = 0x04,
55
58 CONTROL = 0x08,
59
62 ALT = 0x10,
63
65 END = 0x80,
66 };
67
69 explicit ResourceAccelerator(const details::pe_resource_acceltableentry&);
70
73
76
77 ~ResourceAccelerator() override = default;
78
79 std::vector<FLAGS> flags_list() const;
80
81 const char* ansi_str() const {
83 }
84
86 int16_t flags() const {
87 return flags_;
88 }
89
92 int16_t ansi() const {
93 return ansi_;
94 }
95
97 uint16_t id() const {
98 return id_;
99 }
100
103 int16_t padding() const {
104 return padding_;
105 }
106
108 bool has(FLAGS flag) const {
109 return (flags_ & (int16_t)flag) != 0;
110 }
111
113 flags_ |= (int16_t)flag;
114 return *this;
115 }
116
118 flags_ &= ~(int16_t)flag;
119 return *this;
120 }
121
122 void accept(Visitor& visitor) const override;
123
124 LIEF_API friend std::ostream& operator<<(std::ostream& os,
125 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:81
int16_t ansi() const
An ANSI character value or a virtual-key code that identifies the accelerator key.
Definition ResourceAccelerator.hpp:92
ResourceAccelerator & add(FLAGS flag)
Definition ResourceAccelerator.hpp:112
ResourceAccelerator & operator=(ResourceAccelerator &&)=default
ResourceAccelerator & operator=(const ResourceAccelerator &)=default
ResourceAccelerator & remove(FLAGS flag)
Definition ResourceAccelerator.hpp:117
ResourceAccelerator(ResourceAccelerator &&)=default
uint16_t id() const
An identifier for the keyboard accelerator.
Definition ResourceAccelerator.hpp:97
std::vector< FLAGS > flags_list() const
~ResourceAccelerator() override=default
int16_t flags() const
Describe the keyboard accelerator characteristics.
Definition ResourceAccelerator.hpp:86
friend class ResourcesManager
Definition ResourceAccelerator.hpp:38
FLAGS
From: https://docs.microsoft.com/en-us/windows/win32/menurc/acceltableentry.
Definition ResourceAccelerator.hpp:42
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:108
int16_t padding() const
The number of bytes inserted to ensure that the structure is aligned on a DWORD boundary.
Definition ResourceAccelerator.hpp:103
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:212
#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
@ SHIFT
Definition AcceleratorCodes.hpp:36
@ CONTROL
Definition AcceleratorCodes.hpp:37
LIEF namespace.
Definition Abstract/Binary.hpp:41
#define LIEF_API
Definition visibility.h:45