LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
DelayImport.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_DELAY_IMPORT_H
17#define LIEF_PE_DELAY_IMPORT_H
18
19#include <string>
20#include <ostream>
21#include <memory>
22
23#include "LIEF/Object.hpp"
24#include "LIEF/visibility.h"
25#include "LIEF/iterators.hpp"
26
28
29namespace LIEF {
30namespace PE {
31
32namespace details {
33struct delay_imports;
34}
35class LIEF_API DelayImport : public Object {
38
39 friend class Parser;
40 friend class Builder;
41
42 public:
43 using entries_t = std::vector<std::unique_ptr<DelayImportEntry>>;
44 using it_entries = ref_iterator<entries_t&, DelayImportEntry*>;
45 using it_const_entries = const_ref_iterator<const entries_t&, const DelayImportEntry*>;
46
47 DelayImport() = default;
48 DelayImport(const details::delay_imports& import, PE_TYPE type);
49 DelayImport(std::string name) :
50 name_(std::move(name))
51 {}
52
53 ~DelayImport() override = default;
54
55 DelayImport(const DelayImport& other);
56 DelayImport& operator=(DelayImport other) {
57 swap(other);
58 return *this;
59 }
60
61 DelayImport(DelayImport&&) noexcept = default;
62 DelayImport& operator=(DelayImport&&) noexcept = default;
63
64 void swap(DelayImport& other);
65 uint32_t attribute() const {
69 return attribute_;
70 }
71 void attribute(uint32_t hdl) {
72 attribute_ = hdl;
73 }
74 const std::string& name() const {
77 return name_;
78 }
79 void name(std::string name) {
80 name_ = std::move(name);
81 }
82 uint32_t handle() const {
87 return handle_;
88 }
89 void handle(uint32_t hdl) {
90 handle_ = hdl;
91 }
92 uint32_t iat() const {
95 return iat_;
96 }
97 void iat(uint32_t iat) {
98 iat_ = iat;
99 }
100 uint32_t names_table() const {
104 return names_table_;
105 }
106 void names_table(uint32_t value) {
107 names_table_ = value;
108 }
109 uint32_t biat() const {
113 return bound_iat_;
114 }
115 void biat(uint32_t value) {
116 bound_iat_ = value;
117 }
118 uint32_t uiat() const {
126 return unload_iat_;
127 }
128 void uiat(uint32_t value) {
129 unload_iat_ = value;
130 }
131 uint32_t timestamp() const {
134 return timestamp_;
135 }
136 void timestamp(uint32_t value) {
137 timestamp_ = value;
138 }
139 it_entries entries() {
142 return entries_;
143 }
144 it_const_entries entries() const {
147 return entries_;
148 }
149
150 void accept(Visitor& visitor) const override;
151
152 LIEF_API friend std::ostream& operator<<(std::ostream& os, const DelayImport& entry);
153
154 private:
155 uint32_t attribute_ = 0;
156 std::string name_;
157 uint32_t handle_ = 0;
158 uint32_t iat_ = 0;
159 uint32_t names_table_ = 0;
160 uint32_t bound_iat_ = 0;
161 uint32_t unload_iat_ = 0;
162 uint32_t timestamp_ = 0;
163 entries_t entries_;
164
165 PE_TYPE type_ = PE_TYPE::PE32;
166};
167
168}
169}
170
171#endif
DelayImportEntry.hpp
Object.hpp
LIEF::PE::DelayImport
Class that represents a PE delayed import.
Definition DelayImport.hpp:37
LIEF::PE::DelayImport::operator=
DelayImport & operator=(DelayImport other)
Definition DelayImport.hpp:56
LIEF::PE::DelayImport::uiat
uint32_t uiat() const
RVA of the unload delay-load import address table or 0 if the table does not exist.
Definition DelayImport.hpp:125
LIEF::PE::DelayImport::DelayImport
DelayImport()=default
LIEF::PE::DelayImport::timestamp
uint32_t timestamp() const
The timestamp of the DLL to which this image has been bound.
Definition DelayImport.hpp:133
LIEF::PE::DelayImport::~DelayImport
~DelayImport() override=default
LIEF::PE::DelayImport::name
void name(std::string name)
Definition DelayImport.hpp:79
LIEF::PE::DelayImport::timestamp
void timestamp(uint32_t value)
Definition DelayImport.hpp:136
LIEF::PE::DelayImport::DelayImport
DelayImport(const details::delay_imports &import, PE_TYPE type)
LIEF::PE::DelayImport::entries
it_const_entries entries() const
Iterator over the DelayImport's entries (DelayImportEntry)
Definition DelayImport.hpp:146
LIEF::PE::DelayImport::handle
uint32_t handle() const
The RVA of the module handle (in the .data section) It is used for storage by the routine that is sup...
Definition DelayImport.hpp:86
LIEF::PE::DelayImport::DelayImport
DelayImport(const DelayImport &other)
LIEF::PE::DelayImport::names_table
uint32_t names_table() const
RVA of the delay-load import names table. The content of this table has the layout as the Import look...
Definition DelayImport.hpp:103
LIEF::PE::DelayImport::operator<<
friend std::ostream & operator<<(std::ostream &os, const DelayImport &entry)
LIEF::PE::DelayImport::biat
uint32_t biat() const
RVA of the bound delay-load import address table or 0 if the table does not exist.
Definition DelayImport.hpp:112
LIEF::PE::DelayImport::accept
void accept(Visitor &visitor) const override
LIEF::PE::DelayImport::biat
void biat(uint32_t value)
Definition DelayImport.hpp:115
LIEF::PE::DelayImport::attribute
void attribute(uint32_t hdl)
Definition DelayImport.hpp:71
LIEF::PE::DelayImport::entries
it_entries entries()
Iterator over the DelayImport's entries (DelayImportEntry)
Definition DelayImport.hpp:141
LIEF::PE::DelayImport::iat
void iat(uint32_t iat)
Definition DelayImport.hpp:97
LIEF::PE::DelayImport::DelayImport
DelayImport(std::string name)
Definition DelayImport.hpp:49
LIEF::PE::DelayImport::names_table
void names_table(uint32_t value)
Definition DelayImport.hpp:106
LIEF::PE::DelayImport::name
const std::string & name() const
Return the library's name (e.g. kernel32.dll)
Definition DelayImport.hpp:76
LIEF::PE::DelayImport::iat
uint32_t iat() const
RVA of the delay-load import address table.
Definition DelayImport.hpp:94
LIEF::PE::DelayImport::DelayImport
DelayImport(DelayImport &&) noexcept=default
LIEF::PE::DelayImport::handle
void handle(uint32_t hdl)
Definition DelayImport.hpp:89
LIEF::PE::DelayImport::uiat
void uiat(uint32_t value)
Definition DelayImport.hpp:128
iterators.hpp
LIEF::PE::details
Definition DataDirectory.hpp:37
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:22
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:39
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41