LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
LoadConfigurationV1.hpp
Go to the documentation of this file.
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
25
26namespace LIEF {
27namespace PE {
28
29namespace details {
30template<class T>
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
59
60 template<class T>
61 LIEF_LOCAL LoadConfigurationV1(const details::load_configuration_v1<T>& header);
62
63 LoadConfigurationV1& operator=(const LoadConfigurationV1&) = default;
64 LoadConfigurationV1(const LoadConfigurationV1&) = default;
65
66 VERSION version() const override {
67 return WIN_VERSION;
68 }
69 uint64_t guard_cf_check_function_pointer() const {
72 return guard_cf_check_function_pointer_;
73 }
74 uint64_t guard_cf_dispatch_function_pointer() const {
77 return guard_cf_dispatch_function_pointer_;
78 }
79 uint64_t guard_cf_function_table() const {
83 return guard_cf_function_table_;
84 }
85 uint64_t guard_cf_function_count() const {
89 return guard_cf_function_count_;
90 }
91 IMAGE_GUARD guard_flags() const {
94 return flags_;
95 }
96 bool has(IMAGE_GUARD flag) const;
99 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
142ENABLE_BITMASK_OPERATORS(LIEF::PE::LoadConfigurationV1::IMAGE_GUARD);
143
144#endif
LoadConfigurationV0.hpp
LIEF::PE::LoadConfigurationV0
LoadConfiguration enhanced with SEH.
Definition LoadConfigurationV0.hpp:32
LIEF::PE::LoadConfigurationV1
LoadConfiguration enhanced with Control Flow Guard.
Definition LoadConfigurationV1.hpp:36
LIEF::PE::LoadConfigurationV1::guard_cf_function_count
void guard_cf_function_count(uint64_t guard_cf_function_count)
Definition LoadConfigurationV1.hpp:112
LIEF::PE::LoadConfigurationV1::LoadConfigurationV1
LoadConfigurationV1(const LoadConfigurationV1 &)=default
LIEF::PE::LoadConfigurationV1::guard_cf_function_table
void guard_cf_function_table(uint64_t guard_cf_function_table)
Definition LoadConfigurationV1.hpp:109
LIEF::PE::LoadConfigurationV1::guard_flags
IMAGE_GUARD guard_flags() const
Control Flow Guard related flags.
Definition LoadConfigurationV1.hpp:93
LIEF::PE::LoadConfigurationV1::guard_cf_function_count
uint64_t guard_cf_function_count() const
The count of unique RVAs in the LoadConfigurationV1::guard_cf_function_table.
Definition LoadConfigurationV1.hpp:88
LIEF::PE::LoadConfigurationV1::guard_cf_check_function_pointer
void guard_cf_check_function_pointer(uint64_t check_pointer)
Definition LoadConfigurationV1.hpp:103
LIEF::PE::LoadConfigurationV1::guard_cf_dispatch_function_pointer
void guard_cf_dispatch_function_pointer(uint64_t dispatch_pointer)
Definition LoadConfigurationV1.hpp:106
LIEF::PE::LoadConfigurationV1::IMAGE_GUARD
IMAGE_GUARD
Definition LoadConfigurationV1.hpp:40
LIEF::PE::LoadConfigurationV1::classof
static bool classof(const LoadConfiguration *config)
Definition LoadConfigurationV1.hpp:119
LIEF::PE::LoadConfigurationV1::LoadConfigurationV1
LoadConfigurationV1()=default
LIEF::PE::LoadConfigurationV1::~LoadConfigurationV1
~LoadConfigurationV1() override=default
LIEF::PE::LoadConfigurationV1::accept
void accept(Visitor &visitor) const override
LIEF::PE::LoadConfigurationV1::guard_flags
void guard_flags(IMAGE_GUARD flags)
Definition LoadConfigurationV1.hpp:115
LIEF::PE::LoadConfigurationV1::has
bool has(IMAGE_GUARD flag) const
Check if the given flag is present in LoadConfigurationV1::guard_flags.
LIEF::PE::LoadConfigurationV1::print
std::ostream & print(std::ostream &os) const override
LIEF::PE::LoadConfigurationV1::guard_cf_check_function_pointer
uint64_t guard_cf_check_function_pointer() const
The VA where Control Flow Guard check-function pointer is stored.
Definition LoadConfigurationV1.hpp:71
LIEF::PE::LoadConfigurationV1::guard_cf_flags_list
std::vector< IMAGE_GUARD > guard_cf_flags_list() const
LoadConfigurationV1::guard_flags as a list of LIEF::PE::GUARD_CF_FLAGS.
LIEF::PE::LoadConfigurationV1::version
VERSION version() const override
(SDK) Version of the structure
Definition LoadConfigurationV1.hpp:66
LIEF::PE::LoadConfigurationV1::guard_cf_dispatch_function_pointer
uint64_t guard_cf_dispatch_function_pointer() const
The VA where Control Flow Guard dispatch-function pointer is stored.
Definition LoadConfigurationV1.hpp:76
LIEF::PE::LoadConfigurationV1::operator=
LoadConfigurationV1 & operator=(const LoadConfigurationV1 &)=default
LIEF::PE::LoadConfigurationV1::LoadConfigurationV1
LoadConfigurationV1(const details::load_configuration_v1< T > &header)
LIEF::PE::LoadConfigurationV1::guard_cf_function_table
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::PE::LoadConfiguration::version
virtual VERSION version() const
(SDK) Version of the structure
Definition LoadConfiguration.hpp:64
enums.hpp
ENABLE_BITMASK_OPERATORS
#define ENABLE_BITMASK_OPERATORS(X)
Definition enums.hpp:24
LIEF::PE::details
Definition CodeIntegrity.hpp:26
LIEF::PE
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
LIEF::PE::to_string
const char * to_string(DataDirectory::TYPES e)
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:36
LIEF::PE::details::load_configuration_v1
Definition LoadConfigurationV1.hpp:31
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41
LIEF_LOCAL
#define LIEF_LOCAL
Definition visibility.h:42