1

context about action_handler_t

IDA provides multiple features and APIs to extend and enhance it's usability, one of those features is the creation of user defined action_handler_t objects by inheriting idaapi.action_handler_t in IDAPython.

The feature involves several APIs, but one of the requirements is having a class that inherits said idaapi.action_handler_t class and implements two methods. One of those methods is update(self, ctx) (the other being activate(self, ctx)).

During an IDA application's lifetime, the update method will be called multiple times on certain events (startup, a new IDB being loaded, focus shifts to another form, etc). Updates then communicates back wether the action should be enabled or disabled and when to query again by issuing another call to update.

One of those events is an action's activation call returns. The motivation is that actions performed as a result of an action being activated might potentially change the state of that same action or other actions.

actual question

While using IDA and certain Qt signals/slots abilities, I've created an activation method that returns immediately and schedules most of its login to other slots, and I'm now losing the "post-activation" update call that makes actions respond to overall state changes and change their own state (from disabled to enabled and vise versa).

My question is, how can I force an update call by IDA's kernel to all existing actions so that when my delayed code finishes it could manually tell IDA it should call update for all actions to query for their new state?

1 Answer 1

3

The update methods of actions are usually called when the relevant GUI components (usually various IDA views) are refreshed. To make things speedier, IDA avoids refreshing views until such a refresh is required.

When scripting IDA, we often make changes without touching the GUI, so IDA has no way of telling when a change is done and it should refresh. To solve this, we can use the idaapi.request_refresh(mask) function:

idaapi.request_refresh(0xFFFFFFFF)  # IWID_ALL

To refresh a specific view, use a mask made of the following constants (documented here):

#define IWID_EXPORTS  (1u << BWN_EXPORTS) ///< exports           (0)
#define IWID_IMPORTS  (1u << BWN_IMPORTS) ///< imports           (1)
#define IWID_NAMES    (1u << BWN_NAMES  ) ///< names             (2)
#define IWID_FUNCS    (1u << BWN_FUNCS  ) ///< functions         (3)
#define IWID_STRINGS  (1u << BWN_STRINGS) ///< strings           (4)
#define IWID_SEGS     (1u << BWN_SEGS   ) ///< segments          (5)
#define IWID_SEGREGS  (1u << BWN_SEGREGS) ///< segment registers (6)
#define IWID_SELS     (1u << BWN_SELS   ) ///< selectors         (7)
#define IWID_SIGNS    (1u << BWN_SIGNS  ) ///< signatures        (8)
#define IWID_TILS     (1u << BWN_TILS   ) ///< type libraries    (9)
#define IWID_LOCTYPS  (1u << BWN_LOCTYPS) ///< local types       (10)
#define IWID_CALLS    (1u << BWN_CALLS  ) ///< function calls    (11)
#define IWID_PROBS    (1u << BWN_PROBS  ) ///< problems          (12)
#define IWID_BPTS     (1u << BWN_BPTS   ) ///< breakpoints       (13)
#define IWID_THREADS  (1u << BWN_THREADS) ///< threads           (14)
#define IWID_MODULES  (1u << BWN_MODULES) ///< modules           (15)
#define IWID_TRACE    (1u << BWN_TRACE  ) ///< trace view        (16)
#define IWID_STACK    (1u << BWN_STACK  ) ///< call stack        (17)
#define IWID_XREFS    (1u << BWN_XREFS  ) ///< xrefs             (18)
#define IWID_SEARCHS  (1u << BWN_SEARCH ) ///< search results    (19)
#define IWID_FRAME    (1u << BWN_FRAME  ) ///< function frame    (25)
#define IWID_NAVBAND  (1u << BWN_NAVBAND) ///< navigation band   (26)
#define IWID_ENUMS    (1u << BWN_ENUMS  ) ///< enumerations      (27)
#define IWID_STRUCTS  (1u << BWN_STRUCTS) ///< structures        (28)
#define IWID_DISASMS  (1u << BWN_DISASM ) ///< disassembly views (29)
#define IWID_DUMPS    (1u << BWN_DUMP   ) ///< hex dumps         (30)
#define IWID_NOTEPAD  (1u << BWN_NOTEPAD) ///< notepad           (31)
#define IWID_IDAMEMOS (IWID_DISASMS|IWID_DUMPS)
1
  • For future reference: It turns out that for some reason this does not work when there's no IDB loaded in IDA but works when an IDB is loaded.
    – NirIzr
    Mar 29, 2017 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.