Skip to content

Getting address from instruction #2143

Answered by psifertex
BluePython339 asked this question in API
Discussion options

You must be logged in to vote

There's several ways to do this. The simplest is to just pull out the last argument, wrap it in str and int:

int(str(current_basic_block[1][0][-1]), 16)

Note that I'm using current_basic_block[1][0] to get the instruction tokens here.

The better solution though would be to get the IL at that location and simply ask for the destination of the call. This will work better if the argument is a register for example whose value is known.

For example:

Notice that I have to use .value.value at the call because the first .value asks for the constant-data-flow representation. There are other possible types besides constant values (could be any of https://api.binary.ninja/binaryninja.enums-module.h…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by psifertex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants