I'm using the following code to get the address of the selected function/variable:

hightlight = idaapi.get_highlight(idaapi.get_current_viewer())
screen_ea = idaapi.get_screen_ea()
ea = idaapi.get_name_ea(screen_ea, name)

It works like a charm except until you meet demangled name in IDA View :(

For example, for this line

.text:00406744                 call    KBTickCount(void)

idaapi.get_name_ea call would never return the proper address, because the real name is ?KBTickCount@@YIJXZ.

I know that I can just change demangled names representation in IDA Pro, but I'm working on a public plugin and I'm thinking about end users.

And I also want to make it work in Pseudocode view, where all names are demangled.

Any ideas on how to get the address of the selected function/variable for a particular line?

  • On what action/event does your code execute?
    – Igor Skochinsky
    Commented Apr 27, 2020 at 0:34
  • I set hotkey action handler if it matters
    – mastermind
    Commented Apr 27, 2020 at 0:48

1 Answer 1


All action callbacks receive a context pointer with various information pre-filled:

  ea_t cur_ea;           ///< the current EA of the position in the view
  uval_t cur_value;      ///< the possible address, or value the cursor is positioned on

  func_t *cur_func;      ///< the current function
  func_t *cur_fchunk;    ///< the current function chunk

  struc_t *cur_struc;    ///< the current structure
  member_t *cur_strmem;  ///< the current structure member

  enum_t cur_enum;       ///< the current enum

  segment_t *cur_seg;    ///< the current segment

(from kernwin.hpp)

So you can just use ctx.cur_value (or its Python synonym, cur_extracted_ea) to directly get the address/value/identifier under cursor, without having to resolve it yourself.

  • Didn't know about that, thank you very much!
    – mastermind
    Commented Apr 30, 2020 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.