custom_viewer

summary: create custom listings in IDA

description:

How to create simple listings, that will share many of the features as the built-in IDA widgets (highlighting, copy & paste, notifications, …)

In addition, creates actions that will be bound to the freshly-created widget (using ida_kernwin.attach_action_to_popup.)

keywords: listing, actions

level: intermediate

Attributes

actions_variants

actname

mycv

Classes

say_something_handler_t

mycv_t

The base class for implementing simple custom viewers

Functions

show_win()

make_many(n)

Module Contents

class custom_viewer.say_something_handler_t(thing)

Bases: ida_kernwin.action_handler_t

thing
activate(ctx)

Activate an action. This function implements the core behavior of an action. It is called when the action is triggered, from a menu, from a popup menu, from the toolbar, or programmatically.

Returns:

non-zero: all IDA windows will be refreshed

update(ctx)

Update an action. This is called when the context of the UI changed, and we need to let the action update some of its properties if needed (label, icon, …) In addition, this lets IDA know whether the action is enabled, and when it should be queried for availability again. Note: This callback is not meant to change anything in the application’s state, except by calling one (or many) of the “update_action_*()” functions on this very action.

static compose_action_name(v)
custom_viewer.actions_variants = ['Hello', 'World']
custom_viewer.actname = 'custview:say_Hello'
class custom_viewer.mycv_t

Bases: ida_kernwin.simplecustviewer_t

The base class for implementing simple custom viewers

Create(sn=None, use_colors=True)

Creates the custom view. This should be the first method called after instantiation

Parameters:

title – The title of the view

Returns:

Boolean whether it succeeds or fails. It may fail if a window with the same title is already open. In this case better close existing windows

OnClick(shift)

User clicked in the view :param shift: Shift flag :returns: Boolean. True if you handled the event

OnDblClick(shift)

User dbl-clicked in the view :param shift: Shift flag :returns: Boolean. True if you handled the event

OnCursorPosChanged()

Cursor position changed. :returns: Nothing

OnClose()

The view is closing. Use this event to cleanup. :returns: Nothing

OnKeydown(vkey, shift)

User pressed a key :param vkey: Virtual key code :param shift: Shift flag :returns: Boolean. True if you handled the event

OnHint(lineno)

Hint requested for the given line number.

Parameters:

lineno – The line number (zero based)

Returns:

tuple(number of important lines, hint string), or None: if no hint available

Show(*args)

Shows an already created view. It the view was closed, then it will call Create() for you :returns: Boolean

custom_viewer.show_win()
custom_viewer.mycv = None
custom_viewer.make_many(n)