Get memory addresses using IDAPython

Maggie picture Maggie · May 6, 2015 · Viewed 7.1k times · Source

In my code, I am using idc.GetOpnd(ea,0) and idc.GetOpnd(ea,1) to get the 2 operands of an instruction. However, if its a call (or jmp) instruction, I am getting symbols like _perror and loc_8083BA9.

Using IDAPython, is it possible to remove all the symbols and deal only with memory locations.

Answer

nneonneo picture nneonneo · May 6, 2015

Two options:

  1. Use LocByName to resolve names to addresses
  2. Use GetOperandValue instead of GetOpnd to get the value of the operand instead of its display string.