11 #define MEGABYTE(x) (x << 20)
12 #define SAFE_STR_DEF(x, y) (x ? x : y)
13 #define SAFE_STR(x) (x ? x : "")
14 #define IF_STRCMP_S(ret, x, y) \
16 if ((x) != (y) && (!(x) || !(y))) { \
17 return !(y) ? 1 : -1; \
18 } else if ((x) && (y) && (ret = strcmp((x), (y)))) { \
134 #define rz_diff_error(f, ...) \
135 RZ_LOG_ERROR("rz-diff: error, " f, ##__VA_ARGS__)
137 #define rz_diff_error_ret(fail, f, ...) \
138 RZ_LOG_ERROR("rz-diff: error, " f, ##__VA_ARGS__); \
141 #define rz_diff_error_opt(x, o, f, ...) \
143 RZ_LOG_ERROR("rz-diff: error, " f, ##__VA_ARGS__); \
146 #define rz_diff_ctx_set(x, k, v) (x)->k = (v)
148 #define rz_diff_set_def(x, d, v) \
151 RZ_LOG_ERROR("rz-diff: error, invalid combination of arguments for '-%c' (expected " #d " but found something else)\n", c); \
157 #define rz_diff_ctx_set_def(x, k, d, v) \
159 if ((x)->k != (d)) { \
160 rz_diff_error_opt(x, DIFF_OPT_UNKNOWN, "invalid combination of arguments for '-%c' (expected " #d " but found something else)\n", c); \
165 #define rz_diff_ctx_set_val(x, k, d, v) \
167 if ((x)->k != (d)) { \
168 rz_diff_error_opt(x, DIFF_OPT_UNKNOWN, "invalid combination of arguments for '-%c' (expected " #d " but found something else)\n", c); \
173 #define rz_diff_ctx_set_unsigned(x, k, i) \
175 (x)->k = strtoull((i), NULL, 0); \
177 rz_diff_error_opt(x, DIFF_OPT_UNKNOWN, "argument must be > 0\n"); \
181 #define rz_diff_ctx_add_evar(x, o) \
183 char *copy = rz_str_new(o); \
184 if (!copy || !rz_list_append((x)->evars, copy)) { \
186 rz_diff_error_opt(x, DIFF_OPT_ERROR, "cannot add evar '%s' to list\n", o); \
190 #define rz_diff_ctx_set_dist(x, t) rz_diff_ctx_set_def(x, distance, DIFF_DISTANCE_UNKNOWN, t)
191 #define rz_diff_ctx_set_type(x, t) rz_diff_ctx_set_def(x, type, DIFF_TYPE_UNKNOWN, t)
192 #define rz_diff_ctx_set_mode(x, m) rz_diff_ctx_set_def(x, mode, DIFF_MODE_STANDARD, m)
193 #define rz_diff_ctx_set_opt(x, o) rz_diff_ctx_set_def(x, option, DIFF_OPT_UNKNOWN, o)
196 printf(
"Usage: rz-diff [options] <file0> <file1>\n");
201 " -a [arch] specify architecture plugin to use (x86, arm, ..)\n"
202 " -b [bits] specify register size for arch (16 (thumb), 32, 64, ..)\n"
203 " -d [algo] compute edit distance based on the choosen algorithm:\n"
204 " myers | Eugene W. Myers' O(ND) algorithm (no substitution)\n"
205 " leven | Levenshtein O(N^2) algorithm (with substitution)\n"
206 " -H hexadecimal visual mode\n"
207 " -h this help message\n"
210 " -v show version information\n"
211 " -e [k=v] set an evaluable config variable\n"
212 " -A compare virtual and physical addresses\n"
213 " -B run 'aaa' when loading the bin\n"
214 " -C disable colors\n"
215 " -T show timestamp information\n"
216 " -S [WxH] sets the width and height of the terminal for visual mode\n"
217 " -0 [cmd] input for file0 when option -t 'commands' is given.\n"
218 " the same value will be set for file1, if -1 is not set.\n"
219 " -1 [cmd] input for file1 when option -t 'commands' is given.\n"
220 " -t [type] compute the difference between two files based on its type:\n"
221 " bytes | compares raw bytes in the files (only for small files)\n"
222 " lines | compares text files\n"
223 " functions | compares functions found in the files\n"
224 " classes | compares classes found in the files\n"
225 " command | compares command output returned when executed in both files\n"
226 " | requires -0 <cmd> and -1 <cmd> is optional\n"
227 " entries | compares entries found in the files\n"
228 " fields | compares fields found in the files\n"
229 " graphs | compares 2 functions and outputs in graphviz/dot format\n"
230 " | requires -0 <fcn name|offset> and -1 <fcn name|offset> is optional\n"
231 " imports | compares imports found in the files\n"
232 " libraries | compares libraries found in the files\n"
233 " sections | compares sections found in the files\n"
234 " strings | compares strings found in the files\n"
235 " symbols | compares symbols found in the files\n"
236 " palette colors can be changed by adding the following lines\n"
237 " inside the $HOME/.rizinrc file\n"
238 " ec diff.unknown blue | offset color\n"
239 " ec diff.match green | match color\n"
240 " ec diff.unmatch red | mismatch color\n"
256 const char *algorithm =
NULL;
257 const char *screen =
NULL;
299 if (opt.
ind >= argc || (argc - opt.
ind) != 2) {
315 }
else if (
ctx->show_time) {
320 if (!strcmp(algorithm,
"myers")) {
322 }
else if (!strcmp(algorithm,
"leven")) {
330 if (!strcmp(
type,
"bytes")) {
332 }
else if (!strcmp(
type,
"lines")) {
334 }
else if (!strcmp(
type,
"functions")) {
337 }
else if (
ctx->input_b) {
342 }
else if (!strcmp(
type,
"classes")) {
344 }
else if (!strcmp(
type,
"command")) {
349 ctx->input_b =
ctx->input_a;
352 }
else if (!strcmp(
type,
"entries")) {
354 }
else if (!strcmp(
type,
"fields")) {
356 }
else if (!strcmp(
type,
"graphs")) {
359 }
else if (
ctx->input_a && !
ctx->input_b) {
360 ctx->input_b =
ctx->input_a;
364 }
else if (!strcmp(
type,
"imports")) {
366 }
else if (!strcmp(
type,
"libraries")) {
368 }
else if (!strcmp(
type,
"sections")) {
370 }
else if (!strcmp(
type,
"strings")) {
372 }
else if (!strcmp(
type,
"symbols")) {
378 const char *hp =
NULL;
379 if (!(hp = strchr(screen,
'x'))) {
384 if (width < 1 || width > 0xFFFF || height < 1 || height > 0xFFFF) {
412 goto rz_diff_io_open_end;
418 goto rz_diff_io_open_end;
424 goto rz_diff_io_open_end;
456 goto rz_diff_slurp_file_end;
461 goto rz_diff_slurp_file_end;
467 goto rz_diff_slurp_file_end;
476 goto rz_diff_slurp_file_end;
481 rz_diff_slurp_file_end:
492 double similarity = 0.0;
495 goto rz_diff_calculate_distance_bad;
499 goto rz_diff_calculate_distance_bad;
502 switch (
ctx->distance) {
505 rz_diff_error(
"failed to calculate distance with myers algorithm\n");
506 goto rz_diff_calculate_distance_bad;
511 rz_diff_error(
"failed to calculate distance with levenstein algorithm\n");
512 goto rz_diff_calculate_distance_bad;
517 goto rz_diff_calculate_distance_bad;
524 goto rz_diff_calculate_distance_bad;
527 pj_kd(pj,
"similarity", similarity);
528 pj_kn(pj,
"distance", distance);
533 printf(
"%.3f\n", similarity);
537 printf(
"similarity: %.3f\n", similarity);
538 printf(
"distance: %d\n", distance);
544 rz_diff_calculate_distance_bad:
564 goto rz_diff_load_file_with_core_fail;
575 goto rz_diff_load_file_with_core_fail;
580 goto rz_diff_load_file_with_core_fail;
585 goto rz_diff_load_file_with_core_fail;
591 goto rz_diff_load_file_with_core_fail;
594 if (rz_list_empty(bfile->
o->
maps)) {
606 rz_list_foreach (evars, it,
config) {
612 rz_diff_load_file_with_core_fail:
619 RzBinOptions opt = { 0 };
626 goto rz_diff_file_open_bad;
632 goto rz_diff_file_open_bad;
639 opt.obj_opts.elf_load_sections =
true;
640 opt.obj_opts.elf_checks_sections =
true;
641 opt.obj_opts.elf_checks_segments =
true;
647 goto rz_diff_file_open_bad;
656 rz_diff_file_open_bad:
668 #define rz_diff_file_get(df, n) ((df)->file->o->n)
888 return a->addr -
b->addr;
962 return b->type -
a->type;
967 switch (elem->
type) {
1275 char *output_a =
NULL;
1276 char *output_b =
NULL;
1305 bool result =
false;
1310 goto rz_diff_unified_files_bad;
1314 goto rz_diff_unified_files_bad;
1318 goto rz_diff_unified_files_bad;
1321 goto rz_diff_unified_files_bad;
1325 switch (
ctx->type) {
1361 goto rz_diff_unified_files_bad;
1365 goto rz_diff_unified_files_bad;
1371 goto rz_diff_unified_files_bad;
1379 goto rz_diff_unified_files_bad;
1387 rz_diff_unified_files_bad:
1414 bool success =
false;
1420 goto rz_diff_graphs_files_bad;
1425 goto rz_diff_graphs_files_bad;
1434 goto rz_diff_graphs_files_bad;
1439 goto rz_diff_graphs_files_bad;
1442 if (
ctx->analyze_all) {
1445 goto rz_diff_graphs_files_bad;
1449 goto rz_diff_graphs_files_bad;
1452 bool analyze_recursively =
rz_config_get_i(
a->core->config,
"analysis.calls");
1455 goto rz_diff_graphs_files_bad;
1459 goto rz_diff_graphs_files_bad;
1464 rz_diff_error(
"cannot diff graphs with inputs '%s' with '%s'\n",
ctx->input_a,
ctx->input_b);
1465 goto rz_diff_graphs_files_bad;
1471 goto rz_diff_graphs_files_bad;
1475 goto rz_diff_graphs_files_bad;
1479 goto rz_diff_graphs_files_bad;
1486 rz_diff_graphs_files_bad:
1500 static inline int diff_hexdump_partial(
DiffHexView *hview,
int hexlen,
int lp,
int lsize,
const ut8 *bytes_a,
const ut8 *bytes_b,
ut64 address_a,
ut64 address_b,
ut64 size_a,
ut64 size_b,
ut64 pos,
ssize_t read_a,
ssize_t read_b,
ssize_t skip_a,
ssize_t skip_b) {
1508 #define P(x) (IS_PRINTABLE(x) ? x : '.')
1509 #define printline(fmt, ...) snprintf(line + lp, RZ_MAX(lsize - lp, 0), fmt, ##__VA_ARGS__)
1512 for (
i = 0;
i < hexlen &&
i < read_a; ++
i) {
1513 if (
pos +
i >= size_a ||
pos +
i < skip_a) {
1517 }
else if (i < read_b && pos + i >= skip_b) {
1524 lp +=
printline(
"%s%02x%s ", unmatch, bytes_a[
pos +
i], reset);
1530 lp += (hexlen -
i) * 3;
1535 for (
i = 0;
i < hexlen &&
i < read_a; ++
i) {
1536 if (
pos +
i >= size_a ||
pos +
i < skip_a) {
1540 }
else if (i < read_b && pos + i >= skip_b) {
1584 #define printline(fmt, ...) snprintf(line + lp, RZ_MAX(lsize - lp, 0), fmt, ##__VA_ARGS__)
1585 lp =
diff_hexdump_partial(hview, hexlen, 0, lsize, buffer_a, buffer_b, address_a, address_b, hview->
size_a, hview->
size_b,
pos, read_a, read_b, skip_a, skip_b);
1587 lp =
diff_hexdump_partial(hview, hexlen, lp, lsize, buffer_b, buffer_a, address_b, address_a, hview->
size_b, hview->
size_a,
pos, read_b, read_a, skip_b, skip_a);
1633 ssize_t read_a = 0, read_b = 0;
1635 int shift = 8, offlen = 16, xpos = 0;
1650 const char *toolbar =
NULL;
1665 const char *
p =
NULL;
1666 const char *file_a = io_a->
filename;
1667 const char *file_b = io_b->
filename;
1715 for (
ut64 h = 0,
pos = 0;
h < max_rows; ++
h) {
1724 case DIFF_HEX_32: toolbar =
" 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F";
break;
1725 case DIFF_HEX_16: toolbar =
" 0 1 2 3 4 5 6 7 8 9 A B C D E F";
break;
1726 default: toolbar =
" 0 1 2 3 4 5 6 7";
break;
1752 "%s1 2%s -/+0x%x | "
1753 "%sZ A%s file0 +/-1 | "
1754 "%sC D%s file1 +/-1 | "
1755 "%sG B%s end/begin | "
1756 "%sN M%s next/prev | "
1761 , legenda, reset, (1 <<
shift) * max_rows
1766 , legenda, arrow_down, arrow_up, reset, 1 <<
shift
1767 , legenda, arrow_left, arrow_right, reset
1778 snprintf(
line, lsize,
"%sHelp page%s\n", legenda, reset);
1782 snprintf(
line, lsize,
"%s1 2%s increase/decrease the offsets by 0x%x\n", legenda, reset, (1 <<
shift) * (
height - 2));
1786 snprintf(
line, lsize,
"%sZ A%s increase/decrease the offset of the file0 by 1\n", legenda, reset);
1790 snprintf(
line, lsize,
"%sC D%s increase/decrease the offset of the file1 by 1\n", legenda, reset);
1794 snprintf(
line, lsize,
"%sN M%s next/previous difference\n", legenda, reset);
1798 snprintf(
line, lsize,
"%sG B%s seek to end/begin\n", legenda, reset);
1802 snprintf(
line, lsize,
"%s9%s sets both offsets to a common value\n", legenda, reset);
1806 snprintf(
line, lsize,
"%s0%s shows/hides the column legenda\n", legenda, reset);
1810 snprintf(
line, lsize,
"%s%s %s%s increase/decrease both offsets by %u\n", legenda, arrow_down, arrow_up, reset, 1 <<
shift);
1814 snprintf(
line, lsize,
"%s%s %s%s increase/decrease both offsets by 1\n", legenda, arrow_left, arrow_right, reset);
1818 snprintf(
line, lsize,
"%s:%s seek at offset (relative via +-)\n", legenda, reset);
1822 snprintf(
line, lsize,
"%s3%s file0 seek at offset (relative via +-)\n", legenda, reset);
1826 snprintf(
line, lsize,
"%s4%s file1 seek at offset (relative via +-)\n", legenda, reset);
1855 char *
value =
visual_prompt(hview,
" you can input an absolute offset or a relative offset by adding the prefix + or -\n offset");
1862 st64 number = strtoll((*
p ==
'+' || *
p ==
'-') ?
p + 1 :
p,
NULL, 0);
1866 }
else if (*
p ==
'+') {
1878 char *
value =
visual_prompt(hview,
" you can input an absolute offset or a relative offset by adding the prefix + or -\n offset");
1885 st64 number = strtoll((*
p ==
'+' || *
p ==
'-') ?
p + 1 :
p,
NULL, 0);
1892 }
else if (*
p ==
'+') {
1916 ssize_t read_a = 0, read_b = 0;
1917 ssize_t minread = 0, minseek = 0;
1929 if (read_a < 1 || read_b < 1) {
1932 minread =
RZ_MIN(read_a, read_b);
1933 if (minread != minsize && !memcmp(hview->
buffer_a, hview->
buffer_b, minread)) {
1937 }
else if (minread == minsize && !memcmp(hview->
buffer_a, hview->
buffer_b, minsize)) {
1938 address_a += minsize;
1939 address_b += minsize;
1942 minread =
RZ_MIN(minsize, minread);
1944 for (
ssize_t i = 0;
i < minread;
i += minseek) {
1950 address_a += minseek;
1951 address_b += minseek;
1974 ssize_t read_a = 0, read_b = 0;
1981 if (address_a < 0) {
1984 if (address_b < 0) {
1989 if (read_a < 1 || read_b < 1) {
1995 if (address_a == 0 || address_b == 0) {
2033 bool draw_visual =
true;
2048 goto rz_diff_hex_visual_fail;
2056 goto rz_diff_hex_visual_fail;
2063 goto rz_diff_hex_visual_fail;
2068 goto rz_diff_hex_visual_fail;
2074 rz_diff_error(
"invalid screen size; use -S WxH to define the sizes.\n");
2075 goto rz_diff_hex_visual_fail;
2081 rz_diff_error(
"cannot allocate canvas. try to use -S WxH to define the sizes.\n");
2082 goto rz_diff_hex_visual_fail;
2088 canvas->
color =
true;
2096 goto rz_diff_hex_visual_fail;
2101 goto rz_diff_hex_visual_fail;
2106 goto rz_diff_hex_visual_fail;
2136 if (
show_help && (pressed ==
'q' || pressed ==
'Q')) {
2227 draw_visual =
false;
2242 rz_diff_hex_visual_fail:
2255 bool success =
false;
2259 switch (
ctx.option) {
2290 return success ? 0 : 1;
const aarch64_field fields[]
static RZ_NULLABLE RzILOpBitVector * shift(RzILOpBitVector *val, RZ_NULLABLE RzILOpBool **carry_out, arm_shifter type, RZ_OWN RzILOpBitVector *dist)
RZ_API RzBinPlugin * rz_bin_file_cur_plugin(RzBinFile *bf)
RZ_API RzBin * rz_bin_new(void)
RZ_API RzBinFile * rz_bin_open_io(RzBin *bin, RzBinOptions *opt)
RZ_API void rz_bin_options_init(RzBinOptions *opt, int fd, ut64 baseaddr, ut64 loadaddr, bool patch_relocs)
RZ_API void rz_bin_free(RzBin *bin)
static RzList * libs(RzBinFile *bf)
static RzList * classes(RzBinFile *bf)
RzList * entries(RzBinFile *bf)
RzList * symbols(RzBinFile *bf)
RzList * imports(RzBinFile *bf)
RzList * sections(RzBinFile *bf)
RZ_API const RzList * rz_bin_object_get_strings(RZ_NONNULL RzBinObject *obj)
Get list of RzBinString representing the strings identified in the binary object.
RZ_API bool rz_core_analysis_function_add(RzCore *core, const char *name, ut64 addr, bool analyze_recursively)
RZ_API bool rz_core_analysis_everything(RzCore *core, bool experimental, char *dh_orig)
RZ_API void rz_cons_canvas_print(RzConsCanvas *c)
RZ_API void rz_cons_canvas_write(RzConsCanvas *c, const char *s)
RZ_API bool rz_cons_canvas_gotoxy(RzConsCanvas *c, int x, int y)
RZ_API void rz_cons_canvas_fill(RzConsCanvas *c, int x, int y, int w, int h, char ch)
RZ_API void rz_cons_canvas_clear(RzConsCanvas *c)
RZ_API RzConsCanvas * rz_cons_canvas_new(int w, int h)
RZ_API void rz_cons_canvas_box(RzConsCanvas *c, int x, int y, int w, int h, const char *color)
RZ_API void rz_cons_canvas_free(RzConsCanvas *c)
RZ_API int rz_core_bin_update_arch_bits(RzCore *r)
RZ_API void rz_core_parse_rizinrc(RzCore *r)
RZ_API RZ_BORROW RzCoreFile * rz_core_file_open(RZ_NONNULL RzCore *r, RZ_NONNULL const char *file, int flags, ut64 loadaddr)
Tries to open the file as is, otherwise tries as is a compilation of files.
RZ_API bool rz_core_bin_load(RZ_NONNULL RzCore *r, RZ_NULLABLE const char *filenameuri, ut64 baddr)
RZ_API char * rz_core_cmd_str(RzCore *core, const char *cmd)
Executes a rizin command and returns the stdout as a string.
RZ_API ut64 rz_config_get_i(RzConfig *cfg, RZ_NONNULL const char *name)
RZ_API bool rz_config_eval(RZ_NONNULL RzConfig *cfg, RZ_NONNULL const char *str)
Sets the configuration variable and its value passed as argument.
RZ_API RzConfigNode * rz_config_set(RzConfig *cfg, RZ_NONNULL const char *name, const char *value)
RZ_API RzConfigNode * rz_config_set_i(RzConfig *cfg, RZ_NONNULL const char *name, const ut64 i)
RZ_API RzConfigNode * rz_config_set_b(RzConfig *cfg, RZ_NONNULL const char *name, bool value)
RZ_API int rz_cons_get_size(int *rows)
RZ_API bool rz_cons_enable_mouse(const bool enable)
RZ_API RzCons * rz_cons_singleton(void)
RZ_API void rz_cons_clear_line(int std_err)
RZ_API void rz_cons_set_interactive(bool x)
RZ_API int rz_cons_printf(const char *format,...)
RZ_API void rz_cons_goto_origin_reset(void)
RZ_API void rz_cons_show_cursor(int cursor)
RZ_API void rz_cons_flush(void)
RZ_API bool rz_cons_is_breaked(void)
RZ_API void rz_cons_gotoxy(int x, int y)
RZ_API void rz_cons_clear(void)
RZ_API RzCons * rz_cons_free(void)
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
RZ_API RZ_OWN RzDiff * rz_diff_generic_new(RZ_BORROW const void *a, ut32 a_size, RZ_BORROW const void *b, ut32 b_size, RZ_NONNULL RzDiffMethods *methods)
Returns the structure needed to diff arrays of user defined types.
RZ_API ut32 rz_diff_hash_data(RZ_NULLABLE const ut8 *buffer, ut32 size)
Calculates the hash of any given data.
RZ_API RZ_OWN RzDiff * rz_diff_lines_new(RZ_BORROW const char *a, RZ_BORROW const char *b, RZ_NULLABLE RzDiffIgnoreLine ignore)
Returns the structure needed to diff lines.
RZ_API RZ_OWN RzDiff * rz_diff_bytes_new(RZ_BORROW const ut8 *a, ut32 a_size, RZ_BORROW const ut8 *b, ut32 b_size, RZ_NULLABLE RzDiffIgnoreByte ignore)
Returns the structure needed to diff buffers of ut8.
RZ_API void rz_diff_free(RZ_NULLABLE RzDiff *diff)
frees the diff structure
RZ_API bool rz_diff_myers_distance(RZ_NONNULL const ut8 *a, ut32 la, RZ_NONNULL const ut8 *b, ut32 lb, RZ_NULLABLE ut32 *distance, RZ_NULLABLE double *similarity)
Calculates the distance between two buffers using the Myers algorithm.
RZ_API bool rz_diff_levenstein_distance(RZ_NONNULL const ut8 *a, ut32 la, RZ_NONNULL const ut8 *b, ut32 lb, RZ_NULLABLE ut32 *distance, RZ_NULLABLE double *similarity)
Calculates the distance between two buffers using the Levenshtein algorithm.
RZ_API RzFlagItem * rz_flag_get(RzFlag *f, const char *name)
RZ_API bool rz_core_gdiff_function_2_files(RzCore *c, RzCore *c2, ut64 addr, ut64 addr2)
Calculates basic block differences of 2 functions within 2 files.
RZ_API bool rz_core_diff_show_function(RzCore *core, RzCore *core2, ut64 addr1, bool json)
Generate a json or dot output of the graph and its data.
RZ_API void rz_core_diff_show(RzCore *c, RzCore *c2, bool json)
RZ_API bool rz_core_gdiff_2_files(RzCore *c, RzCore *c2)
Calculates basic block differences of all functions within 2 files.
unsigned char match[65280+2]
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
static int compare(const char *s1, const char *s2, int l1, int l2)
RZ_API void rz_core_free(RzCore *c)
RZ_API RzCore * rz_core_new(void)
static void rz_diff_get_colors(DiffColors *dcolors, RzConsContext *ctx, bool colors)
static int import_compare(const RzBinImport *a, const RzBinImport *b)
static void rz_diff_show_help(bool usage_only)
static RzDiff * rz_diff_symbols_new(DiffFile *dfile_a, DiffFile *dfile_b, bool compare_addr)
static ut32 libs_hash(const char *elem)
static const void * rz_diff_list_elem_at(const RzList *array, ut32 index)
#define rz_diff_error_opt(x, o, f,...)
static int seek_min_value(DiffHexView *hview)
static ut32 string_hash_addr(const RzBinString *elem)
static void prompt_offset_and_seek(DiffHexView *hview, ut64 minseek)
static ut32 field_hash_addr(const RzBinField *elem)
static char * execute_command(const char *command, const char *filename, DiffContext *ctx)
static bool rz_diff_calculate_distance(DiffContext *ctx)
static DiffIO * rz_diff_io_open(const char *file)
static RzDiff * rz_diff_libraries_new(DiffFile *dfile_a, DiffFile *dfile_b)
struct diff_screen_t DiffScreen
static ut32 symbol_hash_addr(const RzBinSymbol *elem)
static bool rz_diff_hex_visual(DiffContext *ctx)
#define rz_diff_ctx_set_dist(x, t)
#define rz_diff_error_ret(fail, f,...)
static RzDiff * rz_diff_entries_new(DiffFile *dfile_a, DiffFile *dfile_b)
static int string_compare_addr(const RzBinString *a, const RzBinString *b)
static int diff_hexdump_partial(DiffHexView *hview, int hexlen, int lp, int lsize, const ut8 *bytes_a, const ut8 *bytes_b, ut64 address_a, ut64 address_b, ut64 size_a, ut64 size_b, ut64 pos, ssize_t read_a, ssize_t read_b, ssize_t skip_a, ssize_t skip_b)
static RzCoreFile * rz_diff_load_file_with_core(const char *filename, const char *architecture, ut32 arch_bits, RzList *evars, bool colors)
static bool rz_diff_file_open(DiffFile *dfile, const char *filename)
static void symbol_stringify_addr(const RzBinSymbol *elem, RzStrBuf *sb)
RZ_API int rz_main_rz_diff(int argc, const char **argv)
static ut32 section_hash(const RzBinSection *elem)
static int field_compare_addr(const RzBinField *a, const RzBinField *b)
static void libs_stringify(const char *elem, RzStrBuf *sb)
#define rz_diff_ctx_set_def(x, k, d, v)
#define rz_diff_set_def(x, d, v)
static int symbol_compare_addr(const RzBinSymbol *a, const RzBinSymbol *b)
static ut32 class_hash_addr(const RzBinClass *elem)
static int len_draw_hexdump(DiffHexView *hview)
#define rz_diff_ctx_set_mode(x, m)
static RzDiff * rz_diff_sections_new(DiffFile *dfile_a, DiffFile *dfile_b, bool compare_addr)
static void import_stringify(const RzBinImport *elem, RzStrBuf *sb)
static char * visual_prompt(DiffHexView *hview, const char *prompt)
struct diff_function_t DiffFunction
#define SAFE_STR_DEF(x, y)
static ut32 field_hash(const RzBinField *elem)
static bool rz_diff_graphs_files(DiffContext *ctx)
static RzDiff * rz_diff_command_new(DiffContext *ctx)
static int symbol_compare(const RzBinSymbol *a, const RzBinSymbol *b)
static int libs_compare(const char *a, const char *b)
static ut32 string_hash(const RzBinString *elem)
static void entry_stringify(const RzBinAddr *elem, RzStrBuf *sb)
enum diff_hex_len_t DiffHexLen
struct diff_context_t DiffContext
@ DIFF_DISTANCE_LEVENSHTEIN
static ut32 entry_hash(const RzBinAddr *elem)
static void rz_diff_file_close(DiffFile *file)
static void rz_diff_parse_arguments(int argc, const char **argv, DiffContext *ctx)
static RzDiff * rz_diff_fields_new(DiffFile *dfile_a, DiffFile *dfile_b, bool compare_addr)
static RzDiff * rz_diff_imports_new(DiffFile *dfile_a, DiffFile *dfile_b)
static int section_compare(const RzBinSection *a, const RzBinSection *b)
static int class_compare(const RzBinClass *a, const RzBinClass *b)
#define rz_diff_error(f,...)
struct diff_colors_t DiffColors
static void section_stringify(const RzBinSection *elem, RzStrBuf *sb)
static void class_stringify(const RzBinClass *elem, RzStrBuf *sb)
static int seek_min_shift(DiffHexView *hview)
static void rz_diff_io_close(DiffIO *dio)
static int entry_compare(const RzBinAddr *a, const RzBinAddr *b)
static bool rz_diff_draw_tui(DiffHexView *hview, bool show_help)
static int field_compare(const RzBinField *a, const RzBinField *b)
#define IF_STRCMP_S(ret, x, y)
static int class_compare_addr(const RzBinClass *a, const RzBinClass *b)
static int section_compare_addr(const RzBinSection *a, const RzBinSection *b)
static int offset_len(DiffHexView *hview)
struct diff_hex_view_t DiffHexView
static ut32 section_hash_addr(const RzBinSection *elem)
static ut32 class_hash(const RzBinClass *elem)
static void find_prev_diff(DiffHexView *hview, ut64 seek)
static bool rz_diff_unified_files(DiffContext *ctx)
static int string_compare(const RzBinString *a, const RzBinString *b)
static void class_stringify_addr(const RzBinClass *elem, RzStrBuf *sb)
#define rz_diff_file_get(df, n)
static ut32 symbol_hash(const RzBinSymbol *elem)
static bool convert_offset_from_input(RzCore *core, const char *input, ut64 *offset)
static void diff_hexdump_line(DiffHexView *hview, DiffHexLen hlen, ut64 pos, ssize_t read_a, ssize_t read_b, ssize_t skip_a, ssize_t skip_b)
static RzBinFile * core_get_file(RzCoreFile *cfile)
static void section_stringify_addr(const RzBinSection *elem, RzStrBuf *sb)
#define rz_diff_ctx_add_evar(x, o)
static void string_stringify_addr(const RzBinString *elem, RzStrBuf *sb)
static void field_stringify(const RzBinField *elem, RzStrBuf *sb)
static RzDiff * rz_diff_strings_new(DiffFile *dfile_a, DiffFile *dfile_b, bool compare_addr)
static void prompt_offset_and_seek_file(DiffHexView *hview, ut64 minseek, bool is_file0)
static void rz_diff_resize_buffer(DiffHexView *hview)
#define rz_diff_ctx_set_opt(x, o)
#define rz_diff_ctx_set_unsigned(x, k, i)
static bool rz_diff_is_file(const char *file)
static RzDiff * rz_diff_classes_new(DiffFile *dfile_a, DiffFile *dfile_b, bool compare_addr)
static void find_next_diff(DiffHexView *hview, ut64 seek)
static void string_stringify(const RzBinString *elem, RzStrBuf *sb)
static void symbol_stringify(const RzBinSymbol *elem, RzStrBuf *sb)
static void field_stringify_addr(const RzBinField *elem, RzStrBuf *sb)
#define rz_diff_ctx_set_type(x, t)
static ut32 import_hash(const RzBinImport *elem)
static ut8 * rz_diff_slurp_file(const char *file, size_t *size)
struct diff_file_t DiffFile
#define printline(fmt,...)
static int show_help(const char *argv0, int line)
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
RZ_API void rz_list_sort(RZ_NONNULL RzList *list, RZ_NONNULL RzListComparator cmp)
Sorts via merge sort or via insertion sort a list.
RZ_API RZ_BORROW void * rz_list_get_n(RZ_NONNULL const RzList *list, ut32 n)
Returns the N-th element of the list.
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
RZ_API int rz_core_loadlibs(RzCore *core, int where)
void * realloc(void *ptr, size_t size)
void * malloc(size_t size)
RZ_API void rz_line_set_prompt(const char *prompt)
static static fork const void static count static fd const char const char static newpath char char argv
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
#define RZ_BIN_ENTRY_TYPE_PREINIT
#define RZ_BIN_ENTRY_TYPE_TLS
#define RZ_BIN_ENTRY_TYPE_FINI
#define RZ_BIN_ENTRY_TYPE_INIT
#define RZ_BIN_ENTRY_TYPE_PROGRAM
#define RZ_BIN_TYPE_UNKNOWN_STR
#define RZ_BIN_BIND_UNKNOWN_STR
#define RZ_BIN_ENTRY_TYPE_MAIN
void(* RzConsEvent)(void *)
#define Color_RESET_TERMINAL
const void *(* RzDiffMethodElemAt)(RZ_BORROW const void *array, ut32 index)
ut32(* RzDiffMethodElemHash)(RZ_BORROW const void *elem)
void(* RzDiffMethodStringify)(RZ_BORROW const void *elem, RZ_BORROW RzStrBuf *sb)
int(* RzDiffMethodCompare)(RZ_BORROW const void *a_elem, RZ_BORROW const void *b_elem)
RZ_API bool rz_file_is_directory(const char *str)
RZ_API void rz_getopt_init(RzGetopt *go, int argc, const char **argv, const char *ostr)
RZ_API int rz_getopt_next(RzGetopt *opt)
RZ_API ut64 rz_io_desc_size(RzIODesc *desc)
RZ_API void rz_io_free(RzIO *io)
RZ_API void rz_io_bind(RzIO *io, RzIOBind *bnd)
RZ_API RzIODesc * rz_io_open_nomap(RzIO *io, const char *uri, int flags, int mode)
RZ_API int rz_io_pread_at(RzIO *io, ut64 paddr, ut8 *buf, int len)
RZ_API RzIO * rz_io_new(void)
RZ_API bool rz_io_desc_close(RzIODesc *desc)
int(* RzListComparator)(const void *value, const void *list_data)
RZ_API int rz_main_version_print(const char *program)
RZ_API int rz_num_is_valid_input(RzNum *num, const char *input_value)
RZ_API ut64 rz_num_get_input_value(RzNum *num, const char *input_value)
RZ_API PJ * pj_end(PJ *j)
RZ_API const char * pj_string(PJ *pj)
RZ_API void pj_free(PJ *j)
RZ_API PJ * pj_kn(PJ *j, const char *k, ut64 n)
RZ_API PJ * pj_kd(PJ *j, const char *k, double d)
RZ_API const char * rz_str_trim_head_ro(const char *str)
RZ_API const char * rz_strbuf_setf(RzStrBuf *sb, const char *fmt,...) RZ_PRINTF_CHECK(2
RZ_API int rz_sys_usleep(int usecs)
Sleep for usecs microseconds.
static void * rz_pvector_at(const RzPVector *vec, size_t index)
const char * architecture
XX curplugin == o->plugin.
RzDiffMethodElemAt elem_at
can be either be an element of A or B
struct rz_io_desc_t * desc
RZ_API RZ_OWN char * rz_diff_unified_text(RZ_NONNULL RzDiff *diff, RZ_NULLABLE const char *from, RZ_NULLABLE const char *to, bool show_time, bool color)
Produces a diff output with A and B inputs presented immediately adjacent to each other.
RZ_API RZ_OWN PJ * rz_diff_unified_json(RZ_NONNULL RzDiff *diff, RZ_NULLABLE const char *from, RZ_NULLABLE const char *to, bool show_time)
Produces a diff output to convert A in B in a JSON format.
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)
int read(izstream &zs, T *x, Items items)