LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
FunctionOverrideInfo.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_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>>;
39
42 uint32_t base_reloc_size);
43
46
49
50 std::string to_string() const;
51
53 uint32_t original_rva() const {
54 return original_rva_;
55 }
56
58 uint32_t bdd_offset() const {
59 return bdd_offset_;
60 }
61
63 uint32_t rva_size() const {
64 return rvas_.size() * sizeof(uint32_t);
65 }
66
68 uint32_t base_reloc_size() const {
69 return base_relocsz_;
70 }
71
72 const std::vector<uint32_t>& functions_rva() const {
73 return rvas_;
74 }
75
77 return relocations_;
78 }
79
81 return relocations_;
82 }
83
85 original_rva_ = value;
86 return *this;
87 }
88
90 bdd_offset_ = value;
91 return *this;
92 }
93
95 base_relocsz_ = value;
96 return *this;
97 }
98
99 FunctionOverrideInfo& overriding_funcs(std::vector<uint32_t> funcs) {
100 rvas_ = std::move(funcs);
101 return *this;
102 }
103
104 friend LIEF_API std::ostream& operator<<(std::ostream& os,
105 const FunctionOverrideInfo& info) {
106 os << info.to_string();
107 return os;
108 }
109
111
113 LIEF_LOCAL static std::unique_ptr<FunctionOverrideInfo> parse(Parser& ctx,
114 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:80
FunctionOverrideInfo(const FunctionOverrideInfo &)
uint32_t rva_size() const
Size in bytes taken by RVAs.
Definition FunctionOverrideInfo.hpp:63
FunctionOverrideInfo & original_rva(uint32_t value)
Definition FunctionOverrideInfo.hpp:84
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:68
FunctionOverrideInfo & bdd_offset(uint32_t value)
Definition FunctionOverrideInfo.hpp:89
uint32_t original_rva() const
RVA of the original function.
Definition FunctionOverrideInfo.hpp:53
const std::vector< uint32_t > & functions_rva() const
Definition FunctionOverrideInfo.hpp:72
ref_iterator< relocations_t &, Relocation * > it_relocations
Definition FunctionOverrideInfo.hpp:36
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:99
it_relocations relocations()
Definition FunctionOverrideInfo.hpp:76
FunctionOverrideInfo & operator=(FunctionOverrideInfo &&)
const_ref_iterator< const relocations_t &, const Relocation * > it_const_relocations
Definition FunctionOverrideInfo.hpp:37
uint32_t bdd_offset() const
Offset into the BDD region.
Definition FunctionOverrideInfo.hpp:58
FunctionOverrideInfo(FunctionOverrideInfo &&)
FunctionOverrideInfo & operator=(const FunctionOverrideInfo &)
FunctionOverrideInfo & base_reloc_size(uint32_t value)
Definition FunctionOverrideInfo.hpp:94
Main interface to parse PE binaries. In particular, the static Parser::parse functions 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:45
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:286
#define LIEF_API
Definition visibility.h:43
#define LIEF_LOCAL
Definition visibility.h:44