LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
FunctionOverrideInfo.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_RELOCATION_FUNC_OVERRIDE_INFO_H
17#define LIEF_PE_LOAD_CONFIGURATION_DYNAMIC_RELOCATION_FUNC_OVERRIDE_INFO_H
18
19#include <memory>
20#include <string>
21#include <vector>
22
23#include "LIEF/visibility.h"
24#include "LIEF/iterators.hpp"
25
26namespace LIEF {
27class SpanStream;
28
29namespace PE {
30class Parser;
31class Relocation;
32
34 public:
35 using relocations_t = std::vector<std::unique_ptr<Relocation>>;
38
41 uint32_t base_reloc_size);
42
45
48
49 std::string to_string() const;
50
52 uint32_t original_rva() const {
53 return original_rva_;
54 }
55
57 uint32_t bdd_offset() const {
58 return bdd_offset_;
59 }
60
62 uint32_t rva_size() const {
63 return rvas_.size() * sizeof(uint32_t);
64 }
65
67 uint32_t base_reloc_size() const {
68 return base_relocsz_;
69 }
70
71 const std::vector<uint32_t>& functions_rva() const {
72 return rvas_;
73 }
74
76 return relocations_;
77 }
78
80 return relocations_;
81 }
82
84 original_rva_ = value;
85 return *this;
86 }
87
89 bdd_offset_ = value;
90 return *this;
91 }
92
94 base_relocsz_ = value;
95 return *this;
96 }
97
98 FunctionOverrideInfo& overriding_funcs(std::vector<uint32_t> funcs) {
99 rvas_ = std::move(funcs);
100 return *this;
101 }
102
103 friend LIEF_API
104 std::ostream& operator<<(std::ostream& os, const FunctionOverrideInfo& info)
105 {
106 os << info.to_string();
107 return os;
108 }
109
111
113 LIEF_LOCAL static
114 std::unique_ptr<FunctionOverrideInfo> parse(Parser& ctx, SpanStream& strm);
115
116 private:
117 uint32_t original_rva_ = 0;
118 uint32_t bdd_offset_ = 0;
119 uint32_t base_relocsz_ = 0;
120 std::vector<uint32_t> rvas_;
121 relocations_t relocations_;
122};
123
124}
125}
126
127#endif
std::vector< std::unique_ptr< Relocation > > relocations_t
Definition FunctionOverrideInfo.hpp:35
std::string to_string() const
it_const_relocations relocations() const
Definition FunctionOverrideInfo.hpp:79
FunctionOverrideInfo(const FunctionOverrideInfo &)
uint32_t rva_size() const
Size in bytes taken by RVAs.
Definition FunctionOverrideInfo.hpp:62
FunctionOverrideInfo & original_rva(uint32_t value)
Definition FunctionOverrideInfo.hpp:83
friend std::ostream & operator<<(std::ostream &os, const FunctionOverrideInfo &info)
Definition FunctionOverrideInfo.hpp:104
uint32_t base_reloc_size() const
Size in bytes taken by BaseRelocs.
Definition FunctionOverrideInfo.hpp:67
FunctionOverrideInfo & bdd_offset(uint32_t value)
Definition FunctionOverrideInfo.hpp:88
uint32_t original_rva() const
RVA of the original function.
Definition FunctionOverrideInfo.hpp:52
const std::vector< uint32_t > & functions_rva() const
Definition FunctionOverrideInfo.hpp:71
ref_iterator< relocations_t &, Relocation * > it_relocations
Definition FunctionOverrideInfo.hpp:36
const_ref_iterator< const relocations_t &, const Relocation * > it_const_relocations
Definition FunctionOverrideInfo.hpp:37
FunctionOverrideInfo(uint32_t original_rva, uint32_t bdd_offset, uint32_t base_reloc_size)
FunctionOverrideInfo & overriding_funcs(std::vector< uint32_t > funcs)
Definition FunctionOverrideInfo.hpp:98
it_relocations relocations()
Definition FunctionOverrideInfo.hpp:75
FunctionOverrideInfo & operator=(FunctionOverrideInfo &&)
uint32_t bdd_offset() const
Offset into the BDD region.
Definition FunctionOverrideInfo.hpp:57
FunctionOverrideInfo(FunctionOverrideInfo &&)
FunctionOverrideInfo & operator=(const FunctionOverrideInfo &)
FunctionOverrideInfo & base_reloc_size(uint32_t value)
Definition FunctionOverrideInfo.hpp:93
Main interface to parse PE binaries. In particular the static functions: Parser::parse should be used...
Definition PE/Parser.hpp:52
Class which represents the Base Relocation Block We usually find this structure in the ....
Definition PE/Relocation.hpp:43
Definition SpanStream.hpp:32
Iterator which returns reference on container's values.
Definition iterators.hpp:46
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
LIEF namespace.
Definition Abstract/Binary.hpp:40
ref_iterator< CT, U, typename decay_t< CT >::const_iterator > const_ref_iterator
Iterator which return const ref on container's values.
Definition iterators.hpp:257
#define LIEF_API
Definition visibility.h:41
#define LIEF_LOCAL
Definition visibility.h:42