Search code examples
reverse-engineering

How to get `MediumLevelILVar` type variable reference In Binary ninja with Python api?


I tried to use binary ninja to analysis obfuscated binary function. I want to use python api for binary ninja to get variable var_3290 reference like this:
enter image description here
I used the api get_var_uses which only can be received as variable.Variable type,but var_3290 is MediumLevelILVar,called this api will got error!

get_var_uses
    var_data = var.to_BNVariable()
AttributeError: 'MediumLevelILVar' object has no attribute 'to_BNVariable'

How can i do like binary ninja cross reference behavior? thanks.

To get the var_x3290 variable's cross reference like above.


Solution

  • Try get_var_uses and get_var_definitions with MediumLevelILVar type data's src method like this:

        var=None
        if isinstance(state_var,MediumLevelILVar):
            var = state_var.src
        else:
            var = state_var
    

    state_var as a MediumLevelILVar type data.