From ee500220baa1a46f3d7ca1486fa43dc1587f20d0 Mon Sep 17 00:00:00 2001 From: WeiN76LQh Date: Fri, 3 Jan 2025 17:55:10 +0000 Subject: [ObjC] Create a shared ObjC processor for Macho and DSC views Both the Macho and DSC views need to process Objective-C but have separate processor classes. It would appear that the DSC version was largely a copy and paste of the Macho view one, with some modifications. The majority of code overlaps between the 2 so it doesn't make sense to maintain 2 and copy and paste improvements/fixes between them. This commit fixes that by creating a base Objective-C processor that contains the shared code. View specific code is implemented in the respective subclasses for the views. Although there is very little view specific code for each. --- view/macho/machoview.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'view/macho/machoview.cpp') diff --git a/view/macho/machoview.cpp b/view/macho/machoview.cpp index 2a927671..8a320545 100644 --- a/view/macho/machoview.cpp +++ b/view/macho/machoview.cpp @@ -1840,13 +1840,13 @@ bool MachoView::InitializeHeader(MachOHeader& header, bool isMainHeader, uint64_ parseObjCStructs = settings->Get("loader.macho.processObjectiveC", this); if (settings && settings->Contains("loader.macho.processCFStrings")) parseCFStrings = settings->Get("loader.macho.processCFStrings", this); - if (!ObjCProcessor::ViewHasObjCMetadata(this)) + if (!MachoObjCProcessor::ViewHasObjCMetadata(this)) parseObjCStructs = false; if (!GetSectionByName("__cfstring")) parseCFStrings = false; if (parseObjCStructs || parseCFStrings) { - m_objcProcessor = new ObjCProcessor(this, m_backedByDatabase); + m_objcProcessor = new MachoObjCProcessor(this, m_backedByDatabase); } if (parseObjCStructs) { @@ -2332,7 +2332,7 @@ bool MachoView::InitializeHeader(MachOHeader& header, bool isMainHeader, uint64_ if (parseCFStrings) { try { - m_objcProcessor->ProcessCFStrings(); + m_objcProcessor->ProcessCFStrings(std::nullopt); } catch (std::exception& ex) { @@ -2344,7 +2344,7 @@ bool MachoView::InitializeHeader(MachOHeader& header, bool isMainHeader, uint64_ if (parseObjCStructs) { try { - m_objcProcessor->ProcessObjCData(); + m_objcProcessor->ProcessObjCData(std::nullopt); } catch (std::exception& ex) { @@ -3872,7 +3872,7 @@ Ref MachoViewType::GetLoadSettingsForData(BinaryView* data) settings->UpdateProperty(override, "readOnly", false); } - if (ObjCProcessor::ViewHasObjCMetadata(viewRef)) + if (MachoObjCProcessor::ViewHasObjCMetadata(viewRef)) { settings->RegisterSetting("loader.macho.processObjectiveC", R"({ -- cgit v1.3.1