2828from . import _binaryninjacore as core
2929from .enums import (
3030 InlineDuringAnalysis , StructureVariant , SymbolType , SymbolBinding , TypeClass , NamedTypeReferenceClass ,
31- ReferenceType , VariableSourceType ,
31+ ReferenceType , VariableSourceType , ValueLocationSource ,
3232 TypeReferenceType , MemberAccess , MemberScope , TypeDefinitionLineType ,
3333 TokenEscapingType ,
3434 NameType , PointerSuffix , PointerBaseType ,
@@ -625,16 +625,21 @@ def _to_core_struct(self) -> core.BNReturnValue:
625625class FunctionParameter :
626626 type : SomeType
627627 name : str = ""
628+ location_source : ValueLocationSource = ValueLocationSource .DefaultLocationSource
628629 location : Optional ['ValueLocation' ] = None
629630
630- def __init__ (self , type : SomeType , name : str = "" , location : OptionalLocation = None ):
631+ def __init__ (self , type : SomeType , name : str = "" , location : OptionalLocation = None , source : Optional [ 'ValueLocationSource' ] = None ):
631632 self .type = type
632633 self .name = name
633634 location = ValueLocationWithConfidence .from_optional_location (location )
634635 if location is not None :
635636 self .location = location .location
637+ self .location_source = ValueLocationSource .CustomLocationSource
636638 else :
637639 self .location = None
640+ self .location_source = ValueLocationSource .DefaultLocationSource
641+ if source is not None :
642+ self .location_source = source
638643
639644 def __repr__ (self ):
640645 ic = self .type .immutable_copy ()
@@ -652,11 +657,12 @@ def mutable_copy(self) -> 'FunctionParameter':
652657 def _from_core_struct (struct : 'core.BNFunctionParameter' , arch : Optional ['architecture.Architecture' ] = None ) -> 'FunctionParameter' :
653658 name = struct .name
654659 ty = Type .from_core_struct (struct .type ).with_confidence (struct .typeConfidence )
655- if struct .defaultLocation :
656- location = None
657- else :
660+ source = ValueLocationSource (struct .locationSource )
661+ if source == ValueLocationSource .CustomLocationSource :
658662 location = ValueLocation ._from_core_struct (struct .location , arch )
659- return FunctionParameter (ty , name , location )
663+ else :
664+ location = None
665+ return FunctionParameter (ty , name , location , source )
660666
661667
662668@dataclass (frozen = True )
@@ -1584,10 +1590,11 @@ def parameters(self) -> List[FunctionParameter]:
15841590 param_type = Type .create (
15851591 core .BNNewTypeReference (params [i ].type ), platform = self .platform , confidence = params [i ].typeConfidence
15861592 )
1587- if params [i ].defaultLocation :
1588- param_location = None
1589- else :
1593+ source = ValueLocationSource (params [i ].locationSource )
1594+ if source == ValueLocationSource .CustomLocationSource :
15901595 param_location = ValueLocation ._from_core_struct (params [i ].location , arch )
1596+ else :
1597+ param_location = None
15911598 result .append (FunctionParameter (param_type , params [i ].name , param_location ))
15921599 core .BNFreeTypeParameterList (params , count .value )
15931600 return result
@@ -1616,7 +1623,7 @@ def _to_core_struct(params: Optional[ParamsType] = None):
16161623 core_param .name = ""
16171624 core_param .type = param .handle
16181625 core_param .typeConfidence = param .confidence
1619- core_param .defaultLocation = True
1626+ core_param .locationSource = int ( ValueLocationSource . DefaultLocationSource )
16201627 core_param .location .count = 0
16211628 elif isinstance (param , FunctionParameter ):
16221629 assert param .type is not None , "Attempting to construct function parameter without properly constructed type"
@@ -1625,11 +1632,10 @@ def _to_core_struct(params: Optional[ParamsType] = None):
16251632 core_param .name = param .name
16261633 core_param .type = param_type .handle
16271634 core_param .typeConfidence = param_type .confidence
1635+ core_param .locationSource = int (param .location_source )
16281636 if param .location is None :
1629- core_param .defaultLocation = True
16301637 core_param .location .count = 0
16311638 else :
1632- core_param .defaultLocation = False
16331639 if isinstance (param .location , ValueLocation ):
16341640 core_param .location = param .location ._to_core_struct ()
16351641 elif isinstance (param .location , variable .CoreVariable ):
@@ -1645,7 +1651,7 @@ def _to_core_struct(params: Optional[ParamsType] = None):
16451651 core_param .name = name
16461652 core_param .type = _type .handle
16471653 core_param .typeConfidence = _type .confidence
1648- core_param .defaultLocation = True
1654+ core_param .locationSource = int ( ValueLocationSource . DefaultLocationSource )
16491655 core_param .location .count = 0
16501656 else :
16511657 raise ValueError (f"Conversion from unsupported function parameter type { type (param )} " )
@@ -3543,11 +3549,12 @@ def parameters(self) -> List[FunctionParameter]:
35433549 param_type = Type .create (
35443550 core .BNNewTypeReference (params [i ].type ), platform = self ._platform , confidence = params [i ].typeConfidence
35453551 )
3546- if params [i ].defaultLocation :
3547- param_location = None
3548- else :
3552+ source = ValueLocationSource (params [i ].locationSource )
3553+ if source == ValueLocationSource .CustomLocationSource :
35493554 param_location = ValueLocation ._from_core_struct (params [i ].location , arch )
3550- result .append (FunctionParameter (param_type , params [i ].name , param_location ))
3555+ else :
3556+ param_location = None
3557+ result .append (FunctionParameter (param_type , params [i ].name , param_location , source ))
35513558 core .BNFreeTypeParameterList (params , count .value )
35523559 return result
35533560
0 commit comments