diff options
Diffstat (limited to 'view/sharedcache')
| -rw-r--r-- | view/sharedcache/core/ObjC.cpp | 25 | ||||
| -rw-r--r-- | view/sharedcache/core/ObjC.h | 5 | ||||
| -rw-r--r-- | view/sharedcache/core/SharedCacheController.cpp | 8 |
3 files changed, 29 insertions, 9 deletions
diff --git a/view/sharedcache/core/ObjC.cpp b/view/sharedcache/core/ObjC.cpp index 9fee4628..dc5c3856 100644 --- a/view/sharedcache/core/ObjC.cpp +++ b/view/sharedcache/core/ObjC.cpp @@ -170,6 +170,25 @@ Ref<Symbol> SharedCacheObjCProcessor::GetSymbol(uint64_t address) return symbol; } -SharedCacheObjCProcessor::SharedCacheObjCProcessor(BinaryView* data, bool isBackedByDatabase) : - ObjCProcessor(data, "SharedCache.ObjC", isBackedByDatabase, true) -{} +Ref<Section> SharedCacheObjCProcessor::GetSectionWithName(const char *sectionName) +{ + const auto controller = DSC::SharedCacheController::FromView(*m_data); + if (!controller) + return nullptr; + + const auto image = controller->GetCache().GetImageAt(m_imageAddress); + if (!image) + return nullptr; + + for (const auto& section : image->header->sectionNames) + if (section.find(sectionName) != std::string::npos) + return m_data->GetSectionByName(section); + + return nullptr; +} + +SharedCacheObjCProcessor::SharedCacheObjCProcessor(BinaryView *data, bool isBackedByDatabase, uint64_t imageAddress) + : ObjCProcessor(data, "SharedCache.ObjC", isBackedByDatabase, true) +{ + m_imageAddress = imageAddress; +} diff --git a/view/sharedcache/core/ObjC.h b/view/sharedcache/core/ObjC.h index 81e98f54..f44323d6 100644 --- a/view/sharedcache/core/ObjC.h +++ b/view/sharedcache/core/ObjC.h @@ -58,6 +58,7 @@ namespace DSCObjC { class SharedCacheObjCProcessor : public BinaryNinja::ObjCProcessor { std::optional<uint64_t> m_customRelativeMethodSelectorBase = std::nullopt; + uint64_t m_imageAddress; std::shared_ptr<BinaryNinja::ObjCReader> GetReader() override; @@ -65,8 +66,10 @@ namespace DSCObjC { BinaryNinja::Ref<BinaryNinja::Symbol> GetSymbol(uint64_t address) override; + BinaryNinja::Ref<BinaryNinja::Section> GetSectionWithName(const char *sectionName) override; + public: - SharedCacheObjCProcessor(BinaryNinja::BinaryView* data, bool isBackedByDatabase); + SharedCacheObjCProcessor(BinaryNinja::BinaryView* data, bool isBackedByDatabase, uint64_t imageAddress); uint64_t GetObjCRelativeMethodBaseAddress(BinaryNinja::ObjCReader* reader) override; }; diff --git a/view/sharedcache/core/SharedCacheController.cpp b/view/sharedcache/core/SharedCacheController.cpp index 13afb476..8d036b4a 100644 --- a/view/sharedcache/core/SharedCacheController.cpp +++ b/view/sharedcache/core/SharedCacheController.cpp @@ -215,16 +215,14 @@ bool SharedCacheController::ApplyImage(BinaryView& view, const CacheImage& image machoProcessor.ApplyHeader(*image.header); view.SetFunctionAnalysisUpdateDisabled(prevDisabledState); - // TODO: Passing in an image name here is weird considering this is shared with the MACHO view. - // TODO: We should abstract out the "image" into an objc image type that represents what is required, which ig is the name? // Load objective-c information. - auto objcProcessor = DSCObjC::SharedCacheObjCProcessor(&view, false); + auto objcProcessor = DSCObjC::SharedCacheObjCProcessor(&view, false, image.headerAddress); try { if (m_processObjC) - objcProcessor.ProcessObjCData(image.GetName()); + objcProcessor.ProcessObjCData(); if (m_processCFStrings) - objcProcessor.ProcessCFStrings(image.GetName()); + objcProcessor.ProcessCFStrings(); } catch (std::exception& e) { |
