From 840ae5356fe413049f77afbcb67c027366bdf0f0 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Mon, 7 Apr 2025 12:08:37 -0400 Subject: [SharedCache] Resolve original file path and name from project database file Fixes https://github.com/Vector35/binaryninja-api/issues/6582 More considerations might need to be made for databases saved without the original file path. Likely solved through some shared cache specific metadata. --- view/sharedcache/core/SharedCache.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'view/sharedcache/core/SharedCache.cpp') diff --git a/view/sharedcache/core/SharedCache.cpp b/view/sharedcache/core/SharedCache.cpp index e468b559..bfb10d90 100644 --- a/view/sharedcache/core/SharedCache.cpp +++ b/view/sharedcache/core/SharedCache.cpp @@ -616,9 +616,11 @@ bool CacheProcessor::ProcessProjectCache(SharedCache& cache) auto baseProjectFile = m_view->GetFile()->GetProjectFile(); std::string baseFilePath = baseProjectFile->GetPathOnDisk(); std::string baseFileName = baseProjectFile->GetName(); + // This will point to the path on disk for original non-bndb file. + std::string originalFilePath = m_view->GetFile()->GetOriginalFilename(); // Remove the .bndb extension if present ("dyld_shared_cache_arm64e.bndb" => "dyld_shared_cache_arm64e) - // TODO: This is a little annoying, we need to do this because the file accessor we have is seperate + // TODO: This is a little annoying, we need to do this because the file accessor we have is separate // TODO: from the view file accessor. If we either made it so that we can parse from the BNDB file accessor, // TODO: or... something better than this. if (baseFileName.find(".bndb") != std::string::npos) @@ -629,10 +631,11 @@ bool CacheProcessor::ProcessProjectCache(SharedCache& cache) { auto projectFilePath = projectFile->GetPathOnDisk(); auto projectFileName = projectFile->GetName(); - if (projectFileName == baseFileName) + if (projectFileName == baseFileName || projectFilePath == originalFilePath) { // Use the real file instead. baseFilePath = projectFilePath; + baseFileName = projectFileName; baseProjectFile = projectFile; break; } -- cgit v1.3.1