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>>;
36 using it_relocations = ref_iterator<relocations_t&, Relocation*>;
37 using it_const_relocations = const_ref_iterator<const relocations_t&, const Relocation*>;
38
40 FunctionOverrideInfo(uint32_t original_rva, uint32_t bdd_offset,
41 uint32_t base_reloc_size);
42
43 FunctionOverrideInfo(const FunctionOverrideInfo&);
44 FunctionOverrideInfo& operator=(const FunctionOverrideInfo&);
45
46 FunctionOverrideInfo(FunctionOverrideInfo&&);
47 FunctionOverrideInfo& operator=(FunctionOverrideInfo&&);
48
49 std::string to_string() const;
50 uint32_t original_rva() const {
53 return original_rva_;
54 }
55 uint32_t bdd_offset() const {
58 return bdd_offset_;
59 }
60 uint32_t rva_size() const {
63 return rvas_.size() * sizeof(uint32_t);
64 }
65 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
75 it_relocations relocations() {
76 return relocations_;
77 }
78
79 it_const_relocations relocations() const {
80 return relocations_;
81 }
82
83 FunctionOverrideInfo& original_rva(uint32_t value) {
84 original_rva_ = value;
85 return *this;
86 }
87
88 FunctionOverrideInfo& bdd_offset(uint32_t value) {
89 bdd_offset_ = value;
90 return *this;
91 }
92
93 FunctionOverrideInfo& base_reloc_size(uint32_t value) {
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
110 ~FunctionOverrideInfo();
111 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
LIEF::PE::FunctionOverrideInfo
Definition FunctionOverrideInfo.hpp:33
LIEF::PE::FunctionOverrideInfo::FunctionOverrideInfo
FunctionOverrideInfo()=default
LIEF::PE::FunctionOverrideInfo::to_string
std::string to_string() const
LIEF::PE::FunctionOverrideInfo::relocations
it_const_relocations relocations() const
Definition FunctionOverrideInfo.hpp:79
LIEF::PE::FunctionOverrideInfo::FunctionOverrideInfo
FunctionOverrideInfo(const FunctionOverrideInfo &)
LIEF::PE::FunctionOverrideInfo::rva_size
uint32_t rva_size() const
Size in bytes taken by RVAs.
Definition FunctionOverrideInfo.hpp:62
LIEF::PE::FunctionOverrideInfo::original_rva
FunctionOverrideInfo & original_rva(uint32_t value)
Definition FunctionOverrideInfo.hpp:83
LIEF::PE::FunctionOverrideInfo::operator<<
friend std::ostream & operator<<(std::ostream &os, const FunctionOverrideInfo &info)
Definition FunctionOverrideInfo.hpp:104
LIEF::PE::FunctionOverrideInfo::base_reloc_size
uint32_t base_reloc_size() const
Size in bytes taken by BaseRelocs.
Definition FunctionOverrideInfo.hpp:67
LIEF::PE::FunctionOverrideInfo::bdd_offset
FunctionOverrideInfo & bdd_offset(uint32_t value)
Definition FunctionOverrideInfo.hpp:88
LIEF::PE::FunctionOverrideInfo::original_rva
uint32_t original_rva() const
RVA of the original function.
Definition FunctionOverrideInfo.hpp:52
LIEF::PE::FunctionOverrideInfo::functions_rva
const std::vector< uint32_t > & functions_rva() const
Definition FunctionOverrideInfo.hpp:71
LIEF::PE::FunctionOverrideInfo::FunctionOverrideInfo
FunctionOverrideInfo(uint32_t original_rva, uint32_t bdd_offset, uint32_t base_reloc_size)
LIEF::PE::FunctionOverrideInfo::overriding_funcs
FunctionOverrideInfo & overriding_funcs(std::vector< uint32_t > funcs)
Definition FunctionOverrideInfo.hpp:98
LIEF::PE::FunctionOverrideInfo::~FunctionOverrideInfo
~FunctionOverrideInfo()
LIEF::PE::FunctionOverrideInfo::relocations
it_relocations relocations()
Definition FunctionOverrideInfo.hpp:75
LIEF::PE::FunctionOverrideInfo::operator=
FunctionOverrideInfo & operator=(FunctionOverrideInfo &&)
LIEF::PE::FunctionOverrideInfo::bdd_offset
uint32_t bdd_offset() const
Offset into the BDD region.
Definition FunctionOverrideInfo.hpp:57
LIEF::PE::FunctionOverrideInfo::FunctionOverrideInfo
FunctionOverrideInfo(FunctionOverrideInfo &&)
LIEF::PE::FunctionOverrideInfo::operator=
FunctionOverrideInfo & operator=(const FunctionOverrideInfo &)
LIEF::PE::FunctionOverrideInfo::base_reloc_size
FunctionOverrideInfo & base_reloc_size(uint32_t value)
Definition FunctionOverrideInfo.hpp:93
LIEF::PE::Parser
Main interface to parse PE binaries. In particular the static functions: Parser::parse should be used...
Definition PE/Parser.hpp:52
LIEF::PE::Relocation
Class which represents the Base Relocation Block We usually find this structure in the ....
Definition PE/Relocation.hpp:42
LIEF::SpanStream
Definition SpanStream.hpp:32
iterators.hpp
LIEF::PE
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:36
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41
LIEF_LOCAL
#define LIEF_LOCAL
Definition visibility.h:42