save_and_restore_listing_pos

summary: save, and then restore, positions in a listing

description:

Shows how it is possible re-implement IDA’s bookmark capability, using 2 custom actions: one action saves the current location, and the other restores it.

Note that, contrary to actual bookmarks, this example:

  • remembers only 1 saved position

  • doesn’t save that position in the IDB (and therefore cannot be restored if IDA is closed & reopened.)

keywords: listing, actions

see_also: jump_next_comment

level: intermediate

Attributes

last_pos

klasses

Classes

listing_action_handler_t

last_pos_t

save_position_ah_t

restore_position_ah_t

Module Contents

class save_and_restore_listing_pos.listing_action_handler_t

Bases: ida_kernwin.action_handler_t

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.

class save_and_restore_listing_pos.last_pos_t(widget_title, lochist_entry)

Bases: object

widget_title
lochist_entry
save_and_restore_listing_pos.last_pos = None
class save_and_restore_listing_pos.save_position_ah_t

Bases: listing_action_handler_t

ACTION_NAME = 'save_and_restore_listing_pos:save_position'
ACTION_LABEL = 'Save position'
ACTION_SHORTCUT = 'Ctrl+Shift+S'
HELP_TEXT = "Press Ctrl+Shift+S in a 'listing' widget such as 'IDA View-A', 'Local Types', 'Pseudocode-A',...
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

class save_and_restore_listing_pos.restore_position_ah_t

Bases: listing_action_handler_t

ACTION_NAME = 'save_and_restore_listing_pos:restore_position'
ACTION_LABEL = 'Restore position'
ACTION_SHORTCUT = 'Ctrl+Shift+O'
HELP_TEXT = "Press Ctrl+Shift+O in a 'listing' widget such as 'IDA View-A', 'Local Types', 'Pseudocode-A',...
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

save_and_restore_listing_pos.klasses