LIEF: Library to Instrument Executable Formats Version 0.15.1
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 <vector>
19#include <ostream>
20#include <memory>
21
22#include "LIEF/Object.hpp"
23#include "LIEF/visibility.h"
24#include "LIEF/iterators.hpp"
25
26namespace LIEF {
27namespace PE {
28
29class RelocationEntry;
30
31namespace details {
32struct pe_base_relocation_block;
33}
34
37class LIEF_API Relocation : public Object {
38 friend class Parser;
39 friend class Builder;
40
41 public:
42 using entries_t = std::vector<std::unique_ptr<RelocationEntry>>;
45
46 Relocation() = default;
47 Relocation(const Relocation& other);
49 Relocation(const details::pe_base_relocation_block& header);
50 ~Relocation() override = default;
51
52 void swap(Relocation& other);
53
55 uint32_t virtual_address() const {
56 return virtual_address_;
57 }
58
61 uint32_t block_size() const {
62 return block_size_;
63 }
64
67 return entries_;
68 }
70 return entries_;
71 }
72
73 void virtual_address(uint32_t virtual_address) {
74 virtual_address_ = virtual_address;
75 }
76 void block_size(uint32_t block_size) {
77 block_size_ = block_size;
78 }
79
81
82 void accept(Visitor& visitor) const override;
83
84 LIEF_API friend std::ostream& operator<<(std::ostream& os, const Relocation& relocation);
85
86 private:
87 uint32_t block_size_ = 0;
88 uint32_t virtual_address_ = 0;
89 entries_t entries_;
90};
91
92}
93}
94#endif /* RELOCATION_H */
Definition Object.hpp:25
Class that is used to rebuild a raw PE binary from a PE::Binary object.
Definition PE/Builder.hpp:45
Main interface to parse PE binaries. In particular the static functions: Parser::parse should be used...
Definition PE/Parser.hpp:47
Class which represents an entry of the PE relocation table.
Definition RelocationEntry.hpp:36
Class which represents the Base Relocation Block We usually find this structure in the ....
Definition PE/Relocation.hpp:37
Relocation & operator=(Relocation other)
it_entries entries()
Definition PE/Relocation.hpp:69
void accept(Visitor &visitor) const override
uint32_t block_size() const
The total number of bytes in the base relocation block. block_size = sizeof(BaseRelocationBlock) + nb...
Definition PE/Relocation.hpp:61
void swap(Relocation &other)
uint32_t virtual_address() const
The RVA for which the offset of the relocation entries (RelocationEntry) is added.
Definition PE/Relocation.hpp:55
RelocationEntry & add_entry(const RelocationEntry &entry)
std::vector< std::unique_ptr< RelocationEntry > > entries_t
Definition PE/Relocation.hpp:42
void virtual_address(uint32_t virtual_address)
Definition PE/Relocation.hpp:73
~Relocation() override=default
it_const_entries entries() const
Iterator over the RelocationEntry.
Definition PE/Relocation.hpp:66
Relocation(const details::pe_base_relocation_block &header)
Relocation(const Relocation &other)
friend std::ostream & operator<<(std::ostream &os, const Relocation &relocation)
void block_size(uint32_t block_size)
Definition PE/Relocation.hpp:76
Definition Visitor.hpp:224
Iterator which returns reference on container's values.
Definition iterators.hpp:48
LIEF namespace.
Definition Abstract/Binary.hpp:32
#define LIEF_API
Definition visibility.h:41