From 25cc02431b61097b2adfc2fbc493b648b0300c3b Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Mon, 10 Mar 2025 11:05:40 -0400 Subject: [SharedCache] Refactor Shared Cache In absence of a better name, this commit refactors the shared cache code. --- view/sharedcache/core/SlideInfo.h | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 view/sharedcache/core/SlideInfo.h (limited to 'view/sharedcache/core/SlideInfo.h') diff --git a/view/sharedcache/core/SlideInfo.h b/view/sharedcache/core/SlideInfo.h new file mode 100644 index 00000000..bc165589 --- /dev/null +++ b/view/sharedcache/core/SlideInfo.h @@ -0,0 +1,42 @@ +#pragma once + +#include "binaryninjaapi.h" +#include "SharedCache.h" + +// Information required to apply slide (relocation) info to a mapping +struct SlideMappingInfo +{ + dyld_cache_mapping_info mappingInfo; + // NOTE: Offset is relative to the beginning of the entry file. + uint64_t address; + uint16_t slideInfoVersion; + + union + { + dyld_cache_slide_info_v2 slideInfoV2; + dyld_cache_slide_info_v3 slideInfoV3; + dyld_cache_slide_info_v5 slideInfoV5; + }; +}; + +// Current usages of the slide info are: +// - Reading export symbols requires slide info to be processed. +// - Reading objc stuff +// - Loading an image or region +// - Reading branch island mappings???? +class SlideInfoProcessor +{ + BinaryNinja::Ref m_logger; + // Base address of the shared cache, NOT the base address of the entry. + uint64_t m_baseAddress; + +public: + explicit SlideInfoProcessor(uint64_t baseAddress); + + std::vector ReadEntryInfo(VirtualMemory& vm, const CacheEntry& entry) const; + + // Write the slide information back to the entries memory mapped regions. + void ApplyMappings(VirtualMemory& vm, const std::vector& mappings); + + void ProcessEntry(VirtualMemory& vm, const CacheEntry& entry); +}; -- cgit v1.3.1