16#ifndef LIEF_DSC_DYLD_SHARED_CACHE_H
17#define LIEF_DSC_DYLD_SHARED_CACHE_H
116 static std::unique_ptr<DyldSharedCache>
from_path(
const std::string& path,
117 const std::string&
arch =
"");
120 static std::unique_ptr<DyldSharedCache>
from_files(
const std::vector<std::string>& path);
260 std::unique_ptr<details::DyldSharedCache> impl_;
282inline std::unique_ptr<DyldSharedCache>
load(
const std::string& path,
283 const std::string& arch =
"")
297inline std::unique_ptr<DyldSharedCache>
load(
const std::vector<std::string>& files)
Stream interface over a std::ifstream.
Definition FileStream.hpp:30
This class represents a dyld shared cache file.
Definition DyldSharedCache/DyldSharedCache.hpp:40
std::string filepath() const
Full path to the original dyld shared cache file associated with object (e.g. /home/lief/downloads/vi...
iterator_range< MappingInfo::Iterator > mapping_info_iterator
Iterator over the mapping info in the shared cache.
Definition DyldSharedCache/DyldSharedCache.hpp:105
void flush_cache() const
Flush internal information into the on-disk cache (see: enable_caching).
uint64_t load_address() const
Based address of this cache.
iterator_range< assembly::Instruction::Iterator > instructions_iterator
Definition DyldSharedCache/DyldSharedCache.hpp:110
instructions_iterator disassemble(uint64_t va) const
Disassemble instructions at the provided virtual address. This function returns an iterator over asse...
FileStream & stream() const
Return the stream associated with this dyld shared cache.
FileStream & stream()
Return the stream associated with this dyld shared cache.
dylib_iterator libraries() const
Return an interator over the libraries embedded in this dyld shared cache.
void enable_caching(const std::string &target_cache_dir) const
When enabled, this function allows to record and to keep in cache, dyld shared cache information that...
DyldSharedCache(std::unique_ptr< details::DyldSharedCache > impl)
bool has_subcaches() const
True if the subcaches are associated with this cache.
DYLD_TARGET_ARCH arch() const
Architecture targeted by this cache.
VERSION
This enum wraps the dyld's git tags for which the structure of dyld shared cache evolved.
Definition DyldSharedCache/DyldSharedCache.hpp:45
@ DYLD_95_3
dyld-95.3 (2007-10-30)
Definition DyldSharedCache/DyldSharedCache.hpp:48
@ DYLD_360_14
dyld-360.14 (2015-09-04)
Definition DyldSharedCache/DyldSharedCache.hpp:51
@ UNKNOWN
Definition DyldSharedCache/DyldSharedCache.hpp:46
@ DYLD_421_1
dyld-421.1 (2016-09-22)
Definition DyldSharedCache/DyldSharedCache.hpp:52
@ DYLD_239_3
dyld-239.3 (2013-10-29)
Definition DyldSharedCache/DyldSharedCache.hpp:50
@ DYLD_832_7_1
dyld-832.7.1 (2020-11-19)
Definition DyldSharedCache/DyldSharedCache.hpp:53
@ UNRELEASED
This value is used for versions of dyld not publicly released or not yet supported by LIEF.
Definition DyldSharedCache/DyldSharedCache.hpp:60
@ DYLD_1231_3
dyld-1231.3 (2024-09-24)
Definition DyldSharedCache/DyldSharedCache.hpp:56
@ DYLD_940
dyld-940 (2021-02-09)
Definition DyldSharedCache/DyldSharedCache.hpp:54
@ DYLD_1042_1
dyld-1042.1 (2022-10-19)
Definition DyldSharedCache/DyldSharedCache.hpp:55
@ DYLD_195_5
dyld-195.5 (2011-07-13)
Definition DyldSharedCache/DyldSharedCache.hpp:49
iterator_range< Dylib::Iterator > dylib_iterator
Iterator over the libraries in the shared cache.
Definition DyldSharedCache/DyldSharedCache.hpp:102
DYLD_TARGET_PLATFORM platform() const
Platform targeted by this cache (e.g. vision-os).
std::unique_ptr< Dylib > find_lib_from_path(const std::string &path) const
Find the Dylib whose Dylib::path matches the provided path.
static std::unique_ptr< DyldSharedCache > from_path(const std::string &path, const std::string &arch="")
See the load functions for the details.
std::unique_ptr< Dylib > find_lib_from_name(const std::string &name) const
Find the Dylib whose filename of Dylib::path matches the provided name.
std::unique_ptr< DyldSharedCache > cache_for_address(uint64_t va) const
Find the sub-DyldSharedCache that wraps the given virtual address.
std::vector< uint8_t > get_content_from_va(uint64_t va, uint64_t size) const
Return the content at the specified virtual address.
std::string arch_name() const
Name of the architecture targeted by this cache (x86_64h).
DYLD_TARGET_ARCH
Architecture supported by the dyld shared cache.
Definition DyldSharedCache/DyldSharedCache.hpp:85
@ ARMV6
Definition DyldSharedCache/DyldSharedCache.hpp:94
@ ARMV7
Definition DyldSharedCache/DyldSharedCache.hpp:95
@ ARM64E
Definition DyldSharedCache/DyldSharedCache.hpp:98
@ X86_64
Definition DyldSharedCache/DyldSharedCache.hpp:90
@ ARMV5
Definition DyldSharedCache/DyldSharedCache.hpp:93
@ ARM64
Definition DyldSharedCache/DyldSharedCache.hpp:97
@ I386
Definition DyldSharedCache/DyldSharedCache.hpp:88
@ X86_64H
Definition DyldSharedCache/DyldSharedCache.hpp:91
std::string filename() const
Filename of the dyld shared file associated with this object.
std::unique_ptr< Dylib > find_lib_from_va(uint64_t va) const
Find the Dylib that encompasses the given virtual address. It returns a nullptr if a Dylib can't be f...
mapping_info_iterator mapping_info() const
Return an interator over the mapping information of this dyld shared cache.
std::unique_ptr< DyldSharedCache > find_subcache(const std::string &filename) const
Try to find the DyldSharedCache associated with the filename given in the first parameter.
iterator_range< SubCache::Iterator > subcache_iterator
Iterator over the split/sub-cache in this main shared cache.
Definition DyldSharedCache/DyldSharedCache.hpp:108
static std::unique_ptr< DyldSharedCache > from_files(const std::vector< std::string > &path)
See the load functions for the details.
result< uint64_t > va_to_offset(uint64_t va) const
Convert the given virtual address into an offset.
DYLD_TARGET_PLATFORM
Platforms supported by the dyld shared cache.
Definition DyldSharedCache/DyldSharedCache.hpp:64
@ VISIONOS
Definition DyldSharedCache/DyldSharedCache.hpp:76
@ VISIONOS_SIMULATOR
Definition DyldSharedCache/DyldSharedCache.hpp:77
@ TVOS_SIMULATOR
Definition DyldSharedCache/DyldSharedCache.hpp:73
@ IOS_SIMULATOR
Definition DyldSharedCache/DyldSharedCache.hpp:72
@ TVOS
Definition DyldSharedCache/DyldSharedCache.hpp:68
@ MACOS
Definition DyldSharedCache/DyldSharedCache.hpp:66
@ BRIDGEOS
Definition DyldSharedCache/DyldSharedCache.hpp:70
@ DRIVERKIT
Definition DyldSharedCache/DyldSharedCache.hpp:75
@ ANY
Definition DyldSharedCache/DyldSharedCache.hpp:81
@ IOSMAC
Definition DyldSharedCache/DyldSharedCache.hpp:71
@ SEPOS
Definition DyldSharedCache/DyldSharedCache.hpp:79
@ IOS
Definition DyldSharedCache/DyldSharedCache.hpp:67
@ WATCHOS_SIMULATOR
Definition DyldSharedCache/DyldSharedCache.hpp:74
@ WATCHOS
Definition DyldSharedCache/DyldSharedCache.hpp:69
@ FIRMWARE
Definition DyldSharedCache/DyldSharedCache.hpp:78
std::unique_ptr< DyldSharedCache > main_cache() const
Return the principal dyld shared cache in the case of multiple subcaches.
subcache_iterator subcaches() const
Return an interator over the subcaches associated with this (main) dyld shared cache.
VERSION version() const
Version of dyld used by this cache.
Definition iterators.hpp:486
Definition DyldSharedCache/DyldSharedCache.hpp:35
Namespace related to the dyld shared cache support.
Definition caching.hpp:22
std::unique_ptr< DyldSharedCache > load(const std::string &path, const std::string &arch="")
Load a shared cache from a single file or from a directory specified by the path parameter.
Definition DyldSharedCache/DyldSharedCache.hpp:282
LIEF namespace.
Definition Abstract/Binary.hpp:40
tl::expected< T, lief_errors > result
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:75
#define LIEF_API
Definition visibility.h:41