From 33500b94ad2020a0e4ca5ba4ea990763f7de1fd9 Mon Sep 17 00:00:00 2001 From: tinysec Date: Thu, 23 Jul 2026 10:57:40 +0800 Subject: [PATCH] Add IL operand list navigation --- Handle/BNMediumLevelILFunction.cs | 13 +---------- HighLevelIL/HighLevelILOperandLists.cs | 26 ++++++++++++++++++++++ LowLevelIL/LowLevelILOperandLists.cs | 26 ++++++++++++++++++++++ MediumLevelIL/MediumLevelILOperandLists.cs | 26 ++++++++++++++++++++++ 4 files changed, 79 insertions(+), 12 deletions(-) create mode 100644 HighLevelIL/HighLevelILOperandLists.cs create mode 100644 LowLevelIL/LowLevelILOperandLists.cs create mode 100644 MediumLevelIL/MediumLevelILOperandLists.cs diff --git a/Handle/BNMediumLevelILFunction.cs b/Handle/BNMediumLevelILFunction.cs index b8b1f85..b25ad84 100644 --- a/Handle/BNMediumLevelILFunction.cs +++ b/Handle/BNMediumLevelILFunction.cs @@ -1580,18 +1580,7 @@ public ulong[] GetExpressionOperands( ulong operand ) { - IntPtr arrayPointer = NativeMethods.BNMediumLevelILGetOperandList( - this.handle , - expression , - operand , - out ulong arrayLength - ); - - return UnsafeUtils.TakeNumberArray( - arrayPointer , - arrayLength , - NativeMethods.BNMediumLevelILFreeOperandList - ); + return this.GetOperandList(expression, operand); } public MediumLevelILVariable[] GetExpressionVariables( diff --git a/HighLevelIL/HighLevelILOperandLists.cs b/HighLevelIL/HighLevelILOperandLists.cs new file mode 100644 index 0000000..6ab65a2 --- /dev/null +++ b/HighLevelIL/HighLevelILOperandLists.cs @@ -0,0 +1,26 @@ +using System; + +namespace BinaryNinja +{ + public sealed partial class HighLevelILFunction + { + /// + /// Gets the variable-length operand list stored at an expression operand. + /// + public ulong[] GetOperandList( + HighLevelILExpressionIndex expression, + ulong listOperand) + { + IntPtr arrayPointer = NativeMethods.BNHighLevelILGetOperandList( + this.handle, + expression, + listOperand, + out ulong arrayLength); + + return UnsafeUtils.TakeNumberArray( + arrayPointer, + arrayLength, + NativeMethods.BNHighLevelILFreeOperandList); + } + } +} diff --git a/LowLevelIL/LowLevelILOperandLists.cs b/LowLevelIL/LowLevelILOperandLists.cs new file mode 100644 index 0000000..4b05448 --- /dev/null +++ b/LowLevelIL/LowLevelILOperandLists.cs @@ -0,0 +1,26 @@ +using System; + +namespace BinaryNinja +{ + public sealed partial class LowLevelILFunction + { + /// + /// Gets the variable-length operand list stored at an expression operand. + /// + public ulong[] GetOperandList( + LowLevelILExpressionIndex expression, + ulong listOperand) + { + IntPtr arrayPointer = NativeMethods.BNLowLevelILGetOperandList( + this.handle, + expression, + listOperand, + out ulong arrayLength); + + return UnsafeUtils.TakeNumberArray( + arrayPointer, + arrayLength, + NativeMethods.BNLowLevelILFreeOperandList); + } + } +} diff --git a/MediumLevelIL/MediumLevelILOperandLists.cs b/MediumLevelIL/MediumLevelILOperandLists.cs new file mode 100644 index 0000000..f0a3e47 --- /dev/null +++ b/MediumLevelIL/MediumLevelILOperandLists.cs @@ -0,0 +1,26 @@ +using System; + +namespace BinaryNinja +{ + public sealed partial class MediumLevelILFunction + { + /// + /// Gets the variable-length operand list stored at an expression operand. + /// + public ulong[] GetOperandList( + MediumLevelILExpressionIndex expression, + ulong listOperand) + { + IntPtr arrayPointer = NativeMethods.BNMediumLevelILGetOperandList( + this.handle, + expression, + listOperand, + out ulong arrayLength); + + return UnsafeUtils.TakeNumberArray( + arrayPointer, + arrayLength, + NativeMethods.BNMediumLevelILFreeOperandList); + } + } +}