vds11

summary: add a custom microcode block optimization rule

description:

Installs a custom microcode block optimization rule, to transform:

goto L1 …

L1:

goto L2

into

goto L2

In other words we fix a goto target if it points to a chain of gotos. This improves the decompiler output in some cases.

level: advanced

Classes

goto_optimizer_t

my_plugin_t

Base class for all scripted plugins.

Functions

PLUGIN_ENTRY()

Module Contents

class vds11.goto_optimizer_t

Bases: ida_hexrays.optblock_t

func(blk)

Optimize a block. This function usually performs the optimizations that require analyzing the entire block and/or its neighbors. For example it can recognize patterns and perform conversions like: b0: b0: … … jnz x, 0, @b2 => jnz x, 0, @b2 b1: b1: add x, 0, y mov x, y … …

Parameters:

blk – Basic block to optimize as a whole.

Returns:

number of changes made to the block. See also mark_lists_dirty.

handle_goto_chain(blk)
class vds11.my_plugin_t

Bases: ida_idaapi.plugin_t

Base class for all scripted plugins.

flags = 16
wanted_name = 'Optimize goto chains (IDAPython)'
wanted_hotkey = ''
comment = 'Sample plugin11 for Hex-Rays decompiler'
help = ''
init()
term()
run(arg)
vds11.PLUGIN_ENTRY()