Skip to content

Commit 5e24411

Browse files
committed
Rename Workflow::Instance to Workflow::GetOrCreate, add Workflow::Get
Calls to `Workflow::Instance` that were looking up a built-in workflow name are updated to use `Workflow::Get`. Others are left using `Workflow::GetOrCreate`.
1 parent 72020bd commit 5e24411

File tree

12 files changed

+39
-18
lines changed

12 files changed

+39
-18
lines changed

binaryninjaapi.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11306,13 +11306,23 @@ namespace BinaryNinja {
1130611306
*/
1130711307
static std::vector<Ref<Workflow>> GetList();
1130811308

11309-
/*! Get an instance of a workflow by name. If it is already registered, this will return the registered Workflow.
11310-
If not, it will create and return a new Workflow.
11309+
/*! Get an instance of an existing registered workflow by name.
11310+
If no registered workflow exists, nullptr will be returned.
1131111311

1131211312
\param name Workflow name
1131311313
\return The registered workflow.
1131411314
*/
11315-
static Ref<Workflow> Instance(const std::string& name = "");
11315+
static Ref<Workflow> Get(const std::string& name);
11316+
11317+
/*! Get an instance of a workflow by name. If it is already registered,
11318+
this will return the registered Workflow. If not, a new Workflow will
11319+
be created and returned.
11320+
11321+
\param name Workflow name
11322+
\return The workflow.
11323+
*/
11324+
static Ref<Workflow> GetOrCreate(const std::string& name);
11325+
1131611326
/*! Register a workflow, making it immutable and available for use
1131711327

1131811328
\param workflow The workflow to register

binaryninjacore.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@
3737
// Current ABI version for linking to the core. This is incremented any time
3838
// there are changes to the API that affect linking, including new functions,
3939
// new types, or modifications to existing functions or types.
40-
#define BN_CURRENT_CORE_ABI_VERSION 128
40+
#define BN_CURRENT_CORE_ABI_VERSION 129
4141

4242
// Minimum ABI version that is supported for loading of plugins. Plugins that
4343
// are linked to an ABI version less than this will not be able to load and
4444
// will require rebuilding. The minimum version is increased when there are
4545
// incompatible changes that break binary compatibility, such as changes to
4646
// existing types or functions.
47-
#define BN_MINIMUM_CORE_ABI_VERSION 128
47+
#define BN_MINIMUM_CORE_ABI_VERSION 129
4848

4949
#ifdef __GNUC__
5050
#ifdef BINARYNINJACORE_LIBRARY
@@ -5756,7 +5756,8 @@ extern "C"
57565756

57575757
BINARYNINJACOREAPI BNWorkflow** BNGetWorkflowList(size_t* count);
57585758
BINARYNINJACOREAPI void BNFreeWorkflowList(BNWorkflow** workflows, size_t count);
5759-
BINARYNINJACOREAPI BNWorkflow* BNWorkflowInstance(const char* name);
5759+
BINARYNINJACOREAPI BNWorkflow* BNWorkflowGet(const char* name);
5760+
BINARYNINJACOREAPI BNWorkflow* BNWorkflowGetOrCreate(const char* name);
57605761
BINARYNINJACOREAPI bool BNRegisterWorkflow(BNWorkflow* workflow, const char* configuration);
57615762

57625763
BINARYNINJACOREAPI BNWorkflow* BNWorkflowClone(BNWorkflow* workflow, const char* name, const char* activity);

examples/workflows/inliner/inliner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ extern "C"
158158
},
159159
inlinerIsValid);
160160

161-
Ref<Workflow> inlinerWorkflow = Workflow::Instance("core.function.baseAnalysis")->Clone("InlinerWorkflow");
161+
Ref<Workflow> inlinerWorkflow = Workflow::Get("core.function.baseAnalysis")->Clone("InlinerWorkflow");
162162
inlinerWorkflow->RegisterActivity(new Activity("extension.functionInliner", &FunctionInliner));
163163
inlinerWorkflow->Insert("core.function.translateTailCalls", "extension.functionInliner");
164164
Workflow::RegisterWorkflow(inlinerWorkflow,

examples/workflows/tailcall/tailcall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ extern "C"
117117

118118
BINARYNINJAPLUGIN bool CorePluginInit()
119119
{
120-
Ref<Workflow> customTailCallWorkflow = Workflow::Instance("core.function.baseAnalysis")->Clone("CustomTailCallWorkflow");
120+
Ref<Workflow> customTailCallWorkflow = Workflow::Get("core.function.baseAnalysis")->Clone("CustomTailCallWorkflow");
121121
customTailCallWorkflow->RegisterActivity(new Activity("extension.translateTailCalls", &TailCallTranslation));
122122
customTailCallWorkflow->Replace("core.function.translateTailCalls", "extension.translateTailCalls");
123123
customTailCallWorkflow->Remove("core.function.translateTailCalls");

examples/workflows/unflatten/library.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ extern "C"
411411

412412
BINARYNINJAPLUGIN bool CorePluginInit()
413413
{
414-
auto wf = Workflow::Instance("core.function.metaAnalysis")->Clone("core.function.metaAnalysis");
414+
auto wf = Workflow::Get("core.function.metaAnalysis")->Clone("core.function.metaAnalysis");
415415
wf->RegisterActivity(new Activity(R"~(
416416
{
417417
"name": "extension.unflatten_limoncello_cpp.unflatten.dry_run",

plugins/efi_resolver/src/Plugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ extern "C"
6161
BINARYNINJAPLUGIN bool CorePluginInit()
6262
{
6363
EfiGuidRenderer::Register();
64-
auto workflow = Workflow::Instance("core.module.metaAnalysis")->Clone();
64+
auto workflow = Workflow::Get("core.module.metaAnalysis")->Clone();
6565
workflow->RegisterActivity(R"~({
6666
"title": "EFI Resolver",
6767
"name": "analysis.efi.efiResolver",

plugins/rtti/plugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ extern "C" {
9191
// TODO: 2. Identify if the function is unique to a class, renaming and retyping if true
9292
// TODO: 3. Identify functions which address a VFT and are probably a constructor (alloc use), retyping if true
9393
// TODO: 4. Identify functions which address a VFT and are probably a deconstructor (free use), retyping if true
94-
Ref<Workflow> rttiMetaWorkflow = Workflow::Instance("core.module.metaAnalysis")->Clone();
94+
Ref<Workflow> rttiMetaWorkflow = Workflow::Get("core.module.metaAnalysis")->Clone();
9595

9696
// Add RTTI analysis.
9797
rttiMetaWorkflow->RegisterActivity(R"~({

plugins/workflow_objc/Workflow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ static constexpr auto WorkflowInfo = R"({
307307

308308
void Workflow::registerActivities()
309309
{
310-
const auto wf = BinaryNinja::Workflow::Instance("core.function.baseAnalysis")->Clone("core.function.objectiveC");
310+
const auto wf = BinaryNinja::Workflow::Get("core.function.baseAnalysis")->Clone("core.function.objectiveC");
311311
wf->RegisterActivity(new BinaryNinja::Activity(
312312
ActivityID::ResolveMethodCalls, &Workflow::inlineMethodCalls));
313313
wf->InsertAfter("core.function.translateTailCalls", ActivityID::ResolveMethodCalls);

python/workflow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def __iter__(self):
288288

289289
def __getitem__(self, value):
290290
binaryninja._init_plugins()
291-
workflow = core.BNWorkflowInstance(str(value))
291+
workflow = core.BNWorkflowGet(str(value))
292292
return Workflow(handle=workflow)
293293

294294

@@ -344,7 +344,7 @@ class Workflow(metaclass=_WorkflowMetaclass):
344344
def __init__(self, name: str = "", handle: core.BNWorkflowHandle = None, query_registry: bool = True, object_handle: Union[core.BNFunctionHandle, core.BNBinaryViewHandle] = None):
345345
if handle is None:
346346
if query_registry:
347-
_handle = core.BNWorkflowInstance(str(name))
347+
_handle = core.BNWorkflowGet(str(name))
348348
else:
349349
_handle = core.BNCreateWorkflow(name)
350350
else:

rust/src/workflow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl Workflow {
275275

276276
pub fn instance(name: &str) -> Ref<Workflow> {
277277
let name = name.to_cstr();
278-
let result = unsafe { BNWorkflowInstance(name.as_ptr()) };
278+
let result = unsafe { BNWorkflowGetOrCreate(name.as_ptr()) };
279279
unsafe { Workflow::ref_from_raw(NonNull::new(result).unwrap()) }
280280
}
281281

0 commit comments

Comments
 (0)