From c1cf836de9ae7ec55a131f2ca48756a4a4e9a447 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Tue, 25 Feb 2025 19:13:50 -0500 Subject: [SharedCache] Stop crashing if we don't have a valid dyld in PerformInitialLoad Still need to decide on how we want handle this, because we need multiple files we probably just want to prompt the user for a directory? --- view/sharedcache/core/SharedCache.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'view/sharedcache/core/SharedCache.cpp') diff --git a/view/sharedcache/core/SharedCache.cpp b/view/sharedcache/core/SharedCache.cpp index 25391dc2..a696e9b3 100644 --- a/view/sharedcache/core/SharedCache.cpp +++ b/view/sharedcache/core/SharedCache.cpp @@ -472,12 +472,14 @@ void SharedCache::PerformInitialLoad(std::lock_guard& lock) initialState.baseFilePath = path; initialState.cacheFormat = RegularCacheFormat; + // TODO: If this fails we should prompt the user to select there file, this probably means that + // TODO: They are opening a database with no original file path. DataBuffer sig = baseFile->ReadBuffer(0, 4); if (sig.GetLength() != 4) - abort(); + throw std::runtime_error("Not a valid dyld_shared_cache file"); const char* magic = (char*)sig.GetData(); if (strncmp(magic, "dyld", 4) != 0) - abort(); + throw std::runtime_error("Not a valid dyld_shared_cache file"); dyld_cache_header primaryCacheHeader {}; size_t header_size = baseFile->ReadUInt32(16); @@ -1469,9 +1471,9 @@ SharedCache::SharedCache(BinaryNinja::Ref dscView) : try { PerformInitialLoad(lock); } - catch (...) + catch (std::exception& e) { - m_logger->LogError("Failed to perform initial load of Shared Cache"); + m_logger->LogError("Failed to perform initial load of Shared Cache: %s", e.what()); } auto settings = m_dscView->GetLoadSettings(VIEW_NAME); -- cgit v1.3.1