vds3

summary: invert if/else blocks in decompilation

description:

Registers an action that can be used to invert the if and else blocks of a ida_hexrays.cif_t.

For example, a statement like

if ( cond ) {

statements1;

} else {

statements2;

}

will be displayed as

if ( !cond ) {

statements2;

} else {

statements1;

}

The modifications are persistent: the user can quit & restart IDA, and the changes will be present.

author: EiNSTeiN_ (einstein@g3nius.org)

level: advanced

Attributes

NETNODE_NAME

inverter_actname

Classes

invert_action_handler_t

hexrays_callback_info

vds3_hooks_t

idp_hooks_t

my_plugin_t

Base class for all scripted plugins.

Functions

PLUGIN_ENTRY()

Module Contents

vds3.NETNODE_NAME = '$ hexrays-inverted-if'
vds3.inverter_actname = 'vds3:invert'
class vds3.invert_action_handler_t(inverter)

Bases: ida_kernwin.action_handler_t

inverter
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.

class vds3.hexrays_callback_info

Bases: object

vu = None
node
load()
save()
invert_if(insn)
add_location(ea)
find_if_statement(vu)
invert_if_event(vu)
restore(cfunc)
class vds3.vds3_hooks_t(i)

Bases: ida_hexrays.Hexrays_Hooks

i
populating_popup(widget, phandle, vu)

Populating popup menu. We can add menu items now.

Parameters:
  • widget – (TWidget *)

  • popup_handle – (TPopupMenu *)

  • vu – (vdui_t *)

maturity(cfunc, maturity)

Ctree maturity level is being changed.

Parameters:
  • cfunc – (cfunc_t *)

  • new_maturity – (ctree_maturity_t)

class vds3.idp_hooks_t(i)

Bases: ida_idp.IDP_Hooks

i
ev_privrange_changed(old_privrange, delta)

Privrange interval has been moved to a new location. Most common actions to be done by module in this case: fix indices of netnodes used by module

Parameters:
  • old_privrange – (const range_t *) - old privrange interval

  • delta – (::adiff_t)

Returns:

0: Ok

Returns:

-1: error (and message in errbuf)

class vds3.my_plugin_t

Bases: ida_idaapi.plugin_t

Base class for all scripted plugins.

flags = 16
wanted_name = 'Hex-Rays if-inverter (IDAPython)'
wanted_hotkey = ''
comment = 'Sample plugin3 for Hex-Rays decompiler'
help = ''
init()
term()
run(arg)
vds3.PLUGIN_ENTRY()