LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
ImportEntry.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_IMPORT_ENTRY_H
17#define LIEF_PE_IMPORT_ENTRY_H
18#include <string>
19#include <ostream>
20
21#include "LIEF/Object.hpp"
22#include "LIEF/visibility.h"
24
25#include "LIEF/PE/enums.hpp"
26
27namespace LIEF {
28namespace PE {
29class Parser;
30class Builder;
31
37 friend class Parser;
38 friend class Builder;
39
40 public:
41 ImportEntry() = default;
42
43 ImportEntry(uint64_t data, PE_TYPE type) :
44 data_(data), type_(type)
45 {}
46
47 ImportEntry(std::string name) {
48 this->name(std::move(name));
49 }
50
51 ImportEntry(const ImportEntry&) = default;
52 ImportEntry& operator=(const ImportEntry&) = default;
53 ~ImportEntry() override = default;
54
57 std::string demangled_name() const;
58
60 bool is_ordinal() const;
61
63 uint16_t ordinal() const {
64 static constexpr auto MASK = 0xFFFF;
65 return is_ordinal() ? (data_ & MASK) : 0;
66 }
67
69 uint64_t hint_name_rva() const {
70 return data();
71 }
72
75 uint16_t hint() const {
76 return hint_;
77 }
78
81 uint64_t iat_value() const {
82 return iat_value_;
83 }
84
87 uint64_t ilt_value() const {
88 return ilt_value_;
89 }
90
92 uint64_t data() const {
93 return data_;
94 }
95
97 uint64_t iat_address() const {
98 return rva_;
99 }
100
101 void data(uint64_t data) {
102 data_ = data;
103 }
104
105 void accept(Visitor& visitor) const override;
106
107 LIEF_API friend std::ostream& operator<<(std::ostream& os, const ImportEntry& entry);
108
110 LIEF_LOCAL void iat_address(uint64_t rva) {
111 rva_ = rva;
112 }
113
114 private:
115 uint64_t data_ = 0;
116 uint16_t hint_ = 0;
117 uint64_t iat_value_ = 0;
118 uint64_t ilt_value_ = 0;
119 uint64_t rva_ = 0;
121};
122
123}
124}
125
126#endif /* IMPORTENTRY_H */
Class that is used to rebuild a raw PE binary from a PE::Binary object.
Definition PE/Builder.hpp:45
ImportEntry(uint64_t data, PE_TYPE type)
Definition ImportEntry.hpp:43
void data(uint64_t data)
Definition ImportEntry.hpp:101
uint16_t ordinal() const
The ordinal value.
Definition ImportEntry.hpp:63
uint64_t ilt_value() const
Original value in the import lookup table. This value should match the iat_value().
Definition ImportEntry.hpp:87
~ImportEntry() override=default
uint64_t iat_value() const
Value of the current entry in the Import Address Table. It should match the lookup table value.
Definition ImportEntry.hpp:81
ImportEntry(const ImportEntry &)=default
uint16_t hint() const
Index into the Export::entries that is used to speed-up the symbol resolution.
Definition ImportEntry.hpp:75
void accept(Visitor &visitor) const override
friend std::ostream & operator<<(std::ostream &os, const ImportEntry &entry)
uint64_t hint_name_rva() const
Definition ImportEntry.hpp:69
ImportEntry & operator=(const ImportEntry &)=default
friend class Builder
Definition ImportEntry.hpp:38
uint64_t data() const
Raw value.
Definition ImportEntry.hpp:92
bool is_ordinal() const
True if it is an import by ordinal
friend class Parser
Definition ImportEntry.hpp:37
ImportEntry(std::string name)
Definition ImportEntry.hpp:47
uint64_t iat_address() const
Original address of the entry in the Import Address Table
Definition ImportEntry.hpp:97
std::string demangled_name() const
Demangled representation of the symbol or an empty string if it can't be demangled.
Main interface to parse PE binaries. In particular the static functions: Parser::parse should be used...
Definition PE/Parser.hpp:52
This class represents a symbol in an executable format.
Definition Abstract/Symbol.hpp:28
virtual const std::string & name() const
Return the symbol's name.
Definition Abstract/Symbol.hpp:54
Definition Visitor.hpp:210
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
PE_TYPE
Definition PE/enums.hpp:22
@ PE32_PLUS
64 bits
Definition PE/enums.hpp:24
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:41
#define LIEF_LOCAL
Definition visibility.h:42