LIEF: Library to Instrument Executable Formats
Version 1.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
lief-install
x86_64
static
include
LIEF
DyldSharedCache
Dylib.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_DSC_DYLIB_H
17
#define LIEF_DSC_DYLIB_H
18
#include "
LIEF/visibility.h
"
19
#include "
LIEF/iterators.hpp
"
20
#include "
LIEF/errors.hpp
"
21
22
#include <memory>
23
#include <string>
24
25
namespace
LIEF
{
26
27
namespace
MachO
{
28
class
Binary
;
29
}
30
31
namespace
dsc
{
32
33
namespace
details
{
34
class
Dylib;
35
class
DylibIt;
36
}
37
40
class
LIEF_API
Dylib
{
41
public
:
43
class
LIEF_API
Iterator
44
:
public
iterator_facade_base
<Iterator, std::random_access_iterator_tag, Dylib,
45
std::ptrdiff_t, const Dylib*, const Dylib&> {
46
public
:
47
using
implementation
= details::DylibIt;
48
49
Iterator
();
50
51
Iterator
(std::unique_ptr<details::DylibIt> impl);
52
Iterator
(
const
Iterator
&);
53
Iterator
&
operator=
(
const
Iterator
&);
54
55
Iterator
(
Iterator
&&) noexcept;
56
Iterator
& operator=(
Iterator
&&) noexcept;
57
58
~
Iterator
();
59
bool
operator<(const
Iterator
& rhs) const;
60
61
std::ptrdiff_t operator-(const
Iterator
& R) const;
62
63
Iterator
& operator+=(std::ptrdiff_t n);
64
Iterator
& operator-=(std::ptrdiff_t n);
65
66
friend
LIEF_API
bool
operator==(const
Iterator
& LHS, const
Iterator
& RHS);
67
68
friend
LIEF_API
bool
operator!=(const
Iterator
& LHS, const
Iterator
& RHS) {
69
return
!(LHS == RHS);
70
}
71
72
const
Dylib
&
operator*
()
const
;
73
74
// NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
75
const
Dylib
*
operator->
()
const
;
76
79
std::unique_ptr<Dylib>
yield
();
80
81
private
:
82
void
load()
const
;
83
84
std::unique_ptr<details::DylibIt> impl_;
85
mutable
std::unique_ptr<Dylib> cached_;
86
};
87
88
public
:
92
struct
LIEF_API
extract_opt_t
{
93
extract_opt_t
();
94
99
bool
pack
=
true
;
100
108
bool
fix_branches
=
false
;
109
116
bool
fix_memory
=
false
;
117
124
bool
fix_relocations
=
false
;
125
127
bool
fix_objc
=
false
;
128
133
LIEF::result<bool>
create_dyld_chained_fixup_cmd
;
134
};
135
136
Dylib
(std::unique_ptr<details::Dylib> impl);
137
~Dylib
();
138
140
std::string
path
()
const
;
141
143
uint64_t
address
()
const
;
144
146
uint64_t
modtime
()
const
;
147
152
uint64_t
inode
()
const
;
153
155
uint64_t
padding
()
const
;
156
164
std::unique_ptr<LIEF::MachO::Binary>
165
get
(
const
extract_opt_t
& opt =
extract_opt_t
())
const
;
166
167
private
:
168
std::unique_ptr<details::Dylib> impl_;
169
};
170
171
}
172
}
173
#endif
LIEF::MachO::Binary
Class which represents a MachO binary.
Definition
MachO/Binary.hpp:89
LIEF::dsc::Dylib::Iterator::yield
std::unique_ptr< Dylib > yield()
Transfer ownership of the dylib at the current position to the caller. Returns nullptr if the iterato...
LIEF::dsc::Dylib::Iterator::operator=
Iterator & operator=(const Iterator &)
LIEF::dsc::Dylib::Iterator::Iterator
Iterator(const Iterator &)
LIEF::dsc::Dylib::Iterator::implementation
details::DylibIt implementation
Definition
Dylib.hpp:47
LIEF::dsc::Dylib::Iterator::Iterator
Iterator(std::unique_ptr< details::DylibIt > impl)
LIEF::dsc::Dylib::Iterator::Iterator
Iterator(Iterator &&) noexcept
LIEF::dsc::Dylib::Iterator::operator->
const Dylib * operator->() const
LIEF::dsc::Dylib::Iterator::operator*
const Dylib & operator*() const
LIEF::dsc::Dylib::Iterator::Iterator
Iterator()
LIEF::dsc::Dylib::path
std::string path() const
Original path of the library (e.g. /usr/lib/libcryptex.dylib).
LIEF::dsc::Dylib::modtime
uint64_t modtime() const
Modification time of the library matching stat.st_mtime, or 0.
LIEF::dsc::Dylib::padding
uint64_t padding() const
Padding alignment value (should be 0).
LIEF::dsc::Dylib::get
std::unique_ptr< LIEF::MachO::Binary > get(const extract_opt_t &opt=extract_opt_t()) const
Get a MachO::Binary representation for this Dylib.
LIEF::dsc::Dylib::inode
uint64_t inode() const
File serial number matching stat.st_ino or 0.
LIEF::dsc::Dylib::address
uint64_t address() const
In-memory address of the library.
LIEF::dsc::Dylib::Dylib
Dylib(std::unique_ptr< details::Dylib > impl)
LIEF::dsc::Dylib::~Dylib
~Dylib()
LIEF::iterator_facade_base
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition
iterators.hpp:729
LIEF::result
Wrapper that contains an Object (T) or an error.
Definition
errors.hpp:77
errors.hpp
iterators.hpp
LIEF::MachO
Namespace related to the LIEF's Mach-O module.
Definition
Abstract/Header.hpp:36
LIEF::dsc::details
Definition
DyldSharedCache/DyldSharedCache.hpp:35
LIEF::dsc
Namespace related to the dyld shared cache support.
Definition
caching.hpp:22
LIEF
LIEF namespace.
Definition
Abstract/Binary.hpp:40
LIEF::dsc::Dylib::extract_opt_t
This structure is used to tweak the extraction process while calling Dylib::get. These options allow ...
Definition
Dylib.hpp:92
LIEF::dsc::Dylib::extract_opt_t::create_dyld_chained_fixup_cmd
LIEF::result< bool > create_dyld_chained_fixup_cmd
Whether the LC_DYLD_CHAINED_FIXUPS command should be (re)created.
Definition
Dylib.hpp:133
LIEF::dsc::Dylib::extract_opt_t::extract_opt_t
extract_opt_t()
LIEF::dsc::Dylib::extract_opt_t::fix_relocations
bool fix_relocations
Recover and fix relocations.
Definition
Dylib.hpp:124
LIEF::dsc::Dylib::extract_opt_t::fix_branches
bool fix_branches
Fix call instructions that target addresses outside the current dylib virtual space.
Definition
Dylib.hpp:108
LIEF::dsc::Dylib::extract_opt_t::fix_memory
bool fix_memory
Fix memory accesses performed outside the dylib's virtual space.
Definition
Dylib.hpp:116
LIEF::dsc::Dylib::extract_opt_t::pack
bool pack
Whether the segment's offsets should be packed to avoid an in-memory size while writing back the bina...
Definition
Dylib.hpp:99
LIEF::dsc::Dylib::extract_opt_t::fix_objc
bool fix_objc
Fix Objective-C information.
Definition
Dylib.hpp:127
visibility.h
LIEF_API
#define LIEF_API
Definition
visibility.h:45
Generated by
1.17.0