Skip to content

Commit 7323550

Browse files
committed
Make constructing an MLILFunction require an LLILFunction
1 parent bf02a34 commit 7323550

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

binaryninjaapi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13646,7 +13646,7 @@ namespace BinaryNinja {
1364613646
BNFreeMediumLevelILFunction>
1364713647
{
1364813648
public:
13649-
MediumLevelILFunction(Architecture* arch, Function* func = nullptr);
13649+
MediumLevelILFunction(Architecture* arch, Function* func, LowLevelILFunction* lowLevelIL);
1365013650
MediumLevelILFunction(BNMediumLevelILFunction* func);
1365113651

1365213652
Ref<Function> GetFunction() const;

binaryninjacore.h

Lines changed: 3 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 114
40+
#define BN_CURRENT_CORE_ABI_VERSION 115
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 113
47+
#define BN_MINIMUM_CORE_ABI_VERSION 115
4848

4949
#ifdef __GNUC__
5050
#ifdef BINARYNINJACORE_LIBRARY
@@ -6068,7 +6068,7 @@ extern "C"
60686068
BINARYNINJACOREAPI size_t BNGetMappedMediumLevelILExprIndex(BNLowLevelILFunction* func, size_t expr);
60696069

60706070
// Medium-level IL
6071-
BINARYNINJACOREAPI BNMediumLevelILFunction* BNCreateMediumLevelILFunction(BNArchitecture* arch, BNFunction* func);
6071+
BINARYNINJACOREAPI BNMediumLevelILFunction* BNCreateMediumLevelILFunction(BNArchitecture* arch, BNFunction* func, BNLowLevelILFunction* lowLevelIL);
60726072
BINARYNINJACOREAPI BNMediumLevelILFunction* BNNewMediumLevelILFunctionReference(BNMediumLevelILFunction* func);
60736073
BINARYNINJACOREAPI void BNFreeMediumLevelILFunction(BNMediumLevelILFunction* func);
60746074
BINARYNINJACOREAPI BNFunction* BNGetMediumLevelILOwnerFunction(BNMediumLevelILFunction* func);

mediumlevelil.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ MediumLevelILLabel::MediumLevelILLabel()
3131
}
3232

3333

34-
MediumLevelILFunction::MediumLevelILFunction(Architecture* arch, Function* func)
34+
MediumLevelILFunction::MediumLevelILFunction(Architecture* arch, Function* func, LowLevelILFunction* lowLevelIL)
3535
{
36-
m_object = BNCreateMediumLevelILFunction(arch->GetObject(), func ? func->GetObject() : nullptr);
36+
m_object = BNCreateMediumLevelILFunction(arch->GetObject(), func->GetObject(), lowLevelIL->GetObject());
3737
}
3838

3939

python/mediumlevelil.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3251,8 +3251,11 @@ class MediumLevelILFunction:
32513251
methods which return ExpressionIndex objects.
32523252
"""
32533253
def __init__(
3254-
self, arch: Optional['architecture.Architecture'] = None, handle: Optional[core.BNMediumLevelILFunction] = None,
3255-
source_func: Optional['function.Function'] = None
3254+
self,
3255+
arch: Optional['architecture.Architecture'] = None,
3256+
handle: Optional[core.BNMediumLevelILFunction] = None,
3257+
source_func: Optional['function.Function'] = None,
3258+
low_level_il: Optional['lowlevelil.LowLevelILFunction'] = None
32563259
):
32573260
_arch = arch
32583261
_source_function = source_func
@@ -3264,12 +3267,16 @@ def __init__(
32643267
if _arch is None:
32653268
_arch = _source_function.arch
32663269
else:
3270+
if low_level_il is None:
3271+
raise ValueError("MLIL functions must be created with an associated LLIL function")
3272+
_source_function = low_level_il.source_function
32673273
if _source_function is None:
32683274
raise ValueError("IL functions must be created with an associated function")
32693275
if _arch is None:
3270-
_arch = _source_function.arch
3276+
_arch = low_level_il.arch
32713277
func_handle = _source_function.handle
3272-
_handle = core.BNCreateMediumLevelILFunction(_arch.handle, func_handle)
3278+
llil_handle = low_level_il.handle
3279+
_handle = core.BNCreateMediumLevelILFunction(_arch.handle, func_handle, llil_handle)
32733280
assert _source_function is not None
32743281
assert _arch is not None
32753282
assert _handle is not None

0 commit comments

Comments
 (0)