26 rz_list_foreach (fa->
bbs,
iter, bb) {
29 rz_list_foreach (fb->
bbs,
iter, bb) {
58 rz_list_foreach (fa->
bbs,
iter, bb) {
64 rz_list_foreach (fb->
bbs,
iter, bb) {
100 for (
i = 0;
i < 2;
i++) {
102 rz_list_foreach_safe (cores[
i]->analysis->fcns,
iter, iter2, fcn) {
103 if (!strncmp(fcn->
name,
"str.", 4)) {
108 rz_list_foreach (cores[
i]->analysis->fcns,
iter, fcn) {
109 rz_list_foreach (fcn->
bbs, iter2, bb) {
114 rz_list_foreach (cores[
i]->analysis->fcns,
iter, fcn) {
125 int digits,
ut64 addr2,
const char *name2,
ut32 size2,
126 double dist,
bool bare,
bool color) {
155 maxnamelen,
name, digits,
size,
addr,
type,
prefix, dist,
suffix, addr2,
156 digits, size2, name2);
178 eprintf(
"cannot alocate json\n");
184 rz_list_foreach (fcns,
iter,
f) {
185 if (
f->name && (
len = strlen(
f->name)) > maxnamelen) {
193 rz_list_foreach (fcns,
iter,
f) {
194 if (
f->name && (
len = strlen(
f->name)) > maxnamelen) {
201 while (maxsize > 9) {
207 if (rz_list_empty(fcns)) {
208 eprintf(
"functions list is empty. analyze the binary first\n");
214 rz_list_foreach (fcns,
iter,
f) {
218 switch (
f->diff->type) {
231 double dist =
f->diff->dist;
233 pj_kd(pj,
"distance",
f->diff->dist);
234 pj_ks(pj,
"type", dist >= 1.0 ?
"MATCH" : (dist >= 0.5 ?
"SIMILAR" :
"UNMATCH"));
236 pj_ko(pj,
"original");
237 pj_ks(pj,
"name",
f->name);
238 pj_kn(pj,
"addr",
f->addr);
243 pj_ko(pj,
"modified");
244 pj_ks(pj,
"name",
f->diff->name);
245 pj_kn(pj,
"addr",
f->diff->addr);
246 pj_kn(pj,
"size",
f->diff->size);
252 f->diff->addr,
f->diff->name,
f->diff->size,
253 f->diff->dist, bare,
color);
260 rz_list_foreach (fcns,
iter,
f) {
267 pj_kd(pj,
"distance", 0.0);
268 pj_ks(pj,
"type",
"NEW");
270 pj_ko(pj,
"original");
271 pj_ks(pj,
"name",
f->name);
272 pj_kn(pj,
"addr",
f->addr);
280 printf(
"original not matched:");
288 if (!json && !ignore) {
296 rz_list_foreach (fcns,
iter,
f) {
303 pj_kd(pj,
"distance", 0.0);
304 pj_ks(pj,
"type",
"NEW");
306 pj_ko(pj,
"modified");
307 pj_ks(pj,
"name",
f->name);
308 pj_kn(pj,
"addr",
f->addr);
316 printf(
"modified not matched:");
329 }
else if (!ignore) {
343 return bbi->
diff->
dist >= 0.5 ?
"yellow" :
"red";
351 bool current = rz_analysis_block_contains(bbi, core->
offset);
352 if (current && color_current) {
354 printf(
"\t[fillcolor=gray style=filled shape=box];\n");
359 char addr_a[32], addr_b[32];
363 int is_json = pj !=
NULL;
370 const char *norig = fcn->
name ? fcn->
name : addr_a;
373 rz_list_foreach (fcn->
bbs,
iter, bbi) {
383 if (bbi->
fail != -1) {
388 pj_k(pj,
"switchop");
391 pj_kn(pj,
"defval",
op->def_val);
392 pj_kn(pj,
"maxval",
op->max_val);
393 pj_kn(pj,
"minval",
op->min_val);
398 rz_list_foreach (
op->cases, case_iter, case_op) {
433 "asm.cmt.right",
"asm.lines.fcn",
"asm.bytes",
"asm.comments",
NULL);
450 if (!modified || !strcmp(original, modified)) {
455 goto graph_construct_nodes_is_same;
465 "color=\"black\", fontname=\"%s\","
466 " label=\"%s\", URL=\"%s/0x%08" PFMT64x "\"]\n",
467 bbi->
addr, fillcolor, font, diffstr, fcn->
name,
473 graph_construct_nodes_is_same:
478 "color=\"black\", fontname=\"%s\","
479 " label=\"%s\", URL=\"%s/0x%08" PFMT64x "\"]\n",
480 bbi->
addr, fillcolor, font, original, fcn->
name, bbi->
addr);
494 const char *pal_jump =
"#0037da";
495 const char *pal_fail =
"#c50f1f";
496 const char *pal_true =
"#13a10e";
498 rz_list_foreach (fcn->
bbs,
iter, bbi) {
524 caseop->
addr, caseop->
jump, pal_fail);
540 free(fcn_name_escaped);
590 if (!gv_edge || !*gv_edge) {
591 gv_edge =
"arrowhead=\"normal\"";
593 if (!gv_node || !*gv_node) {
594 gv_node =
"fillcolor=gray style=filled shape=box";
596 if (!gv_spline || !*gv_spline) {
597 gv_spline =
"splines=\"ortho\"";
600 "\tgraph [bgcolor=azure fontsize=8 fontname=\"%s\" %s];\n"
603 font, gv_spline, gv_node, gv_edge);
612 if (nodes < 1 && !json) {
RZ_API size_t rz_analysis_diff_fingerprint_fcn(RzAnalysis *analysis, RzAnalysisFunction *fcn)
RZ_API int rz_analysis_diff_fingerprint_bb(RzAnalysis *analysis, RzAnalysisBlock *bb)
RZ_API int rz_analysis_diff_fcn(RzAnalysis *analysis, RzList *fcns1, RzList *fcns2)
RZ_API RzAnalysisFunction * rz_analysis_get_function_at(RzAnalysis *analysis, ut64 addr)
RZ_API ut64 rz_analysis_function_linear_size(RzAnalysisFunction *fcn)
RZ_API ut64 rz_analysis_function_realsize(const RzAnalysisFunction *fcn)
RZ_API bool rz_analysis_function_delete(RzAnalysisFunction *fcn)
RZ_API RzList * rz_analysis_get_fcns(RzAnalysis *analysis)
lsl lsr asr ror lsl lsr asr ror lsl lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror c2
RZ_API char * rz_core_cmd_strf(RzCore *core, const char *fmt,...)
RZ_API ut64 rz_config_get_i(RzConfig *cfg, RZ_NONNULL const char *name)
RZ_API bool rz_config_get_b(RzConfig *cfg, RZ_NONNULL const char *name)
RZ_API RzConfigNode * rz_config_set_i(RzConfig *cfg, RZ_NONNULL const char *name, const ut64 i)
RZ_API RZ_BORROW const char * rz_config_get(RzConfig *cfg, RZ_NONNULL const char *name)
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
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 void rz_diff_free(RZ_NULLABLE RzDiff *diff)
frees the diff structure
RZ_API int rz_core_print_disasm_json(RzCore *core, ut64 addr, ut8 *buf, int nb_bytes, int nb_opcodes, PJ *pj)
RZ_API const char * rz_analysis_fcntype_tostring(int type)
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.
static int graph_construct_nodes(RzCore *core, RzCore *core2, RzAnalysisFunction *fcn, PJ *pj)
static int draw_graph_nodes(RzCore *core, RzCore *core2, RzAnalysisFunction *fcn, PJ *pj)
RZ_API bool rz_core_gdiff_function_1_file(RzCore *c, ut64 addr, ut64 addr2)
Calculates basic block differences of 2 functions within the same file.
static void diffrow(ut64 addr, const char *name, ut32 size, int maxnamelen, int digits, ut64 addr2, const char *name2, ut32 size2, double dist, bool bare, bool color)
static const char * diff_color(RzAnalysisBlock *bbi)
static int graph_construct_edges(RzCore *core, RzAnalysisFunction *fcn)
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.
static void print_color_node(RzCore *core, RzAnalysisBlock *bbi)
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 suffix[65536]
unsigned short prefix[65536]
RZ_API void rz_config_hold_restore(RzConfigHold *h)
Restore whatever config options were previously saved in h.
RZ_API RzConfigHold * rz_config_hold_new(RzConfig *cfg)
Create an opaque object to save/restore some configuration options.
RZ_API bool rz_config_hold_i(RzConfigHold *h,...)
Save the current values of a list of config options that have integer values.
RZ_API void rz_config_hold_free(RzConfigHold *h)
Free a RzConfigHold object h.
RZ_API void Ht_() free(HtName_(Ht) *ht)
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
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 RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
void * malloc(size_t size)
#define RZ_ANALYSIS_DIFF_THRESHOLD
@ RZ_ANALYSIS_DIFF_TYPE_MATCH
@ RZ_ANALYSIS_DIFF_TYPE_UNMATCH
@ RZ_ANALYSIS_DIFF_TYPE_NULL
@ RZ_ANALYSIS_FCN_TYPE_SYM
@ RZ_ANALYSIS_FCN_TYPE_FCN
#define rz_return_if_fail(expr)
#define rz_return_val_if_fail(expr, val)
RZ_API bool rz_io_read_at(RzIO *io, ut64 addr, ut8 *buf, int len)
RZ_API PJ * pj_ko(PJ *j, const char *k)
RZ_API PJ * pj_ki(PJ *j, const char *k, int d)
RZ_API PJ * pj_k(PJ *j, const char *k)
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_ks(PJ *j, const char *k, const char *v)
RZ_API PJ * pj_kn(PJ *j, const char *k, ut64 n)
RZ_API PJ * pj_kd(PJ *j, const char *k, double d)
static const char * rz_str_get_null(const char *str)
RZ_API char * rz_str_escape_utf8_for_json(const char *s, int len)
RZ_API char * rz_str_replace(char *str, const char *key, const char *val, int g)
RZ_API int rz_str_replace_char(char *s, int a, int b)
RzAnalysisSwitchOp * switch_op
RZ_API RzDebugTracepoint * rz_debug_trace_get(RzDebug *dbg, ut64 addr)
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 int rz_analysis_var_count(RzAnalysis *a, RzAnalysisFunction *fcn, int kind, int type)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()