diff options
| author | Mason Reed <mason@vector35.com> | 2025-04-02 05:35:19 -0400 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-04-02 05:36:54 -0400 |
| commit | bc4ad889f0edc54f0f6e073e3f5a474d8cec55e3 (patch) | |
| tree | 1eaa7be6e8f53ca7b09f089a568ee2ddc42581ac | |
| parent | cfb8215d6aa0703ad0d6c3046431536b4e37d810 (diff) | |
[SharedCache] Consistent logger naming and misc changes
| -rw-r--r-- | view/sharedcache/core/MachOProcessor.cpp | 2 | ||||
| -rw-r--r-- | view/sharedcache/core/SharedCache.cpp | 9 | ||||
| -rw-r--r-- | view/sharedcache/core/SharedCacheController.cpp | 4 | ||||
| -rw-r--r-- | view/sharedcache/core/SharedCacheView.cpp | 3 |
4 files changed, 12 insertions, 6 deletions
diff --git a/view/sharedcache/core/MachOProcessor.cpp b/view/sharedcache/core/MachOProcessor.cpp index 3de2980d..5ef14abd 100644 --- a/view/sharedcache/core/MachOProcessor.cpp +++ b/view/sharedcache/core/MachOProcessor.cpp @@ -6,7 +6,7 @@ using namespace BinaryNinja; SharedCacheMachOProcessor::SharedCacheMachOProcessor(Ref<BinaryView> view, std::shared_ptr<VirtualMemory> vm) { m_view = view; - m_logger = new Logger("SharedCacheMachOProcessor", view->GetFile()->GetSessionId()); + m_logger = new Logger("SharedCache.MachOProcessor", view->GetFile()->GetSessionId()); m_vm = std::move(vm); // Adjust processor settings. diff --git a/view/sharedcache/core/SharedCache.cpp b/view/sharedcache/core/SharedCache.cpp index d0c3d25b..65d5aec1 100644 --- a/view/sharedcache/core/SharedCache.cpp +++ b/view/sharedcache/core/SharedCache.cpp @@ -491,7 +491,7 @@ std::optional<CacheSymbol> SharedCache::GetSymbolWithName(const std::string& nam CacheProcessor::CacheProcessor(Ref<BinaryView> view) { m_view = std::move(view); - m_logger = new Logger("CacheProcessor", m_view->GetFile()->GetSessionId()); + m_logger = new Logger("SharedCache.Processor", m_view->GetFile()->GetSessionId()); } bool CacheProcessor::ProcessCache(SharedCache& cache) @@ -523,6 +523,7 @@ bool CacheProcessor::ProcessFileCache(SharedCache& cache) catch (const std::exception& e) { // Just return false so the view init can continue. + m_logger->LogErrorF("Failed to load base entry {}... {}", baseFileName, e.what()); return false; } @@ -535,7 +536,7 @@ bool CacheProcessor::ProcessFileCache(SharedCache& cache) auto currentFilePath = entry.path().string(); auto currentFileName = BaseFileName(currentFilePath); // Skip our base file, obviously. - if (currentFilePath== baseFilePath) + if (currentFilePath == baseFilePath) continue; // Filter files that don't contain the base file name i.e. "dyld_shared_cache_arm64e" if (currentFilePath.find(baseFileName) == std::string::npos) @@ -559,7 +560,9 @@ bool CacheProcessor::ProcessFileCache(SharedCache& cache) cache.AddEntry(std::move(*additionalEntry)); } catch (const std::exception& e) - {} + { + m_logger->LogErrorF("Failed to load entry {}... {}", currentFileName, e.what()); + } } return true; diff --git a/view/sharedcache/core/SharedCacheController.cpp b/view/sharedcache/core/SharedCacheController.cpp index 72d5d950..e2e49c84 100644 --- a/view/sharedcache/core/SharedCacheController.cpp +++ b/view/sharedcache/core/SharedCacheController.cpp @@ -69,7 +69,7 @@ DSCRef<SharedCacheController> SharedCacheController::Initialize(BinaryView& view { auto id = GetViewIdFromView(view); std::unique_lock<std::shared_mutex> lock(GlobalControllersMutex); - auto logger = new Logger("SharedCacheController", view.GetFile()->GetSessionId()); + auto logger = new Logger("SharedCache.Controller", view.GetFile()->GetSessionId()); DSCRef<SharedCacheController> dscView = new SharedCacheController(std::move(cache), logger); // Pull the settings from the view. @@ -216,6 +216,8 @@ bool SharedCacheController::ApplyImage(BinaryView& view, const CacheImage& image m_loadedImages.insert(image.headerAddress); + m_logger->LogInfoF("Loaded image: '{}'", image.path); + // TODO: This needs to be done in a "database save" callback. view.StoreMetadata(METADATA_KEY, GetMetadata()); diff --git a/view/sharedcache/core/SharedCacheView.cpp b/view/sharedcache/core/SharedCacheView.cpp index f27f7c14..0d9b0e70 100644 --- a/view/sharedcache/core/SharedCacheView.cpp +++ b/view/sharedcache/core/SharedCacheView.cpp @@ -169,7 +169,7 @@ bool SharedCacheView::Init() std::string os; std::string arch; - auto logger = new Logger("SharedCacheView", GetFile()->GetSessionId()); + auto logger = new Logger("SharedCache.View", GetFile()->GetSessionId()); uint32_t platform; GetParentView()->Read(&platform, 0xd8, 4); @@ -794,6 +794,7 @@ bool SharedCacheView::Init() // TODO: Prompt the user to select the primary cache file? We can still recover from here. // Oh no, we failed to process the cache, this likely means the primary on-disk file was not able to be found. logger->LogError("Failed to process cache, likely missing cache files."); + // TODO: Returning false here does not prevent the file from being opened. // NOTE: An interaction handler headlessly could select yes to this, however for the purposes of this we will just let them continue by defualt. if (IsUIEnabled() && ShowMessageBox("Continue opening", "This shared cache file was unable to be processed, would you like to open without shared cache information?", YesNoButtonSet, QuestionIcon) != YesButton) return false; |
