summaryrefslogtreecommitdiff
path: root/view/sharedcache
diff options
context:
space:
mode:
authorkat <kat@vector35.com>2024-11-04 10:20:37 -0500
committerkat <kat@vector35.com>2024-11-05 09:05:04 -0500
commit69598bf4de54956512b0cfa64d9451779a01d30f (patch)
tree371c328b42c98bf8bd1abe1c45ae753afbdabfa9 /view/sharedcache
parenteed33141950281cb8e362ec96a17cd3414d11a1c (diff)
[SharedCache] Add load option to disable automatic loading of libsystem_c
Diffstat (limited to 'view/sharedcache')
-rw-r--r--view/sharedcache/core/DSCView.cpp8
-rw-r--r--view/sharedcache/core/SharedCache.cpp24
2 files changed, 24 insertions, 8 deletions
diff --git a/view/sharedcache/core/DSCView.cpp b/view/sharedcache/core/DSCView.cpp
index 80456fc7..3eb40b7e 100644
--- a/view/sharedcache/core/DSCView.cpp
+++ b/view/sharedcache/core/DSCView.cpp
@@ -814,6 +814,14 @@ Ref<Settings> DSCViewType::GetLoadSettingsForData(BinaryView* data)
"description" : "Processes CoreFoundation strings, applying string values from encoded metadata"
})");
+ settings->RegisterSetting("loader.dsc.autoLoadLibSystem",
+ R"({
+ "title" : "Auto-Load libSystem",
+ "type" : "boolean",
+ "default" : true,
+ "description" : "Whether to automatically load libsystem_c.dylib. This image contains frequently used noreturn symbols, and not loading it will result in frequently incorrect control flows."
+ })");
+
settings->RegisterSetting("loader.dsc.processObjC",
R"({
"title" : "Process Objective-C Metadata",
diff --git a/view/sharedcache/core/SharedCache.cpp b/view/sharedcache/core/SharedCache.cpp
index 40ccea6c..bc3b9321 100644
--- a/view/sharedcache/core/SharedCache.cpp
+++ b/view/sharedcache/core/SharedCache.cpp
@@ -1392,18 +1392,26 @@ SharedCache::SharedCache(BinaryNinja::Ref<BinaryNinja::BinaryView> dscView) : m_
m_logger->LogError("Failed to perform initial load of Shared Cache");
}
- for (const auto& [_, header] : m_headers)
+ auto settings = m_dscView->GetLoadSettings(VIEW_NAME);
+ bool autoLoadLibsystem = true;
+ if (settings && settings->Contains("loader.dsc.autoLoadLibSystem"))
{
- if (header.installName.find("libsystem_c.dylib") != std::string::npos)
+ autoLoadLibsystem = settings->Get<bool>("loader.dsc.autoLoadLibSystem", m_dscView);
+ }
+ if (autoLoadLibsystem)
+ {
+ for (const auto& [_, header] : m_headers)
{
- lock.unlock();
- m_logger->LogInfo("Loading core libsystem_c.dylib library");
- LoadImageWithInstallName(header.installName);
- lock.lock();
- break ;
+ if (header.installName.find("libsystem_c.dylib") != std::string::npos)
+ {
+ lock.unlock();
+ m_logger->LogInfo("Loading core libsystem_c.dylib library");
+ LoadImageWithInstallName(header.installName);
+ lock.lock();
+ break;
+ }
}
}
-
m_viewState = DSCViewStateLoaded;
SaveToDSCView();
}