2

In IDA's Graph View, when we select some register (for example, esp in the image below), every location that the register occurs is highlighted.

Is it possible to read what the selected operand is? (I want to work with registers at the moment, but it would be nice to be able to know any selected value).

I am able to get the address of the instruction using idaapi.get_screen_ea(), but am unable to proceed further.

esp highlight

2 Answers 2

4

You can use

idaapi.get_highlighted_identifier()

This function returns highlighted text. All the IDAPython reference can be found at here, at Hex-Rays site

2

In case the above doesn't work in newer versions try ida_kernwin.get_highlight(ida_kernwin.get_current_viewer())

Example:

Python>ida_kernwin.get_highlight(ida_kernwin.get_current_viewer())
('edx', 0x3)

The backwards compatibility layer shows how to interpret the returned tuple:

def get_highlighted_identifier():
    thing = get_highlight(get_current_viewer())
    if thing and thing[1]:
        return thing[0]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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