LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
LoadConfigurationV1.hpp
1/* Copyright 2017 - 2024 R. Thomas
2 * Copyright 2017 - 2024 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_LOAD_CONFIGURATION_V1_H
17#define LIEF_PE_LOAD_CONFIGURATION_V1_H
18#include <ostream>
19#include <vector>
20
21#include "LIEF/enums.hpp"
22#include "LIEF/visibility.h"
23
24#include "LIEF/PE/LoadConfigurations/LoadConfigurationV0.hpp"
25
26namespace LIEF {
27namespace PE {
28
29namespace details {
30template<class T>
32}
37 public:
38 static constexpr VERSION WIN_VERSION = VERSION::WIN_8_1;
39
40 enum class IMAGE_GUARD : uint32_t {
41 NONE = 0x00000000,
42 CF_INSTRUMENTED = 0x00000100,
43 CFW_INSTRUMENTED = 0x00000200,
44 CF_FUNCTION_TABLE_PRESENT = 0x00000400,
45 SECURITY_COOKIE_UNUSED = 0x00000800,
46 PROTECT_DELAYLOAD_IAT = 0x00001000,
47 DELAYLOAD_IAT_IN_ITS_OWN_SECTION = 0x00002000,
48 CF_EXPORT_SUPPRESSION_INFO_PRESENT = 0x00004000,
49 CF_ENABLE_EXPORT_SUPPRESSION = 0x00008000,
50 CF_LONGJUMP_TABLE_PRESENT = 0x00010000,
51 RF_INSTRUMENTED = 0x00020000,
52 RF_ENABLE = 0x00040000,
53 RF_STRICT = 0x00080000,
54 RETPOLINE_PRESENT = 0x00100000,
55 EH_CONTINUATION_TABLE_PRESENT = 0x00200000,
56 };
57
58 LoadConfigurationV1() = default;
59
60 template<class T>
62
63 LoadConfigurationV1& operator=(const LoadConfigurationV1&) = default;
65
66 VERSION version() const override {
67 return WIN_VERSION;
68 }
69
72 return guard_cf_check_function_pointer_;
73 }
74
77 return guard_cf_dispatch_function_pointer_;
78 }
79
82 uint64_t guard_cf_function_table() const {
83 return guard_cf_function_table_;
84 }
85
88 uint64_t guard_cf_function_count() const {
89 return guard_cf_function_count_;
90 }
91
94 return flags_;
95 }
96
98 bool has(IMAGE_GUARD flag) const;
99
101 std::vector<IMAGE_GUARD> guard_cf_flags_list() const;
102
103 void guard_cf_check_function_pointer(uint64_t check_pointer) {
104 guard_cf_check_function_pointer_ = check_pointer;
105 }
106 void guard_cf_dispatch_function_pointer(uint64_t dispatch_pointer) {
107 guard_cf_dispatch_function_pointer_ = dispatch_pointer;
108 }
109 void guard_cf_function_table(uint64_t guard_cf_function_table) {
110 guard_cf_function_table_ = guard_cf_function_table;
111 }
112 void guard_cf_function_count(uint64_t guard_cf_function_count) {
113 guard_cf_function_count_ = guard_cf_function_count;
114 }
115 void guard_flags(IMAGE_GUARD flags) {
116 flags_ = flags;
117 }
118
119 static bool classof(const LoadConfiguration* config) {
120 return config->version() == WIN_VERSION;
121 }
122
123 ~LoadConfigurationV1() override = default;
124
125 void accept(Visitor& visitor) const override;
126
127 std::ostream& print(std::ostream& os) const override;
128
129 protected:
130 uint64_t guard_cf_check_function_pointer_ = 0;
131 uint64_t guard_cf_dispatch_function_pointer_ = 0;
132 uint64_t guard_cf_function_table_ = 0;
133 uint64_t guard_cf_function_count_ = 0;
134 IMAGE_GUARD flags_ = IMAGE_GUARD::NONE;
135};
136
137LIEF_API const char* to_string(LoadConfigurationV1::IMAGE_GUARD e);
138
139}
140}
141
143
144#endif
LoadConfiguration enhanced with SEH.
Definition LoadConfigurationV0.hpp:32
LoadConfiguration enhanced with Control Flow Guard.
Definition LoadConfigurationV1.hpp:36
IMAGE_GUARD guard_flags() const
Control Flow Guard related flags.
Definition LoadConfigurationV1.hpp:93
uint64_t guard_cf_function_count() const
The count of unique RVAs in the LoadConfigurationV1::guard_cf_function_table.
Definition LoadConfigurationV1.hpp:88
IMAGE_GUARD
Definition LoadConfigurationV1.hpp:40
bool has(IMAGE_GUARD flag) const
Check if the given flag is present in LoadConfigurationV1::guard_flags.
uint64_t guard_cf_check_function_pointer() const
The VA where Control Flow Guard check-function pointer is stored.
Definition LoadConfigurationV1.hpp:71
std::vector< IMAGE_GUARD > guard_cf_flags_list() const
LoadConfigurationV1::guard_flags as a list of LIEF::PE::GUARD_CF_FLAGS.
VERSION version() const override
(SDK) Version of the structure
Definition LoadConfigurationV1.hpp:66
uint64_t guard_cf_dispatch_function_pointer() const
The VA where Control Flow Guard dispatch-function pointer is stored.
Definition LoadConfigurationV1.hpp:76
uint64_t guard_cf_function_table() const
The VA of the sorted table of RVAs of each Control Flow Guard function in the image.
Definition LoadConfigurationV1.hpp:82
LIEF namespace.
Definition Abstract/Binary.hpp:32
Definition LoadConfigurationV1.hpp:31