summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2025-05-06 16:47:15 -0400
committerGlenn Smith <glenn@vector35.com>2025-06-11 17:37:26 -0400
commit6091002460609793463078951047220893747923 (patch)
tree4378eb62ee87b27365b44813413b2c2d839e445b
parent3a1a81c3ddd8340432ecd2687d3a25195cc97d40 (diff)
Expose AnalysisContext::GetLiftedILFunction properly
It was already grabbing the Lifted IL through the function object, which may not be the most up to date
-rw-r--r--binaryninjaapi.h6
-rw-r--r--binaryninjacore.h1
-rw-r--r--python/workflow.py17
-rw-r--r--rust/src/workflow.rs3
-rw-r--r--workflow.cpp9
5 files changed, 27 insertions, 9 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 275ec979..d0c8a660 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -10033,6 +10033,12 @@ namespace BinaryNinja {
*/
Ref<Function> GetFunction();
+ /*! Get the lifted IL function for the current AnalysisContext
+
+ \return The Lifted IL LowLevelILFunction for the current context
+ */
+ Ref<LowLevelILFunction> GetLiftedILFunction();
+
/*! Get the low level IL function for the current AnalysisContext
\return The LowLevelILFunction for the current context
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 1210fcca..88e30c38 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -5541,6 +5541,7 @@ extern "C"
BINARYNINJACOREAPI void BNFreeAnalysisContext(BNAnalysisContext* analysisContext);
BINARYNINJACOREAPI BNBinaryView* BNAnalysisContextGetBinaryView(BNAnalysisContext* analysisContext);
BINARYNINJACOREAPI BNFunction* BNAnalysisContextGetFunction(BNAnalysisContext* analysisContext);
+ BINARYNINJACOREAPI BNLowLevelILFunction* BNAnalysisContextGetLiftedILFunction(BNAnalysisContext* analysisContext);
BINARYNINJACOREAPI BNLowLevelILFunction* BNAnalysisContextGetLowLevelILFunction(BNAnalysisContext* analysisContext);
BINARYNINJACOREAPI BNMediumLevelILFunction* BNAnalysisContextGetMediumLevelILFunction(
BNAnalysisContext* analysisContext);
diff --git a/python/workflow.py b/python/workflow.py
index ba20591f..c63c20b9 100644
--- a/python/workflow.py
+++ b/python/workflow.py
@@ -53,7 +53,7 @@ class AnalysisContext:
self.handle = handle
@property
- def view(self) -> 'binaryview.BinaryView':
+ def view(self) -> Optional['binaryview.BinaryView']:
"""
BinaryView for the current AnalysisContext (writable)
"""
@@ -63,7 +63,7 @@ class AnalysisContext:
return binaryview.BinaryView(handle=result)
@property
- def function(self) -> '_function.Function':
+ def function(self) -> Optional['_function.Function']:
"""
Function for the current AnalysisContext (read-only)
"""
@@ -73,18 +73,21 @@ class AnalysisContext:
return _function.Function(handle=result)
@property
- def lifted_il(self) -> lowlevelil.LowLevelILFunction:
+ def lifted_il(self) -> Optional[lowlevelil.LowLevelILFunction]:
"""
LowLevelILFunction used to represent lifted IL (writable)
"""
- return self.function.lifted_il
+ result = core.BNAnalysisContextGetLiftedILFunction(self.handle)
+ if not result:
+ return None
+ return lowlevelil.LowLevelILFunction(handle=result)
@lifted_il.setter
def lifted_il(self, lifted_il: lowlevelil.LowLevelILFunction) -> None:
core.BNSetLiftedILFunction(self.handle, lifted_il.handle)
@property
- def llil(self) -> lowlevelil.LowLevelILFunction:
+ def llil(self) -> Optional[lowlevelil.LowLevelILFunction]:
"""
LowLevelILFunction used to represent Low Level IL (writable)
"""
@@ -98,7 +101,7 @@ class AnalysisContext:
core.BNSetLowLevelILFunction(self.handle, value.handle)
@property
- def mlil(self) -> mediumlevelil.MediumLevelILFunction:
+ def mlil(self) -> Optional[mediumlevelil.MediumLevelILFunction]:
"""
MediumLevelILFunction used to represent Medium Level IL (writable)
"""
@@ -112,7 +115,7 @@ class AnalysisContext:
core.BNSetMediumLevelILFunction(self.handle, value.handle)
@property
- def hlil(self) -> highlevelil.HighLevelILFunction:
+ def hlil(self) -> Optional[highlevelil.HighLevelILFunction]:
"""
HighLevelILFunction used to represent High Level IL (writable)
"""
diff --git a/rust/src/workflow.rs b/rust/src/workflow.rs
index 3dcb1042..ea69d941 100644
--- a/rust/src/workflow.rs
+++ b/rust/src/workflow.rs
@@ -46,8 +46,7 @@ impl AnalysisContext {
/// [`LowLevelILMutableFunction`] used to represent Lifted Level IL
pub unsafe fn lifted_il_function(&self) -> Option<Ref<LowLevelILMutableFunction>> {
- let func = self.function();
- let result = unsafe { BNGetFunctionLiftedIL(func.handle) };
+ let result = unsafe { BNAnalysisContextGetLiftedILFunction(self.handle.as_ptr()) };
unsafe {
Some(LowLevelILMutableFunction::ref_from_raw(
NonNull::new(result)?.as_ptr(),
diff --git a/workflow.cpp b/workflow.cpp
index b2648d3a..13c69136 100644
--- a/workflow.cpp
+++ b/workflow.cpp
@@ -38,6 +38,15 @@ Ref<Function> AnalysisContext::GetFunction()
}
+Ref<LowLevelILFunction> AnalysisContext::GetLiftedILFunction()
+{
+ BNLowLevelILFunction* func = BNAnalysisContextGetLiftedILFunction(m_object);
+ if (!func)
+ return nullptr;
+ return new LowLevelILFunction(func);
+}
+
+
Ref<LowLevelILFunction> AnalysisContext::GetLowLevelILFunction()
{
BNLowLevelILFunction* func = BNAnalysisContextGetLowLevelILFunction(m_object);