py_mex3
summary: implement merging functionality for custom plugins
- description:
IDA Teams uses a chooser to display the merge conflicts. To fill the chooser columns IDA Teams uses the following methods from diff_source_t type:
print_diffpos_name()
print_diffpos_details()
and UI hints from merge_handler_params_t type:
ui_has_details()
ui_complex_details()
ui_complex_name()
In general, chooser columns are filled as following:
columns.clear() NAME = print_diffpos_name() if ui_complex_name() then
columns.add(split NAME by ui_split_char())
- else
columns[0] = NAME
if not ui_complex_details() then
columns.add(print_diffpos_details())
Also, see SDK/plugins/mex3 example
level: advanced
Attributes
Classes
we need an event listener to catch processor_t::ev_create_merge_handlers |
|
Regular plugin implementation below. |
|
Base class for all scripted plugins. |
Functions
Module Contents
- py_mex3.MEX_NODE_NAME = '$ idapython mex3'
- py_mex3.MEX_OPTION_FLAGS_IDX
- py_mex3.MEX_OPTION_IDENT_IDX
- py_mex3.MEX_EA_TAG = 'm'
- py_mex3.MEX_FLAGS_0 = 1
- py_mex3.MEX_FLAGS_1 = 2
- class py_mex3.idp_listener_t(ctx)
Bases:
ida_idp.IDP_Hookswe need an event listener to catch processor_t::ev_create_merge_handlers
- ctx
- ev_ending_undo()
A well behaving plugin should restore its state from the database upon ev_ending_undo. Otherwise its state may be conflicting with the database.
- ev_create_merge_handlers(md)
This event occurs when IDA is performing a 3-way merge (for IDA Teams) Our plugins should create and register merge handler(s) for its data.
- ev_cvt64_supval(node, tag, idx, data)
Converter to i64 database
- class py_mex3.mex_ctx_t
Bases:
ida_idaapi.plugmod_tRegular plugin implementation below. For example, in our case the plugin asks for 2 bit values and a string value. Then the plugin stores this data in the database. And mark the start address of the current function. These data will be merged later.
- flags = 0
- ident = ''
- idp_listener
- modmerger_helper = None
- idpopts_info = None
- node_helper = None
- merge_node_info = None
- save_to_idb()
Save the plugin state to the idb.
- restore_from_idb()
Restore plugin variables from the idb.
- run(_)
Ask user for the data and save them to database. Add mark for current EA.
- create_merge_handlers(md)
Create merge handlers for plugin
- class py_mex3.mex3_plugin_t
Bases:
ida_idaapi.plugin_tBase class for all scripted plugins.
- flags = 257
- wanted_name = 'IDAPython: Merge example 3'
- comment = 'IDAPython: An example 1 how to implement IDA merge functionality'
- wanted_hotkey = ''
- help = ''
- init()
- term()
- run(arg)
- py_mex3.PLUGIN_ENTRY()