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#include <cstdint>
23
24#include "LIEF/visibility.h"
25#include "LIEF/iterators.hpp"
26
27namespace LIEF {
28class SpanStream;
29
30namespace PE {
31class Parser;
32class Relocation;
33
35 public:
36 using relocations_t = std::vector<std::unique_ptr<Relocation>>;
40
43 uint32_t base_reloc_size);
44
47
50
51 std::string to_string() const;
52
54 uint32_t original_rva() const {
55 return original_rva_;
56 }
57
59 uint32_t bdd_offset() const {
60 return bdd_offset_;
61 }
62
64 uint32_t rva_size() const {
65 return rvas_.size() * sizeof(uint32_t);
66 }
67
69 uint32_t base_reloc_size() const {
70 return base_relocsz_;
71 }
72
73 const std::vector<uint32_t>& functions_rva() const {
74 return rvas_;
75 }
76
78 return relocations_;
79 }
80
82 return relocations_;
83 }
84
86 original_rva_ = value;
87 return *this;
88 }
89
91 bdd_offset_ = value;
92 return *this;
93 }
94
96 base_relocsz_ = value;
97 return *this;
98 }
99
100 FunctionOverrideInfo& overriding_funcs(std::vector<uint32_t> funcs) {
101 rvas_ = std::move(funcs);
102 return *this;
103 }
104
105 friend LIEF_API std::ostream& operator<<(std::ostream& os,
106 const FunctionOverrideInfo& info) {
107 os << info.to_string();
108 return os;
109 }
110
112
114 LIEF_LOCAL static std::unique_ptr<FunctionOverrideInfo> parse(Parser& ctx,
115 SpanStream& strm);
116
117 private:
118 uint32_t original_rva_ = 0;
119 uint32_t bdd_offset_ = 0;
120 uint32_t base_relocsz_ = 0;
121 std::vector<uint32_t> rvas_;
122 relocations_t relocations_;
123};
124
125}
126}
127
128#endif
std::vector< std::unique_ptr< Relocation > > relocations_t
Definition FunctionOverrideInfo.hpp:36
std::string to_string() const
it_const_relocations relocations() const
Definition FunctionOverrideInfo.hpp:81
FunctionOverrideInfo(const FunctionOverrideInfo &)
uint32_t rva_size() const
Size in bytes taken by RVAs.
Definition FunctionOverrideInfo.hpp:64
FunctionOverrideInfo & original_rva(uint32_t value)
Definition FunctionOverrideInfo.hpp:85
friend std::ostream & operator<<(std::ostream &os, const FunctionOverrideInfo &info)
Definition FunctionOverrideInfo.hpp:105
uint32_t base_reloc_size() const
Size in bytes taken by BaseRelocs.
Definition FunctionOverrideInfo.hpp:69
FunctionOverrideInfo & bdd_offset(uint32_t value)
Definition FunctionOverrideInfo.hpp:90
uint32_t original_rva() const
RVA of the original function.
Definition FunctionOverrideInfo.hpp:54
const std::vector< uint32_t > & functions_rva() const
Definition FunctionOverrideInfo.hpp:73
ref_iterator< relocations_t &, Relocation * > it_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:100
it_relocations relocations()
Definition FunctionOverrideInfo.hpp:77
FunctionOverrideInfo & operator=(FunctionOverrideInfo &&)
const_ref_iterator< const relocations_t &, const Relocation * > it_const_relocations
Definition FunctionOverrideInfo.hpp:38
uint32_t bdd_offset() const
Offset into the BDD region.
Definition FunctionOverrideInfo.hpp:59
FunctionOverrideInfo(FunctionOverrideInfo &&)
FunctionOverrideInfo & operator=(const FunctionOverrideInfo &)
FunctionOverrideInfo & base_reloc_size(uint32_t value)
Definition FunctionOverrideInfo.hpp:95
Main interface to parse PE binaries. In particular, the static Parser::parse functions should be used...
Definition PE/Parser.hpp:53
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:47
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
LIEF namespace.
Definition Abstract/Binary.hpp:41
ref_iterator< CT, U, typename decay_t< CT >::const_iterator > const_ref_iterator
Iterator which returns a const ref on container's values.
Definition iterators.hpp:322
#define LIEF_API
Definition visibility.h:45
#define LIEF_LOCAL
Definition visibility.h:46