LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
ImportEntry.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_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;
31class LIEF_API ImportEntry : public LIEF::Symbol {
37 friend class Parser;
38 friend class Builder;
39
40 public:
41 ImportEntry() = default;
42 ImportEntry(uint64_t data, const std::string& name = "");
43 ImportEntry(uint64_t data, PE_TYPE type, const std::string& name);
44 ImportEntry(const std::string& name);
45 ImportEntry(const std::string& name, PE_TYPE type);
46 ImportEntry(const ImportEntry&) = default;
47 ImportEntry& operator=(const ImportEntry&) = default;
48 ~ImportEntry() override = default;
49 std::string demangled_name() const;
53 bool is_ordinal() const;
56 uint16_t ordinal() const {
59 static constexpr auto MASK = 0xFFFF;
60 return is_ordinal() ? (data_ & MASK) : 0;
61 }
62 uint64_t hint_name_rva() const {
65 return data();
66 }
67 uint16_t hint() const {
71 return hint_;
72 }
73 uint64_t iat_value() const {
77 return iat_value_;
78 }
79 uint64_t data() const {
82 return data_;
83 }
84 uint64_t iat_address() const {
87 return rva_;
88 }
89
90 void data(uint64_t data) {
91 data_ = data;
92 }
93
94 void accept(Visitor& visitor) const override;
95
96
97 LIEF_API friend std::ostream& operator<<(std::ostream& os, const ImportEntry& entry);
98
99 private:
100 uint64_t data_ = 0;
101 uint16_t hint_ = 0;
102 uint64_t iat_value_ = 0;
103 uint64_t rva_ = 0;
104 PE_TYPE type_ = PE_TYPE::PE32_PLUS;
105};
106
107}
108}
109
110#endif /* IMPORTENTRY_H */
Symbol.hpp
Object.hpp
enums.hpp
LIEF::PE::Builder
Class that is used to rebuild a raw PE binary from a PE::Binary object.
Definition PE/Builder.hpp:45
LIEF::PE::ImportEntry
Class that represents an entry (i.e. an import) in the import table (Import).
Definition ImportEntry.hpp:36
LIEF::PE::ImportEntry::ImportEntry
ImportEntry(const std::string &name, PE_TYPE type)
LIEF::PE::ImportEntry::data
void data(uint64_t data)
Definition ImportEntry.hpp:90
LIEF::PE::ImportEntry::ordinal
uint16_t ordinal() const
The ordinal value.
Definition ImportEntry.hpp:58
LIEF::PE::ImportEntry::ImportEntry
ImportEntry()=default
LIEF::PE::ImportEntry::~ImportEntry
~ImportEntry() override=default
LIEF::PE::ImportEntry::iat_value
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:76
LIEF::PE::ImportEntry::ImportEntry
ImportEntry(const ImportEntry &)=default
LIEF::PE::ImportEntry::hint
uint16_t hint() const
Index into the Export::entries that is used to speed-up the symbol resolution.
Definition ImportEntry.hpp:70
LIEF::PE::ImportEntry::accept
void accept(Visitor &visitor) const override
LIEF::PE::ImportEntry::operator<<
friend std::ostream & operator<<(std::ostream &os, const ImportEntry &entry)
LIEF::PE::ImportEntry::hint_name_rva
uint64_t hint_name_rva() const
Definition ImportEntry.hpp:64
LIEF::PE::ImportEntry::operator=
ImportEntry & operator=(const ImportEntry &)=default
LIEF::PE::ImportEntry::data
uint64_t data() const
Raw value.
Definition ImportEntry.hpp:81
LIEF::PE::ImportEntry::is_ordinal
bool is_ordinal() const
True if it is an import by ordinal
LIEF::PE::ImportEntry::ImportEntry
ImportEntry(uint64_t data, const std::string &name="")
LIEF::PE::ImportEntry::ImportEntry
ImportEntry(const std::string &name)
LIEF::PE::ImportEntry::ImportEntry
ImportEntry(uint64_t data, PE_TYPE type, const std::string &name)
LIEF::PE::ImportEntry::iat_address
uint64_t iat_address() const
Original address of the entry in the Import Address Table
Definition ImportEntry.hpp:86
LIEF::PE::ImportEntry::demangled_name
std::string demangled_name() const
Demangled representation of the symbol or an empty string if it can't be demangled.
LIEF::PE::Parser
Main interface to parse PE binaries. In particular the static functions: Parser::parse should be used...
Definition PE/Parser.hpp:47
LIEF::PE
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
LIEF::PE::PE_TYPE
PE_TYPE
Definition PE/enums.hpp:680
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:36
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41