diff options
| author | Mason Reed <mason@vector35.com> | 2025-04-10 00:53:06 -0400 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-04-10 14:38:09 -0400 |
| commit | 86019f825db516d8d5349c271f702dfe69b5fead (patch) | |
| tree | ec91007fa0c857bfd54bb3d1d78ff55daf083928 /view/sharedcache/core/SharedCache.h | |
| parent | b00d315524610d8c66af27619e87648bd5d63942 (diff) | |
[SharedCache] Make the shared cache file lookup more straightforward
We already had separated this part out into the `CacheProcessor` but its more like a builder than anything, so this refactors that out into a `SharedCacheBuilder`.
- Separate out the `CacheProcessor` and simplify its implementation
- Move more implementation specific stuff to the shared cache view
- Prepare for more validation of the shared cache to detect irregular or incomplete shared cache information
- Deduplicate a lot of file vs. project file lookup stuff
- Stop copying all images when getting the number of images to log
- Allow user to select another directory to scan for shared cache files, might make this a warning instead to prevent users from relying on this behavior
We will likely follow this commit up soon with better open behavior, maybe open with options can specify a list of cache entry files? Shouldn't be too much effort aside from making the UI modal for that.
Diffstat (limited to 'view/sharedcache/core/SharedCache.h')
| -rw-r--r-- | view/sharedcache/core/SharedCache.h | 35 |
1 files changed, 1 insertions, 34 deletions
diff --git a/view/sharedcache/core/SharedCache.h b/view/sharedcache/core/SharedCache.h index 0bf04776..8aea0362 100644 --- a/view/sharedcache/core/SharedCache.h +++ b/view/sharedcache/core/SharedCache.h @@ -7,8 +7,6 @@ #include "MachO.h" #include "VirtualMemory.h" -class SharedCache; - struct CacheSymbol { BNSymbolType type; @@ -16,19 +14,15 @@ struct CacheSymbol std::string name; CacheSymbol() = default; - CacheSymbol(BNSymbolType type, uint64_t address, std::string name) : type(type), address(address), name(std::move(name)) {} - ~CacheSymbol() = default; CacheSymbol(const CacheSymbol& other) = default; - CacheSymbol& operator=(const CacheSymbol& other) = default; CacheSymbol(CacheSymbol&& other) noexcept = default; - CacheSymbol& operator=(CacheSymbol&& other) noexcept = default; std::pair<std::string, BinaryNinja::Ref<BinaryNinja::Type>> DemangledName(BinaryNinja::BinaryView& view) const; @@ -56,15 +50,12 @@ struct CacheRegion BNSegmentFlag flags; CacheRegion() = default; - ~CacheRegion() = default; CacheRegion(const CacheRegion& other) = default; - CacheRegion& operator=(const CacheRegion& other) = default; CacheRegion(CacheRegion&& other) noexcept = default; - CacheRegion& operator=(CacheRegion&& other) noexcept = default; AddressRange AsAddressRange() const { return {start, start + size}; } @@ -95,15 +86,12 @@ struct CacheImage std::shared_ptr<SharedCacheMachOHeader> header; CacheImage() = default; - ~CacheImage() = default; CacheImage(const CacheImage& other) = default; - CacheImage& operator=(const CacheImage& other) = default; CacheImage(CacheImage&& other) noexcept = default; - CacheImage& operator=(CacheImage&& other) noexcept = default; // Get the file name from the path. @@ -145,11 +133,9 @@ public: std::vector<dyld_cache_mapping_info> mappings, std::vector<std::pair<std::string, dyld_cache_image_info>> images); CacheEntry() = default; - CacheEntry(const CacheEntry&) = default; CacheEntry(CacheEntry&&) = default; - CacheEntry& operator=(CacheEntry&&) = default; // Construct a cache entry from the file on disk. @@ -213,6 +199,7 @@ class SharedCache bool AddNonOverlappingRegion(CacheRegion region); public: + SharedCache() = default; explicit SharedCache(uint64_t addressSize); SharedCache(const SharedCache &) = delete; @@ -269,23 +256,3 @@ public: std::optional<CacheSymbol> GetSymbolWithName(const std::string& name); }; - -// This constructs a Cache, give it a file path, and it will add all relevant cache entries. -class CacheProcessor -{ - BinaryNinja::Ref<BinaryNinja::BinaryView> m_view; - BinaryNinja::Ref<BinaryNinja::Logger> m_logger; - -public: - explicit CacheProcessor(BinaryNinja::Ref<BinaryNinja::BinaryView> view); - - // Construct a cache from the root file, this will parse the cache header and locate all - // applicable cache entries and add them as well. - bool ProcessCache(SharedCache& cache); - - // Process a cache on the file system, this is for when not using a project. - bool ProcessFileCache(SharedCache& cache); - - // Process a cache using Binary Ninja's project system. - bool ProcessProjectCache(SharedCache& cache); -}; |
