LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
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
25namespace LIEF {
26
27namespace MachO {
28class Binary;
29}
30
31namespace dsc {
32
33namespace details {
34class Dylib;
35class DylibIt;
36}
37
41 public:
44 : public iterator_facade_base<Iterator, std::random_access_iterator_tag,
45 std::unique_ptr<Dylib>, std::ptrdiff_t, Dylib*,
46 std::unique_ptr<Dylib>> {
47 public:
48 using implementation = details::DylibIt;
49
50 Iterator(std::unique_ptr<details::DylibIt> impl);
53
54 Iterator(Iterator&&) noexcept;
55 Iterator& operator=(Iterator&&) noexcept;
56
58 bool operator<(const Iterator& rhs) const;
59
60 std::ptrdiff_t operator-(const Iterator& R) const;
61
62 Iterator& operator+=(std::ptrdiff_t n);
63 Iterator& operator-=(std::ptrdiff_t n);
64
65 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
66
67 friend LIEF_API bool operator!=(const Iterator& LHS, const Iterator& RHS) {
68 return !(LHS == RHS);
69 }
70
71 std::unique_ptr<Dylib> operator*() const;
72
73 private:
74 std::unique_ptr<details::DylibIt> impl_;
75 };
76
77 public:
83
88 bool pack = true;
89
97 bool fix_branches = false;
98
105 bool fix_memory = false;
106
113 bool fix_relocations = false;
114
116 bool fix_objc = false;
117
123 };
124
125 Dylib(std::unique_ptr<details::Dylib> impl);
127
129 std::string path() const;
130
132 uint64_t address() const;
133
135 uint64_t modtime() const;
136
141 uint64_t inode() const;
142
144 uint64_t padding() const;
145
153 std::unique_ptr<LIEF::MachO::Binary>
154 get(const extract_opt_t& opt = extract_opt_t()) const;
155
156 private:
157 std::unique_ptr<details::Dylib> impl_;
158};
159
160}
161}
162#endif
Class which represents a MachO binary.
Definition MachO/Binary.hpp:88
Iterator & operator=(const Iterator &)
std::unique_ptr< Dylib > operator*() const
Iterator(const Iterator &)
details::DylibIt implementation
Definition Dylib.hpp:48
Iterator(std::unique_ptr< details::DylibIt > impl)
Iterator(Iterator &&) noexcept
std::string path() const
Original path of the library (e.g. /usr/lib/libcryptex.dylib).
uint64_t modtime() const
Modification time of the library matching stat.st_mtime, or 0.
uint64_t padding() const
Padding alignment value (should be 0).
std::unique_ptr< LIEF::MachO::Binary > get(const extract_opt_t &opt=extract_opt_t()) const
Get a MachO::Binary representation for this Dylib.
uint64_t inode() const
File serial number matching stat.st_ino or 0.
uint64_t address() const
In-memory address of the library.
Dylib(std::unique_ptr< details::Dylib > impl)
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition iterators.hpp:685
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:77
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
Definition DyldSharedCache/DyldSharedCache.hpp:35
Namespace related to the dyld shared cache support.
Definition caching.hpp:22
LIEF namespace.
Definition Abstract/Binary.hpp:40
Definition string.h:155
This structure is used to tweak the extraction process while calling Dylib::get. These options allow ...
Definition Dylib.hpp:81
LIEF::result< bool > create_dyld_chained_fixup_cmd
Whether the LC_DYLD_CHAINED_FIXUPS command should be (re)created.
Definition Dylib.hpp:122
bool fix_relocations
Recover and fix relocations.
Definition Dylib.hpp:113
bool fix_branches
Fix call instructions that target addresses outside the current dylib virtual space.
Definition Dylib.hpp:97
bool fix_memory
Fix memory accesses performed outside the dylib's virtual space.
Definition Dylib.hpp:105
bool pack
Whether the segment's offsets should be packed to avoid an in-memory size while writing back the bina...
Definition Dylib.hpp:88
bool fix_objc
Fix Objective-C information.
Definition Dylib.hpp:116
#define LIEF_API
Definition visibility.h:43