LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
ExportEntry.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_EXPORT_ENTRY_H
17#define LIEF_PE_EXPORT_ENTRY_H
18
19#include <string>
20#include <ostream>
21
22#include "LIEF/Object.hpp"
23#include "LIEF/visibility.h"
25
26namespace LIEF {
27namespace PE {
28
29class Builder;
30class Parser;
31
34
35 friend class Builder;
36 friend class Parser;
37
38 public:
40 std::string library;
41 std::string function;
42
43 operator bool() const {
44 return !library.empty() || !function.empty();
45 }
46
47 LIEF_API friend std::ostream& operator<<(std::ostream& os, const forward_information_t& info);
48 };
49
50 public:
51 ExportEntry() = default;
52 ExportEntry(uint32_t address, bool is_extern,
53 uint16_t ordinal, uint32_t function_rva);
54 ExportEntry(const ExportEntry&) = default;
55 ExportEntry& operator=(const ExportEntry&) = default;
56 ~ExportEntry() override = default;
57
58 uint16_t ordinal() const {
59 return ordinal_;
60 }
61 uint32_t address() const {
62 return address_;
63 }
64 bool is_extern() const {
65 return is_extern_;
66 }
67 bool is_forwarded() const {
68 return forward_info_;
69 }
70
72 return is_forwarded() ? forward_info_ : forward_information_t{};
73 }
74
75 uint32_t function_rva() const {
76 return function_rva_;
77 }
78
79 void ordinal(uint16_t ordinal) {
80 ordinal_ = ordinal;
81 }
82
83 void address(uint32_t address) {
84 address_ = address;
85 }
86
87 void is_extern(bool is_extern) {
88 is_extern_ = is_extern;
89 }
90
91 uint64_t value() const override {
92 return address();
93 }
94
95 void value(uint64_t value) override {
96 address(static_cast<uint32_t>(value));
97 }
98
99 void set_forward_info(std::string lib, std::string function) {
100 forward_info_.library = std::move(lib);
101 forward_info_.function = std::move(function);
102 }
103
104 void accept(Visitor& visitor) const override;
105
106
107 LIEF_API friend std::ostream& operator<<(std::ostream& os, const ExportEntry& exportEntry);
108
109 private:
110 uint32_t function_rva_ = 0;
111 uint16_t ordinal_ = 0;
112 uint32_t address_ = 0;
113 bool is_extern_ = false;
114
115 forward_information_t forward_info_;
116
117};
118
119}
120}
121
122#endif /* PE_EXPORTENTRY_H */
Class that is used to rebuild a raw PE binary from a PE::Binary object.
Definition PE/Builder.hpp:45
Class which represents a PE Export entry (cf. PE::Export)
Definition ExportEntry.hpp:33
ExportEntry & operator=(const ExportEntry &)=default
friend std::ostream & operator<<(std::ostream &os, const ExportEntry &exportEntry)
bool is_forwarded() const
Definition ExportEntry.hpp:67
uint64_t value() const override
Definition ExportEntry.hpp:91
bool is_extern() const
Definition ExportEntry.hpp:64
uint32_t address() const
Definition ExportEntry.hpp:61
void value(uint64_t value) override
Definition ExportEntry.hpp:95
void is_extern(bool is_extern)
Definition ExportEntry.hpp:87
void accept(Visitor &visitor) const override
ExportEntry(uint32_t address, bool is_extern, uint16_t ordinal, uint32_t function_rva)
void set_forward_info(std::string lib, std::string function)
Definition ExportEntry.hpp:99
ExportEntry(const ExportEntry &)=default
~ExportEntry() override=default
uint16_t ordinal() const
Definition ExportEntry.hpp:58
uint32_t function_rva() const
Definition ExportEntry.hpp:75
forward_information_t forward_information() const
Definition ExportEntry.hpp:71
void ordinal(uint16_t ordinal)
Definition ExportEntry.hpp:79
void address(uint32_t address)
Definition ExportEntry.hpp:83
Main interface to parse PE binaries. In particular the static functions: Parser::parse should be used...
Definition PE/Parser.hpp:47
This class represents a symbol in an executable format.
Definition Abstract/Symbol.hpp:28
Definition Visitor.hpp:224
LIEF namespace.
Definition Abstract/Binary.hpp:32
friend std::ostream & operator<<(std::ostream &os, const forward_information_t &info)
std::string library
Definition ExportEntry.hpp:40
std::string function
Definition ExportEntry.hpp:41
#define LIEF_API
Definition visibility.h:41