diff options
| author | WeiN76LQh <WeiN76LQh@github.com> | 2024-11-25 19:54:44 +0000 |
|---|---|---|
| committer | kat <kat@vector35.com> | 2024-12-26 10:42:54 -0500 |
| commit | 2cce2ab6c79879a4d64df1fc7375e2c871565f8f (patch) | |
| tree | 9e6c5273eff573f28b99fd59f98472582df2d639 /view/sharedcache/core | |
| parent | 934104743a0e3071606277692822be4b853288ac (diff) | |
[SharedCache] Add the ability to skip Objective-C processing when loading a library
This is useful when batch loading libraries to avoid extra processing (once the next commit has landed).
Diffstat (limited to 'view/sharedcache/core')
| -rw-r--r-- | view/sharedcache/core/SharedCache.cpp | 59 | ||||
| -rw-r--r-- | view/sharedcache/core/SharedCache.h | 4 |
2 files changed, 33 insertions, 30 deletions
diff --git a/view/sharedcache/core/SharedCache.cpp b/view/sharedcache/core/SharedCache.cpp index 7bbacf63..d4ce0921 100644 --- a/view/sharedcache/core/SharedCache.cpp +++ b/view/sharedcache/core/SharedCache.cpp @@ -1406,7 +1406,7 @@ SharedCache::SharedCache(BinaryNinja::Ref<BinaryNinja::BinaryView> dscView) : m_ { lock.unlock(); m_logger->LogInfo("Loading core libsystem_c.dylib library"); - LoadImageWithInstallName(header.installName); + LoadImageWithInstallName(header.installName, false); lock.lock(); break; } @@ -1518,7 +1518,7 @@ std::string SharedCache::ImageNameForAddress(uint64_t address) return ""; } -bool SharedCache::LoadImageContainingAddress(uint64_t address) +bool SharedCache::LoadImageContainingAddress(uint64_t address, bool skipObjC) { for (const auto& [start, header] : State().headers) { @@ -1526,7 +1526,7 @@ bool SharedCache::LoadImageContainingAddress(uint64_t address) { if (segment.vmaddr <= address && segment.vmaddr + segment.vmsize > address) { - return LoadImageWithInstallName(header.installName); + return LoadImageWithInstallName(header.installName, skipObjC); } } } @@ -1727,7 +1727,7 @@ bool SharedCache::LoadSectionAtAddress(uint64_t address) return true; } -bool SharedCache::LoadImageWithInstallName(std::string installName) +bool SharedCache::LoadImageWithInstallName(std::string installName, bool skipObjC) { auto settings = m_dscView->GetLoadSettings(VIEW_NAME); @@ -1837,28 +1837,31 @@ bool SharedCache::LoadImageWithInstallName(std::string installName) SharedCache::InitializeHeader(m_dscView, vm.get(), *h, regions); - try + if (!skipObjC) { - auto objc = std::make_unique<DSCObjC::DSCObjCProcessor>(m_dscView, this, false); + try + { + auto objc = std::make_unique<DSCObjC::DSCObjCProcessor>(m_dscView, this, false); - bool processCFStrings = true; - bool processObjCMetadata = true; - if (settings && settings->Contains("loader.dsc.processCFStrings")) - processCFStrings = settings->Get<bool>("loader.dsc.processCFStrings", m_dscView); - if (settings && settings->Contains("loader.dsc.processObjC")) - processObjCMetadata = settings->Get<bool>("loader.dsc.processObjC", m_dscView); - if (processObjCMetadata) - objc->ProcessObjCData(vm, h->identifierPrefix); - if (processCFStrings) - objc->ProcessCFStrings(vm, h->identifierPrefix); - } - catch (const std::exception& ex) - { - m_logger->LogWarn("Error processing ObjC data: %s", ex.what()); - } - catch (...) - { - m_logger->LogWarn("Error processing ObjC data"); + bool processCFStrings = true; + bool processObjCMetadata = true; + if (settings && settings->Contains("loader.dsc.processCFStrings")) + processCFStrings = settings->Get<bool>("loader.dsc.processCFStrings", m_dscView); + if (settings && settings->Contains("loader.dsc.processObjC")) + processObjCMetadata = settings->Get<bool>("loader.dsc.processObjC", m_dscView); + if (processObjCMetadata) + objc->ProcessObjCData(vm, h->identifierPrefix); + if (processCFStrings) + objc->ProcessCFStrings(vm, h->identifierPrefix); + } + catch (const std::exception& ex) + { + m_logger->LogWarn("Error processing ObjC data: %s", ex.what()); + } + catch (...) + { + m_logger->LogWarn("Error processing ObjC data"); + } } m_dscView->AddAnalysisOption("linearsweep"); @@ -3033,13 +3036,13 @@ extern "C" cache->object->ReleaseAPIRef(); } - bool BNDSCViewLoadImageWithInstallName(BNSharedCache* cache, char* name) + bool BNDSCViewLoadImageWithInstallName(BNSharedCache* cache, char* name, bool skipObjC) { std::string imageName = std::string(name); // FIXME !!!!!!!! BNFreeString(name); if (cache->object) - return cache->object->LoadImageWithInstallName(imageName); + return cache->object->LoadImageWithInstallName(imageName, skipObjC); return false; } @@ -3054,11 +3057,11 @@ extern "C" return false; } - bool BNDSCViewLoadImageContainingAddress(BNSharedCache* cache, uint64_t address) + bool BNDSCViewLoadImageContainingAddress(BNSharedCache* cache, uint64_t address, bool skipObjC) { if (cache->object) { - return cache->object->LoadImageContainingAddress(address); + return cache->object->LoadImageContainingAddress(address, skipObjC); } return false; diff --git a/view/sharedcache/core/SharedCache.h b/view/sharedcache/core/SharedCache.h index 924d81f2..c82dea5c 100644 --- a/view/sharedcache/core/SharedCache.h +++ b/view/sharedcache/core/SharedCache.h @@ -571,9 +571,9 @@ namespace SharedCacheCore { void ParseAndApplySlideInfoForFile(std::shared_ptr<MMappedFileAccessor> file); std::optional<uint64_t> GetImageStart(std::string installName); std::optional<SharedCacheMachOHeader> HeaderForAddress(uint64_t); - bool LoadImageWithInstallName(std::string installName); + bool LoadImageWithInstallName(std::string installName, bool skipObjC); bool LoadSectionAtAddress(uint64_t address); - bool LoadImageContainingAddress(uint64_t address); + bool LoadImageContainingAddress(uint64_t address, bool skipObjC); std::string NameForAddress(uint64_t address); std::string ImageNameForAddress(uint64_t address); std::vector<std::string> GetAvailableImages(); |
