Skip to content

Commit 8ef4a64

Browse files
committed
Fix Objective-C dynamic dispatch setting.
1 parent da9df16 commit 8ef4a64

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

plugins/workflow_objc/Plugin.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ BINARYNINJAPLUGIN bool CorePluginInit()
3131
BinaryNinja::LogRegistry::CreateLogger(PluginLoggerName);
3232

3333
auto settings = BinaryNinja::Settings::Instance();
34-
settings->RegisterSetting("core.function.objectiveC.rewriteMessageSendTarget",
34+
settings->RegisterSetting("analysis.objectiveC.resolveDynamicDispatch",
3535
R"({
36-
"title" : "Rewrite objc_msgSend calls in IL",
37-
"type" : "boolean",
38-
"default" : false,
39-
"description" : "Message sends of selectors with any visible implementation are replaced with a direct call to the first visible implementation. Note that this can produce false positives if the selector is implemented by more than one class, or shares a name with a method from a system framework."
40-
})");
36+
"title" : "Resolve Dynamic Dispatch Calls",
37+
"type" : "boolean",
38+
"default" : false,
39+
"aliases": ["core.function.objectiveC.assumeMessageSendTarget", "core.function.objectiveC.rewriteMessageSendTarget"],
40+
"description" : "Replaces objc_msgSend calls with direct calls to the first found implementation when the target method is visible. May produce false positives when multiple classes implement the same selector or when selectors conflict with system framework methods."
41+
})");
4142

4243
return true;
4344
}

plugins/workflow_objc/Workflow.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ std::vector<std::string> generateArgumentNames(const std::vector<std::string>& c
8282

8383
bool Workflow::rewriteMethodCall(LLILFunctionRef ssa, size_t insnIndex)
8484
{
85-
const auto bv = ssa->GetFunction()->GetView();
85+
auto function = ssa->GetFunction();
86+
const auto bv = function->GetView();
8687
const auto llil = ssa->GetNonSSAForm();
8788
const auto insn = ssa->GetInstruction(insnIndex);
8889
const auto params = insn.GetParameterExprs<LLIL_CALL_SSA>();
@@ -143,10 +144,10 @@ bool Workflow::rewriteMethodCall(LLILFunctionRef ssa, size_t insnIndex)
143144
}
144145

145146
auto funcType = BinaryNinja::Type::FunctionType(retType, cc, callTypeParams);
146-
ssa->GetFunction()->SetAutoCallTypeAdjustment(ssa->GetFunction()->GetArchitecture(), insn.address, {funcType, BN_DEFAULT_CONFIDENCE});
147+
function->SetAutoCallTypeAdjustment(function->GetArchitecture(), insn.address, {funcType, BN_DEFAULT_CONFIDENCE});
147148
// --
148149

149-
if (!BinaryNinja::Settings::Instance()->Get<bool>("core.function.objectiveC.rewriteMessageSendTarget", bv))
150+
if (!BinaryNinja::Settings::Instance()->Get<bool>("analysis.objectiveC.resolveDynamicDispatch", function))
150151
return false;
151152

152153
// Check the analysis info for a selector reference corresponding to the

0 commit comments

Comments
 (0)