ida_merge
Merge functionality.
NOTE: this functionality is available in IDA Teams (not IDA Pro) There are 3 databases involved in merging: base_idb, local_db, and remote_idb. * base_idb: the common base ancestor of ‘local_db’ and ‘remote_db’. in the UI this database is located in the middle. * local_idb: local database that will contain the result of the merging. in the UI this database is located on the left. * remote_idb: remote database that will merge into local_idb. It may reside locally on the current computer, despite its name. in the UI this database is located on the right. base_idb and remote_idb are opened for reading only. base_idb may be absent, in this case a 2-way merging is performed.
Conflicts can be resolved automatically or interactively. The automatic resolving scores the conflicting blocks and takes the better one. The interactive resolving displays the full rendered contents side by side, and expects the user to select the better side for each conflict. Since IDB files contain various kinds of information, there are many merging phases. The entire list can be found in merge.cpp. Below are just some selected examples: * merge global database settings (inf and other global vars) * merge segmentation and changes to the database bytes * merge various lists: exports, imports, loaded tils, etc * merge names, functions, function frames * merge debugger settings, breakpoints * merge struct/enum views * merge local type libraries * merge the disassembly items (i.e. the segment contents) this includes operand types, code/data separation, etc * merge plugin specific info like decompiler types, dwarf mappings, etc
To unify UI elements of each merge phase, we use merger views: * A view that consists of 2 or 3 panes: left (local_idb) and right (remote_idb). The common base is in the middle, if present. * Rendering of the panes depends on the phase, different phases show different contents. * The conflicts are highlighted by a colored background. Also, the detail pane can be consulted for additional info. * The user can select a conflict (or a bunch of conflicts) and say “use this block”. * The user can browse the panes as he wishes. He will not be forced to handle conflicts in any particular order. However, once he finishes working with a merge handler and proceeds to the next one, he cannot go back. * Scrolling the left pane will synchronously scroll the right pane and vice versa. * There are the navigation commands like “go to the prev/next conflict” * The number of remaining conflicts to resolve is printed in the “Progress” chooser. * The user may manually modify local database inside the merger view. For that he may use the regular hotkeys. However, editing the database may lead to new conflicts, so we better restrict the available actions to some reasonable minimum. Currently, this is not implemented.
IDA works in a new “merge” mode during merging. In this mode most events are not generated. We forbid them to reduce the risk that a rogue third-party plugin that is not aware of the “merge” mode would spoil something. For example, normally renaming a function causes a cascade of events and may lead to other database modifications. Some of them may be desired, some - not. Since there are some undesired events, it is better to stop generating them. However, some events are required to render the disassembly listing. For example, ev_ana_insn, av_out_insn. This is why some events are still generated in the “merge” mode. To let processor modules and plugins merge their data, we introduce a new event: ev_create_merge_handlers. It is generated immediately after opening all three idbs. The interested modules should react to this event by creating new merge handlers, if they need them. While the kernel can create arbitrary merge handlers, modules can create only the standard ones returned by: create_nodeval_merge_handler() create_nodeval_merge_handlers() create_std_modmerge_handlers() We do not document merge_handler_t because once a merge handler is created, it is used exclusively by the kernel. See mergemod.hpp for more information about the merge mode for modules.
Attributes
netnode (no merging, to be used in idbunits) |
|
auto queues |
|
merge the inf variable (global settings) |
|
merge encodings |
|
merge default encodings |
|
merge scripts common info |
|
merge scripts |
|
merge custom data type and formats |
|
merge custom calling conventions |
|
merge enums |
|
merge structs (globally: add/delete structs entirely) |
|
merge type libraries |
|
merge tinfo |
|
merge struct members |
|
merge UDT members (local types) |
|
merge ghost structure comment |
|
merge member comments for ghost struc |
|
merge selectors |
|
merge flag storage types |
|
merge segments |
|
merge segment groups |
|
merge segment registers |
|
merge orphan bytes |
|
merge byte values |
|
merge fixups |
|
merge manual memory mapping |
|
merge exports |
|
merge imports |
|
merge patched bytes |
|
merge flags64_t |
|
merge extra next or prev lines |
|
merge aflags for mapped EA |
|
IM ("$ ignore micro") flags. |
|
merge fileregions |
|
merge hidden ranges |
|
merge source files ranges |
|
merge func info |
|
merge frames (globally: add/delete frames entirely) |
|
merge function frame info (frame members) |
|
merge SP change points |
|
merge flows |
|
merge crefs |
|
merge drefs |
|
merge breakpoints |
|
merge watchpoints |
|
merge bookmarks |
|
merge try blocks |
|
merge std dirtrees |
|
merge vftables |
|
signatures |
|
problems |
|
UI. |
|
dekstops |
|
notepad |
|
loader data |
|
debugger data |
|
manual memory regions (debugger) |
|
lumina function metadata |
|
last predefined merge handler type. please note that there can be more merge handler types, registered by plugins and processor modules. |
|
insert to the end of handler list, valid for merge_handler_params_t::insert_after |
|
merge handler will receive merge events |
|
do not display equal lines in the merge results table |
|
ida will not show the diffpos details |
|
diffpos details won't be displayed in the diffpos chooser |
|
Detail pane: do not show differences inside the line. |
|
Detail pane: use the first part of a complex diffpos name as the tree node name. |
|
preserve indent for diffpos name in diffpos chooser |
|
ida will split the diffpos name by 7-bit ASCII char to create chooser columns |
|
7-bit ASCII split character |
|
ida will split the diffpos name by ',' to create chooser columns |
|
ida will split the diffpos name by ':' to create chooser columns |
|
boolean value |
|
EA value. |
|
value is relative to index (stored as delta) |
|
string value |
|
stored as netnode supvals (not scalar) |
|
stored as netnode blobs |
|
enable default handling of mev_modified_ranges, mev_deleting_segm |
|
enable default handling of mev_added_func/mev_deleting_func |
|
apply ea2node() to index (==NETMAP_IDX) |
|
apply ea2node() to value. Along with NDS_INC it gives effect of NETMAP_VAL, examples: altval_ea : NDS_MAP_IDX charval : NDS_VAL8 charval_ea: NDS_MAP_IDX|NDS_VAL8 eaget : NDS_MAP_IDX|NDS_MAP_VAL|NDS_INC |
|
use 8-bit values (==NETMAP_V8) |
|
stored value is incremented (scalars only) |
|
UI: no need to show diffpos detail pane, MH_UI_NODETAILS, make sense if merge_node_helper_t is used |
Classes
Functions
|
Return TRUE if IDA is running in diff mode (MERGE_POLICY_MDIFF/MERGE_POLICY_VDIFF) |
|
Create a merge handler for netnode scalar/string values |
|
Create a serie of merge handlers for netnode scalar/string values (call create_nodeval_merge_handler() for each member of VALDESC) |
|
|
|
Get nice name for EA diffpos |
Module Contents
- ida_merge.SWIG_PYTHON_LEGACY_BOOL
- ida_merge.MERGE_KIND_NETNODE
netnode (no merging, to be used in idbunits)
- ida_merge.MERGE_KIND_AUTOQ
auto queues
- ida_merge.MERGE_KIND_INF
merge the inf variable (global settings)
- ida_merge.MERGE_KIND_ENCODINGS
merge encodings
- ida_merge.MERGE_KIND_ENCODINGS2
merge default encodings
- ida_merge.MERGE_KIND_SCRIPTS2
merge scripts common info
- ida_merge.MERGE_KIND_SCRIPTS
merge scripts
- ida_merge.MERGE_KIND_CUSTDATA
merge custom data type and formats
- ida_merge.MERGE_KIND_CUSTCNV
merge custom calling conventions
- ida_merge.MERGE_KIND_ENUMS
merge enums
- ida_merge.MERGE_KIND_STRUCTS
merge structs (globally: add/delete structs entirely)
- ida_merge.MERGE_KIND_TILS
merge type libraries
- ida_merge.MERGE_KIND_TINFO
merge tinfo
- ida_merge.MERGE_KIND_STRMEM
merge struct members
- ida_merge.MERGE_KIND_UDTMEM
merge UDT members (local types)
- ida_merge.MERGE_KIND_GHSTRCMT
merge ghost structure comment
- ida_merge.MERGE_KIND_STRMEMCMT
merge member comments for ghost struc
- ida_merge.MERGE_KIND_SELECTORS
merge selectors
- ida_merge.MERGE_KIND_STT
merge flag storage types
- ida_merge.MERGE_KIND_SEGMENTS
merge segments
- ida_merge.MERGE_KIND_SEGGRPS
merge segment groups
- ida_merge.MERGE_KIND_SEGREGS
merge segment registers
- ida_merge.MERGE_KIND_ORPHANS
merge orphan bytes
- ida_merge.MERGE_KIND_BYTEVAL
merge byte values
- ida_merge.MERGE_KIND_FIXUPS
merge fixups
- ida_merge.MERGE_KIND_MAPPING
merge manual memory mapping
- ida_merge.MERGE_KIND_EXPORTS
merge exports
- ida_merge.MERGE_KIND_IMPORTS
merge imports
- ida_merge.MERGE_KIND_PATCHES
merge patched bytes
- ida_merge.MERGE_KIND_FLAGS
merge flags64_t
- ida_merge.MERGE_KIND_EXTRACMT
merge extra next or prev lines
- ida_merge.MERGE_KIND_AFLAGS_EA
merge aflags for mapped EA
- ida_merge.MERGE_KIND_IGNOREMICRO
IM (”$ ignore micro”) flags.
- ida_merge.MERGE_KIND_FILEREGIONS
merge fileregions
- ida_merge.MERGE_KIND_HIDDENRANGES
merge hidden ranges
- ida_merge.MERGE_KIND_SOURCEFILES
merge source files ranges
- ida_merge.MERGE_KIND_FUNC
merge func info
- ida_merge.MERGE_KIND_FRAMEMGR
merge frames (globally: add/delete frames entirely)
- ida_merge.MERGE_KIND_FRAME
merge function frame info (frame members)
- ida_merge.MERGE_KIND_STKPNTS
merge SP change points
- ida_merge.MERGE_KIND_FLOWS
merge flows
- ida_merge.MERGE_KIND_CREFS
merge crefs
- ida_merge.MERGE_KIND_DREFS
merge drefs
- ida_merge.MERGE_KIND_BPTS
merge breakpoints
- ida_merge.MERGE_KIND_WATCHPOINTS
merge watchpoints
- ida_merge.MERGE_KIND_BOOKMARKS
merge bookmarks
- ida_merge.MERGE_KIND_TRYBLKS
merge try blocks
- ida_merge.MERGE_KIND_DIRTREE
merge std dirtrees
- ida_merge.MERGE_KIND_VFTABLES
merge vftables
- ida_merge.MERGE_KIND_SIGNATURES
signatures
- ida_merge.MERGE_KIND_PROBLEMS
problems
- ida_merge.MERGE_KIND_UI
UI.
- ida_merge.MERGE_KIND_DEKSTOPS
dekstops
- ida_merge.MERGE_KIND_NOTEPAD
notepad
- ida_merge.MERGE_KIND_LOADER
loader data
- ida_merge.MERGE_KIND_DEBUGGER
debugger data
- ida_merge.MERGE_KIND_DBG_MEMREGS
manual memory regions (debugger)
- ida_merge.MERGE_KIND_LUMINA
lumina function metadata
- ida_merge.MERGE_KIND_LAST
last predefined merge handler type. please note that there can be more merge handler types, registered by plugins and processor modules.
- ida_merge.MERGE_KIND_END
insert to the end of handler list, valid for merge_handler_params_t::insert_after
- ida_merge.MERGE_KIND_NONE
- ida_merge.is_diff_merge_mode() bool
Return TRUE if IDA is running in diff mode (MERGE_POLICY_MDIFF/MERGE_POLICY_VDIFF)
- class ida_merge.merge_data_t(*args, **kwargs)
Bases:
object
- thisown
- dbctx_ids: int[3]
local, remote, base ids
- nbases: int
number of database participating in merge process, maybe 2 or 3
- ev_handlers: merge_handlers_t
event handlers
- item_block_locator: merge_data_t::item_block_locator_t *
- set_dbctx_ids(local: int, remote: int, base: int) None
- local_id() int
- remote_id() int
- base_id() int
- add_event_handler(handler: merge_handler_t *) None
- remove_event_handler(handler: merge_handler_t *) None
- get_block_head(idx: diff_source_idx_t, item_head: ida_idaapi.ea_t) ida_idaapi.ea_t
- setup_blocks(dst_idx: diff_source_idx_t, src_idx: diff_source_idx_t, region: diff_range_t const &) bool
- has_existing_node(nodename: str) bool
check that node exists in any of databases
- map_privrange_id(tid: tid_t *, ea: ida_idaapi.ea_t, _from: diff_source_idx_t, to: diff_source_idx_t, strict: bool = True) bool
map IDs of structures, enumerations and their members
- Parameters:
tid – item ID in TO database
ea – item ID to find counterpart
to – destination database index, diff_source_idx_t
strict – raise interr if could not map
- Returns:
success
- map_tinfo(tif: tinfo_t, _from: diff_source_idx_t, to: diff_source_idx_t, strict: bool = True) bool
migrate type, replaces type references into FROM database to references into TO database
- Parameters:
tif – type to migrate, will be cleared in case of fail
to – destination database index, diff_source_idx_t
strict – raise interr if could not map
- Returns:
success
- class ida_merge.item_block_locator_t
Bases:
object
- thisown
- get_block_head(md: merge_data_t, idx: diff_source_idx_t, item_head: ida_idaapi.ea_t) ida_idaapi.ea_t
- setup_blocks(md: merge_data_t, _from: diff_source_idx_t, to: diff_source_idx_t, region: diff_range_t const &) bool
- class ida_merge.merge_handler_params_t(_md: merge_data_t, _label: str, _kind: merge_kind_t, _insert_after: merge_kind_t, _mh_flags: int)
Bases:
object
- thisown
- md: merge_data_t &
- label: str
- kind: merge_kind_t
merge handler kind merge_kind_t
- insert_after: merge_kind_t
desired position inside ‘handlers’ merge_kind_t
- mh_flags: int
- ui_has_details(*args) bool
This function has the following signatures:
ui_has_details() -> bool
ui_has_details(_mh_flags: int) -> bool
# 0: ui_has_details() -> bool
# 1: ui_has_details(_mh_flags: int) -> bool
Should IDA display the diffpos detail pane?
- ui_complex_details(*args) bool
This function has the following signatures:
ui_complex_details() -> bool
ui_complex_details(_mh_flags: int) -> bool
# 0: ui_complex_details() -> bool
# 1: ui_complex_details(_mh_flags: int) -> bool
Do not display the diffpos details in the chooser. For example, the MERGE_KIND_SCRIPTS handler puts the script body as the diffpos detail. It would not be great to show them as part of the chooser.
- ui_complex_name(*args) bool
This function has the following signatures:
ui_complex_name() -> bool
ui_complex_name(_mh_flags: int) -> bool
# 0: ui_complex_name() -> bool
# 1: ui_complex_name(_mh_flags: int) -> bool
It customary to create long diffpos names having many components that are separated by any 7-bit ASCII character (besides of ‘0’). In this case it is possible to instruct IDA to use this separator to create a multi-column chooser. For example the MERGE_KIND_ENUMS handler has the following diffpos name: enum_1,enum_2 If MH_UI_COMMANAME is specified, IDA will create 2 columns for these names.
- ui_split_char(*args) char
This function has the following signatures:
ui_split_char() -> char
ui_split_char(_mh_flags: int) -> char
# 0: ui_split_char() -> char
# 1: ui_split_char(_mh_flags: int) -> char
- ui_split_str(*args) str
This function has the following signatures:
ui_split_str() -> str
ui_split_str(_mh_flags: int) -> str
# 0: ui_split_str() -> str
# 1: ui_split_str(_mh_flags: int) -> str
- ui_dp_shortname(*args) bool
This function has the following signatures:
ui_dp_shortname() -> bool
ui_dp_shortname(_mh_flags: int) -> bool
# 0: ui_dp_shortname() -> bool
# 1: ui_dp_shortname(_mh_flags: int) -> bool
The detail pane shows the diffpos details for the current diffpos range as a tree-like view. In this pane the diffpos names are used as tree node names and the diffpos details as their children. Sometimes, for complex diffpos names, the first part of the name looks better than the entire name. For example, the MERGE_KIND_SEGMENTS handler has the following diffpos name: <range>,<segm1>,<segm2>,<segm3> if MH_UI_DP_SHORTNAME is specified, IDA will use <range> as a tree node name
- ui_linediff(*args) bool
This function has the following signatures:
ui_linediff() -> bool
ui_linediff(_mh_flags: int) -> bool
# 0: ui_linediff() -> bool
# 1: ui_linediff(_mh_flags: int) -> bool
In detail pane IDA shows difference between diffpos details. IDA marks added or deleted detail by color. In the modified detail the changes are marked. Use this UI hint if you do not want to show the differences inside detail.
- ui_indent(*args) bool
This function has the following signatures:
ui_indent() -> bool
ui_indent(_mh_flags: int) -> bool
# 0: ui_indent() -> bool
# 1: ui_indent(_mh_flags: int) -> bool
In the ordinary situation the spaces from the both sides of diffpos name are trimmed. Use this UI hint to preserve the leading spaces.
- ida_merge.MH_LISTEN
merge handler will receive merge events
- ida_merge.MH_TERSE
do not display equal lines in the merge results table
- ida_merge.MH_UI_NODETAILS
ida will not show the diffpos details
- ida_merge.MH_UI_COMPLEX
diffpos details won’t be displayed in the diffpos chooser
- ida_merge.MH_UI_DP_NOLINEDIFF
Detail pane: do not show differences inside the line.
- ida_merge.MH_UI_DP_SHORTNAME
Detail pane: use the first part of a complex diffpos name as the tree node name.
- ida_merge.MH_UI_INDENT
preserve indent for diffpos name in diffpos chooser
- ida_merge.MH_UI_SPLITNAME
ida will split the diffpos name by 7-bit ASCII char to create chooser columns
- ida_merge.MH_UI_CHAR_MASK
7-bit ASCII split character
- ida_merge.MH_UI_COMMANAME
ida will split the diffpos name by ‘,’ to create chooser columns
- ida_merge.MH_UI_COLONNAME
ida will split the diffpos name by ‘:’ to create chooser columns
- class ida_merge.moddata_diff_helper_t(_module_name: str, _netnode_name: str, _fields: idbattr_info_t)
Bases:
object
- thisown
- module_name: str
will be used as a prefix for field desc
- netnode_name: str
name of netnode with module data attributes
- fields: idbattr_info_t const *
module data attribute descriptions
- nfields: size_t
number of descriptions
- additional_mh_flags: int
additional merge handler flags
- merge_starting(arg0: diff_source_idx_t, arg1: void *) None
- merge_ending(arg0: diff_source_idx_t, arg1: void *) None
- get_struc_ptr(arg0: merge_data_t, arg1: diff_source_idx_t, arg2: idbattr_info_t) void *
- print_diffpos_details(arg0: qstrvec_t *, arg1: idbattr_info_t) None
- val2str(arg0: str, arg1: idbattr_info_t, arg2: uint64) bool
- str2val(arg0: uint64 *, arg1: idbattr_info_t, arg2: str) bool
- ida_merge.NDS_IS_BOOL
boolean value
- ida_merge.NDS_IS_EA
EA value.
- ida_merge.NDS_IS_RELATIVE
value is relative to index (stored as delta)
- ida_merge.NDS_IS_STR
string value
- ida_merge.NDS_SUPVAL
stored as netnode supvals (not scalar)
- ida_merge.NDS_BLOB
stored as netnode blobs
- ida_merge.NDS_EV_RANGE
enable default handling of mev_modified_ranges, mev_deleting_segm
- ida_merge.NDS_EV_FUNC
enable default handling of mev_added_func/mev_deleting_func
- ida_merge.NDS_MAP_IDX
apply ea2node() to index (==NETMAP_IDX)
- ida_merge.NDS_MAP_VAL
apply ea2node() to value. Along with NDS_INC it gives effect of NETMAP_VAL, examples: altval_ea : NDS_MAP_IDX charval : NDS_VAL8 charval_ea: NDS_MAP_IDX|NDS_VAL8 eaget : NDS_MAP_IDX|NDS_MAP_VAL|NDS_INC
- ida_merge.NDS_VAL8
use 8-bit values (==NETMAP_V8)
- ida_merge.NDS_INC
stored value is incremented (scalars only)
- ida_merge.NDS_UI_ND
UI: no need to show diffpos detail pane, MH_UI_NODETAILS, make sense if merge_node_helper_t is used
- class ida_merge.merge_node_helper_t
Bases:
object
- thisown
- print_entry_name(arg0: uchar, arg1: nodeidx_t, arg2: void *) str
print the name of the specified entry (to be used in print_diffpos_name)
- print_entry_details(arg0: qstrvec_t *, arg1: uchar, arg2: nodeidx_t, arg3: void *) None
print the details of the specified entry usually contains multiple lines, one for each attribute or detail. (to be used in print_diffpos_details)
- get_column_headers(arg0: qstrvec_t *, arg1: uchar, arg2: void *) None
get column headers for chooser (to be used in linear_diff_source_t::get_column_headers)
- is_mergeable(arg0: uchar, arg1: nodeidx_t) bool
filter: check if we should perform merging for given record
- get_netnode() netnode
return netnode to be used as source. If this function returns BADNODE netnode will be created using netnode name passed to create_nodeval_diff_source
- map_scalar(arg0: nodeidx_t *, arg1: void *, arg2: diff_source_idx_t, arg3: diff_source_idx_t) None
map scalar/string/buffered value
- map_string(arg0: str, arg1: void *, arg2: diff_source_idx_t, arg3: diff_source_idx_t) None
- refresh(arg0: uchar, arg1: void *) None
notify helper that some data was changed in the database and internal structures (e.g. caches) should be refreshed
- static append_eavec(s: str, prefix: str, eas: eavec_t const &) None
can be used by derived classes
- class ida_merge.merge_node_info_t(name: str, tag: uchar, nds_flags: int, node_helper: merge_node_helper_t = None)
Bases:
object
- thisown
- name: str
name of the array (label)
- tag: uchar
a tag used to access values in the netnode
- nds_flags: int
node value attributes (a combination of nds_flags_t)
- node_helper: merge_node_helper_t *
- ida_merge.create_nodeval_merge_handler(mhp: merge_handler_params_t, label: str, nodename: str, tag: uchar, nds_flags: int, node_helper: merge_node_helper_t = None, skip_empty_nodes: bool = True) merge_handler_t *
Create a merge handler for netnode scalar/string values
- Parameters:
mhp – merging parameters
label – handler short name (to be be appended to mhp.label)
nodename – netnode name
tag – a tag used to access values in the netnode
nds_flags – netnode value attributes (a combination of nds_flags_t)
skip_empty_nodes – do not create handler in case of empty netnode
- Returns:
diff source object (normally should be attahced to a merge handler)
- ida_merge.create_nodeval_merge_handlers(out: merge_handlers_t *, mhp: merge_handler_params_t, nodename: str, valdesc: merge_node_info_t, skip_empty_nodes: bool = True) None
Create a serie of merge handlers for netnode scalar/string values (call create_nodeval_merge_handler() for each member of VALDESC)
- Parameters:
out – [out] created handlers will be placed here
mhp – merging parameters
nodename – netnode name
valdesc – array of handler descriptions
skip_empty_nodes – do not create handlers for empty netnodes
- Returns:
diff source object (normally should be attahced to a merge handler)
- ida_merge.destroy_moddata_merge_handlers(data_id: int) None
- ida_merge.get_ea_diffpos_name(ea: ida_idaapi.ea_t) str
Get nice name for EA diffpos
- Parameters:
ea – diffpos