summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2025-07-12 21:45:43 -0400
committerGlenn Smith <glenn@vector35.com>2025-07-12 22:07:24 -0400
commit6592214139290634550860697116801883131153 (patch)
tree0ada0a799ffed83a7253cfdaf0c40f6c8b013d6a
parent8143954882881079807041861702046354507957 (diff)
Allow constructing MLILFunction with null LLILFunction/Function
-rw-r--r--binaryninjaapi.h2
-rw-r--r--mediumlevelil.cpp2
-rw-r--r--python/mediumlevelil.py13
3 files changed, 10 insertions, 7 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 27564dc1..c15cf24d 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -13698,7 +13698,7 @@ namespace BinaryNinja {
BNFreeMediumLevelILFunction>
{
public:
- MediumLevelILFunction(Architecture* arch, Function* func, LowLevelILFunction* lowLevelIL);
+ MediumLevelILFunction(Architecture* arch, Function* func = nullptr, LowLevelILFunction* lowLevelIL = nullptr);
MediumLevelILFunction(BNMediumLevelILFunction* func);
Ref<Function> GetFunction() const;
diff --git a/mediumlevelil.cpp b/mediumlevelil.cpp
index 2eb2f9bd..4f6afe27 100644
--- a/mediumlevelil.cpp
+++ b/mediumlevelil.cpp
@@ -33,7 +33,7 @@ MediumLevelILLabel::MediumLevelILLabel()
MediumLevelILFunction::MediumLevelILFunction(Architecture* arch, Function* func, LowLevelILFunction* lowLevelIL)
{
- m_object = BNCreateMediumLevelILFunction(arch->GetObject(), func->GetObject(), lowLevelIL->GetObject());
+ m_object = BNCreateMediumLevelILFunction(arch->GetObject(), func ? func->GetObject() : nullptr, lowLevelIL ? lowLevelIL->GetObject() : nullptr);
}
diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py
index a606ac0f..38256716 100644
--- a/python/mediumlevelil.py
+++ b/python/mediumlevelil.py
@@ -3307,15 +3307,18 @@ class MediumLevelILFunction:
if _arch is None:
_arch = _source_function.arch
else:
+ if low_level_il is None and source_func is None:
+ raise ValueError("IL functions must be created with an associated function or LLIL function")
+
if low_level_il is None:
- raise ValueError("MLIL functions must be created with an associated LLIL function")
- _source_function = low_level_il.source_function
- if _source_function is None:
- raise ValueError("IL functions must be created with an associated function")
+ _source_function = source_func
+ else:
+ _source_function = low_level_il.source_function
+
if _arch is None:
_arch = low_level_il.arch
func_handle = _source_function.handle
- llil_handle = low_level_il.handle
+ llil_handle = low_level_il.handle if low_level_il is not None else None
_handle = core.BNCreateMediumLevelILFunction(_arch.handle, func_handle, llil_handle)
assert _source_function is not None
assert _arch is not None