summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2025-06-30 13:42:58 -0400
committerGlenn Smith <glenn@vector35.com>2025-07-01 23:23:17 -0400
commit7323550247538688397481951258523679955041 (patch)
treeabd0b04400e91d7ac9c4d2cbaa85853da2f36884
parentbf02a342b3122e46a91d0c5da57449c3d4a01999 (diff)
Make constructing an MLILFunction require an LLILFunction
-rw-r--r--binaryninjaapi.h2
-rw-r--r--binaryninjacore.h6
-rw-r--r--mediumlevelil.cpp4
-rw-r--r--python/mediumlevelil.py15
4 files changed, 17 insertions, 10 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 6fcc1d97..5b435cf8 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -13646,7 +13646,7 @@ namespace BinaryNinja {
BNFreeMediumLevelILFunction>
{
public:
- MediumLevelILFunction(Architecture* arch, Function* func = nullptr);
+ MediumLevelILFunction(Architecture* arch, Function* func, LowLevelILFunction* lowLevelIL);
MediumLevelILFunction(BNMediumLevelILFunction* func);
Ref<Function> GetFunction() const;
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 9e72f01b..fda0eb7d 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -37,14 +37,14 @@
// Current ABI version for linking to the core. This is incremented any time
// there are changes to the API that affect linking, including new functions,
// new types, or modifications to existing functions or types.
-#define BN_CURRENT_CORE_ABI_VERSION 114
+#define BN_CURRENT_CORE_ABI_VERSION 115
// Minimum ABI version that is supported for loading of plugins. Plugins that
// are linked to an ABI version less than this will not be able to load and
// will require rebuilding. The minimum version is increased when there are
// incompatible changes that break binary compatibility, such as changes to
// existing types or functions.
-#define BN_MINIMUM_CORE_ABI_VERSION 113
+#define BN_MINIMUM_CORE_ABI_VERSION 115
#ifdef __GNUC__
#ifdef BINARYNINJACORE_LIBRARY
@@ -6068,7 +6068,7 @@ extern "C"
BINARYNINJACOREAPI size_t BNGetMappedMediumLevelILExprIndex(BNLowLevelILFunction* func, size_t expr);
// Medium-level IL
- BINARYNINJACOREAPI BNMediumLevelILFunction* BNCreateMediumLevelILFunction(BNArchitecture* arch, BNFunction* func);
+ BINARYNINJACOREAPI BNMediumLevelILFunction* BNCreateMediumLevelILFunction(BNArchitecture* arch, BNFunction* func, BNLowLevelILFunction* lowLevelIL);
BINARYNINJACOREAPI BNMediumLevelILFunction* BNNewMediumLevelILFunctionReference(BNMediumLevelILFunction* func);
BINARYNINJACOREAPI void BNFreeMediumLevelILFunction(BNMediumLevelILFunction* func);
BINARYNINJACOREAPI BNFunction* BNGetMediumLevelILOwnerFunction(BNMediumLevelILFunction* func);
diff --git a/mediumlevelil.cpp b/mediumlevelil.cpp
index 0a285628..2eb2f9bd 100644
--- a/mediumlevelil.cpp
+++ b/mediumlevelil.cpp
@@ -31,9 +31,9 @@ MediumLevelILLabel::MediumLevelILLabel()
}
-MediumLevelILFunction::MediumLevelILFunction(Architecture* arch, Function* func)
+MediumLevelILFunction::MediumLevelILFunction(Architecture* arch, Function* func, LowLevelILFunction* lowLevelIL)
{
- m_object = BNCreateMediumLevelILFunction(arch->GetObject(), func ? func->GetObject() : nullptr);
+ m_object = BNCreateMediumLevelILFunction(arch->GetObject(), func->GetObject(), lowLevelIL->GetObject());
}
diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py
index 577a48ef..1fa580c3 100644
--- a/python/mediumlevelil.py
+++ b/python/mediumlevelil.py
@@ -3251,8 +3251,11 @@ class MediumLevelILFunction:
methods which return ExpressionIndex objects.
"""
def __init__(
- self, arch: Optional['architecture.Architecture'] = None, handle: Optional[core.BNMediumLevelILFunction] = None,
- source_func: Optional['function.Function'] = None
+ self,
+ arch: Optional['architecture.Architecture'] = None,
+ handle: Optional[core.BNMediumLevelILFunction] = None,
+ source_func: Optional['function.Function'] = None,
+ low_level_il: Optional['lowlevelil.LowLevelILFunction'] = None
):
_arch = arch
_source_function = source_func
@@ -3264,12 +3267,16 @@ class MediumLevelILFunction:
if _arch is None:
_arch = _source_function.arch
else:
+ 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")
if _arch is None:
- _arch = _source_function.arch
+ _arch = low_level_il.arch
func_handle = _source_function.handle
- _handle = core.BNCreateMediumLevelILFunction(_arch.handle, func_handle)
+ llil_handle = low_level_il.handle
+ _handle = core.BNCreateMediumLevelILFunction(_arch.handle, func_handle, llil_handle)
assert _source_function is not None
assert _arch is not None
assert _handle is not None