Skip to content

Commit 7a52517

Browse files
committed
[WARP] Add IsInstructionComputedVariant API
Was previously not exposed, we want it for unit tests.
1 parent 0fcfd65 commit 7a52517

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

plugins/warp/api/python/_warpcore.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,25 @@ def BNWARPIsLiftedInstructionVariant(
955955
return _BNWARPIsLiftedInstructionVariant(liftedFunction, idx)
956956

957957

958+
# -------------------------------------------------------
959+
# _BNWARPIsLowLevelInstructionComputedVariant
960+
961+
_BNWARPIsLowLevelInstructionComputedVariant = core.BNWARPIsLowLevelInstructionComputedVariant
962+
_BNWARPIsLowLevelInstructionComputedVariant.restype = ctypes.c_bool
963+
_BNWARPIsLowLevelInstructionComputedVariant.argtypes = [
964+
ctypes.POINTER(BNLowLevelILFunction),
965+
ctypes.c_ulonglong,
966+
]
967+
968+
969+
# noinspection PyPep8Naming
970+
def BNWARPIsLowLevelInstructionComputedVariant(
971+
llilFunction: ctypes.POINTER(BNLowLevelILFunction),
972+
idx: int
973+
) -> bool:
974+
return _BNWARPIsLowLevelInstructionComputedVariant(llilFunction, idx)
975+
976+
958977
# -------------------------------------------------------
959978
# _BNWARPNewContainerReference
960979

plugins/warp/api/python/warp.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,12 @@ def is_instruction_variant(function: LowLevelILFunction, variant: LowLevelILInst
365365
def is_instruction_blacklisted(function: LowLevelILFunction, variant: LowLevelILInstruction) -> bool:
366366
return warpcore.BNWARPIsLiftedInstructionBlacklisted(function.handle, variant.instr_index)
367367

368+
def is_instruction_computed_variant(function: LowLevelILFunction, variant: LowLevelILInstruction) -> bool:
369+
"""
370+
Checks to see if the instruction is variant due to some computed value. **Must use LLIL.**
371+
"""
372+
return warpcore.BNWARPIsLowLevelInstructionComputedVariant(function.handle, variant.instr_index)
373+
368374
def get_function_guid(function: Function) -> Optional[FunctionGUID]:
369375
guid = warpcore.BNWARPUUID()
370376
if not warpcore.BNWARPGetAnalysisFunctionGUID(function.handle, guid):

plugins/warp/api/warp.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,11 @@ bool IsInstructionBlacklisted(const BinaryNinja::LowLevelILFunction &function, B
319319
return BNWARPIsLiftedInstructionBlacklisted(function.m_object, idx);
320320
}
321321

322+
bool IsInstructionComputedVariant(const BinaryNinja::LowLevelILFunction &function, BinaryNinja::ExprId idx)
323+
{
324+
return BNWARPIsLowLevelInstructionComputedVariant(function.m_object, idx);
325+
}
326+
322327
std::optional<FunctionGUID> Warp::GetAnalysisFunctionGUID(const BinaryNinja::Function &function)
323328
{
324329
FunctionGUID guid;

plugins/warp/api/warpcore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ extern "C"
8787
WARP_FFI_API bool BNWARPGetAnalysisFunctionGUID(BNFunction* analysisFunction, BNWARPFunctionGUID* result);
8888
WARP_FFI_API bool BNWARPIsLiftedInstructionVariant(BNLowLevelILFunction* liftedFunction, size_t idx);
8989
WARP_FFI_API bool BNWARPIsLiftedInstructionBlacklisted(BNLowLevelILFunction* liftedFunction, size_t idx);
90+
WARP_FFI_API bool BNWARPIsLowLevelInstructionComputedVariant(BNLowLevelILFunction* llilFunction, size_t idx);
9091

9192
WARP_FFI_API BNWARPFunction* BNWARPGetFunction(BNFunction* analysisFunction);
9293
WARP_FFI_API BNWARPFunction* BNWARPGetMatchedFunction(BNFunction* analysisFunction);

0 commit comments

Comments
 (0)