16#ifndef LIEF_PE_IMPORT_H
17#define LIEF_PE_IMPORT_H
22#include "LIEF/errors.hpp"
23#include "LIEF/Object.hpp"
24#include "LIEF/visibility.h"
25#include "LIEF/iterators.hpp"
26#include "LIEF/PE/ImportEntry.hpp"
45 using entries_t = std::vector<ImportEntry>;
49 Import(
const details::pe_import&
import);
51 name_(std::move(name))
63 return forwarder_chain_;
69 return timedatestamp_;
77 it_entries entries() {
87 return import_address_table_RVA_;
95 return import_lookup_table_RVA_;
106 return const_cast<ImportEntry*
>(
static_cast<const Import*
>(
this)->get_entry(name));
108 const ImportEntry* get_entry(
const std::string& name)
const;
111 const std::string&
name()
const {
117 name_ = std::move(name);
136 return iat_directory_;
139 return iat_directory_;
148 void import_lookup_table_rva(uint32_t rva);
149 void import_address_table_rva(uint32_t rva);
151 void accept(
Visitor& visitor)
const override;
153 LIEF_API
friend std::ostream& operator<<(std::ostream& os,
const Import& entry);
159 uint32_t import_lookup_table_RVA_ = 0;
160 uint32_t timedatestamp_ = 0;
161 uint32_t forwarder_chain_ = 0;
162 uint32_t name_RVA_ = 0;
163 uint32_t import_address_table_RVA_ = 0;
Class that is used to rebuild a raw PE binary from a PE::Binary object.
Definition PE/Builder.hpp:45
Class that represents a PE data directory entry.
Definition DataDirectory.hpp:38
Class that represents an entry (i.e. an import) in the import table (Import).
Definition ImportEntry.hpp:36
Class that represents a PE import.
Definition Import.hpp:39
DataDirectory * directory()
Return the PE::DataDirectory associated with this import. It should be the one at index PE::DataDirec...
Definition Import.hpp:124
it_const_entries entries() const
Iterator over the PE::ImportEntry.
Definition Import.hpp:73
ImportEntry & add_entry(const std::string &name)
Add a new import entry with the given name (i.e. an imported function)
uint32_t forwarder_chain() const
The index of the first forwarder reference.
Definition Import.hpp:62
ImportEntry * get_entry(const std::string &name)
Return the imported function with the given name.
Definition Import.hpp:105
uint32_t import_lookup_table_rva() const
Return the relative virtual address of the import lookup table.
Definition Import.hpp:94
uint32_t import_address_table_rva() const
The RVA of the import address table (IAT). The content of this table is identical to the content of t...
Definition Import.hpp:86
uint32_t timedatestamp() const
The stamp that is set to zero until the image is bound. After the image is bound, this field is set t...
Definition Import.hpp:68
result< uint32_t > get_function_rva_from_iat(const std::string &function) const
Return the Function's RVA from the import address table (IAT)
const std::string & name() const
Return the library's name (e.g. kernel32.dll)
Definition Import.hpp:111
DataDirectory * iat_directory()
Return the PE::DataDirectory associated associated with the IAT. It should be the one at index PE::Da...
Definition Import.hpp:135
ImportEntry & add_entry(const ImportEntry &entry)
Add a new import entry (i.e. an imported function)
void name(std::string name)
Change the current import name.
Definition Import.hpp:116
Main interface to parse PE binaries. In particular the static functions: Parser::parse should be used...
Definition PE/Parser.hpp:47
Definition Visitor.hpp:219
Iterator which returns reference on container's values.
Definition iterators.hpp:48
PE_TYPE
Definition PE/enums.hpp:680
LIEF namespace.
Definition Abstract/Binary.hpp:32
tl::expected< T, lief_errors > result
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:72