LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
DelayImport.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 * Copyright 2017 - 2026 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_view>
20#include <memory>
21#include <ostream>
22#include <string>
23
24#include "LIEF/Object.hpp"
25#include "LIEF/iterators.hpp"
26#include "LIEF/visibility.h"
27
29
30
31namespace LIEF::PE {
32
33namespace details {
34struct delay_imports;
35}
36
38class LIEF_API DelayImport : public Object {
39
40 friend class Parser;
41 friend class Builder;
42
43 public:
44 using entries_t = std::vector<std::unique_ptr<DelayImportEntry>>;
48
49 DelayImport() = default;
50 DelayImport(const details::delay_imports& import, PE_TYPE type);
51 DelayImport(std::string name) :
52 name_(std::move(name)) {}
53
54 ~DelayImport() override = default;
55
56 DelayImport(const DelayImport& other);
58 swap(other);
59 return *this;
60 }
61
62 DelayImport(DelayImport&&) noexcept = default;
63 DelayImport& operator=(DelayImport&&) noexcept = default;
64
65 void swap(DelayImport& other);
66
69 uint32_t attribute() const {
70 return attribute_;
71 }
72 void attribute(uint32_t hdl) {
73 attribute_ = hdl;
74 }
75
77 std::string_view name() const LIEF_LIFETIMEBOUND {
78 return name_;
79 }
80 void name(std::string name) {
81 name_ = std::move(name);
82 }
83
87 uint32_t handle() const {
88 return handle_;
89 }
90 void handle(uint32_t hdl) {
91 handle_ = hdl;
92 }
93
95 uint32_t iat() const {
96 return iat_;
97 }
98 void iat(uint32_t iat) {
99 iat_ = iat;
100 }
101
104 uint32_t names_table() const {
105 return names_table_;
106 }
107 void names_table(uint32_t value) {
108 names_table_ = value;
109 }
110
113 uint32_t biat() const {
114 return bound_iat_;
115 }
116 void biat(uint32_t value) {
117 bound_iat_ = value;
118 }
119
126 uint32_t uiat() const {
127 return unload_iat_;
128 }
129 void uiat(uint32_t value) {
130 unload_iat_ = value;
131 }
132
134 uint32_t timestamp() const {
135 return timestamp_;
136 }
137 void timestamp(uint32_t value) {
138 timestamp_ = value;
139 }
140
143 return entries_;
144 }
145
148 return entries_;
149 }
150
151 void accept(Visitor& visitor) const override;
152
153 LIEF_API friend std::ostream& operator<<(std::ostream& os,
154 const DelayImport& entry);
155
156 private:
157 uint32_t attribute_ = 0;
158 std::string name_;
159 uint32_t handle_ = 0;
160 uint32_t iat_ = 0;
161 uint32_t names_table_ = 0;
162 uint32_t bound_iat_ = 0;
163 uint32_t unload_iat_ = 0;
164 uint32_t timestamp_ = 0;
165 entries_t entries_;
166
167 PE_TYPE type_ = PE_TYPE::PE32;
168};
169
170}
171
172
173#endif
DelayImport & operator=(DelayImport other)
Definition DelayImport.hpp:57
uint32_t uiat() const
RVA of the unload delay-load import address table or 0 if the table does not exist.
Definition DelayImport.hpp:126
const_ref_iterator< const entries_t &, const DelayImportEntry * > it_const_entries
Definition DelayImport.hpp:46
uint32_t timestamp() const
The timestamp of the DLL to which this image has been bound.
Definition DelayImport.hpp:134
~DelayImport() override=default
void name(std::string name)
Definition DelayImport.hpp:80
void timestamp(uint32_t value)
Definition DelayImport.hpp:137
DelayImport(const details::delay_imports &import, PE_TYPE type)
it_const_entries entries() const
Iterator over the DelayImport's entries (DelayImportEntry).
Definition DelayImport.hpp:147
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:87
std::vector< std::unique_ptr< DelayImportEntry > > entries_t
Definition DelayImport.hpp:44
DelayImport(const DelayImport &other)
std::string_view name() const
Return the library's name (e.g. kernel32.dll).
Definition DelayImport.hpp:77
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:104
friend std::ostream & operator<<(std::ostream &os, const DelayImport &entry)
uint32_t biat() const
RVA of the bound delay-load import address table or 0 if the table does not exist.
Definition DelayImport.hpp:113
void accept(Visitor &visitor) const override
void biat(uint32_t value)
Definition DelayImport.hpp:116
void attribute(uint32_t hdl)
Definition DelayImport.hpp:72
friend class Builder
Definition DelayImport.hpp:41
it_entries entries()
Iterator over the DelayImport's entries (DelayImportEntry).
Definition DelayImport.hpp:142
void iat(uint32_t iat)
Definition DelayImport.hpp:98
friend class Parser
Definition DelayImport.hpp:40
DelayImport(std::string name)
Definition DelayImport.hpp:51
uint32_t attribute() const
According to the official PE specifications, this value is reserved and should be set to 0.
Definition DelayImport.hpp:69
void names_table(uint32_t value)
Definition DelayImport.hpp:107
uint32_t iat() const
RVA of the delay-load import address table.
Definition DelayImport.hpp:95
DelayImport(DelayImport &&) noexcept=default
ref_iterator< entries_t &, DelayImportEntry * > it_entries
Definition DelayImport.hpp:45
void handle(uint32_t hdl)
Definition DelayImport.hpp:90
void swap(DelayImport &other)
void uiat(uint32_t value)
Definition DelayImport.hpp:129
Definition Visitor.hpp:212
Iterator which returns reference on container's values.
Definition iterators.hpp:47
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition DataDirectory.hpp:37
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
PE_TYPE
Definition PE/enums.hpp:22
@ PE32
32bits
Definition PE/enums.hpp:23
ref_iterator< CT, U, typename decay_t< CT >::const_iterator > const_ref_iterator
Iterator which returns a const ref on container's values.
Definition iterators.hpp:316
#define LIEF_API
Definition visibility.h:45