summaryrefslogtreecommitdiff
path: root/python/highlevelil.py
diff options
context:
space:
mode:
authorRusty Wagner <rusty.wagner@gmail.com>2025-12-23 13:12:02 -0700
committerRusty Wagner <rusty.wagner@gmail.com>2026-05-22 16:30:56 -0400
commit8d621c51b2797fda7b1dc22243dde611cfc04f68 (patch)
treeba5e6a90e644d21d13e75dabcbd0cc747444443a /python/highlevelil.py
parent08e34ac325743085911f96b62c81d9a1f2127806 (diff)
Refactor calling conventions to support correct representation of structures
Diffstat (limited to 'python/highlevelil.py')
-rw-r--r--python/highlevelil.py42
1 files changed, 41 insertions, 1 deletions
diff --git a/python/highlevelil.py b/python/highlevelil.py
index bb1f6129..4c81f687 100644
--- a/python/highlevelil.py
+++ b/python/highlevelil.py
@@ -210,7 +210,11 @@ class HighLevelILInstruction(BaseILInstruction):
], HighLevelILOperation.HLIL_DEREF_FIELD_SSA: [
("src", "expr"), ("src_memory", "int"), ("offset", "int"),
("member_index", "member_index")
- ], HighLevelILOperation.HLIL_ADDRESS_OF: [("src", "expr")], HighLevelILOperation.HLIL_CONST: [
+ ], HighLevelILOperation.HLIL_ADDRESS_OF: [("src", "expr")], HighLevelILOperation.HLIL_PASS_BY_REF: [
+ ("src", "expr")
+ ], HighLevelILOperation.HLIL_RETURN_BY_REF: [
+ ("src", "expr")
+ ], HighLevelILOperation.HLIL_CONST: [
("constant", "int")
], HighLevelILOperation.HLIL_CONST_PTR: [("constant", "int")], HighLevelILOperation.HLIL_EXTERN_PTR: [
("constant", "int"), ("offset", "int")
@@ -1744,6 +1748,16 @@ class HighLevelILAddressOf(HighLevelILUnaryBase):
@dataclass(frozen=True, repr=False, eq=False)
+class HighLevelILPassByRef(HighLevelILUnaryBase):
+ pass
+
+
+@dataclass(frozen=True, repr=False, eq=False)
+class HighLevelILReturnByRef(HighLevelILUnaryBase):
+ pass
+
+
+@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILConst(HighLevelILInstruction, Constant):
@property
def constant(self) -> int:
@@ -2429,6 +2443,8 @@ ILInstruction = {
HighLevelILOperation.HLIL_DEREF_FIELD_SSA:
HighLevelILDerefFieldSsa, # ("src", "expr"), ("src_memory", "int"), ("offset", "int"), ("member_index", "member_index"),
HighLevelILOperation.HLIL_ADDRESS_OF: HighLevelILAddressOf, # ("src", "expr"),
+ HighLevelILOperation.HLIL_PASS_BY_REF: HighLevelILPassByRef, # ("src", "expr"),
+ HighLevelILOperation.HLIL_RETURN_BY_REF: HighLevelILReturnByRef, # ("src", "expr"),
HighLevelILOperation.HLIL_CONST: HighLevelILConst, # ("constant", "int"),
HighLevelILOperation.HLIL_CONST_PTR: HighLevelILConstPtr, # ("constant", "int"),
HighLevelILOperation.HLIL_EXTERN_PTR: HighLevelILExternPtr, # ("constant", "int"), ("offset", "int"),
@@ -3380,6 +3396,30 @@ class HighLevelILFunction:
"""
return self.expr(HighLevelILOperation.HLIL_ADDRESS_OF, src, size=0, source_location=loc)
+ def pass_by_ref(self, size: int, src: ExpressionIndex, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex:
+ """
+ ``pass_by_ref`` indicates that ``value`` is being passed by reference to a call with a pointer size of ``size``
+
+ :param int size: the size of the pointer in bytes
+ :param ExpressionIndex src: the expression containing the reference being passed
+ :param ILSourceLocation loc: location of returned expression
+ :return: The expression ``ref *src``
+ :rtype: ExpressionIndex
+ """
+ return self.expr(HighLevelILOperation.HLIL_PASS_BY_REF, src, size, source_location=loc)
+
+ def return_by_ref(self, size: int, dest: ExpressionIndex, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex:
+ """
+ ``return_by_ref`` indicates that ``dest`` is being returned by passing a reference to a call
+
+ :param int size: the size of the value in bytes
+ :param ExpressionIndex dest: the expression containing the target of the return value
+ :param ILSourceLocation loc: location of returned expression
+ :return: The expression ``ref dest``
+ :rtype: ExpressionIndex
+ """
+ return self.expr(HighLevelILOperation.HLIL_RETURN_BY_REF, dest, size, source_location=loc)
+
def const(self, size: int, value: int, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex:
"""
``const`` returns an expression for the constant integer ``value`` of size ``size``