diff options
| author | Glenn Smith <glenn@vector35.com> | 2025-02-18 18:03:06 -0500 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2025-02-26 14:17:52 -0500 |
| commit | b3cfd46356af3416d72bd6593bb2a397e72554b6 (patch) | |
| tree | 0c1a5120a2764c7b64746da902b17d04409043d7 /view/sharedcache/core/SharedCache.cpp | |
| parent | 4bda0ac97e4961cbb0c5d050fc66989135519aac (diff) | |
[SharedCache] Fix loading DSC BNDB from a local project crashing
Also fixes a BinaryViewRef leak
Diffstat (limited to 'view/sharedcache/core/SharedCache.cpp')
| -rw-r--r-- | view/sharedcache/core/SharedCache.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/view/sharedcache/core/SharedCache.cpp b/view/sharedcache/core/SharedCache.cpp index 2980c0e2..e3c115cd 100644 --- a/view/sharedcache/core/SharedCache.cpp +++ b/view/sharedcache/core/SharedCache.cpp @@ -317,19 +317,16 @@ uint64_t SharedCache::FastGetBackingCacheCount(BinaryNinja::Ref<BinaryNinja::Bin } case LargeCacheFormat: { - auto mainFileName = baseFile->Path(); auto subCacheCount = header.subCacheArrayCount; return subCacheCount + 1; } case SplitCacheFormat: { - auto mainFileName = baseFile->Path(); auto subCacheCount = header.subCacheArrayCount; return subCacheCount + 2; } case iOS16CacheFormat: { - auto mainFileName = baseFile->Path(); auto subCacheCount = header.subCacheArrayCount; return subCacheCount + 2; } @@ -640,7 +637,7 @@ void SharedCache::PerformInitialLoad(std::lock_guard<std::mutex>& lock) subCachePath = path + "." + entry.fileExtension; subCacheFilename = mainFileName + "." + entry.fileExtension; } - auto subCacheFile = MapFileWithoutApplyingSlide(subCachePath); + auto subCacheFile = MapFileWithoutApplyingSlide(ResolveFilePath(m_dscView, subCachePath)); dyld_cache_header subCacheHeader {}; uint64_t headerSize = subCacheFile->ReadUInt32(16); @@ -727,7 +724,7 @@ void SharedCache::PerformInitialLoad(std::lock_guard<std::mutex>& lock) { auto subCachePath = path + "." + std::to_string(i); auto subCacheFilename = mainFileName + "." + std::to_string(i); - auto subCacheFile = MapFileWithoutApplyingSlide(subCachePath); + auto subCacheFile = MapFileWithoutApplyingSlide(ResolveFilePath(m_dscView, subCachePath)); dyld_cache_header subCacheHeader {}; uint64_t headerSize = subCacheFile->ReadUInt32(16); @@ -773,7 +770,7 @@ void SharedCache::PerformInitialLoad(std::lock_guard<std::mutex>& lock) // Load .symbols subcache try { auto subCachePath = path + ".symbols"; - auto subCacheFile = MapFileWithoutApplyingSlide(subCachePath); + auto subCacheFile = MapFileWithoutApplyingSlide(ResolveFilePath(m_dscView, subCachePath)); dyld_cache_header subCacheHeader {}; uint64_t headerSize = subCacheFile->ReadUInt32(16); @@ -870,7 +867,7 @@ void SharedCache::PerformInitialLoad(std::lock_guard<std::mutex>& lock) subCacheFilename = mainFileName + "." + entry.fileExtension; } - auto subCacheFile = MapFileWithoutApplyingSlide(subCachePath); + auto subCacheFile = MapFileWithoutApplyingSlide(ResolveFilePath(m_dscView, subCachePath)); dyld_cache_header subCacheHeader {}; uint64_t headerSize = subCacheFile->ReadUInt32(16); @@ -931,7 +928,7 @@ void SharedCache::PerformInitialLoad(std::lock_guard<std::mutex>& lock) try { auto subCachePath = path + ".symbols"; - auto subCacheFile = MapFileWithoutApplyingSlide(subCachePath); + auto subCacheFile = MapFileWithoutApplyingSlide(ResolveFilePath(m_dscView, subCachePath)); dyld_cache_header subCacheHeader {}; uint64_t headerSize = subCacheFile->ReadUInt32(16); if (subCacheFile->ReadUInt32(16) > sizeof(dyld_cache_header)) @@ -3564,7 +3561,7 @@ uint64_t SharedCache::GetObjCRelativeMethodBaseAddress(const VMReader& reader) c std::shared_ptr<MMappedFileAccessor> SharedCache::MapFile(const std::string& path) { uint64_t baseAddress = m_cacheInfo->BaseAddress(); - return MMappedFileAccessor::Open(m_dscView, m_dscView->GetFile()->GetSessionId(), path, + return MMappedFileAccessor::Open(m_dscView->GetFile()->GetSessionId(), path, [baseAddress, logger = m_logger](std::shared_ptr<MMappedFileAccessor> mmap) { ParseAndApplySlideInfoForFile(mmap, baseAddress, logger); }) |
