IDA C++ SDK 9.2
Loading...
Searching...
No Matches
diff3.hpp File Reference

3-way diff for anchored info More...

Go to the source code of this file.

Classes

struct  diff_range_t
 A range of the difference source. More...
struct  diff_region_t
 A difference region. More...
struct  diff_text_t
struct  diff_result_t
 A difference result. More...
class  diff_engine_t
 A difference engine. More...
class  diff2_engine_t
 A 2-way difference engine. More...
class  diff3_engine_t
 A 3-way difference engine. More...
struct  lcsdiff_res_part_t< T >
 difference result, stores vectors' items with action to be applied to construct Y from X More...
struct  lcsdiff_res_part_t< qstring >
class  lcsdiff_res_t< T >
 result More...
class  lcsdiff_t< T >
 Calculate difference between two vectors. More...
struct  txtdiff_printer_t
 Base class for forming "colored" string (in HTML, for example) More...
struct  strdiff_printer_t
 Calculate difference between two string vectors. More...

Typedefs

typedef ssize_t diff_degree_t
 A difference degree.
typedef qvector< diff_region_tdiff_regions_t
typedef qvector< diff_text_tdiff_texts_t

Enumerations

enum  diff_action_t { DIFF_NONE , DIFF_USE1 , DIFF_USE2 , DIFF_BOTH }
enum  diffpos_check_t { DIFFPOS_CHECK , DIFFPOS_FORWARD , DIFFPOS_BACKWARD }
enum  diff_source_idx_t { NONE_IDX = -1 , LOCAL_IDX = 0 , REMOTE_IDX = 1 , BASE_IDX = 2 }
 standard indexes into dbctx_ids[] and similar arrays More...
enum  lcsdiff_result_action_t { TDLA_EQ = 0 , TDLA_ADD , TDLA_SUB , TDLA_MOD }
 diff result actions, lcsdiff_t::diff lcsdiff_t::diff_mod More...

Functions

 DECLARE_TYPE_AS_MOVABLE (diff_range_t)
 DECLARE_TYPE_AS_MOVABLE (diff_region_t)
 DECLARE_TYPE_AS_MOVABLE (diff_text_t)
 DECLARE_DIFF_SOURCE_HELPERS (idaman) class diff_source_t
 A difference source.
enum merge_policy_t ENUM_SIZE (uint8)
diff_result_t perform_diff3 (diff_source_t *base, diff_source_t *src1, diff_source_t *src2)
 Perform 3-way difference.
qstrvec_t put_side_by_side (const char *const *headers, const diff_texts_t *const *linevecs, size_t n, int psbs_flags=0)
 DECLARE_TYPE_AS_MOVABLE (lcsdiff_res_part_t< qstrvec_t >)
 DECLARE_TYPE_AS_MOVABLE (lcsdiff_res_part_t< qstring >)

Detailed Description

3-way diff for anchored info

NOTE: this functionality is available in IDA Teams (not IDA Pro)

Since names, comments, functions, etc, are tied to addresses, we need this kind of diff engine. Other kinds of diff engines will be necessary too (for example: dirtrees, types, and text)

Typedef Documentation

◆ diff_degree_t

A difference degree.

Negative values are illegal. 0 means no difference. 1 means a difference. Bigger values mean more important differences, of another nature. INT_MAX is used for the situations where diffpos_t values are different. Example: when comparing instructions and data, 1 is used to denote differences at the operand type level, and 2 is used to denote differences between instructions and data: diff_degree("cmp eax, 20h", "db 83h, 0F8h, 20h") => 2 diff_degree("cmp eax, 20h", "cmp eax, 32") => 1 In the presence of the differences of higher degree the differences of lower degrees should be ignored.

◆ diff_regions_t

◆ diff_texts_t

Enumeration Type Documentation

◆ diff_action_t

Enumerator
DIFF_NONE 

unknown

DIFF_USE1 

use information from src1

DIFF_USE2 

use information from src2

DIFF_BOTH 

use information from both (conflict)

◆ diffpos_check_t

Enumerator
DIFFPOS_CHECK 

verify if the position is valid; if not, return the next valid position

DIFFPOS_FORWARD 

