LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
SubCache.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_SUBCACHE_H
17#define LIEF_DSC_SUBCACHE_H
19#include "LIEF/visibility.h"
20#include "LIEF/iterators.hpp"
22
23#include <memory>
24#include <string>
25
26namespace LIEF {
27namespace dsc {
28class DyldSharedCache;
29
30namespace details {
31class SubCache;
32class SubCacheIt;
33}
34
41 public:
44 : public iterator_facade_base<Iterator, std::random_access_iterator_tag,
45 SubCache, std::ptrdiff_t, const SubCache*,
46 const SubCache&> {
47 public:
48 using implementation = details::SubCacheIt;
49
51
52 Iterator(std::unique_ptr<details::SubCacheIt> impl);
55
56 Iterator(Iterator&&) noexcept;
57 Iterator& operator=(Iterator&&) noexcept;
58
60 bool operator<(const Iterator& rhs) const;
61
62 std::ptrdiff_t operator-(const Iterator& R) const;
63
64 Iterator& operator+=(std::ptrdiff_t n);
65 Iterator& operator-=(std::ptrdiff_t n);
66
67 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
68
69 friend LIEF_API bool operator!=(const Iterator& LHS, const Iterator& RHS) {
70 return !(LHS == RHS);
71 }
72
74
75 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
76 const SubCache* operator->() const LIEF_LIFETIMEBOUND;
77
80 std::unique_ptr<SubCache> yield();
81
82 private:
83 void load() const;
84
85 std::unique_ptr<details::SubCacheIt> impl_;
86 mutable std::unique_ptr<SubCache> cached_;
87 };
88
89 public:
90 SubCache(std::unique_ptr<details::SubCache> impl);
92
94 sc_uuid_t uuid() const;
95
97 uint64_t vm_offset() const;
98
101 std::string suffix() const;
102
104 std::unique_ptr<const DyldSharedCache> cache() const LIEF_LIFETIMEBOUND;
105
106 friend LIEF_API std::ostream& operator<<(std::ostream& os,
107 const SubCache& subcache);
108
109 private:
110 std::unique_ptr<details::SubCache> impl_;
111};
112
113}
114}
115#endif
This class represents a dyld shared cache file.
Definition DyldSharedCache/DyldSharedCache.hpp:41
std::unique_ptr< SubCache > yield()
Transfer ownership of the subcache at the current position to the caller. Returns nullptr if the iter...
details::SubCacheIt implementation
Definition SubCache.hpp:48
const SubCache & operator*() const
Iterator(std::unique_ptr< details::SubCacheIt > impl)
Iterator(const Iterator &)
Iterator(Iterator &&) noexcept
Iterator & operator=(const Iterator &)
std::unique_ptr< const DyldSharedCache > cache() const
The associated DyldSharedCache object for this subcache.
SubCache(std::unique_ptr< details::SubCache > impl)
sc_uuid_t uuid() const
The uuid of the subcache file.
uint64_t vm_offset() const
The offset of this subcache from the main cache base address.
std::string suffix() const
The file name suffix of the subCache file (e.g. .25.data, .03.development).
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition iterators.hpp:729
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition DyldSharedCache/DyldSharedCache.hpp:36
Namespace related to the dyld shared cache support.
Definition caching.hpp:22
std::array< uint8_t, 16 > sc_uuid_t
UUID used in different places of the shared cache.
Definition uuid.hpp:26
LIEF namespace.
Definition Abstract/Binary.hpp:41
#define LIEF_API
Definition visibility.h:45