LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
DynamicFixup.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_LOAD_CONFIGURATION_DYNAMIC_FIXUP_H
17#define LIEF_PE_LOAD_CONFIGURATION_DYNAMIC_FIXUP_H
18
19#include <ostream>
20#include <memory>
21#include <string>
22
23#include "LIEF/visibility.h"
24#include "LIEF/errors.hpp"
25
26namespace LIEF {
27class SpanStream;
28
29namespace PE {
30class Parser;
32
35 public:
56
57 DynamicFixup() = delete;
59 kind_(kind)
60 {}
61
62 DynamicFixup(const DynamicFixup&) = default;
64
67
68 virtual std::unique_ptr<DynamicFixup> clone() const = 0;
69
70 virtual std::string to_string() const = 0;
71
73 KIND kind() const {
74 return kind_;
75 }
76
77 template<class T>
78 T* as() {
79 static_assert(std::is_base_of<DynamicFixup, T>::value,
80 "Require DynamicFixup inheritance");
81 if (T::classof(this)) {
82 return static_cast<T*>(this);
83 }
84 return nullptr;
85 }
86
87 template<class T>
88 const T* as() const {
89 return const_cast<DynamicFixup*>(this)->as<T>();
90 }
91
92 LIEF_API friend
93 std::ostream& operator<<(std::ostream& os, const DynamicFixup& fixup)
94 {
95 os << fixup.to_string();
96 return os;
97 }
98
99 virtual ~DynamicFixup() = default;
100
103 parse(Parser& ctx, SpanStream& stream, DynamicRelocation& R);
104
105 protected:
106 KIND kind_ = KIND::UNKNOWN;
107
108};
109
110
111}
112}
113
114#endif
const T * as() const
Definition DynamicFixup.hpp:88
KIND
Definition DynamicFixup.hpp:36
@ ARM64_KERNEL_IMPORT_CALL_TRANSFER
If DynamicRelocation::symbol is set to IMAGE_DYNAMIC_RELOCATION_ARM64_KERNEL_IMPORT_CALL_TRANSFER.
Definition DynamicFixup.hpp:51
@ ARM64X
If DynamicRelocation::symbol is set to IMAGE_DYNAMIC_RELOCATION_ARM64X.
Definition DynamicFixup.hpp:45
@ GUARD_IMPORT_CONTROL_TRANSFER
If DynamicRelocation::symbol is set to IMAGE_DYNAMIC_RELOCATION_GUARD_IMPORT_CONTROL_TRANSFER.
Definition DynamicFixup.hpp:54
@ GENERIC
If DynamicRelocation::symbol is not a special value.
Definition DynamicFixup.hpp:42
@ UNKNOWN
If DynamicRelocation::symbol is a special value that is not supported by LIEF.
Definition DynamicFixup.hpp:39
@ FUNCTION_OVERRIDE
If DynamicRelocation::symbol is set to IMAGE_DYNAMIC_RELOCATION_FUNCTION_OVERRIDE.
Definition DynamicFixup.hpp:48
T * as()
Definition DynamicFixup.hpp:78
DynamicFixup & operator=(const DynamicFixup &)=default
KIND kind() const
Encoding of the fixups.
Definition DynamicFixup.hpp:73
friend std::ostream & operator<<(std::ostream &os, const DynamicFixup &fixup)
Definition DynamicFixup.hpp:93
virtual std::unique_ptr< DynamicFixup > clone() const =0
DynamicFixup(const DynamicFixup &)=default
virtual std::string to_string() const =0
DynamicFixup & operator=(DynamicFixup &&)=default
DynamicFixup(DynamicFixup &&)=default
virtual ~DynamicFixup()=default
DynamicFixup(KIND kind)
Definition DynamicFixup.hpp:58
This is the base class for any IMAGE_DYNAMIC_RELOCATION32, IMAGE_DYNAMIC_RELOCATION32_V2,...
Definition DynamicRelocationBase.hpp:33
Main interface to parse PE binaries. In particular the static functions: Parser::parse should be used...
Definition PE/Parser.hpp:52
Definition SpanStream.hpp:32
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
@ T
Definition AcceleratorCodes.hpp:97
@ R
Definition AcceleratorCodes.hpp:95
LIEF namespace.
Definition Abstract/Binary.hpp:40
result< ok_t > ok_error_t
Opaque structure that is used by LIEF to avoid writing result<void> f(...). Instead,...
Definition errors.hpp:109
#define LIEF_API
Definition visibility.h:41
#define LIEF_LOCAL
Definition visibility.h:42