LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
ImportEntry.hpp
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"
23#include "LIEF/Abstract/Symbol.hpp"
24
25#include "LIEF/PE/enums.hpp"
26
27namespace LIEF {
28namespace PE {
29class Parser;
30class Builder;
31
36class LIEF_API ImportEntry : public LIEF::Symbol {
37 friend class Parser;
38 friend class Builder;
39
40 public:
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);
47 ImportEntry& operator=(const ImportEntry&);
48 ~ImportEntry() override;
49
51 bool is_ordinal() const;
52
54 uint16_t ordinal() const;
55
57 uint64_t hint_name_rva() const;
58
61 uint16_t hint() const;
62
65 uint64_t iat_value() const;
66
68 uint64_t data() const;
69
71 uint64_t iat_address() const;
72
73 void data(uint64_t data);
74
75 void accept(Visitor& visitor) const override;
76
77
78 LIEF_API friend std::ostream& operator<<(std::ostream& os, const ImportEntry& entry);
79
80 private:
81 uint64_t data_ = 0;
82 uint16_t hint_ = 0;
83 uint64_t iat_value_ = 0;
84 uint64_t rva_ = 0;
85 PE_TYPE type_ = PE_TYPE::PE32_PLUS;
86};
87
88}
89}
90
91#endif /* IMPORTENTRY_H */
Class that is used to rebuild a raw PE binary from a PE::Binary object.
Definition PE/Builder.hpp:45
Class that represents an entry (i.e. an import) in the import table (Import).
Definition ImportEntry.hpp:36
uint16_t ordinal() const
The ordinal value.
uint64_t iat_value() const
Value of the current entry in the Import Address Table. It should match the lookup table value.
uint16_t hint() const
Index into the Export::entries that is used to speed-up the symbol resolution.
uint64_t hint_name_rva() const
uint64_t data() const
Raw value.
bool is_ordinal() const
True if it is an import by ordinal
uint64_t iat_address() const
Original address of the entry in the Import Address Table
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:219
PE_TYPE
Definition PE/enums.hpp:680
LIEF namespace.
Definition Abstract/Binary.hpp:32