advance to the next valid position

DIFFPOS_BACKWARD 

back off to the previous valid position

◆ diff_source_idx_t

standard indexes into dbctx_ids[] and similar arrays

Enumerator
NONE_IDX 
LOCAL_IDX 
REMOTE_IDX 
BASE_IDX 

◆ lcsdiff_result_action_t

diff result actions, lcsdiff_t::diff lcsdiff_t::diff_mod

Enumerator
TDLA_EQ 

items are equal

TDLA_ADD 

added items

TDLA_SUB 

removed items

TDLA_MOD 

updated items (new content)

Function Documentation

◆ DECLARE_TYPE_AS_MOVABLE() [1/5]

DECLARE_TYPE_AS_MOVABLE ( diff_range_t )

◆ DECLARE_TYPE_AS_MOVABLE() [2/5]

DECLARE_TYPE_AS_MOVABLE ( diff_region_t )

◆ DECLARE_TYPE_AS_MOVABLE() [3/5]

DECLARE_TYPE_AS_MOVABLE ( diff_text_t )

◆ DECLARE_DIFF_SOURCE_HELPERS()

DECLARE_DIFF_SOURCE_HELPERS ( idaman )

A difference source.

This abstract class provides information that is necessary for comparisons. It can represent list of types, names, structs, enums. It can also represent the program addresses, which can be used to compare the attributes of the disassembly instructions, data, etc.

initialize diff source. this function is called immediately before starting to use the diff source. this is the right place to read info from the idb for diffing. doing it earlier (for example, in the diff_source_t ctr) is wrong because a diff_source_t of one kind may depend on a diff_source_t of another kind. For example, crefs_diff_source_t depends on the flags_diff_source_t. It makes to start diffing only after completing work with flags.

Note
in short, do not perform initialization in the ctr, do it here!

set new range of positions

get current range of positions

check the position, adjust and move it if requested if the requested position after DIFFPOS_FORWARD/DIFFPOS_BACKWARD does not exist, return a value outside of get_range()

compare two difference source at the specified position. returns difference degree. 0 - no difference. non-zero return value mean that the chunks differ. the bigger the number, more important are differences. for simple cases please use 1 to indicate differences.

find the next difference. this is an optional callback to speed up comparisons.

Parameters
dpos1pointer to position in the current source. out: position of the next difference.
dpos2pointer to position in the second source. out: position of the next difference.
src2pointer to the second source.
Returns
>= if implemented. the returned value is the difference degree, the same thing as returned by compare_chunks

print the name at the specified position. usually it is the position name or a similar short string.

print the details at the specified position. usually contains multiple lines, one for each attribute or detail.

Note
add details to OUT, do not clean the existing content

merge from another diff source. this optional callback provides functionality to copy information from SRC at position DPOS.

delete information at the specified position.

replace information at the position DPOS using SRC. the default implementation is provided below.

merge a region from another diff source. default implementation that uses one of merge_add/merge_del/merge_replace calls for each item in the region. A derived class may override this function to do that in a more optimal way

◆ ENUM_SIZE()

enum merge_policy_t ENUM_SIZE ( uint8 )

< do not merge

< merge, resolve conflicts using local data

< merge, resolve conflicts using remote data

< merge, do not resolve conflicts

< view mode: diff only, do not save the database

< view mode: visual diff only, do not save the database

◆ perform_diff3()

diff_result_t perform_diff3 ( diff_source_t * base,
diff_source_t * src1,
diff_source_t * src2 )

Perform 3-way difference.

Parameters
basethe base (common) source. if nullptr, then perform 2-way diff
src1the first source (and destination)
src2the second source

◆ put_side_by_side()

qstrvec_t put_side_by_side ( const char *const * headers,
const diff_texts_t *const * linevecs,
size_t n,
int psbs_flags = 0 )

◆ DECLARE_TYPE_AS_MOVABLE() [4/5]

DECLARE_TYPE_AS_MOVABLE ( lcsdiff_res_part_t< qstrvec_t > )

◆ DECLARE_TYPE_AS_MOVABLE() [5/5]

DECLARE_TYPE_AS_MOVABLE ( lcsdiff_res_part_t< qstring > )