IDA has a specific mechanism for storing and reading references (either code, data or both) to and from a specific instruction. That mechanism works whenever IDA successfully resolves a reference, which may not always be the case (think of call eax
where eax
is not easily resolved staticly). You should use that interface for all types of calls.
The function that best suits your use case is probably idautils.CodeRefsFrom
which accepts two parameters ea
and flow
and returns a generator for all code references from given ea
. flow
is a boolean used to control whether you wish the next instruction included.
There are a bunch of other related functions, such as CodeRefsTo
, DataRefsFrom
, XrefsTo
, etc...
extrn
line when the call is immediate by getting the instruction'sOperands[1].value