MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / GetLoadSettingsForData

Method GetLoadSettingsForData

view/macho/machoview.cpp:4005–4084  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4003
4004
4005Ref<Settings> MachoViewType::GetLoadSettingsForData(BinaryView* data)
4006{
4007 Ref<BinaryView> viewRef = Parse(data);
4008 if (!viewRef || !viewRef->Init())
4009 {
4010 m_logger->LogWarn("Failed to initialize view of type '%s'. Generating default load settings.", GetName().c_str());
4011 viewRef = data;
4012 }
4013
4014 Ref<Settings> settings = GetDefaultLoadSettingsForData(viewRef);
4015
4016 // specify default load settings that can be overridden
4017 vector<string> overrides = {"loader.imageBase", "loader.platform"};
4018 if (!viewRef->IsRelocatable())
4019 settings->UpdateProperty("loader.imageBase", "message", "Note: File indicates image is not relocatable.");
4020
4021 for (const auto& override : overrides)
4022 {
4023 if (settings->Contains(override))
4024 settings->UpdateProperty(override, "readOnly", false);
4025 }
4026
4027 if (MachoObjCProcessor::ViewHasObjCMetadata(viewRef))
4028 {
4029 settings->RegisterSetting("loader.macho.processObjectiveC",
4030 R"({
4031 "title" : "Process Objective-C metadata",
4032 "type" : "boolean",
4033 "default" : true,
4034 "description" : "Processes Objective-C structures, applying method names and types from encoded metadata"
4035 })");
4036 Ref<Settings> programSettings = Settings::Instance();
4037 if (programSettings->Contains("corePlugins.workflows.objc"))
4038 {
4039 if (programSettings->Get<bool>("corePlugins.workflows.objc"))
4040 {
4041 programSettings->Set("analysis.workflows.functionWorkflow", "core.function.objectiveC", viewRef);
4042 }
4043 }
4044 }
4045 if (viewRef->GetSectionByName("__cfstring"))
4046 {
4047 settings->RegisterSetting("loader.macho.processCFStrings",
4048 R"({
4049 "title" : "Process CFString Metadata",
4050 "type" : "boolean",
4051 "default" : true,
4052 "description" : "Processes CoreFoundation strings, applying string values from encoded metadata"
4053 })");
4054 }
4055
4056 // register additional settings
4057 settings->RegisterSetting("loader.macho.processFunctionStarts",
4058 R"({
4059 "title" : "Process Mach-O Function Starts Table",
4060 "type" : "boolean",
4061 "default" : true,
4062 "description" : "Add function starts sourced from the Function Starts table to the core for analysis."

Callers 1

MachoViewMethod · 0.45

Calls 14

LogWarnMethod · 0.80
c_strMethod · 0.80
IsRelocatableMethod · 0.80
UpdatePropertyMethod · 0.80
RegisterSettingMethod · 0.80
Get<bool>Method · 0.80
GetSectionByNameMethod · 0.80
GetLoadSettingsMethod · 0.80
DeserializeSchemaMethod · 0.80
SerializeSchemaMethod · 0.80
InitMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected