LIEF: Library to Instrument Executable Formats Version 0.16.5
Loading...
Searching...
No Matches
PE/Relocation.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2024 R. Thomas
2 * Copyright 2017 - 2024 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_RELOCATION_H
17#define LIEF_PE_RELOCATION_H
18#include <cstdint>
19#include <vector>
20#include <ostream>
21#include <memory>
22
23#include "LIEF/Object.hpp"
24#include "LIEF/visibility.h"
25#include "LIEF/iterators.hpp"
26
27namespace LIEF {
28namespace PE {
29
30class RelocationEntry;
31
32namespace details {
33struct pe_base_relocation_block;
34}
35class LIEF_API Relocation : public Object {
39 friend class Parser;
40 friend class Builder;
41
42 public:
43 using entries_t = std::vector<std::unique_ptr<RelocationEntry>>;
44 using it_entries = ref_iterator<entries_t&, RelocationEntry*>;
45 using it_const_entries = const_ref_iterator<const entries_t&, RelocationEntry*>;
46
47
49 Relocation(uint32_t base, uint32_t block_size);
50 Relocation(uint32_t base);
51
52 Relocation(const Relocation& other);
53 Relocation& operator=(Relocation other);
54
55 Relocation(Relocation&&);
56 Relocation& operator=(Relocation&& other);
57
58 Relocation(const details::pe_base_relocation_block& header);
59 ~Relocation() override;
60
61 void swap(Relocation& other);
62 uint32_t virtual_address() const {
65 return virtual_address_;
66 }
67 uint32_t block_size() const {
71 return block_size_;
72 }
73 it_const_entries entries() const {
76 return entries_;
77 }
78 it_entries entries() {
79 return entries_;
80 }
81
82 void virtual_address(uint32_t virtual_address) {
83 virtual_address_ = virtual_address;
84 }
85 void block_size(uint32_t block_size) {
86 block_size_ = block_size;
87 }
88
89 RelocationEntry& add_entry(const RelocationEntry& entry);
90
91 void accept(Visitor& visitor) const override;
92
93 LIEF_API friend std::ostream& operator<<(std::ostream& os, const Relocation& relocation);
94 private:
95 uint32_t block_size_ = 0;
96 uint32_t virtual_address_ = 0;
97 entries_t entries_;
98};
99
100}
101}
102#endif /* RELOCATION_H */
Object.hpp
LIEF::PE::RelocationEntry
Class which represents an entry of the PE relocation table.
Definition RelocationEntry.hpp:36
LIEF::PE::Relocation
Class which represents the Base Relocation Block We usually find this structure in the ....
Definition PE/Relocation.hpp:38
LIEF::PE::Relocation::operator=
Relocation & operator=(Relocation other)
LIEF::PE::Relocation::Relocation
Relocation()
LIEF::PE::Relocation::entries
it_entries entries()
Definition PE/Relocation.hpp:78
LIEF::PE::Relocation::Relocation
Relocation(Relocation &&)
LIEF::PE::Relocation::accept
void accept(Visitor &visitor) const override
LIEF::PE::Relocation::block_size
uint32_t block_size() const
The total number of bytes in the base relocation block. block_size = sizeof(BaseRelocationBlock) + nb...
Definition PE/Relocation.hpp:70
LIEF::PE::Relocation::swap
void swap(Relocation &other)
LIEF::PE::Relocation::~Relocation
~Relocation() override
LIEF::PE::Relocation::operator=
Relocation & operator=(Relocation &&other)
LIEF::PE::Relocation::virtual_address
uint32_t virtual_address() const
The RVA for which the offset of the relocation entries (RelocationEntry) is added.
Definition PE/Relocation.hpp:64
LIEF::PE::Relocation::add_entry
RelocationEntry & add_entry(const RelocationEntry &entry)
LIEF::PE::Relocation::Relocation
Relocation(uint32_t base)
LIEF::PE::Relocation::virtual_address
void virtual_address(uint32_t virtual_address)
Definition PE/Relocation.hpp:82
LIEF::PE::Relocation::entries
it_const_entries entries() const
Iterator over the RelocationEntry.
Definition PE/Relocation.hpp:75
LIEF::PE::Relocation::Relocation
Relocation(const details::pe_base_relocation_block &header)
LIEF::PE::Relocation::Relocation
Relocation(const Relocation &other)
LIEF::PE::Relocation::operator<<
friend std::ostream & operator<<(std::ostream &os, const Relocation &relocation)
LIEF::PE::Relocation::Relocation
Relocation(uint32_t base, uint32_t block_size)
LIEF::PE::Relocation::block_size
void block_size(uint32_t block_size)
Definition PE/Relocation.hpp:85
iterators.hpp
LIEF::PE::details
Definition CodeIntegrity.hpp:26
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