Rizin
unix-like reverse engineering framework and cli tools
cconfig.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009-2021 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <rz_core.h>
5 #include <rz_cons.h>
6 #include <rz_basefind.h>
7 #include <rz_th.h>
8 #include <rz_windows.h>
9 #include <rz_config.h>
10 
11 #include "core_private.h"
12 
13 static bool boolify_var_cb(void *user, void *data) {
14  RzConfigNode *node = (RzConfigNode *)data;
15  if (node->i_value || rz_str_is_false(node->value)) {
16  free(node->value);
17  node->value = strdup(rz_str_bool(node->i_value));
18  }
19  return true;
20 }
21 
22 static void set_options(RzConfigNode *node, ...) {
23  va_list argp;
24  char *option = NULL;
25  va_start(argp, node);
26  option = va_arg(argp, char *);
27  while (option) {
29  option = va_arg(argp, char *);
30  }
31  va_end(argp);
32 }
33 
34 static bool isGdbPlugin(RzCore *core) {
35  if (core->io && core->io->desc && core->io->desc->plugin) {
36  if (core->io->desc->plugin->name && !strcmp(core->io->desc->plugin->name, "gdb")) {
37  return true;
38  }
39  }
40  return false;
41 }
42 
43 static void print_node_options(RzConfigNode *node) {
45  char *option;
46  rz_list_foreach (node->options, iter, option) {
47  rz_cons_printf("%s\n", option);
48  }
49 }
50 
51 static int compareName(const RzAnalysisFunction *a, const RzAnalysisFunction *b) {
52  return (a && b && a->name && b->name ? strcmp(a->name, b->name) : 0);
53 }
54 
56  size_t la, lb;
57  if (!a || !b || !a->name || !b->name) {
58  return 0;
59  }
60  la = strlen(a->name);
61  lb = strlen(a->name);
62  return (la > lb) - (la < lb);
63 }
64 
66  return (a && b && a->addr && b->addr ? (a->addr > b->addr) - (a->addr < b->addr) : 0);
67 }
68 
69 static int compareType(const RzAnalysisFunction *a, const RzAnalysisFunction *b) {
70  return (a && b && a->diff->type && b->diff->type ? (a->diff->type > b->diff->type) - (a->diff->type < b->diff->type) : 0);
71 }
72 
73 static int compareSize(const RzAnalysisFunction *a, const RzAnalysisFunction *b) {
74  ut64 sa, sb;
75  // return a && b && a->_size < b->_size;
76  if (!a || !b) {
77  return 0;
78  }
81  return (sa > sb) - (sa < sb);
82 }
83 
84 static int compareDist(const RzAnalysisFunction *a, const RzAnalysisFunction *b) {
85  return (a && b && a->diff->dist && b->diff->dist ? (a->diff->dist > b->diff->dist) - (a->diff->dist < b->diff->dist) : 0);
86 }
87 
88 static bool cb_diff_sort(void *_core, void *_node) {
89  RzConfigNode *node = _node;
90  const char *column = node->value;
91  RzCore *core = _core;
92  if (column && strcmp(column, "?")) {
93  if (!strcmp(column, "name")) {
95  } else if (!strcmp(column, "namelen")) {
97  } else if (!strcmp(column, "addr")) {
99  } else if (!strcmp(column, "type")) {
101  } else if (!strcmp(column, "size")) {
103  } else if (!strcmp(column, "dist")) {
105  } else {
106  goto fail;
107  }
108  return true;
109  }
110 fail:
111  eprintf("e diff.sort = [name, namelen, addr, type, size, dist]\n");
112  return false;
113 }
114 
115 static inline void __setsegoff(RzConfig *cfg, const char *asmarch, int asmbits) {
116  int autoseg = (!strncmp(asmarch, "x86", 3) && asmbits == 16);
117  rz_config_set(cfg, "asm.segoff", rz_str_bool(autoseg));
118 }
119 
120 static bool cb_debug_hitinfo(void *user, void *data) {
121  RzCore *core = (RzCore *)user;
122  RzConfigNode *node = (RzConfigNode *)data;
123  core->dbg->hitinfo = node->i_value;
124  return true;
125 }
126 
127 static bool cb_analysis_jmpretpoline(void *user, void *data) {
128  RzCore *core = (RzCore *)user;
129  RzConfigNode *node = (RzConfigNode *)data;
130  core->analysis->opt.retpoline = node->i_value;
131  return true;
132 }
133 static bool cb_analysis_jmptailcall(void *user, void *data) {
134  RzCore *core = (RzCore *)user;
135  RzConfigNode *node = (RzConfigNode *)data;
136  core->analysis->opt.tailcall = node->i_value;
137  return true;
138 }
139 
140 static bool cb_analysis_armthumb(void *user, void *data) {
141  RzCore *core = (RzCore *)user;
142  RzConfigNode *node = (RzConfigNode *)data;
143  core->analysis->opt.armthumb = node->i_value;
144  return true;
145 }
146 
147 static bool cb_analysis_depth(void *user, void *data) {
148  RzCore *core = (RzCore *)user;
149  RzConfigNode *node = (RzConfigNode *)data;
150  core->analysis->opt.depth = node->i_value;
151  return true;
152 }
153 
154 static bool cb_analysis_graphdepth(void *user, void *data) {
155  RzCore *core = (RzCore *)user;
156  RzConfigNode *node = (RzConfigNode *)data;
157  core->analysis->opt.graph_depth = node->i_value;
158  return true;
159 }
160 
161 static bool cb_analysis_afterjmp(void *user, void *data) {
162  RzCore *core = (RzCore *)user;
163  RzConfigNode *node = (RzConfigNode *)data;
164  core->analysis->opt.afterjmp = node->i_value;
165  return true;
166 }
167 
168 static bool cb_analysis_aftertrap(void *user, void *data) {
169  RzCore *core = (RzCore *)user;
170  RzConfigNode *node = (RzConfigNode *)data;
171  core->analysis->opt.aftertrap = node->i_value;
172  return true;
173 }
174 
175 static bool cb_analysis_delay(void *user, void *data) {
176  RzCore *core = (RzCore *)user;
177  RzConfigNode *node = (RzConfigNode *)data;
178  core->analysis->opt.delay = node->i_value;
179  return true;
180 }
181 
182 static bool cb_analysis_vars(void *user, void *data) {
183  RzCore *core = (RzCore *)user;
184  RzConfigNode *node = (RzConfigNode *)data;
185  core->analysis->opt.vars = node->i_value;
186  return true;
187 }
188 
189 static bool cb_analysis_vars_stackname(void *user, void *data) {
190  RzCore *core = (RzCore *)user;
191  RzConfigNode *node = (RzConfigNode *)data;
192  core->analysis->opt.varname_stack = node->i_value;
193  return true;
194 }
195 
196 static bool cb_analysis_nonull(void *user, void *data) {
197  RzCore *core = (RzCore *)user;
198  RzConfigNode *node = (RzConfigNode *)data;
199  core->analysis->opt.nonull = node->i_value;
200  return true;
201 }
202 
203 static bool cb_analysis_strings(void *user, void *data) {
204  RzCore *core = (RzCore *)user;
205  RzConfigNode *node = (RzConfigNode *)data;
206  if (node->i_value) {
207  rz_config_set(core->config, "bin.strings", "false");
208  }
209  return true;
210 }
211 
212 static bool cb_analysis_ignbithints(void *user, void *data) {
213  RzCore *core = (RzCore *)user;
214  RzConfigNode *node = (RzConfigNode *)data;
215  core->analysis->opt.ignbithints = node->i_value;
216  return true;
217 }
218 
219 static bool cb_analysis_sleep(void *user, void *data) {
220  RzCore *core = (RzCore *)user;
221  RzConfigNode *node = (RzConfigNode *)data;
222  core->analysis->sleep = node->i_value;
223  return true;
224 }
225 
226 static bool cb_analysis_maxrefs(void *user, void *data) {
227  RzCore *core = (RzCore *)user;
228  RzConfigNode *node = (RzConfigNode *)data;
229  core->analysis->maxreflines = node->i_value;
230  return true;
231 }
232 
233 static bool cb_analysis_norevisit(void *user, void *data) {
234  RzCore *core = (RzCore *)user;
235  RzConfigNode *node = (RzConfigNode *)data;
236  core->analysis->opt.norevisit = node->i_value;
237  return true;
238 }
239 
240 static bool cb_analysis_nopskip(void *user, void *data) {
241  RzCore *core = (RzCore *)user;
242  RzConfigNode *node = (RzConfigNode *)data;
243  core->analysis->opt.nopskip = node->i_value;
244  return true;
245 }
246 
247 static bool cb_analysis_hpskip(void *user, void *data) {
248  RzCore *core = (RzCore *)user;
249  RzConfigNode *node = (RzConfigNode *)data;
250  core->analysis->opt.hpskip = node->i_value;
251  return true;
252 }
253 
256  RzListIter *it;
257  if (core && core->analysis && node) {
258  rz_list_purge(node->options);
259  rz_list_foreach (core->analysis->plugins, it, h) {
260  SETOPTIONS(node, h->name, NULL);
261  }
262  }
263 }
264 
265 static bool cb_analysis_arch(void *user, void *data) {
266  RzCore *core = (RzCore *)user;
267  RzConfigNode *node = (RzConfigNode *)data;
268  if (*node->value == '?') {
269  update_analysis_arch_options(core, node);
270  print_node_options(node);
271  return false;
272  }
273  if (*node->value) {
274  if (rz_analysis_use(core->analysis, node->value)) {
275  return true;
276  }
277  const char *aa = rz_config_get(core->config, "asm.arch");
278  if (!aa || strcmp(aa, node->value)) {
279  eprintf("analysis.arch: cannot find '%s'\n", node->value);
280  }
281  }
282  return false;
283 }
284 
285 static bool cb_analysis_cpu(void *user, void *data) {
286  RzCore *core = (RzCore *)user;
287  RzConfigNode *node = (RzConfigNode *)data;
288  rz_analysis_set_cpu(core->analysis, node->value);
289  /* set pcalign */
290  {
292  rz_config_set_i(core->config, "asm.pcalign", (v != -1) ? v : 0);
293  }
294  return true;
295 }
296 
297 static bool cb_analysis_recont(void *user, void *data) {
298  RzCore *core = (RzCore *)user;
299  RzConfigNode *node = (RzConfigNode *)data;
300  core->analysis->opt.recont = node->i_value;
301  return true;
302 }
303 
304 static bool cb_analysis_ijmp(void *user, void *data) {
305  RzCore *core = (RzCore *)user;
306  RzConfigNode *node = (RzConfigNode *)data;
307  core->analysis->opt.ijmp = node->i_value;
308  return true;
309 }
310 
311 static bool cb_asmsubvarmin(void *user, void *data) {
312  RzCore *core = (RzCore *)user;
313  RzConfigNode *node = (RzConfigNode *)data;
314  core->parser->minval = node->i_value;
315  return true;
316 }
317 
318 static bool cb_asmsubtail(void *user, void *data) {
319  RzCore *core = (RzCore *)user;
320  RzConfigNode *node = (RzConfigNode *)data;
321  core->parser->subtail = node->i_value;
322  return true;
323 }
324 
325 static bool cb_scrlast(void *user, void *data) {
326  RzConfigNode *node = (RzConfigNode *)data;
328  return true;
329 }
330 
331 static bool cb_scr_vi(void *user, void *data) {
332  RzCore *core = (RzCore *)user;
333  RzConfigNode *node = (RzConfigNode *)data;
334  core->cons->line->enable_vi_mode = node->i_value;
335  return true;
336 }
337 
338 static bool cb_scr_prompt_mode(void *user, void *data) {
339  RzCore *core = (RzCore *)user;
340  RzConfigNode *node = (RzConfigNode *)data;
341  core->cons->line->prompt_mode = node->i_value;
342  return true;
343 }
344 
345 static bool cb_scr_wideoff(void *user, void *data) {
346  RzCore *core = (RzCore *)user;
347  RzConfigNode *node = (RzConfigNode *)data;
348  core->print->wide_offsets = node->i_value;
349  return true;
350 }
351 
352 static bool cb_scrrainbow(void *user, void *data) {
353  RzCore *core = (RzCore *)user;
354  RzConfigNode *node = (RzConfigNode *)data;
355  if (node->i_value) {
358  } else {
359  core->print->flags &= (~RZ_PRINT_FLAGS_RAINBOW);
361  }
362  rz_print_set_flags(core->print, core->print->flags);
363  return true;
364 }
365 
366 static bool cb_asmpseudo(void *user, void *data) {
367  RzCore *core = (RzCore *)user;
368  RzConfigNode *node = (RzConfigNode *)data;
369  core->rasm->pseudo = node->i_value;
370  return true;
371 }
372 
373 static bool cb_asmsubsec(void *user, void *data) {
374  RzCore *core = (RzCore *)user;
375  RzConfigNode *node = (RzConfigNode *)data;
376  if (node->i_value) {
378  } else {
379  core->print->flags &= (~RZ_PRINT_FLAGS_SECSUB);
380  }
381  rz_print_set_flags(core->print, core->print->flags);
382  return true;
383 }
384 
385 static bool cb_asmassembler(void *user, void *data) {
386  RzCore *core = (RzCore *)user;
387  RzConfigNode *node = (RzConfigNode *)data;
388  rz_asm_use_assembler(core->rasm, node->value);
389  return true;
390 }
391 
392 static void update_asmcpu_options(RzCore *core, RzConfigNode *node) {
393  RzAsmPlugin *h;
394  RzListIter *iter;
395  rz_return_if_fail(core && core->rasm);
396  const char *arch = rz_config_get(core->config, "asm.arch");
397  if (!arch || !*arch) {
398  return;
399  }
400  rz_list_purge(node->options);
401  rz_list_foreach (core->rasm->plugins, iter, h) {
402  if (h->cpus && !strcmp(arch, h->name)) {
403  char *c = strdup(h->cpus);
404  int i, n = rz_str_split(c, ',');
405  for (i = 0; i < n; i++) {
406  const char *word = rz_str_word_get0(c, i);
407  if (word && *word) {
408  node->options->free = free;
409  SETOPTIONS(node, strdup(word), NULL);
410  }
411  }
412  free(c);
413  }
414  }
415 }
416 
417 static bool cb_asmcpu(void *user, void *data) {
418  RzCore *core = (RzCore *)user;
419  RzConfigNode *node = (RzConfigNode *)data;
420  if (*node->value == '?') {
421  update_asmcpu_options(core, node);
422  /* print verbose help instead of plain option listing */
423  RzCmdStateOutput state = { 0 };
425  rz_core_asm_plugins_print(core, rz_config_get(core->config, "asm.arch"), &state);
428  return 0;
429  }
430  rz_asm_set_cpu(core->rasm, node->value);
431  rz_config_set(core->config, "analysis.cpu", node->value);
432 
433  char *cpus_dir = rz_path_system(RZ_SDB_ARCH_CPUS);
434  rz_platform_profiles_init(core->analysis->arch_target, node->value, rz_config_get(core->config, "asm.arch"), cpus_dir);
435  free(cpus_dir);
436  const char *platform = rz_config_get(core->config, "asm.platform");
437  char *platforms_dir = rz_path_system(RZ_SDB_ARCH_PLATFORMS);
438  rz_platform_target_index_init(core->analysis->platform_target, rz_config_get(core->config, "asm.arch"), node->value, platform, platforms_dir);
439  free(platforms_dir);
440 
441  return true;
442 }
443 
444 static void update_asmarch_options(RzCore *core, RzConfigNode *node) {
445  RzAsmPlugin *h;
446  RzListIter *iter;
447  if (core && node && core->rasm) {
448  rz_list_purge(node->options);
449  rz_list_foreach (core->rasm->plugins, iter, h) {
450  SETOPTIONS(node, h->name, NULL);
451  }
452  }
453 }
454 
455 static void update_asmbits_options(RzCore *core, RzConfigNode *node) {
456  if (core && core->rasm && core->rasm->cur && node) {
457  int bits = core->rasm->cur->bits;
458  int i;
459  node->options->free = free;
460  rz_list_purge(node->options);
461  for (i = 1; i <= bits; i <<= 1) {
462  if (i & bits) {
463  SETOPTIONS(node, rz_str_newf("%d", i), NULL);
464  }
465  }
466  }
467 }
468 
469 static void update_syscall_ns(RzCore *core) {
470  if (core->analysis->syscall->db) {
471  sdb_ns_set(core->sdb, "syscall", core->analysis->syscall->db);
472  } else {
473  sdb_ns_unset(core->sdb, "syscall", NULL);
474  }
475 }
476 
477 static bool cb_asmarch(void *user, void *data) {
478  char asmparser[32];
479  RzCore *core = (RzCore *)user;
480  RzConfigNode *node = (RzConfigNode *)data;
481  const char *asmos = NULL;
482  int bits = RZ_SYS_BITS;
483  if (!*node->value || !core || !core->rasm) {
484  return false;
485  }
486  asmos = rz_config_get(core->config, "asm.os");
487  if (core && core->analysis && core->analysis->bits) {
488  bits = core->analysis->bits;
489  }
490  if (node->value[0] == '?') {
491  update_asmarch_options(core, node);
492  if (strlen(node->value) > 1 && node->value[1] == '?') {
493  /* print more verbose help instead of plain option values */
494  RzCmdStateOutput state = { 0 };
499  return false;
500  } else {
501  print_node_options(node);
502  return false;
503  }
504  }
505  rz_egg_setup(core->egg, node->value, bits, 0, RZ_SYS_OS);
506 
507  if (!rz_asm_use(core->rasm, node->value)) {
508  eprintf("asm.arch: cannot find (%s)\n", node->value);
509  return false;
510  }
511  // we should strdup here otherwise will crash if any rz_config_set
512  // free the old value
513  char *asm_cpu = strdup(rz_config_get(core->config, "asm.cpu"));
514  if (core->rasm->cur) {
515  const char *newAsmCPU = core->rasm->cur->cpus;
516  if (newAsmCPU) {
517  if (*newAsmCPU) {
518  char *nac = strdup(newAsmCPU);
519  char *comma = strchr(nac, ',');
520  if (comma) {
521  if (!*asm_cpu || (*asm_cpu && !strstr(nac, asm_cpu))) {
522  *comma = 0;
523  rz_config_set(core->config, "asm.cpu", nac);
524  }
525  }
526  free(nac);
527  } else {
528  rz_config_set(core->config, "asm.cpu", "");
529  }
530  }
531  bits = core->rasm->cur->bits;
532  if (8 & bits) {
533  bits = 8;
534  } else if (16 & bits) {
535  bits = 16;
536  } else if (32 & bits) {
537  bits = 32;
538  } else {
539  bits = 64;
540  }
541  update_asmbits_options(core, rz_config_node_get(core->config, "asm.bits"));
542  }
543  snprintf(asmparser, sizeof(asmparser), "%s.pseudo", node->value);
544  rz_config_set(core->config, "asm.parser", asmparser);
545  if (core->rasm->cur && core->analysis &&
546  !(core->rasm->cur->bits & core->analysis->bits)) {
547  rz_config_set_i(core->config, "asm.bits", bits);
548  }
549 
550  rz_debug_set_arch(core->dbg, node->value, bits);
551  if (!rz_config_set(core->config, "analysis.arch", node->value)) {
552  char *p, *s = strdup(node->value);
553  if (s) {
554  p = strchr(s, '.');
555  if (p) {
556  *p = 0;
557  }
558  if (!rz_config_set(core->config, "analysis.arch", s)) {
559  /* fall back to the analysis.null plugin */
560  rz_config_set(core->config, "analysis.arch", "null");
561  }
562  free(s);
563  }
564  }
565  // set pcalign
566  if (core->analysis) {
567  const char *asmcpu = rz_config_get(core->config, "asm.cpu");
568  const char *platform = rz_config_get(core->config, "asm.platform");
569  rz_syscall_setup(core->analysis->syscall, node->value, core->analysis->bits, asmcpu, asmos);
570  update_syscall_ns(core);
571  char *platforms_dir = rz_path_system(RZ_SDB_ARCH_PLATFORMS);
572  char *cpus_dir = rz_path_system(RZ_SDB_ARCH_CPUS);
573  rz_platform_target_index_init(core->analysis->platform_target, node->value, asmcpu, platform, platforms_dir);
574  rz_platform_profiles_init(core->analysis->arch_target, asmcpu, node->value, cpus_dir);
575  free(platforms_dir);
576  free(cpus_dir);
577  }
578  __setsegoff(core->config, node->value, core->rasm->bits);
579 
580  // set a default endianness
581  bool big_endian = rz_config_get_b(core->config, "cfg.bigendian");
582 
583  // try to set endian of RzAsm to match binary
584  rz_asm_set_big_endian(core->rasm, big_endian);
585  // set endian of display to match binary
586  core->print->big_endian = big_endian;
587 
588  rz_asm_set_cpu(core->rasm, asm_cpu);
589  free(asm_cpu);
590  RzConfigNode *asmcpu = rz_config_node_get(core->config, "asm.cpu");
591  if (asmcpu) {
592  update_asmcpu_options(core, asmcpu);
593  }
594  {
596  if (v != -1) {
597  rz_config_set_i(core->config, "asm.pcalign", v);
598  } else {
599  rz_config_set_i(core->config, "asm.pcalign", 0);
600  }
601  }
602  /* reload types and cc info */
603  // changing asm.arch changes analysis.arch
604  // changing analysis.arch sets types db
605  // so ressetting is redundant and may lead to bugs
606  // 1 case this is usefull is when types is null
607  if (!core->analysis || !core->analysis->typedb) {
609  }
610  // set endian of RzAnalysis to match binary
611  rz_analysis_set_big_endian(core->analysis, big_endian);
613 
614  const char *platform = rz_config_get(core->config, "asm.platform");
615  if (asmcpu) {
616  char *platforms_dir = rz_path_system(RZ_SDB_ARCH_PLATFORMS);
617  char *cpus_dir = rz_path_system(RZ_SDB_ARCH_CPUS);
618  rz_platform_target_index_init(core->analysis->platform_target, node->value, asmcpu->value, platform, platforms_dir);
619  rz_platform_profiles_init(core->analysis->arch_target, asmcpu->value, node->value, cpus_dir);
620  free(cpus_dir);
621  free(platforms_dir);
622  }
623 
624  return true;
625 }
626 
627 static bool cb_dbgbtdepth(void *user, void *data) {
628  RzCore *core = (RzCore *)user;
629  RzConfigNode *node = (RzConfigNode *)data;
630  core->dbg->btdepth = node->i_value;
631  return true;
632 }
633 
634 static bool cb_asmbits(void *user, void *data) {
635  RzCore *core = (RzCore *)user;
636  RzConfigNode *node = (RzConfigNode *)data;
637 
638  if (node->value[0] == '?') {
639  update_asmbits_options(core, node);
640  print_node_options(node);
641  return false;
642  }
643 
644  bool ret = false;
645  if (!core) {
646  eprintf("user can't be NULL\n");
647  return false;
648  }
649 
650  int bits = node->i_value;
651  if (!bits) {
652  return false;
653  }
654  if (bits > 0) {
655  ret = rz_asm_set_bits(core->rasm, bits);
656  if (!ret) {
657  RzAsmPlugin *h = core->rasm->cur;
658  if (!h) {
659  eprintf("e asm.bits: Cannot set value, no plugins defined yet\n");
660  ret = true;
661  }
662  // else { eprintf ("Cannot set bits %d to '%s'\n", bits, h->name); }
663  }
664  if (!rz_analysis_set_bits(core->analysis, bits)) {
665  eprintf("asm.arch: Cannot setup '%d' bits analysis engine\n", bits);
666  ret = false;
667  }
668  core->print->bits = bits;
669  }
670  if (core->dbg && core->analysis && core->analysis->cur) {
671  rz_debug_set_arch(core->dbg, core->analysis->cur->arch, bits);
673  }
675  const char *asmos = rz_config_get(core->config, "asm.os");
676  const char *asmarch = rz_config_get(core->config, "asm.arch");
677  const char *asmcpu = rz_config_get(core->config, "asm.cpu");
678  if (core->analysis) {
679  if (!rz_syscall_setup(core->analysis->syscall, asmarch, bits, asmcpu, asmos)) {
680  // eprintf ("asm.arch: Cannot setup syscall '%s/%s' from '%s'\n",
681  // node->value, asmos, RZ_LIBDIR"/rizin/"RZ_VERSION"/syscall");
682  }
683  update_syscall_ns(core);
684  __setsegoff(core->config, asmarch, core->analysis->bits);
685  if (core->dbg) {
686  rz_bp_use(core->dbg->bp, asmarch);
687  }
688  /* set pcalign */
690  rz_config_set_i(core->config, "asm.pcalign", (v != -1) ? v : 0);
691  }
692  return ret;
693 }
694 
695 static void update_asmfeatures_options(RzCore *core, RzConfigNode *node) {
696  int i, argc;
697 
698  if (core && core->rasm && core->rasm->cur) {
699  if (core->rasm->cur->features) {
700  char *features = strdup(core->rasm->cur->features);
701  rz_list_purge(node->options);
702  argc = rz_str_split(features, ',');
703  for (i = 0; i < argc; i++) {
704  node->options->free = free;
705  const char *feature = rz_str_word_get0(features, i);
706  if (feature) {
707  rz_list_append(node->options, strdup(feature));
708  }
709  }
710  free(features);
711  }
712  }
713 }
714 
715 static bool cb_flag_realnames(void *user, void *data) {
716  RzCore *core = (RzCore *)user;
717  RzConfigNode *node = (RzConfigNode *)data;
718  core->flags->realnames = node->i_value;
719  return true;
720 }
721 
722 static bool cb_asmfeatures(void *user, void *data) {
723  RzCore *core = (RzCore *)user;
724  RzConfigNode *node = (RzConfigNode *)data;
725  if (*node->value == '?') {
726  update_asmfeatures_options(core, node);
727  print_node_options(node);
728  return 0;
729  }
730  RZ_FREE(core->rasm->features);
731  if (node->value[0]) {
732  core->rasm->features = strdup(node->value);
733  }
734  return 1;
735 }
736 
738  int i, argc;
739 
740  if (core && core->rasm && core->rasm->cur) {
741  if (core->rasm->cur->platforms) {
742  char *platforms = strdup(core->rasm->cur->platforms);
743  rz_list_purge(node->options);
744  argc = rz_str_split(platforms, ',');
745  for (i = 0; i < argc; i++) {
746  node->options->free = free;
747  const char *feature = rz_str_word_get0(platforms, i);
748  if (feature) {
749  rz_list_append(node->options, strdup(feature));
750  }
751  }
752  free(platforms);
753  }
754  }
755 }
756 
757 static bool cb_asmplatform(void *user, void *data) {
758  RzCore *core = (RzCore *)user;
759  RzConfigNode *node = (RzConfigNode *)data;
760  if (!core) {
761  return false;
762  }
763  if (*node->value == '?') {
764  update_asmplatforms_options(core, node);
765  print_node_options(node);
766  return 0;
767  }
768  RZ_FREE(core->rasm->platforms);
769  if (node->value[0]) {
770  core->rasm->platforms = strdup(node->value);
771  }
772  const char *asmcpu = rz_config_get(core->config, "asm.cpu");
773  const char *asmarch = rz_config_get(core->config, "asm.arch");
774  char *platforms_dir = rz_path_system(RZ_SDB_ARCH_PLATFORMS);
775  rz_platform_target_index_init(core->analysis->platform_target, asmarch, asmcpu, node->value, platforms_dir);
776  free(platforms_dir);
777  return 1;
778 }
779 
780 static bool cb_asmlineswidth(void *user, void *data) {
781  RzCore *core = (RzCore *)user;
782  RzConfigNode *node = (RzConfigNode *)data;
783  core->analysis->lineswidth = node->i_value;
784  return true;
785 }
786 
787 static bool cb_emustr(void *user, void *data) {
788  RzCore *core = (RzCore *)user;
789  RzConfigNode *node = (RzConfigNode *)data;
790  if (node->i_value) {
791  rz_config_set(core->config, "asm.emu", "true");
792  }
793  return true;
794 }
795 
796 static bool cb_emuskip(void *user, void *data) {
797  RzConfigNode *node = (RzConfigNode *)data;
798  if (*node->value == '?') {
799  if (strlen(node->value) > 1 && node->value[1] == '?') {
800  rz_cons_printf("Concatenation of meta types encoded as characters:\n"
801  "'d': data\n'c': code\n's': string\n'f': format\n'm': magic\n"
802  "'h': hide\n'C': comment\n'r': run\n"
803  "(default is 'ds' to skip data and strings)\n");
804  } else {
805  print_node_options(node);
806  }
807  return false;
808  }
809  return true;
810 }
811 
812 static bool cb_asm_immhash(void *user, void *data) {
813  RzCore *core = (RzCore *)user;
814  RzConfigNode *node = (RzConfigNode *)data;
815  core->rasm->immdisp = node->i_value ? true : false;
816  return true;
817 }
818 
819 static bool cb_asm_invhex(void *user, void *data) {
820  RzCore *core = (RzCore *)user;
821  RzConfigNode *node = (RzConfigNode *)data;
822  core->rasm->invhex = node->i_value;
823  return true;
824 }
825 
826 static bool cb_asm_pcalign(void *user, void *data) {
827  RzCore *core = (RzCore *)user;
828  RzConfigNode *node = (RzConfigNode *)data;
829  int align = node->i_value;
830  if (align < 0) {
831  align = 0;
832  }
833  core->rasm->pcalign = align;
834  core->analysis->pcalign = align;
835  return true;
836 }
837 
838 static bool cb_asmos(void *user, void *data) {
839  RzCore *core = (RzCore *)user;
840  int asmbits = rz_config_get_i(core->config, "asm.bits");
841  RzConfigNode *asmarch, *node = (RzConfigNode *)data;
842 
843  if (*node->value == '?') {
844  print_node_options(node);
845  return 0;
846  }
847  if (!node->value[0]) {
848  free(node->value);
849  node->value = strdup(RZ_SYS_OS);
850  }
851  asmarch = rz_config_node_get(core->config, "asm.arch");
852  if (asmarch) {
853  const char *asmcpu = rz_config_get(core->config, "asm.cpu");
854  rz_syscall_setup(core->analysis->syscall, asmarch->value, core->analysis->bits, asmcpu, node->value);
855  update_syscall_ns(core);
856  __setsegoff(core->config, asmarch->value, asmbits);
857  }
858  rz_analysis_set_os(core->analysis, node->value);
860  return true;
861 }
862 
863 static void update_asmparser_options(RzCore *core, RzConfigNode *node) {
864  RzListIter *iter;
866  if (core && node && core->parser && core->parser->parsers) {
867  rz_list_purge(node->options);
868  rz_list_foreach (core->parser->parsers, iter, parser) {
869  SETOPTIONS(node, parser->name, NULL);
870  }
871  }
872 }
873 
874 static bool cb_asmparser(void *user, void *data) {
875  RzCore *core = (RzCore *)user;
876  RzConfigNode *node = (RzConfigNode *)data;
877  if (node->value[0] == '?') {
878  update_asmparser_options(core, node);
879  print_node_options(node);
880  return false;
881  }
882 
883  return rz_parse_use(core->parser, node->value);
884 }
885 
886 typedef struct {
887  const char *name;
888  const char *aliases;
890 
891 static bool cb_binstrenc(void *user, void *data) {
892  RzCore *core = (RzCore *)user;
893  RzConfigNode *node = (RzConfigNode *)data;
894  if (node->value[0] == '?') {
895  print_node_options(node);
896  rz_cons_printf(" -- if string's 2nd & 4th bytes are 0 then utf16le else "
897  "if 2nd - 4th & 6th bytes are 0 & no char > 0x10ffff then utf32le else "
898  "if utf8 char detected then utf8 else 8bit\n");
899  return false;
900  }
901  const namealiases_pair names[] = {
902  { "guess", NULL },
903  { "8bit", "ascii" },
904  { "utf8", "utf-8" },
905  { "utf16le", "utf-16le,utf16-le" },
906  { "utf32le", "utf-32le,utf32-le" },
907  { "utf16be", "utf-16be,utf16-be" },
908  { "utf32be", "utf-32be,utf32-be" },
909  { "ibm037", "ebcdic" },
910  { "ibm290", NULL },
911  { "ebcdices", NULL },
912  { "ebcdicuk", NULL },
913  { "ebcdicus", NULL },
914 
915  };
916  int i;
917  char *enc = strdup(node->value);
918  if (!enc) {
919  return false;
920  }
921  rz_str_case(enc, false);
922  for (i = 0; i < RZ_ARRAY_SIZE(names); i++) {
923  const namealiases_pair *pair = &names[i];
924  if (!strcmp(pair->name, enc) || rz_str_cmp_list(pair->aliases, enc, ',')) {
925  free(node->value);
926  node->value = strdup(pair->name);
927  free(enc);
928  if (core->bin) {
929  free(core->bin->strenc);
930  core->bin->strenc = !strcmp(node->value, "guess") ? NULL : strdup(node->value);
931  RzBinFile *bf = rz_bin_cur(core->bin);
932  if (bf && bf->o) {
933  rz_bin_object_reset_strings(core->bin, bf, bf->o);
934  }
935  }
936  return true;
937  }
938  }
939  eprintf("Unknown encoding: %s\n", node->value);
940  free(enc);
941  return false;
942 }
943 
944 static bool cb_binfilter(void *user, void *data) {
945  RzCore *core = (RzCore *)user;
946  RzConfigNode *node = (RzConfigNode *)data;
947  core->bin->filter = node->i_value;
948  return true;
949 }
950 
951 static bool cb_binat(void *user, void *data) {
952  RzCore *core = (RzCore *)user;
953  RzConfigNode *node = (RzConfigNode *)data;
954  core->binat = node->i_value;
955  return true;
956 }
957 
958 static bool cb_usextr(void *user, void *data) {
959  RzCore *core = (RzCore *)user;
960  RzConfigNode *node = (RzConfigNode *)data;
961  core->bin->use_xtr = node->i_value;
962  return true;
963 }
964 
965 static bool cb_strpurge(void *user, void *data) {
966  RzCore *core = (RzCore *)user;
967  RzConfigNode *node = (RzConfigNode *)data;
968  if (*node->value == '?') {
970  "There can be multiple entries separated by commas. No whitespace before/after entries.\n"
971  "Possible entries:\n"
972  " all : purge all strings\n"
973  " true : use the false_positive() classifier in cbin.c\n"
974  " addr : purge string at addr\n"
975  " addr1-addr2 : purge all strings in the range addr1-addr2 inclusive\n"
976  " !addr : prevent purge of string at addr by prev entries\n"
977  " !addr1-addr2 : prevent purge of strings in range addr1-addr2 inclusive by prev entries\n"
978  "Neither !true nor !false is supported.\n"
979  "\n"
980  "Examples:\n"
981  " e bin.str.purge=true,0-0xff,!0x1a\n"
982  " -- purge strings using the false_positive() classifier in cbin.c and also strings \n"
983  " with addresses in the range 0-0xff, but not the string at 0x1a.\n"
984  " e bin.str.purge=all,!0x1000-0x1fff\n"
985  " -- purge all strings except the strings with addresses in the range 0x1000-0x1fff.\n");
986  return false;
987  }
988  free(core->bin->strpurge);
989  core->bin->strpurge = !*node->value || !strcmp(node->value, "false")
990  ? NULL
991  : strdup(node->value);
992  return true;
993 }
994 
995 static bool cb_maxname(void *user, void *data) {
996  RzConfigNode *node = (RzConfigNode *)data;
997  RzCore *core = (RzCore *)user;
998  core->parser->maxflagnamelen = node->i_value;
999  return true;
1000 }
1001 
1002 static bool cb_midflags(void *user, void *data) {
1003  RzConfigNode *node = (RzConfigNode *)data;
1004  if (node->value[0] == '?') {
1005  print_node_options(node);
1006  return false;
1007  }
1008  return true;
1009 }
1010 
1011 static bool cb_strfilter(void *user, void *data) {
1012  RzCore *core = (RzCore *)user;
1013  RzConfigNode *node = (RzConfigNode *)data;
1014  if (node->value[0] == '?') {
1015  if (strlen(node->value) > 1 && node->value[1] == '?') {
1016  rz_cons_printf("Valid values for bin.str.filter:\n"
1017  "a only alphanumeric printable\n"
1018  "8 only strings with utf8 chars\n"
1019  "p file/directory paths\n"
1020  "e email-like addresses\n"
1021  "u urls\n"
1022  "i IPv4 address-like strings\n"
1023  "U only uppercase strings\n"
1024  "f format-strings\n");
1025  } else {
1026  print_node_options(node);
1027  }
1028  return false;
1029  } else {
1030  core->bin->strfilter = node->value[0];
1031  }
1032  return true;
1033 }
1034 
1035 static bool cb_binforce(void *user, void *data) {
1036  RzCore *core = (RzCore *)user;
1037  RzConfigNode *node = (RzConfigNode *)data;
1038  rz_bin_force_plugin(core->bin, node->value);
1039  return true;
1040 }
1041 
1042 static bool cb_asmsyntax(void *user, void *data) {
1043  RzCore *core = (RzCore *)user;
1044  RzConfigNode *node = (RzConfigNode *)data;
1045  if (*node->value == '?') {
1046  print_node_options(node);
1047  return false;
1048  } else {
1049  int syntax = rz_asm_syntax_from_string(node->value);
1050  if (syntax == -1) {
1051  return false;
1052  }
1053  rz_asm_set_syntax(core->rasm, syntax);
1054  }
1055  return true;
1056 }
1057 
1058 static bool cb_bigendian(void *user, void *data) {
1059  RzCore *core = (RzCore *)user;
1060  RzConfigNode *node = (RzConfigNode *)data;
1061  // Try to set endian based on preference, restrict by RzAsmPlugin
1062  bool isbig = rz_asm_set_big_endian(core->rasm, node->i_value);
1063  // Set analysis endianness the same as asm
1064  rz_analysis_set_big_endian(core->analysis, isbig);
1065  // While analysis sets endianess for TypesDB there might
1066  // be cases when it isn't availble for the chosen analysis
1067  // plugin but types and printing commands still need the
1068  // corresponding endianness. Thus we set these explicitly:
1070  core->print->big_endian = node->i_value;
1071  // the big endian should also be assigned to dbg->bp->endian
1072  if (core->dbg && core->dbg->bp) {
1073  core->dbg->bp->endian = isbig;
1074  }
1075  return true;
1076 }
1077 
1078 static bool cb_cfgdatefmt(void *user, void *data) {
1079  RzCore *core = (RzCore *)user;
1080  RzConfigNode *node = (RzConfigNode *)data;
1081  snprintf(core->print->datefmt, 32, "%s", node->value);
1082  return true;
1083 }
1084 
1085 static bool cb_timezone(void *user, void *data) {
1086  RzCore *core = (RzCore *)user;
1087  RzConfigNode *node = (RzConfigNode *)data;
1088  core->print->datezone = node->i_value;
1089  return true;
1090 }
1091 
1092 static bool cb_cfgdebug(void *user, void *data) {
1093  RzCore *core = (RzCore *)user;
1094  RzConfigNode *node = (RzConfigNode *)data;
1095  if (!core) {
1096  return false;
1097  }
1098  if (core->io) {
1099  rz_config_set_b(core->config, "io.va", !node->i_value);
1100  }
1101  if (core->dbg && node->i_value) {
1102  const char *dbgbackend = rz_config_get(core->config, "dbg.backend");
1103  core->bin->is_debugger = true;
1104  rz_debug_use(core->dbg, dbgbackend);
1105  if (!strcmp(dbgbackend, "bf")) {
1106  rz_config_set(core->config, "asm.arch", "bf");
1107  }
1108  if (core->file) {
1109  rz_debug_select(core->dbg, rz_io_fd_get_pid(core->io, core->file->fd),
1110  rz_io_fd_get_tid(core->io, core->file->fd));
1111  }
1112  } else {
1113  rz_debug_use(core->dbg, NULL);
1114  core->bin->is_debugger = false;
1115  }
1116  return true;
1117 }
1118 
1119 static bool cb_dirhome(void *user, void *data) {
1120  RzConfigNode *node = (RzConfigNode *)data;
1121  if (node->value) {
1123  }
1124  return true;
1125 }
1126 
1127 static bool cb_dirtmp(void *user, void *data) {
1128  RzConfigNode *node = (RzConfigNode *)data;
1129  char *value = RZ_STR_ISNOTEMPTY(node->value) ? node->value : NULL;
1131  return true;
1132 }
1133 
1134 static bool cb_dirsrc(void *user, void *data) {
1135  RzConfigNode *node = (RzConfigNode *)data;
1136  RzCore *core = (RzCore *)user;
1137  free(core->bin->srcdir);
1138  core->bin->srcdir = strdup(node->value);
1139  return true;
1140 }
1141 
1142 static bool cb_str_escbslash(void *user, void *data) {
1143  RzCore *core = (RzCore *)user;
1144  RzConfigNode *node = (RzConfigNode *)data;
1145  core->print->esc_bslash = node->i_value;
1146  return true;
1147 }
1148 
1149 static bool cb_strsearch_check_ascii_freq(void *user, void *data) {
1150  RzCore *core = (RzCore *)user;
1151  RzConfigNode *node = (RzConfigNode *)data;
1152  core->bin->strseach_check_ascii_freq = node->i_value;
1153  return true;
1154 }
1155 
1156 static bool cb_completion_maxtab(void *user, void *data) {
1157  RzCore *core = (RzCore *)user;
1158  RzConfigNode *node = (RzConfigNode *)data;
1159  core->cons->line->completion.args_limit = node->i_value;
1160  return true;
1161 }
1162 
1163 static bool cb_cfg_fortunes(void *user, void *data) {
1164  RzCore *core = (RzCore *)user;
1165  RzConfigNode *node = (RzConfigNode *)data;
1166  // TODO CN_BOOL option does not receive the right hand side of assignment as an argument
1167  if (node->value[0] == '?') {
1168  rz_core_fortune_list(core);
1169  return false;
1170  }
1171  return true;
1172 }
1173 
1174 static bool cb_cfg_fortunes_file(void *user, void *data) {
1175  RzConfigNode *node = (RzConfigNode *)data;
1176  if (node->value[0] == '?') {
1178  return false;
1179  }
1180  return true;
1181 }
1182 
1183 static bool cb_cmdtimes(void *user, void *data) {
1184  RzCore *core = (RzCore *)user;
1185  RzConfigNode *node = (RzConfigNode *)data;
1186  core->cmdtimes = node->value;
1187  return true;
1188 }
1189 
1190 static bool cb_cmdrepeat(void *user, void *data) {
1191  RzCore *core = (RzCore *)user;
1192  RzConfigNode *node = (RzConfigNode *)data;
1193  core->cmdrepeat = node->i_value;
1194  return true;
1195 }
1196 
1197 static bool cb_scrnull(void *user, void *data) {
1198  RzCore *core = (RzCore *)user;
1199  RzConfigNode *node = (RzConfigNode *)data;
1200  core->cons->null = node->i_value;
1201  return true;
1202 }
1203 
1204 static bool cb_color(void *user, void *data) {
1205  RzCore *core = (RzCore *)user;
1206  RzConfigNode *node = (RzConfigNode *)data;
1207  if (node->i_value) {
1208  core->print->flags |= RZ_PRINT_FLAGS_COLOR;
1209  } else {
1210  core->print->flags &= (~RZ_PRINT_FLAGS_COLOR);
1211  }
1212  if (!strcmp(node->value, "true")) {
1213  node->i_value = 1;
1214  } else if (!strcmp(node->value, "false")) {
1215  node->i_value = 0;
1216  }
1218  ? COLOR_MODE_16M
1219  : node->i_value;
1221  rz_print_set_flags(core->print, core->print->flags);
1222  return true;
1223 }
1224 
1225 static bool cb_color_getter(void *user, RzConfigNode *node) {
1226  (void)user;
1228  char buf[128];
1229  rz_config_node_value_format_i(buf, sizeof(buf), rz_cons_singleton()->context->color_mode, node);
1230  if (!node->value || strcmp(node->value, buf) != 0) {
1231  free(node->value);
1232  node->value = strdup(buf);
1233  }
1234  return true;
1235 }
1236 
1237 static bool cb_decoff(void *user, void *data) {
1238  RzCore *core = (RzCore *)user;
1239  RzConfigNode *node = (RzConfigNode *)data;
1240  if (node->i_value) {
1242  } else {
1243  core->print->flags &= (~RZ_PRINT_FLAGS_ADDRDEC);
1244  }
1245  rz_print_set_flags(core->print, core->print->flags);
1246  return true;
1247 }
1248 
1249 static bool cb_dbgbep(void *user, void *data) {
1250  RzConfigNode *node = (RzConfigNode *)data;
1251  if (*node->value == '?') {
1252  print_node_options(node);
1253  return false;
1254  }
1255  return true;
1256 }
1257 
1258 static bool cb_dbg_btalgo(void *user, void *data) {
1259  RzCore *core = (RzCore *)user;
1260  RzConfigNode *node = (RzConfigNode *)data;
1261  if (*node->value == '?') {
1262  print_node_options(node);
1263  return false;
1264  }
1265  free(core->dbg->btalgo);
1266  core->dbg->btalgo = strdup(node->value);
1267  return true;
1268 }
1269 
1270 static bool cb_dbg_libs(void *user, void *data) {
1271  RzCore *core = (RzCore *)user;
1272  RzConfigNode *node = (RzConfigNode *)data;
1273  free(core->dbg->glob_libs);
1274  core->dbg->glob_libs = strdup(node->value);
1275  return true;
1276 }
1277 
1278 static bool cb_dbg_unlibs(void *user, void *data) {
1279  RzCore *core = (RzCore *)user;
1280  RzConfigNode *node = (RzConfigNode *)data;
1281  free(core->dbg->glob_unlibs);
1282  core->dbg->glob_unlibs = strdup(node->value);
1283  return true;
1284 }
1285 
1286 static bool cb_dbg_bpinmaps(void *user, void *data) {
1287  RzCore *core = (RzCore *)user;
1288  RzConfigNode *node = (RzConfigNode *)data;
1289  core->dbg->bp->bpinmaps = node->i_value;
1290  return true;
1291 }
1292 
1293 static bool cb_dbg_forks(void *user, void *data) {
1294  RzCore *core = (RzCore *)user;
1295  RzConfigNode *node = (RzConfigNode *)data;
1296  core->dbg->trace_forks = node->i_value;
1297  if (core->bin->is_debugger) {
1298  rz_debug_attach(core->dbg, core->dbg->pid);
1299  }
1300  return true;
1301 }
1302 
1303 static bool cb_dbg_gdb_page_size(void *user, void *data) {
1304  RzCore *core = (RzCore *)user;
1305  RzConfigNode *node = (RzConfigNode *)data;
1306  if (node->i_value < 64) { // 64 is hardcoded min packet size
1307  return false;
1308  }
1309  if (isGdbPlugin(core)) {
1310  char cmd[64];
1311  snprintf(cmd, sizeof(cmd), "page_size %" PFMT64d, node->i_value);
1312  free(rz_io_system(core->io, cmd));
1313  }
1314  return true;
1315 }
1316 
1317 static bool cb_dbg_gdb_retries(void *user, void *data) {
1318  RzCore *core = (RzCore *)user;
1319  RzConfigNode *node = (RzConfigNode *)data;
1320  if (node->i_value <= 0) {
1321  return false;
1322  }
1323  if (isGdbPlugin(core)) {
1324  char cmd[64];
1325  snprintf(cmd, sizeof(cmd), "retries %" PFMT64d, node->i_value);
1326  free(rz_io_system(core->io, cmd));
1327  }
1328  return true;
1329 }
1330 
1331 static bool cb_dbg_execs(void *user, void *data) {
1332  RzConfigNode *node = (RzConfigNode *)data;
1333 #if __linux__
1334  RzCore *core = (RzCore *)user;
1335  core->dbg->trace_execs = node->i_value;
1336  if (core->bin->is_debugger) {
1337  rz_debug_attach(core->dbg, core->dbg->pid);
1338  }
1339 #else
1340  if (node->i_value) {
1341  eprintf("Warning: dbg.execs is not supported in this platform.\n");
1342  }
1343 #endif
1344  return true;
1345 }
1346 
1347 static bool cb_dbg_clone(void *user, void *data) {
1348  RzCore *core = (RzCore *)user;
1349  RzConfigNode *node = (RzConfigNode *)data;
1350  core->dbg->trace_clone = node->i_value;
1351  if (core->bin->is_debugger) {
1352  rz_debug_attach(core->dbg, core->dbg->pid);
1353  }
1354  return true;
1355 }
1356 
1357 static bool cb_dbg_follow_child(void *user, void *data) {
1358  RzCore *core = (RzCore *)user;
1359  RzConfigNode *node = (RzConfigNode *)data;
1360  core->dbg->follow_child = node->i_value;
1361  return true;
1362 }
1363 
1364 static bool cb_dbg_create_new_console(void *user, void *data) {
1365  RzCore *core = (RzCore *)user;
1366  RzConfigNode *node = (RzConfigNode *)data;
1367  core->dbg->create_new_console = node->i_value;
1368  return true;
1369 }
1370 
1371 static bool cb_dbg_trace_continue(void *user, void *data) {
1372  RzCore *core = (RzCore *)user;
1373  RzConfigNode *node = (RzConfigNode *)data;
1374  core->dbg->trace_continue = node->i_value;
1375  return true;
1376 }
1377 
1378 static bool cb_dbg_aftersc(void *user, void *data) {
1379  RzCore *core = (RzCore *)user;
1380  RzConfigNode *node = (RzConfigNode *)data;
1381  core->dbg->trace_aftersyscall = node->i_value;
1382  if (core->bin->is_debugger) {
1383  rz_debug_attach(core->dbg, core->dbg->pid);
1384  }
1385  return true;
1386 }
1387 
1388 static bool cb_runprofile(void *user, void *data) {
1389  RzCore *r = (RzCore *)user;
1390  RzConfigNode *node = (RzConfigNode *)data;
1391  free((void *)r->io->runprofile);
1392  if (!node || !*(node->value)) {
1393  r->io->runprofile = NULL;
1394  } else {
1395  r->io->runprofile = strdup(node->value);
1396  }
1397  return true;
1398 }
1399 
1400 static bool cb_dbg_args(void *user, void *data) {
1401  RzCore *core = (RzCore *)user;
1402  RzConfigNode *node = (RzConfigNode *)data;
1403  if (!node || !*(node->value)) {
1404  core->io->args = NULL;
1405  } else {
1406  core->io->args = strdup(node->value);
1407  }
1408  return true;
1409 }
1410 
1411 static bool cb_dbgbackend(void *user, void *data) {
1412  RzCore *core = (RzCore *)user;
1413  RzConfigNode *node = (RzConfigNode *)data;
1414  RzCmdStateOutput state = { 0 };
1416  if (!strcmp(node->value, "?")) {
1420  return false;
1421  }
1422  if (!strcmp(node->value, "bf")) {
1423  // hack
1424  rz_config_set(core->config, "asm.arch", "bf");
1425  }
1426  rz_debug_use(core->dbg, node->value);
1427  return true;
1428 }
1429 
1430 static bool cb_gotolimit(void *user, void *data) {
1431  RzCore *core = (RzCore *)user;
1432  RzConfigNode *node = (RzConfigNode *)data;
1433  if (core->analysis->esil) {
1434  core->analysis->esil_goto_limit = node->i_value;
1435  }
1436  return true;
1437 }
1438 
1439 static bool cb_esilverbose(void *user, void *data) {
1440  RzCore *core = (RzCore *)user;
1441  RzConfigNode *node = (RzConfigNode *)data;
1442  if (core->analysis->esil) {
1443  core->analysis->esil->verbose = node->i_value;
1444  }
1445  return true;
1446 }
1447 
1448 static bool cb_esilstackdepth(void *user, void *data) {
1449  RzConfigNode *node = (RzConfigNode *)data;
1450  if (node->i_value < 3) {
1451  eprintf("esil.stack.depth must be greater than 2\n");
1452  node->i_value = 32;
1453  }
1454  return true;
1455 }
1456 
1457 static bool cb_fixrows(void *user, void *data) {
1458  RzConfigNode *node = (RzConfigNode *)data;
1459  rz_cons_singleton()->fix_rows = (int)node->i_value;
1460  return true;
1461 }
1462 
1463 static bool cb_fixcolumns(void *user, void *data) {
1464  RzConfigNode *node = (RzConfigNode *)data;
1465  rz_cons_singleton()->fix_columns = atoi(node->value);
1466  return true;
1467 }
1468 
1469 static bool cb_rows(void *user, void *data) {
1470  RzConfigNode *node = (RzConfigNode *)data;
1472  return true;
1473 }
1474 
1475 static bool cb_cmd_hexcursor(void *user, void *data) {
1476  RzCore *core = (RzCore *)user;
1477  RzConfigNode *node = (RzConfigNode *)data;
1478  core->print->cfmt = node->value;
1479  return true;
1480 }
1481 
1482 static bool cb_hexcompact(void *user, void *data) {
1483  RzCore *core = (RzCore *)user;
1484  RzConfigNode *node = (RzConfigNode *)data;
1485  if (node->i_value) {
1487  } else {
1488  core->print->flags &= (~RZ_PRINT_FLAGS_COMPACT);
1489  }
1490  return true;
1491 }
1492 
1493 static bool cb_hex_pairs(void *user, void *data) {
1494  RzCore *core = (RzCore *)user;
1495  RzConfigNode *node = (RzConfigNode *)data;
1496  core->print->pairs = node->i_value;
1497  return true;
1498 }
1499 
1500 static bool cb_hex_section(void *user, void *data) {
1501  RzCore *core = (RzCore *)user;
1502  RzConfigNode *node = (RzConfigNode *)data;
1503  if (node->i_value) {
1505  } else {
1506  core->print->flags &= ~RZ_PRINT_FLAGS_SECTION;
1507  }
1508  return true;
1509 }
1510 
1511 static bool cb_hex_align(void *user, void *data) {
1512  RzCore *core = (RzCore *)user;
1513  RzConfigNode *node = (RzConfigNode *)data;
1514  if (node->i_value) {
1515  core->print->flags |= RZ_PRINT_FLAGS_ALIGN;
1516  } else {
1517  core->print->flags &= ~RZ_PRINT_FLAGS_ALIGN;
1518  }
1519  return true;
1520 }
1521 
1522 static bool cb_io_unalloc(void *user, void *data) {
1523  RzCore *core = (RzCore *)user;
1524  RzConfigNode *node = (RzConfigNode *)data;
1525  if (node->i_value) {
1527  } else {
1528  core->print->flags &= ~RZ_PRINT_FLAGS_UNALLOC;
1529  }
1530  return true;
1531 }
1532 
1533 static bool cb_io_unalloc_ch(void *user, void *data) {
1534  RzCore *core = (RzCore *)user;
1535  RzConfigNode *node = (RzConfigNode *)data;
1536  core->print->io_unalloc_ch = *node->value ? node->value[0] : ' ';
1537  return true;
1538 }
1539 
1540 static bool cb_hex_header(void *user, void *data) {
1541  RzCore *core = (RzCore *)user;
1542  RzConfigNode *node = (RzConfigNode *)data;
1543  if (node->i_value) {
1544  core->print->flags |= RZ_PRINT_FLAGS_HEADER;
1545  } else {
1546  core->print->flags &= ~RZ_PRINT_FLAGS_HEADER;
1547  }
1548  return true;
1549 }
1550 
1551 static bool cb_hex_bytes(void *user, void *data) {
1552  RzCore *core = (RzCore *)user;
1553  RzConfigNode *node = (RzConfigNode *)data;
1554  if (node->i_value) {
1555  core->print->flags &= ~RZ_PRINT_FLAGS_NONHEX;
1556  } else {
1557  core->print->flags |= RZ_PRINT_FLAGS_NONHEX;
1558  }
1559  return true;
1560 }
1561 
1562 static bool cb_hex_ascii(void *user, void *data) {
1563  RzCore *core = (RzCore *)user;
1564  RzConfigNode *node = (RzConfigNode *)data;
1565  if (node->i_value) {
1566  core->print->flags &= ~RZ_PRINT_FLAGS_NONASCII;
1567  } else {
1569  }
1570  return true;
1571 }
1572 
1573 static bool cb_hex_style(void *user, void *data) {
1574  RzCore *core = (RzCore *)user;
1575  RzConfigNode *node = (RzConfigNode *)data;
1576  if (node->i_value) {
1577  core->print->flags |= RZ_PRINT_FLAGS_STYLE;
1578  } else {
1579  core->print->flags &= ~RZ_PRINT_FLAGS_STYLE;
1580  }
1581  return true;
1582 }
1583 
1584 static bool cb_hex_hdroff(void *user, void *data) {
1585  RzCore *core = (RzCore *)user;
1586  RzConfigNode *node = (RzConfigNode *)data;
1587  if (node->i_value) {
1588  core->print->flags |= RZ_PRINT_FLAGS_HDROFF;
1589  } else {
1590  core->print->flags &= ~RZ_PRINT_FLAGS_HDROFF;
1591  }
1592  return true;
1593 }
1594 
1595 static bool cb_log_events(void *user, void *data) {
1596  RzCore *core = (RzCore *)user;
1597  RzConfigNode *node = (RzConfigNode *)data;
1598  core->log_events = node->i_value;
1599  return true;
1600 }
1601 
1602 static bool cb_hexcomments(void *user, void *data) {
1603  RzCore *core = (RzCore *)user;
1604  RzConfigNode *node = (RzConfigNode *)data;
1605  if (node->i_value) {
1607  } else {
1608  core->print->flags &= ~RZ_PRINT_FLAGS_COMMENT;
1609  }
1610  return true;
1611 }
1612 
1613 static bool cb_iopcache(void *user, void *data) {
1614  RzCore *core = (RzCore *)user;
1615  RzConfigNode *node = (RzConfigNode *)data;
1616  if ((bool)node->i_value) {
1617  if (core) {
1618  rz_config_set_b(core->config, "io.pcache.read", true);
1619  rz_config_set_b(core->config, "io.pcache.write", true);
1620  }
1621  } else {
1622  if (core && core->io) {
1624  rz_config_set_b(core->config, "io.pcache.read", false);
1625  rz_config_set_b(core->config, "io.pcache.write", false);
1626  }
1627  }
1628  return true;
1629 }
1630 
1631 static bool cb_iopcacheread(void *user, void *data) {
1632  RzCore *core = (RzCore *)user;
1633  RzConfigNode *node = (RzConfigNode *)data;
1634  if ((bool)node->i_value) {
1635  if (core && core->io) {
1636  core->io->p_cache |= 1;
1637  }
1638  } else {
1639  if (core && core->io && core->io->p_cache) {
1640  core->io->p_cache &= 2;
1641  if (!(core->io->p_cache & 2)) {
1643  rz_config_set_b(core->config, "io.pcache", false);
1644  }
1645  }
1646  }
1647  return true;
1648 }
1649 
1650 static bool cb_iopcachewrite(void *user, void *data) {
1651  RzCore *core = (RzCore *)user;
1652  RzConfigNode *node = (RzConfigNode *)data;
1653  if ((bool)node->i_value) {
1654  if (core && core->io) {
1655  core->io->p_cache |= 2;
1656  }
1657  } else {
1658  if (core && core->io && core->io->p_cache) {
1659  core->io->p_cache &= 1;
1660  if (!(core->io->p_cache & 1)) {
1662  rz_config_set_b(core->config, "io.pcache", false);
1663  }
1664  }
1665  }
1666  return true;
1667 }
1668 
1669 RZ_API bool rz_core_esil_cmd(RzAnalysisEsil *esil, const char *cmd, ut64 a1, ut64 a2) {
1670  if (cmd && *cmd) {
1671  RzCore *core = esil->analysis->core;
1672  rz_core_cmdf(core, "%s %" PFMT64d " %" PFMT64d, cmd, a1, a2);
1673  return core->num->value;
1674  }
1675  return false;
1676 }
1677 
1679  rz_return_if_fail(cfg && node && state);
1680  char *option;
1681  bool isFirst;
1682  RzOutputMode mode = state->mode;
1683  PJ *pj = state->d.pj;
1684  RzListIter *iter;
1685  char *es = NULL;
1686 
1687  switch (mode) {
1688  case RZ_OUTPUT_MODE_JSON:
1689  if (rz_str_isnumber(node->value)) {
1690  pj_kn(pj, node->name, rz_num_math(NULL, node->value));
1691  return;
1692  } else if (rz_str_is_bool(node->value)) {
1693  pj_kb(pj, node->name, (node->value));
1694  return;
1695  } else {
1696  pj_ks(pj, node->name, node->value);
1697  }
1698  break;
1700  pj_o(pj);
1701  pj_ks(pj, "name", node->name);
1702  if (rz_str_isnumber(node->value)) {
1703  pj_kn(pj, "value", rz_num_math(NULL, node->value));
1704  } else if (rz_str_is_bool(node->value)) {
1705  pj_kb(pj, "value", (node->value));
1706  } else {
1707  pj_ks(pj, "value", node->value);
1708  }
1709  pj_ks(pj, "type", rz_config_node_type(node));
1710  es = rz_str_escape(node->desc);
1711  if (es) {
1712  pj_ks(pj, "desc", es);
1713  free(es);
1714  }
1715  pj_kb(pj, "ro", rz_config_node_is_ro(node));
1716  if (!rz_list_empty(node->options)) {
1717  pj_ka(pj, "options");
1718  rz_list_foreach (node->options, iter, option) {
1719  pj_s(pj, option);
1720  }
1721  pj_end(pj);
1722  }
1723  pj_end(pj);
1724  break;
1725  case RZ_OUTPUT_MODE_LONG:
1726  rz_cons_printf("%s = %s %s; %s",
1727  node->name, node->value,
1728  rz_config_node_is_ro(node) ? "(ro)" : "",
1729  node->desc);
1730  if (!rz_list_empty(node->options)) {
1731  isFirst = true;
1732  rz_cons_printf(" [");
1733  rz_list_foreach (node->options, iter, option) {
1734  if (isFirst) {
1735  isFirst = false;
1736  } else {
1737  rz_cons_printf(", ");
1738  }
1739  rz_cons_printf("%s", option);
1740  }
1741  rz_cons_printf("]");
1742  }
1743  rz_cons_println("");
1744  break;
1745  case RZ_OUTPUT_MODE_QUIET:
1746  rz_cons_printf("%s=%s\n", node->name, node->value);
1747  break;
1748  case RZ_OUTPUT_MODE_RIZIN:
1750  rz_cons_printf("e %s=%s\n", node->name, es);
1751  free(es);
1752  break;
1754  rz_cons_printf("%20s: %s\n", node->name,
1755  node->desc ? node->desc : "");
1756  break;
1757  default:
1759  break;
1760  }
1761 }
1762 
1771  rz_return_if_fail(cfg);
1772  RzConfigNode *node;
1773  RzListIter *iter;
1774  PJ *pj = state->d.pj;
1775  RzOutputMode mode = state->mode;
1776 
1777  if (mode == RZ_OUTPUT_MODE_LONG_JSON) {
1778  pj_a(pj);
1779  } else if (mode == RZ_OUTPUT_MODE_JSON) {
1780  pj_o(pj);
1781  }
1782 
1783  rz_list_foreach (cfg->nodes, iter, node) {
1784  if (rz_str_startswith(node->name, str)) {
1785  config_print_node(cfg, node, state);
1786  }
1787  }
1788 
1790  pj_end(pj);
1791  }
1792 }
1793 
1794 static bool cb_cmd_esil_ioer(void *user, void *data) {
1795  RzCore *core = (RzCore *)user;
1796  RzConfigNode *node = (RzConfigNode *)data;
1797  if (core && core->analysis && core->analysis->esil) {
1798  core->analysis->esil->cmd = rz_core_esil_cmd;
1799  free(core->analysis->esil->cmd_ioer);
1800  core->analysis->esil->cmd_ioer = strdup(node->value);
1801  }
1802  return true;
1803 }
1804 
1805 static bool cb_cmd_esil_todo(void *user, void *data) {
1806  RzCore *core = (RzCore *)user;
1807  RzConfigNode *node = (RzConfigNode *)data;
1808  if (core && core->analysis && core->analysis->esil) {
1809  core->analysis->esil->cmd = rz_core_esil_cmd;
1810  free(core->analysis->esil->cmd_todo);
1811  core->analysis->esil->cmd_todo = strdup(node->value);
1812  }
1813  return true;
1814 }
1815 
1816 static bool cb_cmd_esil_intr(void *user, void *data) {
1817  RzCore *core = (RzCore *)user;
1818  RzConfigNode *node = (RzConfigNode *)data;
1819  if (core && core->analysis && core->analysis->esil) {
1820  core->analysis->esil->cmd = rz_core_esil_cmd;
1821  free(core->analysis->esil->cmd_intr);
1822  core->analysis->esil->cmd_intr = strdup(node->value);
1823  }
1824  return true;
1825 }
1826 
1827 static bool cb_mdevrange(void *user, void *data) {
1828  RzCore *core = (RzCore *)user;
1829  RzConfigNode *node = (RzConfigNode *)data;
1830  if (core && core->analysis && core->analysis->esil) {
1831  core->analysis->esil->cmd = rz_core_esil_cmd;
1832  free(core->analysis->esil->mdev_range);
1833  core->analysis->esil->mdev_range = strdup(node->value);
1834  }
1835  return true;
1836 }
1837 
1838 static bool cb_cmd_esil_step(void *user, void *data) {
1839  RzCore *core = (RzCore *)user;
1840  RzConfigNode *node = (RzConfigNode *)data;
1841  if (core && core->analysis && core->analysis->esil) {
1842  core->analysis->esil->cmd = rz_core_esil_cmd;
1843  free(core->analysis->esil->cmd_step);
1844  core->analysis->esil->cmd_step = strdup(node->value);
1845  }
1846  return true;
1847 }
1848 
1849 static bool cb_cmd_esil_step_out(void *user, void *data) {
1850  RzCore *core = (RzCore *)user;
1851  RzConfigNode *node = (RzConfigNode *)data;
1852  if (core && core->analysis && core->analysis->esil) {
1853  core->analysis->esil->cmd = rz_core_esil_cmd;
1854  free(core->analysis->esil->cmd_step_out);
1855  core->analysis->esil->cmd_step_out = strdup(node->value);
1856  }
1857  return true;
1858 }
1859 
1860 static bool cb_cmd_esil_mdev(void *user, void *data) {
1861  RzCore *core = (RzCore *)user;
1862  RzConfigNode *node = (RzConfigNode *)data;
1863  if (core && core->analysis && core->analysis->esil) {
1864  core->analysis->esil->cmd = rz_core_esil_cmd;
1865  free(core->analysis->esil->cmd_mdev);
1866  core->analysis->esil->cmd_mdev = strdup(node->value);
1867  }
1868  return true;
1869 }
1870 
1871 static bool cb_cmd_esil_trap(void *user, void *data) {
1872  RzCore *core = (RzCore *)user;
1873  RzConfigNode *node = (RzConfigNode *)data;
1874  if (core && core->analysis && core->analysis->esil) {
1875  core->analysis->esil->cmd = rz_core_esil_cmd;
1876  core->analysis->esil->cmd_trap = strdup(node->value);
1877  }
1878  return true;
1879 }
1880 
1881 static bool cb_cmddepth(void *user, void *data) {
1882  RzCore *core = (RzCore *)user;
1883  int c = RZ_MAX(((RzConfigNode *)data)->i_value, 0);
1884  core->max_cmd_depth = c;
1885  core->cons->context->cmd_depth = c;
1886  return true;
1887 }
1888 
1889 static bool cb_hexcols(void *user, void *data) {
1890  RzCore *core = (RzCore *)user;
1891  int c = RZ_MIN(1024, RZ_MAX(((RzConfigNode *)data)->i_value, 0));
1892  core->print->cols = c; // & ~1;
1893  core->dbg->regcols = c / 4;
1894  return true;
1895 }
1896 
1897 static bool cb_hexstride(void *user, void *data) {
1898  RzConfigNode *node = (RzConfigNode *)data;
1899  ((RzCore *)user)->print->stride = node->i_value;
1900  return true;
1901 }
1902 
1903 static bool cb_search_kwidx(void *user, void *data) {
1904  RzCore *core = (RzCore *)user;
1905  RzConfigNode *node = (RzConfigNode *)data;
1906  core->search->n_kws = node->i_value;
1907  return true;
1908 }
1909 
1910 static bool cb_io_cache_mode(void *user, void *data) {
1911  RzCore *core = (RzCore *)user;
1912  RzConfigNode *node = (RzConfigNode *)data;
1913  if (node->i_value) {
1914  core->io->cachemode = true;
1915  } else {
1916  core->io->cachemode = false;
1917  }
1918  return true;
1919 }
1920 
1921 static bool cb_io_cache_read(void *user, void *data) {
1922  RzCore *core = (RzCore *)user;
1923  RzConfigNode *node = (RzConfigNode *)data;
1924  if (node->i_value) {
1925  core->io->cached |= RZ_PERM_R;
1926  } else {
1927  core->io->cached &= ~RZ_PERM_R;
1928  }
1929  return true;
1930 }
1931 
1932 static bool cb_io_cache_write(void *user, void *data) {
1933  RzCore *core = (RzCore *)user;
1934  RzConfigNode *node = (RzConfigNode *)data;
1935  if (node->i_value) {
1936  core->io->cached |= RZ_PERM_W;
1937  } else {
1938  core->io->cached &= ~RZ_PERM_W;
1939  }
1940  return true;
1941 }
1942 
1943 static bool cb_io_cache(void *user, void *data) {
1944  (void)cb_io_cache_read(user, data);
1945  (void)cb_io_cache_write(user, data);
1946  return true;
1947 }
1948 
1949 static bool cb_ioaslr(void *user, void *data) {
1950  RzCore *core = (RzCore *)user;
1951  RzConfigNode *node = (RzConfigNode *)data;
1952  if (node->i_value != core->io->aslr) {
1953  core->io->aslr = node->i_value;
1954  }
1955  return true;
1956 }
1957 
1958 static bool cb_io_pava(void *user, void *data) {
1959  RzCore *core = (RzCore *)user;
1960  RzConfigNode *node = (RzConfigNode *)data;
1961  core->print->pava = node->i_value;
1962  if (node->i_value && core->io->va) {
1963  eprintf("WARNING: You may probably want to disable io.va too\n");
1964  }
1965  return true;
1966 }
1967 
1968 static bool cb_iova(void *user, void *data) {
1969  RzCore *core = (RzCore *)user;
1970  RzConfigNode *node = (RzConfigNode *)data;
1971  if (node->i_value != core->io->va) {
1972  core->io->va = node->i_value;
1973  /* ugly fix for rizin -d ... "rizin is going to die soon ..." */
1974  if (core->io->desc) {
1975  rz_core_block_read(core);
1976  }
1977 #if 0
1978  /* reload symbol information */
1979  if (rz_list_length (rz_bin_get_sections (core->bin)) > 0) {
1980  rz_core_cmd0 (core, ".ia*");
1981  }
1982 #endif
1983  }
1984  return true;
1985 }
1986 
1987 static bool cb_ioff(void *user, void *data) {
1988  RzCore *core = (RzCore *)user;
1989  RzConfigNode *node = (RzConfigNode *)data;
1990  core->io->ff = node->i_value;
1991  return true;
1992 }
1993 
1994 static bool cb_io_oxff(void *user, void *data) {
1995  RzCore *core = (RzCore *)user;
1996  RzConfigNode *node = (RzConfigNode *)data;
1997  core->io->Oxff = node->i_value;
1998  return true;
1999 }
2000 
2001 static bool cb_filepath(void *user, void *data) {
2002  RzCore *core = (RzCore *)user;
2003  RzConfigNode *node = (RzConfigNode *)data;
2004  char *pikaboo = strstr(node->value, "://");
2005  if (pikaboo) {
2006  if (pikaboo[3] == '/') {
2007  rz_config_set(core->config, "file.lastpath", node->value);
2008  char *ovalue = node->value;
2009  node->value = strdup(pikaboo + 3);
2010  free(ovalue);
2011  return true;
2012  }
2013  return false;
2014  }
2015  rz_config_set(core->config, "file.lastpath", node->value);
2016  return true;
2017 }
2018 
2019 static bool cb_ioautofd(void *user, void *data) {
2020  RzCore *core = (RzCore *)user;
2021  RzConfigNode *node = (RzConfigNode *)data;
2022  core->io->autofd = node->i_value;
2023  return true;
2024 }
2025 
2026 static bool cb_scr_color_grep(void *user, void *data) {
2027  RzCore *core = (RzCore *)user;
2028  RzConfigNode *node = (RzConfigNode *)data;
2029 
2030  /* Let cons know we have a new pager. */
2031  core->cons->grep_color = node->i_value;
2032  return true;
2033 }
2034 
2035 static bool cb_scr_color_grep_highlight(void *user, void *data) {
2036  RzCore *core = (RzCore *)user;
2037  RzConfigNode *node = (RzConfigNode *)data;
2038  core->cons->grep_highlight = node->i_value;
2039  return true;
2040 }
2041 
2042 static bool cb_pager(void *user, void *data) {
2043  RzCore *core = (RzCore *)user;
2044  RzConfigNode *node = (RzConfigNode *)data;
2045  if (!strcmp(node->value, "?")) {
2046  eprintf("Usage: scr.pager must be '..' for internal less, or the path to a program in $PATH");
2047  return false;
2048  }
2049  /* Let cons know we have a new pager. */
2050  free(core->cons->pager);
2051  core->cons->pager = strdup(node->value);
2052  return true;
2053 }
2054 
2055 static bool cb_breaklines(void *user, void *data) {
2056  RzConfigNode *node = (RzConfigNode *)data;
2058  return true;
2059 }
2060 
2061 static bool cb_scr_gadgets(void *user, void *data) {
2062  RzCore *core = (RzCore *)user;
2063  RzConfigNode *node = (RzConfigNode *)data;
2064  core->scr_gadgets = node->i_value;
2065  return true;
2066 }
2067 
2068 static bool cb_scrbreakword(void *user, void *data) {
2069  RzConfigNode *node = (RzConfigNode *)data;
2070  if (*node->value) {
2071  rz_cons_breakword(node->value);
2072  } else {
2074  }
2075  return true;
2076 }
2077 
2078 static bool cb_scrcolumns(void *user, void *data) {
2079  RzConfigNode *node = (RzConfigNode *)data;
2080  RzCore *core = (RzCore *)user;
2081  int n = atoi(node->value);
2082  core->cons->force_columns = n;
2083  core->dbg->regcols = n / 20;
2085  return true;
2086 }
2087 
2088 static bool cb_scrfgets(void *user, void *data) {
2089  RzCore *core = (RzCore *)user;
2090  RzConfigNode *node = (RzConfigNode *)data;
2091  core->cons->user_fgets = node->i_value
2092  ? NULL
2093  : (void *)rz_core_fgets;
2094  core->cons->user_fgets_user = core;
2095  return true;
2096 }
2097 
2098 static bool cb_scrhtml(void *user, void *data) {
2099  RzConfigNode *node = (RzConfigNode *)data;
2100  rz_cons_singleton()->is_html = node->i_value;
2101  // TODO: control error and restore old value (return false?) show errormsg?
2102  return true;
2103 }
2104 
2105 static bool cb_scrhighlight(void *user, void *data) {
2106  RzConfigNode *node = (RzConfigNode *)data;
2107  rz_cons_highlight(node->value);
2108  return true;
2109 }
2110 
2111 #if __WINDOWS__
2112 static bool scr_vtmode(void *user, void *data) {
2113  RzConfigNode *node = (RzConfigNode *)data;
2114  if (rz_str_is_true(node->value)) {
2116  }
2119 
2120  DWORD mode;
2121  HANDLE input = GetStdHandle(STD_INPUT_HANDLE);
2122  GetConsoleMode(input, &mode);
2123  if (node->i_value == RZ_VIRT_TERM_MODE_COMPLETE) {
2124  SetConsoleMode(input, mode & ENABLE_VIRTUAL_TERMINAL_INPUT);
2125  rz_cons_singleton()->term_raw |= ENABLE_VIRTUAL_TERMINAL_INPUT;
2126  } else {
2127  SetConsoleMode(input, mode & ~ENABLE_VIRTUAL_TERMINAL_INPUT);
2128  rz_cons_singleton()->term_raw &= ~ENABLE_VIRTUAL_TERMINAL_INPUT;
2129  }
2130  HANDLE streams[] = { GetStdHandle(STD_OUTPUT_HANDLE), GetStdHandle(STD_ERROR_HANDLE) };
2131  int i;
2132  if (node->i_value > RZ_VIRT_TERM_MODE_DISABLE) {
2133  for (i = 0; i < RZ_ARRAY_SIZE(streams); i++) {
2134  GetConsoleMode(streams[i], &mode);
2135  SetConsoleMode(streams[i],
2136  mode | ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
2137  }
2138  } else {
2139  for (i = 0; i < RZ_ARRAY_SIZE(streams); i++) {
2140  GetConsoleMode(streams[i], &mode);
2141  SetConsoleMode(streams[i],
2142  mode & ~ENABLE_VIRTUAL_TERMINAL_PROCESSING & ~ENABLE_WRAP_AT_EOL_OUTPUT);
2143  }
2144  }
2145  return true;
2146 }
2147 #endif
2148 
2149 static bool cb_screcho(void *user, void *data) {
2150  RzConfigNode *node = (RzConfigNode *)data;
2151  rz_cons_singleton()->echo = node->i_value;
2152  return true;
2153 }
2154 
2155 static bool cb_scrlinesleep(void *user, void *data) {
2156  RzConfigNode *node = (RzConfigNode *)data;
2157  rz_cons_singleton()->linesleep = node->i_value;
2158  return true;
2159 }
2160 
2161 static bool cb_scrpagesize(void *user, void *data) {
2162  RzConfigNode *node = (RzConfigNode *)data;
2163  rz_cons_singleton()->pagesize = node->i_value;
2164  return true;
2165 }
2166 
2167 static bool cb_scrflush(void *user, void *data) {
2168  RzConfigNode *node = (RzConfigNode *)data;
2169  rz_cons_singleton()->flush = node->i_value;
2170  return true;
2171 }
2172 
2173 static bool cb_scrstrconv(void *user, void *data) {
2174  RzCore *core = (RzCore *)user;
2175  RzConfigNode *node = (RzConfigNode *)data;
2176  if (node->value[0] == '?') {
2177  if (strlen(node->value) > 1 && node->value[1] == '?') {
2178  rz_cons_printf("Valid values for scr.strconv:\n"
2179  " asciiesc convert to ascii with non-ascii chars escaped\n"
2180  " asciidot convert to ascii with non-ascii chars turned into a dot (except control chars stated below)\n"
2181  "\n"
2182  "Ascii chars are in the range 0x20-0x7e. Always escaped control chars are alert (\\a),\n"
2183  "backspace (\\b), formfeed (\\f), newline (\\n), carriage return (\\r), horizontal tab (\\t)\n"
2184  "and vertical tab (\\v). Also, double quotes (\\\") are always escaped, but backslashes (\\\\)\n"
2185  "are only escaped if str.escbslash = true.\n");
2186  } else {
2187  print_node_options(node);
2188  }
2189  return false;
2190  } else {
2191  free((char *)core->print->strconv_mode);
2192  core->print->strconv_mode = strdup(node->value);
2193  }
2194  return true;
2195 }
2196 
2197 static bool cb_graphformat(void *user, void *data) {
2198  RzConfigNode *node = (RzConfigNode *)data;
2199  if (!strcmp(node->value, "?")) {
2200  rz_cons_printf("png\njpg\npdf\nps\nsvg\njson\n");
2201  return false;
2202  }
2203  return true;
2204 }
2205 
2206 static bool cb_exectrap(void *user, void *data) {
2207  RzConfigNode *node = (RzConfigNode *)data;
2208  RzCore *core = (RzCore *)user;
2209  if (core->analysis && core->analysis->esil) {
2210  core->analysis->esil->exectrap = node->i_value;
2211  }
2212  return true;
2213 }
2214 
2215 static bool cb_iotrap(void *user, void *data) {
2216  RzConfigNode *node = (RzConfigNode *)data;
2217  RzCore *core = (RzCore *)user;
2218  if (core->analysis && core->analysis->esil) {
2219  core->analysis->esil->iotrap = node->i_value;
2220  }
2221  return true;
2222 }
2223 
2224 static bool cb_scr_bgfill(void *user, void *data) {
2225  RzCore *core = (RzCore *)user;
2226  RzConfigNode *node = (RzConfigNode *)data;
2227  if (node->i_value) {
2228  core->print->flags |= RZ_PRINT_FLAGS_BGFILL;
2229  } else {
2230  core->print->flags &= (~RZ_PRINT_FLAGS_BGFILL);
2231  }
2232  rz_print_set_flags(core->print, core->print->flags);
2233  return true;
2234 }
2235 
2236 static bool cb_scrint(void *user, void *data) {
2237  RzConfigNode *node = (RzConfigNode *)data;
2239  return true;
2240 }
2241 
2242 static bool cb_scrnkey(void *user, void *data) {
2243  RzConfigNode *node = (RzConfigNode *)data;
2244  if (!strcmp(node->value, "help") || *node->value == '?') {
2245  print_node_options(node);
2246  return false;
2247  }
2248  return true;
2249 }
2250 
2251 static bool cb_scr_histblock(void *user, void *data) {
2252  RzCore *core = (RzCore *)user;
2253  RzConfigNode *node = (RzConfigNode *)data;
2254  core->print->histblock = node->i_value;
2255  return true;
2256 }
2257 
2258 static bool cb_scrprompt(void *user, void *data) {
2259  RzCore *core = (RzCore *)user;
2260  RzConfigNode *node = (RzConfigNode *)data;
2261  core->print->scr_prompt = node->i_value;
2262  rz_line_singleton()->echo = node->i_value;
2263  return true;
2264 }
2265 
2266 static bool cb_scrrows(void *user, void *data) {
2267  RzConfigNode *node = (RzConfigNode *)data;
2268  int n = atoi(node->value);
2269  ((RzCore *)user)->cons->force_rows = n;
2270  return true;
2271 }
2272 
2273 static bool cb_contiguous(void *user, void *data) {
2274  RzCore *core = (RzCore *)user;
2275  RzConfigNode *node = (RzConfigNode *)data;
2276  core->search->contiguous = node->i_value;
2277  return true;
2278 }
2279 
2280 static bool cb_searchalign(void *user, void *data) {
2281  RzCore *core = (RzCore *)user;
2282  RzConfigNode *node = (RzConfigNode *)data;
2283  core->search->align = node->i_value;
2284  core->print->addrmod = node->i_value;
2285  return true;
2286 }
2287 
2288 static bool cb_segoff(void *user, void *data) {
2289  RzCore *core = (RzCore *)user;
2290  RzConfigNode *node = (RzConfigNode *)data;
2291  if (node->i_value) {
2292  core->print->flags |= RZ_PRINT_FLAGS_SEGOFF;
2293  } else {
2294  core->print->flags &= (((ut32)-1) & (~RZ_PRINT_FLAGS_SEGOFF));
2295  }
2296  return true;
2297 }
2298 
2299 static bool cb_seggrn(void *user, void *data) {
2300  RzCore *core = (RzCore *)user;
2301  RzConfigNode *node = (RzConfigNode *)data;
2302  core->rasm->seggrn = node->i_value;
2303  core->analysis->seggrn = node->i_value;
2304  core->print->seggrn = node->i_value;
2305  return true;
2306 }
2307 
2308 static bool cb_stopthreads(void *user, void *data) {
2309  RzCore *core = (RzCore *)user;
2310  RzConfigNode *node = (RzConfigNode *)data;
2311  core->dbg->stop_all_threads = node->i_value;
2312  return true;
2313 }
2314 
2315 static bool cb_scr_prompt_popup(void *user, void *data) {
2316  RzCore *core = (RzCore *)user;
2317  RzConfigNode *node = (RzConfigNode *)data;
2318  core->cons->show_autocomplete_widget = node->i_value;
2319  return true;
2320 }
2321 
2322 static bool cb_swstep(void *user, void *data) {
2323  RzCore *core = (RzCore *)user;
2324  RzConfigNode *node = (RzConfigNode *)data;
2325  core->dbg->swstep = node->i_value;
2326  return true;
2327 }
2328 
2329 static bool cb_consbreak(void *user, void *data) {
2330  RzCore *core = (RzCore *)user;
2331  RzConfigNode *node = (RzConfigNode *)data;
2332  core->dbg->consbreak = node->i_value;
2333  return true;
2334 }
2335 
2336 static bool cb_teefile(void *user, void *data) {
2337  RzConfigNode *node = (RzConfigNode *)data;
2338  rz_cons_singleton()->teefile = node->value;
2339  return true;
2340 }
2341 
2342 static bool cb_trace(void *user, void *data) {
2343  RzCore *core = (RzCore *)user;
2344  RzConfigNode *node = (RzConfigNode *)data;
2345  core->dbg->trace->enabled = node->i_value;
2346  return true;
2347 }
2348 
2349 static bool cb_tracetag(void *user, void *data) {
2350  RzCore *core = (RzCore *)user;
2351  RzConfigNode *node = (RzConfigNode *)data;
2352  core->dbg->trace->tag = node->i_value;
2353  return true;
2354 }
2355 
2356 static bool cb_utf8(void *user, void *data) {
2357  RzCore *core = (RzCore *)user;
2358  RzConfigNode *node = (RzConfigNode *)data;
2359  core->rasm->utf8 = (bool)node->i_value;
2360  rz_cons_set_utf8((bool)node->i_value);
2361  return true;
2362 }
2363 
2364 static bool cb_utf8_curvy(void *user, void *data) {
2365  RzCore *core = (RzCore *)user;
2366  RzConfigNode *node = (RzConfigNode *)data;
2367  core->cons->use_utf8_curvy = node->i_value;
2368  return true;
2369 }
2370 
2371 static bool cb_visual_mode(void *user, void *data) {
2372  RzConfigNode *node = (RzConfigNode *)data;
2373  if (node->i_value > RZ_CORE_VISUAL_MODE_CD) {
2375  }
2376  RzCore *core = (RzCore *)user;
2377  core->printidx = node->i_value;
2378  return true;
2379 }
2380 
2381 static bool cb_dotted(void *user, void *data) {
2382  RzCore *core = (RzCore *)user;
2383  RzConfigNode *node = (RzConfigNode *)data;
2384  core->cons->dotted_lines = node->i_value;
2385  return true;
2386 }
2387 
2388 static bool cb_zoombyte(void *user, void *data) {
2389  RzCore *core = (RzCore *)user;
2390  RzConfigNode *node = (RzConfigNode *)data;
2391  switch (*node->value) {
2392  case 'p':
2393  case 'f':
2394  case 's':
2395  case '0':
2396  case 'F':
2397  case 'e':
2398  case 'h':
2399  core->print->zoom->mode = *node->value;
2400  break;
2401  default:
2402  eprintf("Invalid zoom.byte value. See pz? for help\n");
2403  rz_cons_printf("pzp\npzf\npzs\npz0\npzF\npze\npzh\n");
2404  return false;
2405  }
2406  return true;
2407 }
2408 
2409 static bool cb_binverbose(void *user, void *data) {
2410  RzCore *core = (RzCore *)user;
2411  RzConfigNode *node = (RzConfigNode *)data;
2412  core->bin->verbose = node->i_value;
2413  return true;
2414 }
2415 
2416 static bool cb_debase64(void *user, void *data) {
2417  RzCore *core = (RzCore *)user;
2418  RzConfigNode *node = (RzConfigNode *)data;
2419  core->bin->debase64 = node->i_value;
2420  return true;
2421 }
2422 
2423 static bool cb_binstrings(void *user, void *data) {
2424  const ut32 req = RZ_BIN_REQ_STRINGS;
2425  RzCore *core = (RzCore *)user;
2426  RzConfigNode *node = (RzConfigNode *)data;
2427  if (node->i_value) {
2428  core->bin->filter_rules |= req;
2429  } else {
2430  core->bin->filter_rules &= ~req;
2431  }
2432  return true;
2433 }
2434 
2435 static bool cb_bindbginfo(void *user, void *data) {
2436  RzCore *core = (RzCore *)user;
2437  RzConfigNode *node = (RzConfigNode *)data;
2438  if (!core || !core->bin) {
2439  return false;
2440  }
2441  core->bin->want_dbginfo = node->i_value;
2442  return true;
2443 }
2444 
2445 static bool cb_binprefix(void *user, void *data) {
2446  RzCore *core = (RzCore *)user;
2447  RzConfigNode *node = (RzConfigNode *)data;
2448  if (!core || !core->bin) {
2449  return false;
2450  }
2451  if (node->value && *node->value) {
2452  if (!strcmp(node->value, "auto")) {
2453  if (!core->bin->file) {
2454  return false;
2455  }
2456  char *name = (char *)rz_file_basename(core->bin->file);
2457  if (name) {
2458  rz_name_filter(name, strlen(name), true);
2460  core->bin->prefix = strdup(name);
2461  free(name);
2462  }
2463  } else {
2464  core->bin->prefix = node->value;
2465  }
2466  }
2467  return true;
2468 }
2469 
2470 static bool cb_binmaxstrbuf(void *user, void *data) {
2471  RzCore *core = (RzCore *)user;
2472  RzConfigNode *node = (RzConfigNode *)data;
2473  if (core->bin) {
2474  int v = node->i_value;
2475  ut64 old_v = core->bin->maxstrbuf;
2476  if (v < 1) {
2477  v = 4; // HACK
2478  }
2479  core->bin->maxstrbuf = v;
2480  if (v > old_v) {
2481  RzBinFile *bf = rz_bin_cur(core->bin);
2482  if (bf && bf->o) {
2483  rz_bin_object_reset_strings(core->bin, bf, bf->o);
2484  }
2485  }
2486  return true;
2487  }
2488  return true;
2489 }
2490 
2491 static bool cb_binmaxstr(void *user, void *data) {
2492  RzCore *core = (RzCore *)user;
2493  RzConfigNode *node = (RzConfigNode *)data;
2494  if (core->bin) {
2495  int v = node->i_value;
2496  if (v < 0) {
2497  v = 0;
2498  }
2499  core->bin->maxstrlen = v;
2500  RzBinFile *bf = rz_bin_cur(core->bin);
2501  if (bf && bf->o) {
2502  rz_bin_object_reset_strings(core->bin, bf, bf->o);
2503  }
2504  return true;
2505  }
2506  return true;
2507 }
2508 
2509 static bool cb_binminstr(void *user, void *data) {
2510  RzCore *core = (RzCore *)user;
2511  RzConfigNode *node = (RzConfigNode *)data;
2512  if (core->bin) {
2513  int v = node->i_value;
2514  if (v < 1) {
2515  v = 4; // HACK
2516  }
2517  core->bin->minstrlen = v;
2518  RzBinFile *bf = rz_bin_cur(core->bin);
2519  if (bf && bf->o) {
2520  rz_bin_object_reset_strings(core->bin, bf, bf->o);
2521  }
2522  return true;
2523  }
2524  return true;
2525 }
2526 
2527 static bool cb_searchin(void *user, void *data) {
2528  RzCore *core = (RzCore *)user;
2529  RzConfigNode *node = (RzConfigNode *)data;
2530  if (node->value[0] == '?') {
2531  if (strlen(node->value) > 1 && node->value[1] == '?') {
2532  rz_cons_printf("Valid values for search.in (depends on .from/.to and io.va):\n"
2533  "raw search in raw io (ignoring bounds)\n"
2534  "block search in the current block\n"
2535  "io.map search in current map\n"
2536  "io.sky.[rwx] search in all skyline segments\n"
2537  "io.maps search in all maps\n"
2538  "io.maps.[rwx] search in all r-w-x io maps\n"
2539  "bin.segment search in current mapped segment\n"
2540  "bin.segments search in all mapped segments\n"
2541  "bin.segments.[rwx] search in all r-w-x segments\n"
2542  "bin.section search in current mapped section\n"
2543  "bin.sections search in all mapped sections\n"
2544  "bin.sections.[rwx] search in all r-w-x sections\n"
2545  "dbg.stack search in the stack\n"
2546  "dbg.heap search in the heap\n"
2547  "dbg.map search in current memory map\n"
2548  "dbg.maps search in all memory maps\n"
2549  "dbg.maps.[rwx] search in all executable marked memory maps\n"
2550  "analysis.fcn search in the current function\n"
2551  "analysis.bb search in the current basic-block\n");
2552  } else {
2553  print_node_options(node);
2554  }
2555  return false;
2556  }
2557  // Set analysis.noncode if exec bit set in analysis.in
2558  if (rz_str_startswith(node->name, "analysis")) {
2559  core->analysis->opt.noncode = (strchr(node->value, 'x') == NULL);
2560  }
2561  return true;
2562 }
2563 
2564 static int __dbg_swstep_getter(void *user, RzConfigNode *node) {
2565  RzCore *core = (RzCore *)user;
2566  node->i_value = core->dbg->swstep;
2567  return true;
2568 }
2569 
2570 static bool cb_analysis_roregs(RzCore *core, RzConfigNode *node) {
2571  if (core && core->analysis && core->analysis->reg) {
2572  rz_list_free(core->analysis->reg->roregs);
2573  core->analysis->reg->roregs = rz_str_split_duplist(node->value, ",", true);
2574  }
2575  return true;
2576 }
2577 
2578 static bool cb_analysissyscc(RzCore *core, RzConfigNode *node) {
2579  if (core && core->analysis) {
2580  if (!strcmp(node->value, "?")) {
2582  return false;
2583  }
2585  }
2586  return true;
2587 }
2588 
2589 static bool cb_analysiscc(RzCore *core, RzConfigNode *node) {
2590  if (core && core->analysis) {
2591  if (!strcmp(node->value, "?")) {
2593  return false;
2594  }
2596  }
2597  return true;
2598 }
2599 
2600 static bool cb_analysis_gp(RzCore *core, RzConfigNode *node) {
2601  core->analysis->gp = node->i_value;
2602  return true;
2603 }
2604 
2605 static bool cb_analysis_from(RzCore *core, RzConfigNode *node) {
2606  if (rz_config_get_i(core->config, "analysis.limits")) {
2608  rz_config_get_i(core->config, "analysis.from"),
2609  rz_config_get_i(core->config, "analysis.to"));
2610  }
2611  return true;
2612 }
2613 
2614 static bool cb_analysis_limits(void *user, RzConfigNode *node) {
2615  RzCore *core = (RzCore *)user;
2616  if (node->i_value) {
2618  rz_config_get_i(core->config, "analysis.from"),
2619  rz_config_get_i(core->config, "analysis.to"));
2620  } else {
2622  }
2623  return 1;
2624 }
2625 
2626 static bool cb_analysis_rnr(void *user, RzConfigNode *node) {
2627  RzCore *core = (RzCore *)user;
2628  core->analysis->recursive_noreturn = node->i_value;
2629  return 1;
2630 }
2631 
2632 static bool cb_analysis_jmptbl(void *user, void *data) {
2633  RzCore *core = (RzCore *)user;
2634  RzConfigNode *node = (RzConfigNode *)data;
2635  core->analysis->opt.jmptbl = node->i_value;
2636  return true;
2637 }
2638 
2639 static bool cb_analysis_jmptblmax(void *user, void *data) {
2640  RzCore *core = (RzCore *)user;
2641  RzConfigNode *node = (RzConfigNode *)data;
2642  core->analysis->opt.jmptbl_maxcount = node->i_value;
2643  return true;
2644 }
2645 
2646 static bool cb_analysis_jmptblmaxoffset(void *user, void *data) {
2647  RzCore *core = (RzCore *)user;
2648  RzConfigNode *node = (RzConfigNode *)data;
2649  core->analysis->opt.jmptbl_maxoffset = node->i_value > UT32_MAX ? UT32_MAX : node->i_value;
2650  return true;
2651 }
2652 
2653 static bool cb_analysis_cjmpref(void *user, void *data) {
2654  RzCore *core = (RzCore *)user;
2655  RzConfigNode *node = (RzConfigNode *)data;
2656  core->analysis->opt.cjmpref = node->i_value;
2657  return true;
2658 }
2659 
2660 static bool cb_analysis_jmpref(void *user, void *data) {
2661  RzCore *core = (RzCore *)user;
2662  RzConfigNode *node = (RzConfigNode *)data;
2663  core->analysis->opt.jmpref = node->i_value;
2664  return true;
2665 }
2666 
2667 static bool cb_analysis_jmpabove(void *user, void *data) {
2668  RzCore *core = (RzCore *)user;
2669  RzConfigNode *node = (RzConfigNode *)data;
2670  core->analysis->opt.jmpabove = node->i_value;
2671  return true;
2672 }
2673 
2674 static bool cb_analysis_loads(void *user, void *data) {
2675  RzCore *core = (RzCore *)user;
2676  RzConfigNode *node = (RzConfigNode *)data;
2677  core->analysis->opt.loads = node->i_value;
2678  return true;
2679 }
2680 
2681 static bool cb_analysis_followdatarefs(void *user, void *data) {
2682  RzCore *core = (RzCore *)user;
2683  RzConfigNode *node = (RzConfigNode *)data;
2684  core->analysis->opt.followdatarefs = node->i_value;
2685  return true;
2686 }
2687 
2688 static bool cb_analysis_jmpmid(void *user, void *data) {
2689  RzCore *core = (RzCore *)user;
2690  RzConfigNode *node = (RzConfigNode *)data;
2691  core->analysis->opt.jmpmid = node->i_value;
2692  return true;
2693 }
2694 
2695 static bool cb_analysis_searchstringrefs(void *user, void *data) {
2696  RzCore *core = (RzCore *)user;
2697  RzConfigNode *node = (RzConfigNode *)data;
2698  core->analysis->opt.searchstringrefs = node->i_value;
2699  return true;
2700 }
2701 
2702 static bool cb_analysis_pushret(void *user, void *data) {
2703  RzCore *core = (RzCore *)user;
2704  RzConfigNode *node = (RzConfigNode *)data;
2705  core->analysis->opt.pushret = node->i_value;
2706  return true;
2707 }
2708 
2709 static bool cb_analysis_brokenrefs(void *user, void *data) {
2710  RzCore *core = (RzCore *)user;
2711  RzConfigNode *node = (RzConfigNode *)data;
2712  core->analysis->opt.followbrokenfcnsrefs = node->i_value;
2713  return true;
2714 }
2715 
2716 static bool cb_analysis_trycatch(void *user, void *data) {
2717  RzCore *core = (RzCore *)user;
2718  RzConfigNode *node = (RzConfigNode *)data;
2719  core->analysis->opt.trycatch = node->i_value;
2720  return true;
2721 }
2722 
2723 static bool cb_analysis_bb_max_size(void *user, void *data) {
2724  RzCore *core = (RzCore *)user;
2725  RzConfigNode *node = (RzConfigNode *)data;
2726  core->analysis->opt.bb_max_size = node->i_value;
2727  return true;
2728 }
2729 
2730 static bool cb_analysis_cpp_abi(void *user, void *data) {
2731  RzCore *core = (RzCore *)user;
2732  RzConfigNode *node = (RzConfigNode *)data;
2733 
2734  if (*node->value == '?') {
2735  print_node_options(node);
2736  return false;
2737  }
2738 
2739  if (*node->value) {
2740  if (strcmp(node->value, "itanium") == 0) {
2742  return true;
2743  } else if (strcmp(node->value, "msvc") == 0) {
2745  return true;
2746  }
2747  eprintf("analysis.cpp.abi: cannot find '%s'\n", node->value);
2748  }
2749  return false;
2750 }
2751 
2752 static bool cb_malloc(void *user, void *data) {
2753  RzCore *core = (RzCore *)user;
2754  RzConfigNode *node = (RzConfigNode *)data;
2755 
2756  if (node->value) {
2757  if (!strcmp("jemalloc", node->value) || !strcmp("glibc", node->value)) {
2758  if (core->dbg) {
2759  core->dbg->malloc = data;
2760  }
2761  }
2762  }
2763  return true;
2764 }
2765 
2766 static bool cb_log_config_level(void *coreptr, void *nodeptr) {
2767  RzConfigNode *node = (RzConfigNode *)nodeptr;
2768  rz_log_set_level(node->i_value);
2769  return true;
2770 }
2771 
2772 static bool cb_log_config_traplevel(void *coreptr, void *nodeptr) {
2773  RzConfigNode *node = (RzConfigNode *)nodeptr;
2775  return true;
2776 }
2777 
2778 static bool cb_log_config_file(void *coreptr, void *nodeptr) {
2779  RzConfigNode *node = (RzConfigNode *)nodeptr;
2780  const char *value = node->value;
2782  return true;
2783 }
2784 
2785 static bool cb_log_config_srcinfo(void *coreptr, void *nodeptr) {
2786  RzConfigNode *node = (RzConfigNode *)nodeptr;
2787  const char *value = node->value;
2788  switch (value[0]) {
2789  case 't':
2790  case 'T':
2791  rz_log_set_srcinfo(true);
2792  break;
2793  default:
2794  rz_log_set_srcinfo(false);
2795  }
2796  return true;
2797 }
2798 
2799 static bool cb_log_config_colors(void *coreptr, void *nodeptr) {
2800  RzConfigNode *node = (RzConfigNode *)nodeptr;
2801  const char *value = node->value;
2802  switch (value[0]) {
2803  case 't':
2804  case 'T':
2805  rz_log_set_colors(true);
2806  break;
2807  default:
2808  rz_log_set_colors(false);
2809  }
2810  return true;
2811 }
2812 
2813 static bool cb_dbg_verbose(void *user, void *data) {
2814  RzCore *core = (RzCore *)user;
2815  RzConfigNode *node = (RzConfigNode *)data;
2816  core->dbg->verbose = node->i_value;
2817  return true;
2818 }
2819 
2820 static bool cb_flirt(void *user, void *data) {
2821  rz_return_val_if_fail(data, false);
2822  RzConfigNode *node = (RzConfigNode *)data;
2823  if (*node->value == '?') {
2824  print_node_options(node);
2825  return false;
2826  }
2827  return true;
2828 }
2829 
2831  int i;
2832  char buf[128], *p, *tmpdir;
2833  RzConfigNode *n;
2834  RzConfig *cfg = core->config = rz_config_new(core);
2835  if (!cfg) {
2836  return 0;
2837  }
2838  cfg->num = core->num;
2839  /* dir.prefix is used in other modules, set it first */
2840  {
2841  char *pfx = rz_sys_getenv("RZ_PREFIX");
2842  if (!pfx) {
2843  pfx = rz_path_prefix(NULL);
2844  }
2845  SETCB("dir.prefix", pfx, NULL, "Default prefix rizin was compiled for");
2846  free(pfx);
2847  }
2848 #if __ANDROID__
2849  { // use dir.home and also adjust check for permissions in directory before choosing a home
2850  char *h = rz_sys_getenv(RZ_SYS_HOME);
2851  if (h) {
2852  if (!strcmp(h, "/")) {
2853  rz_sys_setenv(RZ_SYS_HOME, "/data/local/tmp");
2854  }
2855  free(h);
2856  }
2857  }
2858 #endif
2859  SETCB("cmd.times", "", &cb_cmdtimes, "Run when a command is repeated (number prefix)");
2860  /* pdb */
2861  SETPREF("pdb.server", "https://msdl.microsoft.com/download/symbols", "Semi-colon separated list of base URLs for Microsoft symbol servers");
2862  {
2863  char *pdb_path = rz_path_home_prefix(RZ_PDB);
2864  SETPREF("pdb.symstore", pdb_path, "Path to downstream symbol store");
2865  RZ_FREE(pdb_path);
2866  }
2867  SETI("pdb.extract", 1, "Avoid extract of the pdb file, just download");
2868  SETI("pdb.autoload", false, "Automatically load the required pdb files for loaded DLLs");
2869 
2870  /* elf */
2871  SETBPREF("elf.checks.sections", "true", "Check elf sections during loading");
2872  SETBPREF("elf.checks.segments", "true", "Check elf segments during loading");
2873  SETBPREF("elf.load.sections", "true", "Automatically load elf sections");
2874 
2875  /* analysis */
2876  SETBPREF("analysis.detectwrites", "false", "Automatically reanalyze function after a write");
2877  SETPREF("analysis.fcnprefix", "fcn", "Prefix new function names with this");
2878  const char *analysiscc = rz_analysis_cc_default(core->analysis);
2879  SETCB("analysis.cc", analysiscc ? analysiscc : "", (RzConfigCallback)&cb_analysiscc, "Specify default calling convention");
2880  const char *analysissyscc = rz_analysis_syscc_default(core->analysis);
2881  SETCB("analysis.syscc", analysissyscc ? analysissyscc : "", (RzConfigCallback)&cb_analysissyscc, "Specify default syscall calling convention");
2882  SETCB("analysis.roregs", "gp,zero", (RzConfigCallback)&cb_analysis_roregs, "Comma separated list of register names to be readonly");
2883  SETICB("analysis.gp", 0, (RzConfigCallback)&cb_analysis_gp, "Set the value of the GP register (MIPS)");
2884  SETBPREF("analysis.gpfixed", "true", "Set gp register to analysis.gp before emulating each instruction in aae");
2885  SETCB("analysis.limits", "false", (RzConfigCallback)&cb_analysis_limits, "Restrict analysis to address range [analysis.from:analysis.to]");
2886  SETCB("analysis.rnr", "false", (RzConfigCallback)&cb_analysis_rnr, "Recursive no return checks (EXPERIMENTAL)");
2887  SETCB("analysis.limits", "false", (RzConfigCallback)&cb_analysis_limits, "Restrict analysis to address range [analysis.from:analysis.to]");
2888  SETICB("analysis.from", -1, (RzConfigCallback)&cb_analysis_from, "Lower limit on the address range for analysis");
2889  SETICB("analysis.to", -1, (RzConfigCallback)&cb_analysis_from, "Upper limit on the address range for analysis");
2890  n = NODECB("analysis.in", "io.maps.x", &cb_searchin);
2891  SETDESC(n, "Specify search boundaries for analysis");
2892  SETOPTIONS(n, "range", "block",
2893  "bin.segment", "bin.segments", "bin.segments.x", "bin.segments.r", "bin.section", "bin.sections", "bin.sections.rwx", "bin.sections.r", "bin.sections.rw", "bin.sections.rx", "bin.sections.wx", "bin.sections.x",
2894  "io.map", "io.maps", "io.maps.rwx", "io.maps.r", "io.maps.rw", "io.maps.rx", "io.maps.wx", "io.maps.x",
2895  "dbg.stack", "dbg.heap",
2896  "dbg.map", "dbg.maps", "dbg.maps.rwx", "dbg.maps.r", "dbg.maps.rw", "dbg.maps.rx", "dbg.maps.wx", "dbg.maps.x",
2897  "analysis.fcn", "analysis.bb",
2898  NULL);
2899  SETI("analysis.timeout", 0, "Stop analyzing after a couple of seconds");
2900  SETCB("analysis.jmp.retpoline", "true", &cb_analysis_jmpretpoline, "Analyze retpolines, may be slower if not needed");
2901  SETICB("analysis.jmp.tailcall", 0, &cb_analysis_jmptailcall, "Consume a branch as a call if delta is big");
2902 
2903  SETCB("analysis.armthumb", "false", &cb_analysis_armthumb, "aae computes arm/thumb changes (lot of false positives ahead)");
2904  SETCB("analysis.jmp.after", "true", &cb_analysis_afterjmp, "Continue analysis after jmp/ujmp");
2905  SETCB("analysis.trap.after", "false", &cb_analysis_aftertrap, "Continue analysis after trap instructions.");
2906  SETCB("analysis.delay", "true", &cb_analysis_delay, "Enable delay slot analysis if supported by the architecture");
2907  SETICB("analysis.depth", 64, &cb_analysis_depth, "Max depth at code analysis"); // XXX: warn if depth is > 50 .. can be problematic
2908  SETICB("analysis.graph_depth", 256, &cb_analysis_graphdepth, "Max depth for path search");
2909  SETICB("analysis.sleep", 0, &cb_analysis_sleep, "Sleep N usecs every so often during analysis. Avoid 100% CPU usage");
2910  SETCB("analysis.ignbithints", "false", &cb_analysis_ignbithints, "Ignore the ahb hints (only obey asm.bits)");
2911  SETBPREF("analysis.calls", "false", "Make basic af analysis walk into calls");
2912  SETBPREF("analysis.autoname", "false", "Speculatively set a name for the functions, may result in some false positives");
2913  SETBPREF("analysis.hasnext", "false", "Continue analysis after each function");
2914  SETICB("analysis.nonull", 0, &cb_analysis_nonull, "Do not analyze regions of N null bytes");
2915  SETBPREF("analysis.esil", "false", "Use the new ESIL code analysis");
2916  SETCB("analysis.strings", "false", &cb_analysis_strings, "Identify and register strings during analysis (aar only)");
2917  SETPREF("analysis.types.spec", "gcc", "Set profile for specifying format chars used in type analysis");
2918  SETBPREF("analysis.types.verbose", "false", "Verbose output from type analysis");
2919  SETBPREF("analysis.types.constraint", "false", "Enable constraint types analysis for variables");
2920  SETCB("analysis.vars", "true", &cb_analysis_vars, "Analyze local variables and arguments");
2921  SETCB("analysis.vars.stackname", "false", &cb_analysis_vars_stackname, "Name variables based on their offset on the stack");
2922  SETBPREF("analysis.vinfun", "true", "Search values in functions (aav) (false by default to only find on non-code)");
2923  SETBPREF("analysis.vinfunrange", "false", "Search values outside function ranges (requires analysis.vinfun=false)\n");
2924  SETCB("analysis.norevisit", "false", &cb_analysis_norevisit, "Do not visit function analysis twice (EXPERIMENTAL)");
2925  SETCB("analysis.nopskip", "true", &cb_analysis_nopskip, "Skip nops at the beginning of functions");
2926  SETCB("analysis.hpskip", "false", &cb_analysis_hpskip, "Skip `mov reg, reg` and `lea reg, [reg] at the beginning of functions");
2927  n = NODECB("analysis.arch", RZ_SYS_ARCH, &cb_analysis_arch);
2928  SETDESC(n, "Select the architecture to use");
2930  SETCB("analysis.cpu", RZ_SYS_ARCH, &cb_analysis_cpu, "Specify the analysis.cpu to use");
2931  SETPREF("analysis.prelude", "", "Specify an hexpair to find preludes in code");
2932  SETCB("analysis.recont", "false", &cb_analysis_recont, "End block after splitting a basic block instead of error"); // testing
2933  SETCB("analysis.jmp.indir", "false", &cb_analysis_ijmp, "Follow the indirect jumps in function analysis"); // testing
2934  SETI("analysis.ptrdepth", 3, "Maximum number of nested pointers to follow in analysis");
2935  SETICB("asm.lines.maxref", 0, &cb_analysis_maxrefs, "Maximum number of reflines to be analyzed and displayed in asm.lines with pd");
2936 
2937  SETCB("analysis.jmp.tbl", "true", &cb_analysis_jmptbl, "Analyze jump tables in switch statements");
2938  SETICB("analysis.jmp.tblmax", 512, &cb_analysis_jmptblmax, "Maximum amount of entries to analyze in jump tables");
2939  SETICB("analysis.jmp.tblmaxoffset", 4096, &cb_analysis_jmptblmaxoffset, "Maximum offset from the jump table jump instruction to consider it valid");
2940 
2941  SETCB("analysis.jmp.cref", "false", &cb_analysis_cjmpref, "Create references for conditional jumps");
2942  SETCB("analysis.jmp.ref", "true", &cb_analysis_jmpref, "Create references for unconditional jumps");
2943 
2944  SETCB("analysis.jmp.above", "true", &cb_analysis_jmpabove, "Jump above function pointer");
2945  SETCB("analysis.loads", "false", &cb_analysis_loads, "Define as dword/string/qword when analyzing load instructions");
2946  SETCB("analysis.datarefs", "false", &cb_analysis_followdatarefs, "Follow data references for code coverage");
2947  SETCB("analysis.brokenrefs", "false", &cb_analysis_brokenrefs, "Follow function references as well if function analysis was failed");
2948  SETCB("analysis.jmp.mid", "true", &cb_analysis_jmpmid, "Continue analysis after jump to middle of instruction (x86 only)");
2949 
2950  SETCB("analysis.refstr", "false", &cb_analysis_searchstringrefs, "Search string references in data references");
2951  SETCB("analysis.trycatch", "false", &cb_analysis_trycatch, "Honor try.X.Y.{from,to,catch} flags");
2952  SETCB("analysis.bb.maxsize", "512K", &cb_analysis_bb_max_size, "Maximum basic block size");
2953  SETCB("analysis.pushret", "false", &cb_analysis_pushret, "Analyze push+ret as jmp");
2954 
2955  n = NODECB("analysis.cpp.abi", "itanium", &cb_analysis_cpp_abi);
2956  SETDESC(n, "Select C++ ABI (Compiler)");
2957  SETOPTIONS(n, "itanium", "msvc", NULL);
2958  SETB("analysis.apply.signature", true, "enables/disables auto-applying signatures to the loaded binary (see also flirt.sigdb.path)");
2959 
2960 #if __linux__ && __GNU_LIBRARY__ && __GLIBC__ && __GLIBC_MINOR__
2961  SETCB("dbg.malloc", "glibc", &cb_malloc, "Choose malloc structure parser");
2962 #else
2963  SETCB("dbg.malloc", "jemalloc", &cb_malloc, "Choose malloc structure parser");
2964 #endif
2965 #if __GLIBC_MINOR__ > 25
2966  SETBPREF("dbg.glibc.tcache", "true", "Set glib tcache parsing");
2967 #else
2968  SETBPREF("dbg.glibc.tcache", "false", "Set glib tcache parsing");
2969 #endif
2970 #if __x86_64__
2971  SETI("dbg.glibc.ma_offset", 0x000000, "Main_arena offset from his symbol");
2972  SETI("dbg.glibc.fc_offset", 0x00280, "First chunk offset from brk_start");
2973 #else
2974  SETI("dbg.glibc.ma_offset", 0x1bb000, "Main_arena offset from his symbol");
2975  SETI("dbg.glibc.fc_offset", 0x148, "First chunk offset from brk_start");
2976 #endif
2977  SETI("dbg.glibc.fastbinmax", 10, "Upper bound on the number of fastbins printed");
2978 
2979  SETBPREF("esil.prestep", "true", "Step before esil evaluation in `de` commands");
2980  SETPREF("esil.fillstack", "", "Initialize ESIL stack with (random, debrujn, sequence, zeros, ...)");
2981  SETICB("esil.verbose", 0, &cb_esilverbose, "Show ESIL verbose level (0, 1, 2)");
2982  SETICB("esil.gotolimit", core->analysis->esil_goto_limit, &cb_gotolimit, "Maximum number of gotos per ESIL expression");
2983  SETICB("esil.stack.depth", 256, &cb_esilstackdepth, "Number of elements that can be pushed on the esilstack");
2984  SETI("esil.stack.size", 0xf0000, "Set stack size in ESIL VM");
2985  SETI("esil.stack.addr", 0x100000, "Set stack address in ESIL VM");
2986  SETPREF("esil.stack.pattern", "0", "Specify fill pattern to initialize the stack (0, w, d, i)");
2987  SETI("esil.addr.size", 64, "Maximum address size in accessed by the ESIL VM");
2988  SETBPREF("esil.breakoninvalid", "false", "Break esil execution when instruction is invalid");
2989  SETI("esil.timeout", 0, "A timeout (in seconds) for when we should give up emulating");
2990  /* asm */
2991  // asm.os needs to be first, since other asm.* depend on it
2992  n = NODECB("asm.os", "none", &cb_asmos);
2993  SETDESC(n, "Select operating system (kernel)");
2994  SETOPTIONS(n, "ios", "dos", "darwin", "linux", "freebsd", "openbsd", "netbsd", "windows", "s110", "none", NULL);
2995  SETI("asm.xrefs.fold", 5, "Maximum number of xrefs to be displayed as list (use columns above)");
2996  SETBPREF("asm.xrefs.code", "true", "Show the code xrefs (generated by jumps instead of calls)");
2997  SETI("asm.xrefs.max", 20, "Maximum number of xrefs to be displayed without folding");
2998  SETCB("asm.invhex", "false", &cb_asm_invhex, "Show invalid instructions as hexadecimal numbers");
2999  SETBPREF("asm.instr", "true", "Display the disassembled instruction");
3000  SETBPREF("asm.meta", "true", "Display the code/data/format conversions in disasm");
3001  SETBPREF("asm.bytes", "false", "Display the bytes of each instruction");
3002  SETBPREF("asm.bytes.right", "false", "Display the bytes at the right of the disassembly");
3003  SETI("asm.types", 1, "Display the fcn types in calls (0=no,1=quiet,2=verbose)");
3004  SETBPREF("asm.midcursor", "false", "Cursor in visual disasm mode breaks the instruction");
3005  SETBPREF("asm.cmt.flgrefs", "true", "Show comment flags associated to branch reference");
3006  SETBPREF("asm.cmt.right", "true", "Show comments at right of disassembly if they fit in screen");
3007  SETBPREF("asm.cmt.esil", "false", "Show ESIL expressions as comments");
3008  SETBPREF("asm.cmt.il", "false", "Show RzIL expressions as comments");
3009  SETI("asm.cmt.col", 71, "Column to align comments");
3010  SETICB("asm.pcalign", 0, &cb_asm_pcalign, "Only recognize as valid instructions aligned to this value");
3011  // maybe rename to asm.cmt.calls
3012  SETBPREF("asm.calls", "true", "Show callee function related info as comments in disasm");
3013  SETBPREF("asm.comments", "true", "Show comments in disassembly view");
3014  SETBPREF("asm.usercomments", "false", "Show user comments even if asm.comments is false");
3015  SETBPREF("asm.sub.jmp", "true", "Always substitute jump, call and branch targets in disassembly");
3016  SETBPREF("asm.hints", "true", "Disable all asm.hint* if false");
3017  SETBPREF("asm.hint.jmp", "false", "Show jump hints [numbers] in disasm");
3018  SETBPREF("asm.hint.call", "true", "Show call hints [numbers] in disasm");
3019  SETBPREF("asm.hint.call.indirect", "true", "Hints for indirect call intructions go to the call destination");
3020  SETBPREF("asm.hint.lea", "false", "Show LEA hints [numbers] in disasm");
3021  SETBPREF("asm.hint.emu", "false", "Show asm.emu hints [numbers] in disasm");
3022  SETBPREF("asm.hint.cdiv", "false", "Show CDIV hints optimization hint");
3023  SETI("asm.hint.pos", 1, "Shortcut hint position (-1, 0, 1)");
3024  SETBPREF("asm.slow", "true", "Perform slow analysis operations in disasm");
3025  SETBPREF("asm.decode", "false", "Use code analysis as a disassembler");
3026  SETICB("asm.imm.hash", 0, &cb_asm_immhash, "Display # for immediates in ARM and Hexagon (0 = on)");
3027  SETBPREF("asm.imm.str", "true", "Show immediates values as strings");
3028  SETBPREF("asm.imm.trim", "false", "Remove all offsets and constants from disassembly");
3029  SETBPREF("asm.indent", "false", "Indent disassembly based on reflines depth");
3030  SETI("asm.indentspace", 2, "How many spaces to indent the code");
3031  SETBPREF("asm.dwarf", "false", "Show dwarf comment at disassembly");
3032  SETBPREF("asm.dwarf.abspath", "false", "Show absolute path in asm.dwarf");
3033  SETBPREF("asm.dwarf.file", "true", "Show filename of asm.dwarf in pd");
3034  SETBPREF("asm.esil", "false", "Show ESIL instead of mnemonic");
3035  SETBPREF("asm.nodup", "false", "Do not show dupped instructions (collapse disasm)");
3036  SETBPREF("asm.emu", "false", "Run ESIL emulation analysis on disasm");
3037  SETBPREF("emu.pre", "false", "Run ESIL emulation starting at the closest flag in pd");
3038  SETBPREF("asm.refptr", "true", "Show refpointer information in disasm");
3039  SETBPREF("emu.lazy", "false", "Do not emulate all instructions with aae (optimization)");
3040  SETBPREF("emu.stack", "false", "Create a temporary fake stack when emulating in disasm (asm.emu)");
3041  SETCB("emu.str", "false", &cb_emustr, "Show only strings if any in the asm.emu output");
3042  SETBPREF("emu.str.lea", "true", "Disable this in ARM64 code to remove some false positives");
3043  SETBPREF("emu.str.off", "false", "Always show offset when printing asm.emu strings");
3044  SETBPREF("emu.str.inv", "true", "Color-invert emu.str strings");
3045  SETBPREF("emu.str.flag", "true", "Also show flag (if any) for asm.emu string");
3046  SETBPREF("emu.write", "false", "Allow asm.emu to modify memory (WARNING)");
3047  SETBPREF("emu.ssa", "false", "Perform SSA checks and show the ssa reg names as comments");
3048  n = NODECB("emu.skip", "ds", &cb_emuskip);
3049  SETDESC(n, "Skip metadata of given types in asm.emu");
3050  SETOPTIONS(n, "d", "c", "s", "f", "m", "h", "C", "r", NULL);
3051  SETBPREF("asm.sub.names", "true", "Replace numeric values by flags (e.g. 0x4003e0 -> sym.imp.printf)");
3052  SETPREF("asm.strip", "", "strip all instructions given comma separated types");
3053  SETBPREF("asm.optype", "false", "show opcode type next to the instruction bytes");
3054  SETBPREF("asm.lines.fcn", "true", "Show function boundary lines");
3055  SETBPREF("asm.flags", "true", "Show flags");
3056  SETICB("asm.flags.maxname", 0, &cb_maxname, "Maximum length of flag name with smart chopping");
3057  SETI("asm.flags.limit", 0, "Maximum number of flags to show in a single offset");
3058  SETBPREF("asm.flags.offset", "false", "Show offset in flags");
3059  SETBPREF("asm.flags.inbytes", "false", "Display flags inside the bytes space");
3060  SETBPREF("asm.flags.inline", "false", "Display flags in line separated by commas instead of newlines");
3061  n = NODEICB("asm.flags.middle", 2, &cb_midflags);
3062  SETOPTIONS(n, "0 = do not show flag", "1 = show without realign", "2 = realign at middle flag",
3063  "3 = realign at middle flag if sym.*", NULL);
3064  SETDESC(n, "Realign disassembly if there is a flag in the middle of an instruction");
3065  SETCB("asm.flags.real", "false", &cb_flag_realnames,
3066  "Show flags' unfiltered realnames instead of names, except realnames from demangling");
3067  SETBPREF("asm.bb.line", "false", "Show empty line after every basic block");
3068  SETBPREF("asm.bb.middle", "true", "Realign disassembly if a basic block starts in the middle of an instruction");
3069  SETBPREF("asm.lbytes", "true", "Align disasm bytes to left");
3070  SETBPREF("asm.lines", "true", "Show ASCII-art lines at disassembly");
3071  SETBPREF("asm.lines.bb", "true", "Show flow lines at jumps");
3072  SETBPREF("asm.lines.call", "false", "Enable call lines");
3073  SETBPREF("asm.lines.ret", "false", "Show separator lines after ret");
3074  SETBPREF("asm.lines.out", "true", "Show out of block lines");
3075  SETBPREF("asm.lines.right", "false", "Show lines before opcode instead of offset");
3076  SETBPREF("asm.lines.wide", "false", "Put a space between lines");
3077  SETBPREF("asm.fcn.signature", "true", "Show function signature in disasm");
3078  SETBPREF("asm.fcn.size", "false", "Show function size in disasm");
3079  SETICB("asm.lines.width", 7, &cb_asmlineswidth, "Number of columns for program flow arrows");
3080  SETICB("asm.sub.varmin", 0x100, &cb_asmsubvarmin, "Minimum value to substitute in instructions (asm.sub.var)");
3081  SETCB("asm.sub.tail", "false", &cb_asmsubtail, "Replace addresses with prefix .. syntax");
3082  SETBPREF("asm.middle", "false", "Allow disassembling jumps in the middle of an instruction");
3083  SETBPREF("asm.noisy", "true", "Show comments considered noisy but possibly useful");
3084  SETBPREF("asm.offset", "true", "Show offsets in disassembly");
3085  SETBPREF("hex.offset", "true", "Show offsets in hex-dump");
3086  SETBPREF("scr.square", "true", "Use square pixels or not");
3087  SETCB("scr.prompt.vi", "false", &cb_scr_vi, "Use vi mode for input prompt");
3088  SETCB("scr.prompt.mode", "false", &cb_scr_prompt_mode, "Set prompt color based on vi mode");
3089  SETCB("scr.wideoff", "false", &cb_scr_wideoff, "Adjust offsets to match asm.bits");
3090  SETCB("scr.rainbow", "false", &cb_scrrainbow, "Shows rainbow colors depending of address");
3091  SETCB("scr.last", "true", &cb_scrlast, "Cache last output after flush to make _ command work (disable for performance)");
3092  SETBPREF("asm.reloff", "false", "Show relative offsets instead of absolute address in disasm");
3093  SETBPREF("asm.reloff.flags", "false", "Show relative offsets to flags (not only functions)");
3094  SETBPREF("asm.section", "false", "Show section name before offset");
3095  SETBPREF("asm.section.perm", "false", "Show section permissions in the disasm");
3096  SETBPREF("asm.section.name", "true", "Show section name in the disasm");
3097  SETI("asm.section.col", 30, "Columns width to show asm.section");
3098  SETCB("asm.sub.section", "false", &cb_asmsubsec, "Show offsets in disasm prefixed with section/map name");
3099  SETCB("asm.pseudo", "false", &cb_asmpseudo, "Enable pseudo syntax");
3100  SETBPREF("asm.size", "false", "Show size of opcodes in disassembly (pd)");
3101  SETBPREF("asm.stackptr", "false", "Show stack pointer at disassembly");
3102  SETBPREF("asm.cyclespace", "false", "Indent instructions depending on CPU-cycles");
3103  SETBPREF("asm.cycles", "false", "Show CPU-cycles taken by instruction at disassembly");
3104  SETI("asm.tabs", 6, "Use tabs in disassembly");
3105  SETBPREF("asm.tabs.once", "true", "Only tabulate the opcode, not the arguments");
3106  SETI("asm.tabs.off", 0, "tabulate spaces after the offset");
3107  SETBPREF("asm.trace", "false", "Show execution traces for each opcode");
3108  SETBPREF("asm.tracespace", "false", "Indent disassembly with trace.count information");
3109  SETBPREF("asm.ucase", "false", "Use uppercase syntax at disassembly");
3110  SETBPREF("asm.capitalize", "false", "Use camelcase at disassembly");
3111  SETBPREF("asm.var", "true", "Show local function variables in disassembly");
3112  SETBPREF("asm.var.access", "false", "Show accesses of local variables");
3113  SETBPREF("asm.sub.var", "true", "Substitute variables in disassembly");
3114  SETI("asm.var.summary", 0, "Show variables summary instead of full list in disasm (0, 1, 2)");
3115  SETBPREF("asm.sub.varonly", "true", "Substitute the entire variable expression with the local variable name (e.g. [local10h] instead of [ebp+local10h])");
3116  SETBPREF("asm.sub.reg", "false", "Substitute register names with their associated role name (drp~=)");
3117  SETBPREF("asm.sub.rel", "true", "Substitute pc relative expressions in disasm");
3118  SETBPREF("asm.family", "false", "Show family name in disasm");
3119  SETBPREF("asm.symbol", "false", "Show symbol+delta instead of absolute offset");
3120  SETBPREF("asm.analysis", "false", "Analyze code and refs while disassembling (see analysis.strings)");
3121  SETI("asm.symbol.col", 40, "Columns width to show asm.section");
3122  SETCB("asm.assembler", "", &cb_asmassembler, "Set the plugin name to use when assembling");
3123  SETBPREF("asm.minicols", "false", "Only show the instruction in the column disasm");
3124  RzConfigNode *asmcpu = NODECB("asm.cpu", RZ_SYS_ARCH, &cb_asmcpu);
3125  SETDESC(asmcpu, "Set the kind of asm.arch cpu");
3126  RzConfigNode *asmarch = NODECB("asm.arch", RZ_SYS_ARCH, &cb_asmarch);
3127  SETDESC(asmarch, "Set the arch to be used by asm");
3128  /* we need to have both asm.arch and asm.cpu defined before updating options */
3129  update_asmarch_options(core, asmarch);
3130  update_asmcpu_options(core, asmcpu);
3131  n = NODECB("asm.features", "", &cb_asmfeatures);
3132  SETDESC(n, "Specify supported features by the target CPU");
3134  n = NODECB("asm.platform", "", &cb_asmplatform);
3135  SETDESC(n, "Specify supported platforms by the target architecture");
3137  n = NODECB("asm.parser", "x86.pseudo", &cb_asmparser);
3138  SETDESC(n, "Set the asm parser to use");
3139  update_asmparser_options(core, n);
3140  SETCB("asm.segoff", "false", &cb_segoff, "Show segmented address in prompt (x86-16)");
3141  SETCB("asm.decoff", "false", &cb_decoff, "Show segmented address in prompt (x86-16)");
3142  SETICB("asm.seggrn", 4, &cb_seggrn, "Segment granularity in bits (x86-16)");
3143  n = NODECB("asm.syntax", "intel", &cb_asmsyntax);
3144  SETDESC(n, "Select assembly syntax");
3145  SETOPTIONS(n, "att", "intel", "masm", "jz", "regnum", NULL);
3146  SETI("asm.nbytes", 6, "Number of bytes for each opcode at disassembly");
3147  SETBPREF("asm.bytes.space", "false", "Separate hexadecimal bytes with a whitespace");
3148 #if RZ_SYS_BITS == RZ_SYS_BITS_64
3149  SETICB("asm.bits", 64, &cb_asmbits, "Word size in bits at assembler");
3150 #else
3151  SETICB("asm.bits", 32, &cb_asmbits, "Word size in bits at assembler");
3152 #endif
3153  n = rz_config_node_get(cfg, "asm.bits");
3154  update_asmbits_options(core, n);
3155  SETBPREF("asm.functions", "true", "Show functions in disassembly");
3156  SETBPREF("asm.xrefs", "true", "Show xrefs in disassembly");
3157  SETBPREF("asm.demangle", "true", "Show demangled symbols in disasm");
3158  SETBPREF("asm.describe", "false", "Show opcode description");
3159  SETPREF("asm.highlight", "", "Highlight current line");
3160  SETBPREF("asm.marks", "true", "Show marks before the disassembly");
3161  SETBPREF("asm.cmt.refs", "false", "Show flag and comments from refs in disasm");
3162  SETBPREF("asm.cmt.patch", "false", "Show patch comments in disasm");
3163  SETBPREF("asm.cmt.off", "nodup", "Show offset comment in disasm (true, false, nodup)");
3164  SETBPREF("asm.payloads", "false", "Show payload bytes in disasm");
3165 
3166  /* bin */
3167  SETPREF("bin.hashlimit", "10M", "Only compute hash when opening a file if smaller than this size");
3168  SETCB("bin.usextr", "true", &cb_usextr, "Use extract plugins when loading files");
3169  SETCB("bin.str.purge", "", &cb_strpurge, "Purge strings (e bin.str.purge=? provides more detail)");
3170  SETBPREF("bin.b64str", "false", "Try to debase64 the strings");
3171  SETCB("bin.at", "false", &cb_binat, "RzBin.cur depends on RzCore.offset");
3172  SETBPREF("bin.libs", "false", "Try to load libraries after loading main binary");
3173  n = NODECB("bin.str.filter", "", &cb_strfilter);
3174  SETDESC(n, "Filter strings");
3175  SETOPTIONS(n, "a", "8", "p", "e", "u", "i", "U", "f", NULL);
3176  SETCB("bin.filter", "true", &cb_binfilter, "Filter symbol names to fix dupped names");
3177  SETCB("bin.force", "", &cb_binforce, "Force that rbin plugin");
3178  SETPREF("bin.lang", "", "Language for bin.demangle");
3179  SETBPREF("bin.demangle", "true", "Import demangled symbols from RzBin");
3180  SETBPREF("bin.demangle.libs", "false", "Show library name on demangled symbols names");
3181  SETI("bin.baddr", -1, "Base address of the binary");
3182  SETI("bin.laddr", 0, "Base address for loading library ('*.so')");
3183  SETCB("bin.dbginfo", "true", &cb_bindbginfo, "Load debug information at startup if available");
3184  SETBPREF("bin.relocs", "true", "Load relocs information at startup if available");
3185  SETICB("bin.minstr", 0, &cb_binminstr, "Minimum string length for rz_bin");
3186  SETICB("bin.maxstr", 0, &cb_binmaxstr, "Maximum string length for rz_bin");
3187  SETICB("bin.maxstrbuf", 1024 * 1024 * 10, &cb_binmaxstrbuf, "Maximum size of range to load strings from");
3188  n = NODECB("bin.str.enc", "guess", &cb_binstrenc);
3189  SETDESC(n, "Default string encoding of binary");
3190  SETOPTIONS(n, "ascii", "8bit", "utf8", "utf16le", "utf32le", "utf16be", "utf32be", "guess", NULL);
3191  SETCB("bin.prefix", "", &cb_binprefix, "Prefix all symbols/sections/relocs with a specific string");
3192  SETCB("bin.strings", "true", &cb_binstrings, "Load strings from rbin on startup");
3193  SETCB("bin.debase64", "false", &cb_debase64, "Try to debase64 all strings");
3194  SETBPREF("bin.classes", "true", "Load classes from rbin on startup");
3195  SETCB("bin.verbose", "false", &cb_binverbose, "Show RzBin warnings when loading binaries");
3196 
3197  /* prj */
3198  SETPREF("prj.file", "", "Path of the currently opened project");
3199  SETBPREF("prj.compress", "false", "Compress the project file while saving");
3200 
3201  /* cfg */
3202  SETBPREF("cfg.plugins", "true", "Load plugins at startup");
3203  SETCB("time.fmt", "%Y-%m-%d %H:%M:%S %z", &cb_cfgdatefmt, "Date format (%Y-%m-%d %H:%M:%S %z)");
3204  SETICB("time.zone", 0, &cb_timezone, "Time zone, in hours relative to GMT: +2, -1,..");
3205  SETBPREF("cfg.newtab", "false", "Show descriptions in command completion");
3206  SETCB("cfg.debug", "false", &cb_cfgdebug, "Debugger mode");
3207  p = rz_sys_getenv("EDITOR");
3208 #if __WINDOWS__
3209  rz_config_set(cfg, "cfg.editor", p ? p : "notepad");
3210 #else
3211  rz_config_set(cfg, "cfg.editor", p ? p : "vi");
3212 #endif
3213  free(p);
3214  rz_config_desc(cfg, "cfg.editor", "Select default editor program");
3215  SETPREF("cfg.user", rz_sys_whoami(buf), "Set current username/pid");
3216  SETCB("cfg.fortunes", "true", &cb_cfg_fortunes, "If enabled show tips at start");
3217  SETCB("cfg.fortunes.file", "tips", &cb_cfg_fortunes_file, "Type of fortunes to show (tips, fun)");
3218  SETBPREF("cfg.fortunes.clippy", "false", "Use ?E instead of ?e");
3219  SETPREF("cfg.prefixdump", "dump", "Filename prefix for automated dumps");
3220  SETBPREF("cfg.wseek", "false", "Seek after write");
3221  SETICB("cfg.seek.histsize", 63, NULL, "Maximum size of the seek history");
3222  SETCB("cfg.seek.silent", "false", NULL, "When true, seek movements are not logged in seek history");
3223  SETCB("cfg.bigendian", "false", &cb_bigendian, "Use little (false) or big (true) endianness");
3224  SETI("cfg.cpuaffinity", 0, "Run on cpuid");
3225 
3226  /* log */
3227  // RZ_LOGLEVEL / log.level
3228  p = rz_sys_getenv("RZ_LOGLEVEL");
3229  SETICB("log.level", p ? atoi(p) : RZ_DEFAULT_LOGLVL, cb_log_config_level, "Target log level/severity"
3230  " (0:SILLY, 1:DEBUG, 2:VERBOSE, 3:INFO, 4:WARN, 5:ERROR, 6:FATAL)");
3231  free(p);
3232  // RZ_LOGTRAP_LEVEL / log.traplevel
3233  p = rz_sys_getenv("RZ_LOGTRAPLEVEL");
3234  SETICB("log.traplevel", p ? atoi(p) : RZ_LOGLVL_FATAL, cb_log_config_traplevel, "Log level for trapping rizin when hit"
3235  " (0:SILLY, 1:VERBOSE, 2:DEBUG, 3:INFO, 4:WARN, 5:ERROR, 6:FATAL)");
3236  free(p);
3237  // RZ_LOGFILE / log.file
3238  p = rz_sys_getenv("RZ_LOGFILE");
3239  SETCB("log.file", p ? p : "", cb_log_config_file, "Logging output filename / path");
3240  free(p);
3241  // RZ_LOGSRCINFO / log.srcinfo
3242  p = rz_sys_getenv("RZ_LOGSRCINFO");
3243  SETCB("log.srcinfo", p ? p : "false", cb_log_config_srcinfo, "Should the log output contain src info (filename:lineno)");
3244  free(p);
3245  // RZ_LOGCOLORS / log.colors
3246  p = rz_sys_getenv("RZ_LOGCOLORS");
3247  SETCB("log.colors", p ? p : "false", cb_log_config_colors, "Should the log output use colors (TODO)");
3248  free(p);
3249 
3250  SETCB("log.events", "false", &cb_log_events, "Remote HTTP server to sync events with");
3251 
3252  /* diff */
3253  SETCB("diff.sort", "addr", &cb_diff_sort, "Specify function diff sorting column see (e diff.sort=?)");
3254  SETI("diff.from", 0, "Set source diffing address for px (uses cc command)");
3255  SETI("diff.to", 0, "Set destination diffing address for px (uses cc command)");
3256  SETBPREF("diff.bare", "false", "Never show function names in diff output");
3257  SETBPREF("diff.levenstein", "false", "Use faster (and buggy) levenstein algorithm for buffer distance diffing");
3258 
3259  /* dir */
3260  SETI("dir.depth", 10, "Maximum depth when searching recursively for files");
3261  {
3262  char *path = rz_path_system(RZ_SDB_MAGIC);
3263  SETPREF("dir.magic", path, "Path to rz_magic files");
3264  free(path);
3266  SETPREF("dir.plugins", path, "Path to plugin files to be loaded at startup");
3267  free(path);
3268  }
3269  SETCB("dir.source", "", &cb_dirsrc, "Path to find source files");
3270  SETPREF("dir.types", "/usr/include", "Default path to look for cparse type files");
3271  SETPREF("dir.libs", "", "Specify path to find libraries to load when bin.libs=true");
3273  SETCB("dir.home", p ? p : "/", &cb_dirhome, "Path for the home directory");
3274  free(p);
3276  SETCB("dir.tmp", p ? p : "", &cb_dirtmp, "Path of the tmp directory");
3277  free(p);
3278 #if __ANDROID__
3279  SETPREF("dir.projects", "/data/data/org.rizin.rizininstaller/rizin/projects", "Default path for projects");
3280 #else
3281  char *projects_dir = rz_path_home_prefix(RZ_PROJECTS);
3282  SETPREF("dir.projects", projects_dir, "Default path for projects");
3283  free(projects_dir);
3284 #endif
3285  SETPREF("stack.reg", "SP", "Which register to use as stack pointer in the visual debug");
3286  SETBPREF("stack.bytes", "true", "Show bytes instead of words in stack");
3287  SETBPREF("stack.anotated", "false", "Show anotated hexdump in visual debug");
3288  SETI("stack.size", 64, "Size in bytes of stack hexdump in visual debug");
3289  SETI("stack.delta", 0, "Delta for the stack dump");
3290 
3291  SETCB("dbg.libs", "", &cb_dbg_libs, "If set stop when loading matching libname");
3292  SETBPREF("dbg.skipover", "false", "Make dso perform a dss (same goes for esil and visual/graph");
3293  SETI("dbg.hwbp", 0, "Set HW or SW breakpoints");
3294  SETCB("dbg.unlibs", "", &cb_dbg_unlibs, "If set stop when unloading matching libname");
3295  SETCB("dbg.verbose", "false", &cb_dbg_verbose, "Verbose debug output");
3296  SETBPREF("dbg.slow", "false", "Show stack and regs in visual mode in a slow but verbose mode");
3297  SETBPREF("dbg.funcarg", "false", "Display arguments to function call in visual mode");
3298 
3299  SETCB("dbg.bpinmaps", "true", &cb_dbg_bpinmaps, "Activate breakpoints only if they are inside a valid map");
3300  SETCB("dbg.forks", "false", &cb_dbg_forks, "Stop execution if fork() is done (see dbg.threads)");
3301 #if __WINDOWS__
3302  n = NODECB("dbg.btalgo", "default", &cb_dbg_btalgo);
3303 #else
3304  n = NODECB("dbg.btalgo", "fuzzy", &cb_dbg_btalgo);
3305 #endif
3306  SETDESC(n, "Select backtrace algorithm");
3307  SETOPTIONS(n, "default", "fuzzy", "analysis", "trace", NULL);
3308  SETCB("dbg.threads", "false", &cb_stopthreads, "Stop all threads when debugger breaks (see dbg.forks)");
3309  SETCB("dbg.clone", "false", &cb_dbg_clone, "Stop execution if new thread is created");
3310  SETCB("dbg.aftersyscall", "true", &cb_dbg_aftersc, "Stop execution before the syscall is executed (see dcs)");
3311  SETCB("dbg.profile", "", &cb_runprofile, "Path to RzRunProfile file");
3312  SETCB("dbg.args", "", &cb_dbg_args, "Set the args of the program to debug");
3313  SETCB("dbg.follow.child", "false", &cb_dbg_follow_child, "Continue tracing the child process on fork. By default the parent process is traced");
3314  SETCB("dbg.trace_continue", "true", &cb_dbg_trace_continue, "Trace every instruction between the initial PC position and the PC position at the end of continue's execution");
3315  SETCB("dbg.create_new_console", "true", &cb_dbg_create_new_console, "Create a new console window for the debugee on debug start");
3316  /* debug */
3317  SETBPREF("dbg.status", "false", "Set cmd.prompt to '.dr*' or '.dr*;drd;sr PC;pi 1;shu'");
3318 #if DEBUGGER
3319  SETCB("dbg.backend", "native", &cb_dbgbackend, "Select the debugger backend");
3320 #else
3321  SETCB("dbg.backend", "esil", &cb_dbgbackend, "Select the debugger backend");
3322 #endif
3323  n = NODECB("dbg.bep", "loader", &cb_dbgbep);
3324  SETDESC(n, "Break on entrypoint");
3325  SETOPTIONS(n, "loader", "entry", "constructor", "main", NULL);
3326  if (core->cons->rows > 30) { // HACKY
3327  rz_config_set_i(cfg, "dbg.follow", 64);
3328  } else {
3329  rz_config_set_i(cfg, "dbg.follow", 32);
3330  }
3331  rz_config_desc(cfg, "dbg.follow", "Follow program counter when pc > core->offset + dbg.follow");
3332  SETBPREF("dbg.rebase", "true", "Rebase analysis/meta/comments/flags when reopening file in debugger");
3333  SETCB("dbg.swstep", "false", &cb_swstep, "Force use of software steps (code analysis+breakpoint)");
3334  SETBPREF("dbg.trace.inrange", "false", "While tracing, avoid following calls outside specified range");
3335  SETBPREF("dbg.trace.libs", "true", "Trace library code too");
3336  SETBPREF("dbg.exitkills", "true", "Kill process on exit");
3337  SETPREF("dbg.exe.path", "", "Path to binary being debugged");
3338  SETCB("dbg.execs", "false", &cb_dbg_execs, "Stop execution if new thread is created");
3339  SETICB("dbg.gdb.page_size", 4096, &cb_dbg_gdb_page_size, "Page size on gdb target (useful for QEMU)");
3340  SETICB("dbg.gdb.retries", 10, &cb_dbg_gdb_retries, "Number of retries before gdb packet read times out");
3341  SETCB("dbg.consbreak", "false", &cb_consbreak, "SIGINT handle for attached processes");
3342 
3344 
3345  SETBPREF("dbg.bpsysign", "false", "Ignore system breakpoints");
3346  SETICB("dbg.btdepth", 128, &cb_dbgbtdepth, "Depth of backtrace");
3347  SETCB("dbg.trace", "false", &cb_trace, "Trace program execution (see asm.trace)");
3348  SETICB("dbg.trace.tag", 0, &cb_tracetag, "Trace tag");
3349 
3350  /* cmd */
3351  SETICB("cmd.depth", 10, &cb_cmddepth, "Maximum command depth");
3352  SETPREF("cmd.bp", "", "Run when a breakpoint is hit");
3353  SETPREF("cmd.onsyscall", "", "Run when a syscall is hit");
3354  SETICB("cmd.hitinfo", 1, &cb_debug_hitinfo, "Show info when a tracepoint/breakpoint is hit");
3355  SETPREF("cmd.stack", "", "Command to display the stack in visual debug mode");
3356  SETPREF("cmd.cprompt", "", "Column visual prompt commands");
3357  SETPREF("cmd.gprompt", "", "Graph visual prompt commands");
3358  SETPREF("cmd.hit", "", "Run when a search hit is found");
3359  SETPREF("cmd.open", "", "Run when file is opened");
3360  SETPREF("cmd.load", "", "Run when binary is loaded");
3361  SETPREF("cmd.prompt", "", "Prompt commands");
3362  SETCB("cmd.repeat", "false", &cb_cmdrepeat, "Empty command an alias for '..' (repeat last command)");
3363  SETPREF("cmd.fcn.new", "", "Run when new function is analyzed");
3364  SETPREF("cmd.fcn.delete", "", "Run when a function is deleted");
3365  SETPREF("cmd.fcn.rename", "", "Run when a function is renamed");
3366  SETPREF("cmd.visual", "", "Replace current print mode");
3367  SETPREF("cmd.vprompt", "", "Visual prompt commands");
3368 
3369  SETCB("cmd.esil.step", "", &cb_cmd_esil_step, "Command to run before performing a step in the emulator");
3370  SETCB("cmd.esil.stepout", "", &cb_cmd_esil_step_out, "Command to run after performing a step in the emulator");
3371  SETCB("cmd.esil.mdev", "", &cb_cmd_esil_mdev, "Command to run when memory device address is accessed");
3372  SETCB("cmd.esil.intr", "", &cb_cmd_esil_intr, "Command to run when an esil interrupt happens");
3373  SETCB("cmd.esil.trap", "", &cb_cmd_esil_trap, "Command to run when an esil trap happens");
3374  SETCB("cmd.esil.todo", "", &cb_cmd_esil_todo, "Command to run when the esil instruction contains TODO");
3375  SETCB("cmd.esil.ioer", "", &cb_cmd_esil_ioer, "Command to run when esil fails to IO (invalid read/write)");
3376 
3377  /* hexdump */
3378  SETCB("hex.header", "true", &cb_hex_header, "Show header in hexdump");
3379  SETCB("hex.bytes", "true", &cb_hex_bytes, "Show bytes column in hexdump");
3380  SETCB("hex.ascii", "true", &cb_hex_ascii, "Show ascii column in hexdump");
3381  SETCB("hex.hdroff", "false", &cb_hex_hdroff, "Show aligned 1 byte in header instead of delta nibble");
3382  SETCB("hex.style", "false", &cb_hex_style, "Improve the hexdump header style");
3383  SETCB("hex.pairs", "true", &cb_hex_pairs, "Show bytes paired in 'px' hexdump");
3384  SETCB("hex.align", "false", &cb_hex_align, "Align hexdump with flag + flagsize");
3385  SETCB("hex.section", "false", &cb_hex_section, "Show section name before the offset");
3386  SETCB("hex.compact", "false", &cb_hexcompact, "Show smallest 16 byte col hexdump (60 columns)");
3387  SETCB("cmd.hexcursor", "", &cb_cmd_hexcursor, "If set and cursor is enabled display given pf format string");
3388  SETI("hex.flagsz", 0, "If non zero, overrides the flag size in pxa");
3389  SETICB("hex.cols", 16, &cb_hexcols, "Number of columns in hexdump");
3390  SETI("hex.depth", 5, "Maximal level of recurrence while telescoping memory");
3391  SETBPREF("hex.onechar", "false", "Number of columns in hexdump");
3392  SETICB("hex.stride", 0, &cb_hexstride, "Line stride in hexdump (default is 0)");
3393  SETCB("hex.comments", "true", &cb_hexcomments, "Show comments in 'px' hexdump");
3394 
3395  /* http */
3396  SETBPREF("http.log", "true", "Show HTTP requests processed");
3397  SETBPREF("http.colon", "false", "Only accept the : command");
3398  SETPREF("http.logfile", "", "Specify a log file instead of stderr for http requests");
3399  SETBPREF("http.cors", "false", "Enable CORS");
3400  SETPREF("http.referer", "", "CSFR protection if set");
3401  SETBPREF("http.dirlist", "false", "Enable directory listing");
3402  SETPREF("http.allow", "", "Only accept clients from the comma separated IP list");
3403 #if __WINDOWS__
3404  rz_config_set(cfg, "http.browser", "start");
3405 #else
3406  if (rz_file_exists("/usr/bin/openURL")) { // iOS ericautils
3407  rz_config_set(cfg, "http.browser", "/usr/bin/openURL");
3408  } else if (rz_file_exists("/system/bin/toolbox")) {
3409  rz_config_set(cfg, "http.browser",
3410  "LD_LIBRARY_PATH=/system/lib am start -a android.intent.action.VIEW -d");
3411  } else if (rz_file_exists("/usr/bin/xdg-open")) {
3412  rz_config_set(cfg, "http.browser", "xdg-open");
3413  } else if (rz_file_exists("/usr/bin/open")) {
3414  rz_config_set(cfg, "http.browser", "open");
3415  } else {
3416  rz_config_set(cfg, "http.browser", "firefox");
3417  }
3418  rz_config_desc(cfg, "http.browser", "Command to open HTTP URLs");
3419 #endif
3420  SETI("http.maxsize", 0, "Maximum file size for upload");
3421  SETPREF("http.index", "index.html", "Main html file to check in directory");
3422  SETPREF("http.bind", "localhost", "Server address");
3423  char *wwwroot_dir = rz_path_home_prefix(RZ_WWWROOT);
3424  SETPREF("http.homeroot", wwwroot_dir, "http home root directory");
3425  free(wwwroot_dir);
3426 #if __ANDROID__
3427  SETPREF("http.root", "/data/data/org.rizin.rizininstaller/www", "http root directory");
3428 #else
3429  char *wwwroot = rz_path_system(RZ_WWWROOT);
3430  SETPREF("http.root", wwwroot, "http root directory");
3431  free(wwwroot);
3432 #endif
3433  SETPREF("http.port", "9090", "HTTP server port");
3434  SETPREF("http.maxport", "9999", "Last HTTP server port");
3435  SETI("http.timeout", 3, "Disconnect clients after N seconds of inactivity");
3436  SETI("http.dietime", 0, "Kill server after N seconds with no client");
3437  SETBPREF("http.verbose", "false", "Output server logs to stdout");
3438  SETBPREF("http.upget", "false", "/up/ answers GET requests, in addition to POST");
3439  SETBPREF("http.upload", "false", "Enable file uploads to /up/<filename>");
3440  SETPREF("http.uri", "", "Address of HTTP proxy");
3441  SETBPREF("http.auth", "false", "Enable/Disable HTTP Authentification");
3442  p = rz_sys_getenv("RZ_HTTP_AUTHFILE");
3443  SETPREF("http.authfile", p ? p : "", "HTTP Authentification user file");
3444  tmpdir = rz_file_tmpdir();
3445  rz_config_set(cfg, "http.uproot", tmpdir);
3446  free(tmpdir);
3447  rz_config_desc(cfg, "http.uproot", "Path where files are uploaded");
3448 
3449  /* tcp */
3450  SETBPREF("tcp.islocal", "false", "Bind a loopback for tcp command server");
3451 
3452  /* graph */
3453  SETBPREF("graph.aeab", "false", "Show aeab info on each basic block instead of disasm");
3454  SETBPREF("graph.trace", "false", "Fold all non-traced basic blocks");
3455  SETBPREF("graph.dummy", "true", "Create dummy nodes in the graph for better layout (20% slower)");
3456  SETBPREF("graph.few", "false", "Show few basic blocks in the graph");
3457  SETBPREF("graph.comments", "true", "Show disasm comments in graph");
3458  SETBPREF("graph.cmtright", "false", "Show comments at right");
3459  SETCB("graph.gv.format", "gif", &cb_graphformat, "Graph image extension when using 'w' format (png, jpg, pdf, ps, svg, json)");
3460  SETBPREF("graph.refs", "false", "Graph references in callgraphs (.agc*;aggi)");
3461  SETBPREF("graph.json.usenames", "true", "Use names instead of addresses in Global Call Graph (agCj)");
3462  SETI("graph.edges", 2, "0=no edges, 1=simple edges, 2=avoid collisions");
3463  SETI("graph.layout", 0, "Graph layout (0=vertical, 1=horizontal)");
3464  SETI("graph.linemode", 1, "Graph edges (0=diagonal, 1=square)");
3465  SETPREF("graph.font", "Courier", "Font for dot graphs");
3466  SETBPREF("graph.offset", "false", "Show offsets in graphs");
3467  SETBPREF("graph.bytes", "false", "Show opcode bytes in graphs");
3468  SETI("graph.from", UT64_MAX, "Lower bound address when drawing global graphs");
3469  SETI("graph.to", UT64_MAX, "Upper bound address when drawing global graphs");
3470  SETI("graph.scroll", 5, "Scroll speed in ascii-art graph");
3471  SETBPREF("graph.invscroll", "false", "Invert scroll direction in ascii-art graph");
3472  SETPREF("graph.title", "", "Title of the graph");
3473  SETBPREF("graph.body", "true", "Show body of the nodes in the graph");
3474  SETBPREF("graph.ntitles", "true", "Display title of node");
3475  SETPREF("graph.gv.node", "", "Graphviz node style. (color=gray, style=filled shape=box)");
3476  SETPREF("graph.gv.edge", "", "Graphviz edge style. (arrowhead=\"vee\")");
3477  SETPREF("graph.gv.spline", "", "Graphviz spline style. (splines=\"ortho\")");
3478  SETPREF("graph.gv.graph", "", "Graphviz global style attributes. (bgcolor=white)");
3479  SETPREF("graph.gv.current", "false", "Highlight the current node in graphviz graph.");
3480  SETBPREF("graph.nodejmps", "true", "Enables shortcuts for every node.");
3481  SETBPREF("graph.hints", "true", "Show true (t) and false (f) hints for conditional edges in graph");
3482  SETCB("graph.dotted", "false", &cb_dotted, "Dotted lines for conditional jumps in graph");
3483 
3484  /* hud */
3485  SETPREF("hud.path", "", "Set a custom path for the HUD file");
3486 
3487  SETCB("esil.exectrap", "false", &cb_exectrap, "trap when executing code in non-executable memory");
3488  SETCB("esil.iotrap", "true", &cb_iotrap, "invalid read or writes produce a trap exception");
3489  SETBPREF("esil.romem", "false", "Set memory as read-only for ESIL");
3490  SETBPREF("esil.stats", "false", "Statistics from ESIL emulation stored in sdb");
3491  SETBPREF("esil.nonull", "false", "Prevent memory read, memory write at null pointer");
3492  SETCB("esil.mdev.range", "", &cb_mdevrange, "Specify a range of memory to be handled by cmd.esil.mdev");
3493 
3494  /* scr */
3495 #if __EMSCRIPTEN__
3496  rz_config_set_cb(cfg, "scr.fgets", "true", cb_scrfgets);
3497 #else
3498  rz_config_set_cb(cfg, "scr.fgets", "false", cb_scrfgets);
3499 #endif
3500  rz_config_desc(cfg, "scr.fgets", "Use fgets() instead of dietline for prompt input");
3501  SETCB("scr.echo", "false", &cb_screcho, "Show rcons output in realtime to stderr and buffer");
3502  SETICB("scr.linesleep", 0, &cb_scrlinesleep, "Flush sleeping some ms in every line");
3503  SETICB("scr.maxtab", 4096, &cb_completion_maxtab, "Change max number of auto completion suggestions");
3504  SETICB("scr.pagesize", 1, &cb_scrpagesize, "Flush in pages when scr.linesleep is != 0");
3505  SETCB("scr.flush", "false", &cb_scrflush, "Force flush to console in realtime (breaks scripting)");
3506  SETBPREF("scr.slow", "true", "Do slow stuff on visual mode like RzFlag.get_at(true)");
3507  SETCB("scr.prompt.popup", "false", &cb_scr_prompt_popup, "Show widget dropdown for autocomplete");
3508 #if __WINDOWS__
3509  SETICB("scr.vtmode", rz_cons_singleton()->vtmode,
3510  &scr_vtmode, "Use VT sequences on Windows (0: Disable, 1: Output, 2: Input & Output)");
3511 #endif
3512 #if __ANDROID__
3513  SETBPREF("scr.responsive", "true", "Auto-adjust Visual depending on screen (e.g. unset asm.bytes)");
3514  SETI("scr.wheel.speed", 1, "Mouse wheel speed");
3515 #else
3516  SETBPREF("scr.responsive", "false", "Auto-adjust Visual depending on screen (e.g. unset asm.bytes)");
3517  SETI("scr.wheel.speed", 4, "Mouse wheel speed");
3518 #endif
3519  SETBPREF("scr.wheel.nkey", "false", "Use sn/sp and scr.nkey on wheel instead of scroll");
3520  // RENAME TO scr.mouse
3521  SETBPREF("scr.wheel", "true", "Mouse wheel in Visual; temporaryly disable/reenable by right click/Enter)");
3522  SETPREF("scr.layout", "", "Name of the selected layout");
3523  // DEPRECATED: USES hex.cols now SETI ("scr.colpos", 80, "Column position of cmd.cprompt in visual");
3524  SETCB("scr.breakword", "", &cb_scrbreakword, "Emulate console break (^C) when a word is printed (useful for pD)");
3525  SETCB("scr.breaklines", "false", &cb_breaklines, "Break lines in Visual instead of truncating them");
3526  SETCB("scr.gadgets", "true", &cb_scr_gadgets, "Run pg in prompt, visual and panels");
3527  SETBPREF("scr.panelborder", "false", "Specify panels border active area (0 by default)");
3528  SETICB("scr.columns", 0, &cb_scrcolumns, "Force console column count (width)");
3529  SETBPREF("scr.dumpcols", "false", "Prefer pC commands before p ones");
3530  SETCB("scr.rows", "0", &cb_scrrows, "Force console row count (height) ");
3531  SETICB("scr.rows", 0, &cb_rows, "Force console row count (height) (duplicate?)");
3532  SETICB("scr.fix.rows", 0, &cb_fixrows, "Workaround for Linux TTY");
3533  SETICB("scr.fix.columns", 0, &cb_fixcolumns, "Workaround for Prompt iOS SSH client");
3534  SETCB("scr.highlight", "", &cb_scrhighlight, "Highlight that word at RzCons level");
3535  SETCB("scr.interactive", "true", &cb_scrint, "Start in interactive mode");
3536  SETCB("scr.bgfill", "false", &cb_scr_bgfill, "Fill background for ascii art when possible");
3537  SETI("scr.feedback", 1, "Set visual feedback level (1=arrow on jump, 2=every key (useful for videos))");
3538  SETCB("scr.html", "false", &cb_scrhtml, "Disassembly uses HTML syntax");
3539  n = NODECB("scr.nkey", "flag", &cb_scrnkey);
3540  SETDESC(n, "Select visual seek mode (affects n/N visual commands)");
3541  SETOPTIONS(n, "fun", "hit", "flag", NULL);
3542  SETCB("scr.pager", "", &cb_pager, "System program (or '..') to use when output exceeds screen boundaries");
3543  SETI("scr.scrollbar", 0, "Show flagzone (fz) scrollbar in visual mode (0=no,1=right,2=top,3=bottom)");
3544  SETBPREF("scr.randpal", "false", "Random color palete or just get the next one from 'eco'");
3545  SETCB("scr.highlight.grep", "false", &cb_scr_color_grep_highlight, "Highlight (INVERT) the grepped words");
3546  SETBPREF("scr.prompt.file", "false", "Show user prompt file (used by rizin -q)");
3547  SETBPREF("scr.prompt.flag", "false", "Show flag name in the prompt");
3548  SETBPREF("scr.prompt.flag.only", "false", "Show the flag name only in the prompt");
3549  SETBPREF("scr.prompt.sect", "false", "Show section name in the prompt");
3550  SETCB("scr.hist.block", "true", &cb_scr_histblock, "Use blocks for histogram");
3551  SETCB("scr.prompt", "true", &cb_scrprompt, "Show user prompt (used by rizin -q)");
3552  SETCB("scr.tee", "", &cb_teefile, "Pipe output to file of this name");
3553  SETPREF("scr.seek", "", "Seek to the specified address on startup");
3554  SETICB("scr.color", (core->print->flags & RZ_PRINT_FLAGS_COLOR) ? COLOR_MODE_16 : COLOR_MODE_DISABLED, &cb_color, "Enable colors (0: none, 1: ansi, 2: 256 colors, 3: truecolor)");
3556  SETCB("scr.color.grep", "false", &cb_scr_color_grep, "Enable colors when using ~grep");
3557  SETBPREF("scr.color.pipe", "false", "Enable colors when using pipes");
3558  SETBPREF("scr.color.ops", "true", "Colorize numbers and registers in opcodes");
3559  SETBPREF("scr.color.args", "true", "Colorize arguments and variables of functions");
3560  SETBPREF("scr.color.bytes", "true", "Colorize bytes that represent the opcodes of the instruction");
3561  SETCB("scr.null", "false", &cb_scrnull, "Show no output");
3562  SETCB("scr.utf8", rz_str_bool(rz_cons_is_utf8()), &cb_utf8, "Show UTF-8 characters instead of ANSI");
3563  SETCB("scr.utf8.curvy", "false", &cb_utf8_curvy, "Show curved UTF-8 corners (requires scr.utf8)");
3564  SETBPREF("scr.histsave", "true", "Always save history on exit");
3565  n = NODECB("scr.strconv", "asciiesc", &cb_scrstrconv);
3566  SETDESC(n, "Convert string before display");
3567  SETOPTIONS(n, "asciiesc", "asciidot", NULL);
3568  SETBPREF("scr.confirmquit", "false", "Confirm on quit");
3569  SETICB("scr.visual.mode", RZ_CORE_VISUAL_MODE_PX, &cb_visual_mode, "Visual mode (0: hexdump, 1: disassembly, 2: debug, 3: color blocks, 4: strings)");
3570 
3571  /* str */
3572  SETCB("str.escbslash", "false", &cb_str_escbslash, "Escape the backslash");
3573  SETCB("str.search.check_ascii_freq", "true", &cb_strsearch_check_ascii_freq,
3574  "Perform ASCII frequency analysis when looking for false positives during string search");
3575 
3576  /* search */
3577  SETCB("search.contiguous", "true", &cb_contiguous, "Accept contiguous/adjacent search hits");
3578  SETICB("search.align", 0, &cb_searchalign, "Only catch aligned search hits");
3579  SETI("search.chunk", 0, "Chunk size for /+ (default size is asm.bits/8");
3580  SETI("search.esilcombo", 8, "Stop search after N consecutive hits");
3581  SETI("search.distance", 0, "Search string distance");
3582  SETBPREF("search.flags", "true", "All search results are flagged, otherwise only printed");
3583  SETBPREF("search.overlap", "false", "Look for overlapped search hits");
3584  SETI("search.maxhits", 0, "Maximum number of hits (0: no limit)");
3585  SETI("search.from", -1, "Search start address");
3586  n = NODECB("search.in", "io.maps", &cb_searchin);
3587  SETDESC(n, "Specify search boundaries");
3588  SETOPTIONS(n, "raw", "block",
3589  "bin.section", "bin.sections", "bin.sections.rwx", "bin.sections.r", "bin.sections.rw", "bin.sections.rx", "bin.sections.wx", "bin.sections.x",
3590  "io.map", "io.maps", "io.maps.rwx", "io.maps.r", "io.maps.rw", "io.maps.rx", "io.maps.wx", "io.maps.x",
3591  "dbg.stack", "dbg.heap",
3592  "dbg.map", "dbg.maps", "dbg.maps.rwx", "dbg.maps.r", "dbg.maps.rw", "dbg.maps.rx", "dbg.maps.wx", "dbg.maps.x",
3593  "analysis.fcn", "analysis.bb",
3594  NULL);
3595  SETICB("search.kwidx", 0, &cb_search_kwidx, "Store last search index count");
3596  SETPREF("search.prefix", "hit", "Prefix name in search hits label");
3597  SETBPREF("search.show", "true", "Show search results");
3598  SETI("search.to", -1, "Search end address");
3599 
3600  /* rop */
3601  SETI("rop.len", 5, "Maximum ROP gadget length");
3602  SETBPREF("rop.sdb", "false", "Cache results in sdb (experimental)");
3603  SETBPREF("rop.db", "true", "Categorize rop gadgets in sdb");
3604  SETBPREF("rop.subchains", "false", "Display every length gadget from rop.len=X to 2 in /Rl");
3605  SETBPREF("rop.conditional", "false", "Include conditional jump, calls and returns in ropsearch");
3606  SETBPREF("rop.comments", "false", "Display comments in rop search output");
3607 
3608  /* io */
3609  SETCB("io.cache", "false", &cb_io_cache, "Change both of io.cache.{read,write}");
3610  SETCB("io.cache.auto", "false", &cb_io_cache_mode, "Automatic cache all reads in the IO backend");
3611  SETCB("io.cache.read", "false", &cb_io_cache_read, "Enable read cache for vaddr (or paddr when io.va=0)");
3612  SETCB("io.cache.write", "false", &cb_io_cache_write, "Enable write cache for vaddr (or paddr when io.va=0)");
3613  SETCB("io.pcache", "false", &cb_iopcache, "io.cache for p-level");
3614  SETCB("io.pcache.write", "false", &cb_iopcachewrite, "Enable write-cache");
3615  SETCB("io.pcache.read", "false", &cb_iopcacheread, "Enable read-cache");
3616  SETCB("io.ff", "true", &cb_ioff, "Fill invalid buffers with 0xff instead of returning error");
3617  SETBPREF("io.exec", "true", "See !!rizin -h~-x");
3618  SETICB("io.0xff", 0xff, &cb_io_oxff, "Use this value instead of 0xff to fill unallocated areas");
3619  SETCB("io.aslr", "false", &cb_ioaslr, "Disable ASLR for spawn and such");
3620  SETCB("io.va", "true", &cb_iova, "Use virtual address layout");
3621  SETCB("io.pava", "false", &cb_io_pava, "Use EXPERIMENTAL paddr -> vaddr address mode");
3622  SETCB("io.autofd", "true", &cb_ioautofd, "Change fd when opening a new file");
3623  SETCB("io.unalloc", "false", &cb_io_unalloc, "Check each byte if it's allocated");
3624  SETCB("io.unalloc.ch", ".", &cb_io_unalloc_ch, "Char to display if byte is unallocated");
3625 
3626  /* file */
3627  SETBPREF("file.info", "true", "RzBin info loaded");
3628  SETPREF("file.offset", "", "Offset where the file will be mapped at");
3629  SETCB("file.path", "", &cb_filepath, "Path of current file");
3630  SETPREF("file.lastpath", "", "Path of current file");
3631  SETPREF("file.type", "", "Type of current file");
3632  SETI("file.loadalign", 1024, "Alignment of load addresses");
3633  SETI("file.openmany", 1, "Maximum number of files opened at once");
3634  /* magic */
3635  SETI("magic.depth", 100, "Recursivity depth in magic description strings");
3636 
3637  /* rap */
3638  SETBPREF("rap.loop", "true", "Run rap as a forever-listening daemon (=:9090)");
3639 
3640  /* basefind */
3641  SETB("basefind.progress", false, "Basefind threads progress (true: enable, false: disable)");
3642  SETI("basefind.search.start", RZ_BASEFIND_BASE_MIN_ADDRESS, "Basefind start search address");
3643  SETI("basefind.search.end", RZ_BASEFIND_BASE_MAX_ADDRESS, "Basefind end search address");
3644  SETI("basefind.alignment", RZ_BASEFIND_BASE_ALIGNMENT, "Basefind alignment in bytes");
3645  SETI("basefind.min.score", RZ_BASEFIND_SCORE_MIN_VALUE, "Basefind min score value to consider it valid");
3646  SETI("basefind.min.string", RZ_BASEFIND_STRING_MIN_LENGTH, "Basefind min string size to find to consider it valid");
3647  SETI("basefind.max.threads", RZ_THREAD_POOL_ALL_CORES, "Basefind max threads number (when 0 uses all available cores)");
3648 
3649  /* nkeys */
3650  SETPREF("key.s", "", "override step into action");
3651  SETPREF("key.S", "", "override step over action");
3652  for (i = 1; i < 13; i++) {
3653  snprintf(buf, sizeof(buf), "key.f%d", i);
3654  snprintf(buf + 10, sizeof(buf) - 10,
3655  "Run this when F%d key is pressed in visual mode", i);
3656  switch (i) {
3657  default: p = ""; break;
3658  }
3659  rz_config_set(cfg, buf, p);
3660  rz_config_desc(cfg, buf, buf + 10);
3661  }
3662 
3663  /* zoom */
3664  SETCB("zoom.byte", "h", &cb_zoombyte, "Zoom callback to calculate each byte (See pz? for help)");
3665  SETI("zoom.from", 0, "Zoom start address");
3666  SETI("zoom.maxsz", 512, "Zoom max size of block");
3667  SETI("zoom.to", 0, "Zoom end address");
3668  n = NODECB("zoom.in", "io.map", &cb_searchin);
3669  SETDESC(n, "Specify boundaries for zoom");
3670  SETOPTIONS(n, "raw", "block",
3671  "bin.section", "bin.sections", "bin.sections.rwx", "bin.sections.r", "bin.sections.rw", "bin.sections.rx", "bin.sections.wx", "bin.sections.x",
3672  "io.map", "io.maps", "io.maps.rwx", "io.maps.r", "io.maps.rw", "io.maps.rx", "io.maps.wx", "io.maps.x",
3673  "dbg.stack", "dbg.heap",
3674  "dbg.map", "dbg.maps", "dbg.maps.rwx", "dbg.maps.r", "dbg.maps.rw", "dbg.maps.rx", "dbg.maps.wx", "dbg.maps.x",
3675  "analysis.fcn", "analysis.bb",
3676  NULL);
3677 
3678  /* RzIL config */
3679  SETB("rzil.step.events.read", false, "enables/disables printing aezse read event");
3680  SETB("rzil.step.events.write", true, "enables/disables printing aezse write event");
3681 
3682  /* FLIRT config */
3683  SETBPREF("flirt.sig.library", RZ_FLIRT_LIBRARY_NAME_DFL, "FLIRT library name for sig format");
3684  SETI("flirt.sig.version", 10, "FLIRT version for sig format");
3685  n = NODECB("flirt.sig.file", "all", &cb_flirt);
3686  SETDESC(n, "FLIRT file list (comma separated) for sig format");
3687  SETOPTIONS(n, "msdos", "win", "os2", "netware", "unix", "other", "all", "none", NULL);
3688  n = NODECB("flirt.sig.os", "all", &cb_flirt);
3689  SETDESC(n, "FLIRT operating system list (comma separated) for sig format");
3690  SETOPTIONS(n,
3691  "aixar", "aout", "ar", "bin", "coff", "dos:com", "dos:com:old", "dos:exe", "dos:exe:old",
3692  "dosdrv", "elf", "intelhex", "le", "loader", "lx", "moshex", "ne", "nlm", "omf", "omflib",
3693  "pe", "pilot", "srec", "w32run", "zip", "all", "none", NULL);
3694  SETB("flirt.sig.deflate", false, "enables/disables FLIRT zlib compression when creating a signature file (available only for .sig files)");
3695  SETI("flirt.node.optimize", RZ_FLIRT_NODE_OPTIMIZE_MAX, "FLIRT optimization option when creating a signature file (none: 0, normal: 1, smallest: 2)");
3696  SETPREF("flirt.sigdb.path", "", "Additional user defined rizin sigdb location to load on the filesystem.");
3697  SETB("flirt.sigdb.load.system", true, "Load signatures from the system path");
3698  SETB("flirt.sigdb.load.home", true, "Load signatures from the home path");
3699 
3700  rz_config_lock(cfg, true);
3701  return true;
3702 }
3703 
3705  bool has_debug = rz_sys_getenv_asbool("RZ_DEBUG");
3706  char *rcfile = rz_sys_getenv("RZ_RCFILE");
3707  char *homerc = NULL;
3708  if (!RZ_STR_ISEMPTY(rcfile)) {
3709  homerc = rcfile;
3710  } else {
3711  free(rcfile);
3712  homerc = rz_path_home_rc();
3713  }
3714  if (homerc && rz_file_is_regular(homerc)) {
3715  if (has_debug) {
3716  eprintf("USER CONFIG loaded from %s\n", homerc);
3717  }
3718  rz_core_cmd_file(r, homerc);
3719  }
3720  free(homerc);
3721  homerc = rz_path_home_config_rc();
3722  if (homerc && rz_file_is_regular(homerc)) {
3723  if (has_debug) {
3724  eprintf("USER CONFIG loaded from %s\n", homerc);
3725  }
3726  rz_core_cmd_file(r, homerc);
3727  }
3728  free(homerc);
3729  homerc = rz_path_home_config_rcdir();
3730  if (homerc) {
3731  if (rz_file_is_directory(homerc)) {
3732  char *file;
3733  RzListIter *iter;
3734  RzList *files = rz_sys_dir(homerc);
3735  rz_list_foreach (files, iter, file) {
3736  if (*file != '.') {
3737  char *path = rz_str_newf("%s/%s", homerc, file);
3738  if (rz_file_is_regular(path)) {
3739  if (has_debug) {
3740  eprintf("USER CONFIG loaded from %s\n", homerc);
3741  }
3743  }
3744  free(path);
3745  }
3746  }
3748  }
3749  free(homerc);
3750  }
3751 }
3752 
3759 RZ_API RZ_OWN RzList /*<char *>*/ *rz_core_config_in_space(RZ_NONNULL RzCore *core, RZ_NULLABLE const char *space) {
3760  rz_return_val_if_fail(core && core->config, NULL);
3761  RzList *list = rz_list_new();
3762  if (!list) {
3763  return NULL;
3764  }
3765  RzConfigNode *node;
3766  RzListIter *iter;
3767  rz_list_foreach (core->config->nodes, iter, node) {
3768  char *name = strdup(node->name);
3769  if (!name) {
3770  continue;
3771  }
3772  char *dot = strchr(name, '.');
3773  if (dot) {
3774  *dot = 0;
3775  }
3776 
3777  if (RZ_STR_ISNOTEMPTY(space)) {
3778  if (0 == strcmp(name, space) && dot && !rz_list_find(list, dot + 1, (RzListComparator)strcmp)) {
3779  rz_list_append(list, strdup(dot + 1));
3780  }
3781  } else {
3782  if (!rz_list_find(list, name, (RzListComparator)strcmp)) {
3784  }
3785  }
3786  free(name);
3787  }
3788  return list;
3789 }
RZ_API ut64 rz_analysis_function_realsize(const RzAnalysisFunction *fcn)
Definition: function.c:338
RZ_API void rz_analysis_unset_limits(RzAnalysis *analysis)
Definition: analysis.c:24
RZ_API void rz_analysis_set_cpu(RzAnalysis *analysis, const char *cpu)
Definition: analysis.c:311
RZ_API bool rz_analysis_set_bits(RzAnalysis *analysis, int bits)
Definition: analysis.c:270
RZ_API int rz_analysis_archinfo(RzAnalysis *analysis, int query)
Definition: analysis.c:449
RZ_API void rz_analysis_set_limits(RzAnalysis *analysis, ut64 from, ut64 to)
Definition: analysis.c:15
RZ_API bool rz_analysis_set_reg_profile(RzAnalysis *analysis)
Definition: analysis.c:218
RZ_API int rz_analysis_set_big_endian(RzAnalysis *analysis, int bigend)
Definition: analysis.c:325
RZ_API bool rz_analysis_use(RzAnalysis *analysis, const char *name)
Definition: analysis.c:184
RZ_API bool rz_analysis_set_os(RzAnalysis *analysis, const char *os)
Definition: analysis.c:256
lzma_index ** i
Definition: index.h:629
RZ_API int rz_asm_syntax_from_string(const char *name)
Definition: asm.c:1227
RZ_API bool rz_asm_set_big_endian(RzAsm *a, bool b)
Definition: asm.c:496
RZ_DEPRECATE RZ_API int rz_asm_set_bits(RzAsm *a, int bits)
Definition: asm.c:488
RZ_API bool rz_asm_set_syntax(RzAsm *a, int syntax)
Definition: asm.c:518
RZ_DEPRECATE RZ_API void rz_asm_set_cpu(RzAsm *a, const char *cpu)
Definition: asm.c:477
RZ_API bool rz_asm_use(RzAsm *a, const char *name)
Puts an Asm plugin in use and disables the previous one.
Definition: asm.c:429
RZ_API bool rz_asm_use_assembler(RzAsm *a, const char *name)
Definition: asm.c:363
RZ_API void rz_bin_force_plugin(RzBin *bin, const char *name)
Definition: bin.c:906
RZ_API RzBinFile * rz_bin_cur(RzBin *bin)
Definition: bin.c:895
RZ_DEPRECATE RZ_API RZ_BORROW RzList * rz_bin_get_sections(RZ_NONNULL RzBin *bin)
Definition: bin.c:597
static SblHeader sb
Definition: bin_mbn.c:26
int bits(struct state *s, int need)
Definition: blast.c:72
RZ_API bool rz_bin_object_reset_strings(RZ_NONNULL RzBin *bin, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzBinObject *obj)
Remove all previously identified strings in the binary object and scan it again for strings.
Definition: bobj.c:833
RZ_API int rz_bp_use(RZ_NONNULL RzBreakpoint *bp, RZ_NONNULL const char *name)
Definition: bp_plugin.c:47
RZ_API void rz_core_analysis_type_init(RzCore *core)
Definition: canalysis.c:6610
RZ_API void rz_core_analysis_cc_init(RzCore *core)
Definition: canalysis.c:6628
RZ_API RzCmdStatus rz_core_asm_plugins_print(RzCore *core, const char *arch, RzCmdStateOutput *state)
Definition: casm.c:150
RZ_API const char * rz_analysis_syscc_default(RzAnalysis *analysis)
Definition: cc.c:210
RZ_API void rz_analysis_set_syscc_default(RzAnalysis *analysis, const char *cc)
Definition: cc.c:215
RZ_API const char * rz_analysis_cc_default(RzAnalysis *analysis)
Definition: cc.c:200
RZ_API void rz_analysis_set_cc_default(RzAnalysis *analysis, const char *cc)
Definition: cc.c:205
static bool cb_ioaslr(void *user, void *data)
Definition: cconfig.c:1949
static bool cb_cmd_esil_step_out(void *user, void *data)
Definition: cconfig.c:1849
static bool cb_analysis_afterjmp(void *user, void *data)
Definition: cconfig.c:161
static bool cb_analysissyscc(RzCore *core, RzConfigNode *node)
Definition: cconfig.c:2578
static bool cb_visual_mode(void *user, void *data)
Definition: cconfig.c:2371
static bool cb_asmsyntax(void *user, void *data)
Definition: cconfig.c:1042
static bool cb_hex_section(void *user, void *data)
Definition: cconfig.c:1500
static bool cb_io_unalloc_ch(void *user, void *data)
Definition: cconfig.c:1533
static bool cb_analysis_nopskip(void *user, void *data)
Definition: cconfig.c:240
static bool cb_analysis_jmptbl(void *user, void *data)
Definition: cconfig.c:2632
static bool cb_analysis_cpp_abi(void *user, void *data)
Definition: cconfig.c:2730
static bool cb_scrfgets(void *user, void *data)
Definition: cconfig.c:2088
static void update_asmparser_options(RzCore *core, RzConfigNode *node)
Definition: cconfig.c:863
static bool cb_dotted(void *user, void *data)
Definition: cconfig.c:2381
static bool cb_analysis_ijmp(void *user, void *data)
Definition: cconfig.c:304
static bool cb_strsearch_check_ascii_freq(void *user, void *data)
Definition: cconfig.c:1149
static bool cb_cmd_esil_intr(void *user, void *data)
Definition: cconfig.c:1816
static bool cb_dbg_bpinmaps(void *user, void *data)
Definition: cconfig.c:1286
static bool cb_analysis_armthumb(void *user, void *data)
Definition: cconfig.c:140
static bool cb_cfg_fortunes(void *user, void *data)
Definition: cconfig.c:1163
static bool cb_trace(void *user, void *data)
Definition: cconfig.c:2342
static bool isGdbPlugin(RzCore *core)
Definition: cconfig.c:34
static bool cb_asmfeatures(void *user, void *data)
Definition: cconfig.c:722
static bool cb_mdevrange(void *user, void *data)
Definition: cconfig.c:1827
static bool cb_utf8(void *user, void *data)
Definition: cconfig.c:2356
static bool cb_binverbose(void *user, void *data)
Definition: cconfig.c:2409
static bool cb_asmparser(void *user, void *data)
Definition: cconfig.c:874
static bool cb_scrlinesleep(void *user, void *data)
Definition: cconfig.c:2155
RZ_API void rz_core_parse_rizinrc(RzCore *r)
Definition: cconfig.c:3704
static bool cb_scrbreakword(void *user, void *data)
Definition: cconfig.c:2068
static bool cb_hex_pairs(void *user, void *data)
Definition: cconfig.c:1493
static bool cb_dbg_gdb_retries(void *user, void *data)
Definition: cconfig.c:1317
static bool cb_log_config_traplevel(void *coreptr, void *nodeptr)
Definition: cconfig.c:2772
static bool cb_analysis_jmptblmaxoffset(void *user, void *data)
Definition: cconfig.c:2646
static void set_options(RzConfigNode *node,...)
Definition: cconfig.c:22
static bool cb_dbgbackend(void *user, void *data)
Definition: cconfig.c:1411
static bool cb_analysis_roregs(RzCore *core, RzConfigNode *node)
Definition: cconfig.c:2570
static bool cb_cmd_esil_trap(void *user, void *data)
Definition: cconfig.c:1871
static bool cb_utf8_curvy(void *user, void *data)
Definition: cconfig.c:2364
static bool cb_hex_hdroff(void *user, void *data)
Definition: cconfig.c:1584
static bool cb_scrpagesize(void *user, void *data)
Definition: cconfig.c:2161
static bool cb_scrhtml(void *user, void *data)
Definition: cconfig.c:2098
static bool cb_screcho(void *user, void *data)
Definition: cconfig.c:2149
static bool cb_cfgdatefmt(void *user, void *data)
Definition: cconfig.c:1078
static bool cb_analysis_ignbithints(void *user, void *data)
Definition: cconfig.c:212
static bool cb_analysis_graphdepth(void *user, void *data)
Definition: cconfig.c:154
static bool cb_iopcache(void *user, void *data)
Definition: cconfig.c:1613
static bool cb_asmpseudo(void *user, void *data)
Definition: cconfig.c:366
static bool cb_cmd_esil_mdev(void *user, void *data)
Definition: cconfig.c:1860
static bool cb_contiguous(void *user, void *data)
Definition: cconfig.c:2273
static bool cb_scr_bgfill(void *user, void *data)
Definition: cconfig.c:2224
static bool cb_analysis_strings(void *user, void *data)
Definition: cconfig.c:203
static bool cb_analysis_jmpretpoline(void *user, void *data)
Definition: cconfig.c:127
static bool cb_maxname(void *user, void *data)
Definition: cconfig.c:995
static bool cb_strfilter(void *user, void *data)
Definition: cconfig.c:1011
static bool cb_debase64(void *user, void *data)
Definition: cconfig.c:2416
static bool cb_binminstr(void *user, void *data)
Definition: cconfig.c:2509
static bool cb_iopcacheread(void *user, void *data)
Definition: cconfig.c:1631
static bool cb_scr_gadgets(void *user, void *data)
Definition: cconfig.c:2061
static bool cb_scrint(void *user, void *data)
Definition: cconfig.c:2236
static bool cb_scrstrconv(void *user, void *data)
Definition: cconfig.c:2173
static bool cb_rows(void *user, void *data)
Definition: cconfig.c:1469
static bool cb_consbreak(void *user, void *data)
Definition: cconfig.c:2329
static bool cb_hex_style(void *user, void *data)
Definition: cconfig.c:1573
static bool cb_scrrainbow(void *user, void *data)
Definition: cconfig.c:352
static bool cb_analysis_nonull(void *user, void *data)
Definition: cconfig.c:196
static bool cb_segoff(void *user, void *data)
Definition: cconfig.c:2288
static bool boolify_var_cb(void *user, void *data)
Definition: cconfig.c:13
static int compareAddress(const RzAnalysisFunction *a, const RzAnalysisFunction *b)
Definition: cconfig.c:65
static bool cb_binmaxstr(void *user, void *data)
Definition: cconfig.c:2491
RZ_API void rz_core_config_print_all(RzConfig *cfg, const char *str, RzCmdStateOutput *state)
Prints the configuation variables with their description and its values.
Definition: cconfig.c:1770
static bool cb_asmlineswidth(void *user, void *data)
Definition: cconfig.c:780
static bool cb_breaklines(void *user, void *data)
Definition: cconfig.c:2055
static bool cb_runprofile(void *user, void *data)
Definition: cconfig.c:1388
static bool cb_flag_realnames(void *user, void *data)
Definition: cconfig.c:715
static bool cb_analysis_jmpref(void *user, void *data)
Definition: cconfig.c:2660
static bool cb_hex_header(void *user, void *data)
Definition: cconfig.c:1540
static bool cb_asmsubvarmin(void *user, void *data)
Definition: cconfig.c:311
static bool cb_emustr(void *user, void *data)
Definition: cconfig.c:787
static int compareSize(const RzAnalysisFunction *a, const RzAnalysisFunction *b)
Definition: cconfig.c:73
static bool cb_cmddepth(void *user, void *data)
Definition: cconfig.c:1881
static bool cb_asm_pcalign(void *user, void *data)
Definition: cconfig.c:826
static bool cb_search_kwidx(void *user, void *data)
Definition: cconfig.c:1903
static bool cb_dbgbep(void *user, void *data)
Definition: cconfig.c:1249
static bool cb_teefile(void *user, void *data)
Definition: cconfig.c:2336
static bool cb_dirtmp(void *user, void *data)
Definition: cconfig.c:1127
static bool cb_flirt(void *user, void *data)
Definition: cconfig.c:2820
static bool cb_decoff(void *user, void *data)
Definition: cconfig.c:1237
RZ_API bool rz_core_esil_cmd(RzAnalysisEsil *esil, const char *cmd, ut64 a1, ut64 a2)
Definition: cconfig.c:1669
static bool cb_dbg_unlibs(void *user, void *data)
Definition: cconfig.c:1278
static bool cb_log_config_level(void *coreptr, void *nodeptr)
Definition: cconfig.c:2766
static bool cb_analysis_limits(void *user, RzConfigNode *node)
Definition: cconfig.c:2614
static bool cb_asm_invhex(void *user, void *data)
Definition: cconfig.c:819
static bool cb_malloc(void *user, void *data)
Definition: cconfig.c:2752
static bool cb_scr_prompt_mode(void *user, void *data)
Definition: cconfig.c:338
static int compareDist(const RzAnalysisFunction *a, const RzAnalysisFunction *b)
Definition: cconfig.c:84
static bool cb_dirhome(void *user, void *data)
Definition: cconfig.c:1119
static bool cb_asm_immhash(void *user, void *data)
Definition: cconfig.c:812
static bool cb_tracetag(void *user, void *data)
Definition: cconfig.c:2349
static bool cb_log_config_colors(void *coreptr, void *nodeptr)
Definition: cconfig.c:2799
static bool cb_analysis_loads(void *user, void *data)
Definition: cconfig.c:2674
static bool cb_dbg_btalgo(void *user, void *data)
Definition: cconfig.c:1258
static bool cb_asmassembler(void *user, void *data)
Definition: cconfig.c:385
static bool cb_asmcpu(void *user, void *data)
Definition: cconfig.c:417
static bool cb_usextr(void *user, void *data)
Definition: cconfig.c:958
static bool cb_hexcompact(void *user, void *data)
Definition: cconfig.c:1482
static bool cb_fixrows(void *user, void *data)
Definition: cconfig.c:1457
static bool cb_analysis_vars_stackname(void *user, void *data)
Definition: cconfig.c:189
RZ_API int rz_core_config_init(RzCore *core)
Definition: cconfig.c:2830
static bool cb_scrlast(void *user, void *data)
Definition: cconfig.c:325
static bool cb_gotolimit(void *user, void *data)
Definition: cconfig.c:1430
static bool cb_hexstride(void *user, void *data)
Definition: cconfig.c:1897
static bool cb_cmd_esil_step(void *user, void *data)
Definition: cconfig.c:1838
static int __dbg_swstep_getter(void *user, RzConfigNode *node)
Definition: cconfig.c:2564
static bool cb_cmd_esil_todo(void *user, void *data)
Definition: cconfig.c:1805
static void update_syscall_ns(RzCore *core)
Definition: cconfig.c:469
static bool cb_binstrenc(void *user, void *data)
Definition: cconfig.c:891
static bool cb_dbg_trace_continue(void *user, void *data)
Definition: cconfig.c:1371
static bool cb_searchalign(void *user, void *data)
Definition: cconfig.c:2280
static void __setsegoff(RzConfig *cfg, const char *asmarch, int asmbits)
Definition: cconfig.c:115
static bool cb_analysis_bb_max_size(void *user, void *data)
Definition: cconfig.c:2723
static bool cb_binforce(void *user, void *data)
Definition: cconfig.c:1035
static bool cb_analysis_trycatch(void *user, void *data)
Definition: cconfig.c:2716
static bool cb_dbg_clone(void *user, void *data)
Definition: cconfig.c:1347
static void update_analysis_arch_options(RzCore *core, RzConfigNode *node)
Definition: cconfig.c:254
static void update_asmplatforms_options(RzCore *core, RzConfigNode *node)
Definition: cconfig.c:737
static int compareName(const RzAnalysisFunction *a, const RzAnalysisFunction *b)
Definition: cconfig.c:51
static bool cb_dbg_follow_child(void *user, void *data)
Definition: cconfig.c:1357
static bool cb_asmsubsec(void *user, void *data)
Definition: cconfig.c:373
static bool cb_scrflush(void *user, void *data)
Definition: cconfig.c:2167
static bool cb_dbg_forks(void *user, void *data)
Definition: cconfig.c:1293
static bool cb_dbg_gdb_page_size(void *user, void *data)
Definition: cconfig.c:1303
static bool cb_iotrap(void *user, void *data)
Definition: cconfig.c:2215
static bool cb_analysis_norevisit(void *user, void *data)
Definition: cconfig.c:233
static bool cb_cfg_fortunes_file(void *user, void *data)
Definition: cconfig.c:1174
static bool cb_analysis_cpu(void *user, void *data)
Definition: cconfig.c:285
static bool cb_dbg_aftersc(void *user, void *data)
Definition: cconfig.c:1378
static bool cb_esilstackdepth(void *user, void *data)
Definition: cconfig.c:1448
static bool cb_binmaxstrbuf(void *user, void *data)
Definition: cconfig.c:2470
static bool cb_io_cache(void *user, void *data)
Definition: cconfig.c:1943
static bool cb_asmplatform(void *user, void *data)
Definition: cconfig.c:757
static bool cb_cfgdebug(void *user, void *data)
Definition: cconfig.c:1092
static bool cb_analysis_depth(void *user, void *data)
Definition: cconfig.c:147
static bool cb_hex_align(void *user, void *data)
Definition: cconfig.c:1511
static bool cb_strpurge(void *user, void *data)
Definition: cconfig.c:965
static bool cb_str_escbslash(void *user, void *data)
Definition: cconfig.c:1142
static bool cb_analysis_aftertrap(void *user, void *data)
Definition: cconfig.c:168
static bool cb_dbg_verbose(void *user, void *data)
Definition: cconfig.c:2813
static bool cb_hexcols(void *user, void *data)
Definition: cconfig.c:1889
static int compareType(const RzAnalysisFunction *a, const RzAnalysisFunction *b)
Definition: cconfig.c:69
static bool cb_analysis_brokenrefs(void *user, void *data)
Definition: cconfig.c:2709
static bool cb_analysis_gp(RzCore *core, RzConfigNode *node)
Definition: cconfig.c:2600
static int compareNameLen(const RzAnalysisFunction *a, const RzAnalysisFunction *b)
Definition: cconfig.c:55
static bool cb_graphformat(void *user, void *data)
Definition: cconfig.c:2197
static bool cb_scrnkey(void *user, void *data)
Definition: cconfig.c:2242
static bool cb_io_oxff(void *user, void *data)
Definition: cconfig.c:1994
static bool cb_io_cache_read(void *user, void *data)
Definition: cconfig.c:1921
static bool cb_swstep(void *user, void *data)
Definition: cconfig.c:2322
static bool cb_analysis_sleep(void *user, void *data)
Definition: cconfig.c:219
static bool cb_scr_color_grep_highlight(void *user, void *data)
Definition: cconfig.c:2035
static bool cb_analysis_searchstringrefs(void *user, void *data)
Definition: cconfig.c:2695
static bool cb_cmdrepeat(void *user, void *data)
Definition: cconfig.c:1190
static bool cb_zoombyte(void *user, void *data)
Definition: cconfig.c:2388
static bool cb_log_config_srcinfo(void *coreptr, void *nodeptr)
Definition: cconfig.c:2785
static bool cb_scr_prompt_popup(void *user, void *data)
Definition: cconfig.c:2315
static bool cb_analysis_pushret(void *user, void *data)
Definition: cconfig.c:2702
static bool cb_analysis_followdatarefs(void *user, void *data)
Definition: cconfig.c:2681
static bool cb_analysis_from(RzCore *core, RzConfigNode *node)
Definition: cconfig.c:2605
static bool cb_io_unalloc(void *user, void *data)
Definition: cconfig.c:1522
static bool cb_timezone(void *user, void *data)
Definition: cconfig.c:1085
static void config_print_node(RzConfig *cfg, RzConfigNode *node, RzCmdStateOutput *state)
Definition: cconfig.c:1678
static bool cb_scrrows(void *user, void *data)
Definition: cconfig.c:2266
static void update_asmfeatures_options(RzCore *core, RzConfigNode *node)
Definition: cconfig.c:695
static bool cb_fixcolumns(void *user, void *data)
Definition: cconfig.c:1463
static bool cb_scrnull(void *user, void *data)
Definition: cconfig.c:1197
static bool cb_asmbits(void *user, void *data)
Definition: cconfig.c:634
static bool cb_filepath(void *user, void *data)
Definition: cconfig.c:2001
static bool cb_bigendian(void *user, void *data)
Definition: cconfig.c:1058
static bool cb_emuskip(void *user, void *data)
Definition: cconfig.c:796
static bool cb_seggrn(void *user, void *data)
Definition: cconfig.c:2299
static bool cb_cmd_hexcursor(void *user, void *data)
Definition: cconfig.c:1475
static bool cb_analysis_hpskip(void *user, void *data)
Definition: cconfig.c:247
static bool cb_iopcachewrite(void *user, void *data)
Definition: cconfig.c:1650
static bool cb_binfilter(void *user, void *data)
Definition: cconfig.c:944
static bool cb_analysis_arch(void *user, void *data)
Definition: cconfig.c:265
static bool cb_analysis_recont(void *user, void *data)
Definition: cconfig.c:297
static bool cb_searchin(void *user, void *data)
Definition: cconfig.c:2527
static bool cb_scr_wideoff(void *user, void *data)
Definition: cconfig.c:345
static bool cb_bindbginfo(void *user, void *data)
Definition: cconfig.c:2435
static void update_asmarch_options(RzCore *core, RzConfigNode *node)
Definition: cconfig.c:444
static bool cb_io_cache_write(void *user, void *data)
Definition: cconfig.c:1932
RZ_API RZ_OWN RzList * rz_core_config_in_space(RZ_NONNULL RzCore *core, RZ_NULLABLE const char *space)
Get config variable spaces.
Definition: cconfig.c:3759
static bool cb_io_pava(void *user, void *data)
Definition: cconfig.c:1958
static bool cb_completion_maxtab(void *user, void *data)
Definition: cconfig.c:1156
static bool cb_iova(void *user, void *data)
Definition: cconfig.c:1968
static bool cb_dbg_create_new_console(void *user, void *data)
Definition: cconfig.c:1364
static bool cb_ioff(void *user, void *data)
Definition: cconfig.c:1987
static bool cb_analysis_cjmpref(void *user, void *data)
Definition: cconfig.c:2653
static bool cb_dbg_execs(void *user, void *data)
Definition: cconfig.c:1331
static bool cb_asmsubtail(void *user, void *data)
Definition: cconfig.c:318
static bool cb_io_cache_mode(void *user, void *data)
Definition: cconfig.c:1910
static bool cb_analysis_rnr(void *user, RzConfigNode *node)
Definition: cconfig.c:2626
static bool cb_scrprompt(void *user, void *data)
Definition: cconfig.c:2258
static void update_asmbits_options(RzCore *core, RzConfigNode *node)
Definition: cconfig.c:455
static bool cb_dirsrc(void *user, void *data)
Definition: cconfig.c:1134
static bool cb_analysis_jmptblmax(void *user, void *data)
Definition: cconfig.c:2639
static bool cb_asmarch(void *user, void *data)
Definition: cconfig.c:477
static bool cb_log_config_file(void *coreptr, void *nodeptr)
Definition: cconfig.c:2778
static bool cb_binat(void *user, void *data)
Definition: cconfig.c:951
static void print_node_options(RzConfigNode *node)
Definition: cconfig.c:43
static bool cb_dbg_args(void *user, void *data)
Definition: cconfig.c:1400
static bool cb_analysis_jmptailcall(void *user, void *data)
Definition: cconfig.c:133
static bool cb_scr_color_grep(void *user, void *data)
Definition: cconfig.c:2026
static bool cb_analysis_delay(void *user, void *data)
Definition: cconfig.c:175
static bool cb_hexcomments(void *user, void *data)
Definition: cconfig.c:1602
static bool cb_binstrings(void *user, void *data)
Definition: cconfig.c:2423
static bool cb_analysis_maxrefs(void *user, void *data)
Definition: cconfig.c:226
static bool cb_color(void *user, void *data)
Definition: cconfig.c:1204
static bool cb_scr_histblock(void *user, void *data)
Definition: cconfig.c:2251
static bool cb_midflags(void *user, void *data)
Definition: cconfig.c:1002
static bool cb_cmd_esil_ioer(void *user, void *data)
Definition: cconfig.c:1794
static bool cb_analysiscc(RzCore *core, RzConfigNode *node)
Definition: cconfig.c:2589
static void update_asmcpu_options(RzCore *core, RzConfigNode *node)
Definition: cconfig.c:392
static bool cb_hex_ascii(void *user, void *data)
Definition: cconfig.c:1562
static bool cb_hex_bytes(void *user, void *data)
Definition: cconfig.c:1551
static bool cb_stopthreads(void *user, void *data)
Definition: cconfig.c:2308
static bool cb_exectrap(void *user, void *data)
Definition: cconfig.c:2206
static bool cb_asmos(void *user, void *data)
Definition: cconfig.c:838
static bool cb_scr_vi(void *user, void *data)
Definition: cconfig.c:331
static bool cb_dbgbtdepth(void *user, void *data)
Definition: cconfig.c:627
static bool cb_analysis_jmpmid(void *user, void *data)
Definition: cconfig.c:2688
static bool cb_log_events(void *user, void *data)
Definition: cconfig.c:1595
static bool cb_analysis_jmpabove(void *user, void *data)
Definition: cconfig.c:2667
static bool cb_scrcolumns(void *user, void *data)
Definition: cconfig.c:2078
static bool cb_dbg_libs(void *user, void *data)
Definition: cconfig.c:1270
static bool cb_analysis_vars(void *user, void *data)
Definition: cconfig.c:182
static bool cb_cmdtimes(void *user, void *data)
Definition: cconfig.c:1183
static bool cb_ioautofd(void *user, void *data)
Definition: cconfig.c:2019
static bool cb_esilverbose(void *user, void *data)
Definition: cconfig.c:1439
static bool cb_color_getter(void *user, RzConfigNode *node)
Definition: cconfig.c:1225
static bool cb_binprefix(void *user, void *data)
Definition: cconfig.c:2445
static bool cb_scrhighlight(void *user, void *data)
Definition: cconfig.c:2105
static bool cb_debug_hitinfo(void *user, void *data)
Definition: cconfig.c:120
static bool cb_pager(void *user, void *data)
Definition: cconfig.c:2042
static bool cb_diff_sort(void *_core, void *_node)
Definition: cconfig.c:88
RZ_API RzCmdStatus rz_core_debug_plugins_print(RzCore *core, RzCmdStateOutput *state)
Definition: cdebug.c:329
RZ_API int rz_core_block_read(RzCore *core)
Definition: cio.c:243
RZ_API int rz_core_cmd0(RzCore *core, const char *cmd)
Definition: cmd.c:5428
RZ_API int rz_core_cmd_file(RzCore *core, const char *file)
Definition: cmd.c:5341
RZ_API int rz_core_cmdf(RzCore *core, const char *fmt,...)
Definition: cmd.c:5413
RZ_API bool rz_cmd_state_output_init(RZ_NONNULL RzCmdStateOutput *state, RzOutputMode mode)
Initialize a RzCmdStateOutput structure and its inner fields based on the provided mode.
Definition: cmd_api.c:2634
RZ_API void rz_cmd_state_output_fini(RZ_NONNULL RzCmdStateOutput *state)
Clear the inner fields of RzCmdStateOutput structure, but do not free it.
Definition: cmd_api.c:2603
static int value
Definition: cmd_api.c:93
RZ_API void rz_cmd_state_output_print(RZ_NONNULL RzCmdStateOutput *state)
Print the output accumulated in state to RzCons, if necessary.
Definition: cmd_api.c:2668
RZ_API char * rz_cmd_escape_arg(const char *arg, RzCmdEscape esc)
Definition: cmd_api.c:2516
static RzCore * _core
Definition: cmd_debug.c:1622
RZ_API char * rz_core_theme_get(RzCore *core)
Definition: cmd_eval.c:103
RZ_API bool rz_core_theme_load(RzCore *core, const char *name)
Definition: cmd_eval.c:56
RZ_API ut64 rz_config_get_i(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:119
RZ_API bool rz_config_get_b(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:142
RZ_API RzConfigNode * rz_config_set(RzConfig *cfg, RZ_NONNULL const char *name, const char *value)
Definition: config.c:267
RZ_API bool rz_config_set_getter(RzConfig *cfg, const char *key, RzConfigCallback cb)
Definition: config.c:53
RZ_API RZ_BORROW RzConfigNode * rz_config_node_get(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:48
RZ_API RzConfigNode * rz_config_set_i(RzConfig *cfg, RZ_NONNULL const char *name, const ut64 i)
Definition: config.c:419
RZ_API RzConfigNode * rz_config_set_cb(RzConfig *cfg, const char *name, const char *value, RzConfigCallback cb)
Definition: config.c:173
RZ_API RZ_BORROW const char * rz_config_get(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:75
RZ_API const char * rz_config_node_type(RzConfigNode *node)
Definition: config.c:155
RZ_API const char * rz_config_desc(RzConfig *cfg, RZ_NONNULL const char *name, RZ_NULLABLE const char *desc)
Definition: config.c:377
RZ_API RzConfig * rz_config_new(void *user)
Definition: config.c:490
RZ_API void rz_config_lock(RzConfig *cfg, int l)
Definition: config.c:476
RZ_API RzConfigNode * rz_config_set_b(RzConfig *cfg, RZ_NONNULL const char *name, bool value)
Definition: config.c:201
RZ_API void rz_config_node_value_format_i(char *buf, size_t buf_size, const ut64 i, RZ_NULLABLE RzConfigNode *node)
Definition: config.c:403
RZ_API void rz_cons_set_utf8(bool b)
Definition: cons.c:1658
RZ_API void rz_cons_breakword(RZ_NULLABLE const char *s)
Definition: cons.c:1939
RZ_API int rz_cons_get_size(int *rows)
Definition: cons.c:1446
RZ_API RzCons * rz_cons_singleton(void)
Definition: cons.c:300
RZ_API void rz_cons_highlight(const char *word)
Definition: cons.c:1756
RZ_API int rz_cons_printf(const char *format,...)
Definition: cons.c:1202
RZ_API void rz_cons_println(const char *str)
Definition: cons.c:233
#define RZ_API
RZ_IPI void rz_core_types_calling_conventions_print(RzCore *core, RzOutputMode mode)
Definition: ctypes.c:19
#define NULL
Definition: cris-opc.c:27
#define r
Definition: crypto_rc6.c:12
cs_arch arch
Definition: cstool.c:13
RZ_API bool rz_cons_is_utf8(void)
Definition: cutf8.c:242
static static fork const void static count static fd const char const char static newpath const char static path const char path
Definition: sflib.h:35
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec req
Definition: sflib.h:128
static static sync static getppid static getegid const char static filename char argp
Definition: sflib.h:62
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
Definition: sflib.h:79
#define true
uint32_t ut32
const char * v
Definition: dsignal.c:12
RZ_API bool rz_egg_setup(RzEgg *egg, const char *arch, int bits, int endian, const char *os)
Definition: egg.c:139
checking print the parsed form of the magic use in n conjunction with m to debug a new magic file n before installing it n output MIME type special files
Definition: file_opts.h:46
static const struct @646 features[]
RZ_API void rz_core_fortune_list(RzCore *core)
Definition: fortune.c:28
RZ_API void rz_core_fortune_list_types(void)
Definition: fortune.c:21
struct platform platforms[]
Definition: fuzz_diff.c:18
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
const char int mode
Definition: ioapi.h:137
voidpf void * buf
Definition: ioapi.h:138
snprintf
Definition: kernel.h:364
void * p
Definition: libc.cpp:67
RZ_API int rz_core_fgets(char *buf, int len, void *user)
Definition: core.c:1694
RZ_API int rz_debug_attach(RzDebug *dbg, int pid)
Definition: debug.c:445
RZ_API bool rz_debug_set_arch(RzDebug *dbg, const char *arch, int bits)
Definition: debug.c:465
RZ_API bool rz_debug_select(RzDebug *dbg, int pid, int tid)
Definition: debug.c:595
static void list(RzEgg *egg)
Definition: rz-gg.c:52
RZ_API RZ_BORROW RzListIter * rz_list_find(RZ_NONNULL const RzList *list, const void *p, RZ_NONNULL RzListComparator cmp)
Returns RzListIter element which matches via the RzListComparator.
Definition: list.c:620
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
Definition: list.c:235
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
Definition: list.c:109
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
RZ_API void rz_list_purge(RZ_NONNULL RzList *list)
Empties the list without freeing the list pointer.
Definition: list.c:120
RZ_API RzLine * rz_line_singleton(void)
Definition: line.c:15
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")
int n
Definition: mipsasm.c:19
RZ_API int sdb_ns_set(Sdb *s, const char *name, Sdb *r)
Definition: ns.c:156
RZ_API bool sdb_ns_unset(Sdb *s, const char *name, Sdb *r)
Definition: ns.c:136
RZ_API void rz_cons_pal_update_event(void)
Definition: pal.c:652
RZ_API void rz_cons_pal_random(void)
Definition: pal.c:270
RZ_API bool rz_parse_use(RzParse *p, const char *name)
Definition: parse.c:56
RZ_API bool rz_platform_profiles_init(RzPlatformTarget *t, const char *cpu, const char *arch, const char *cpus_dir)
Initializes RzPlatformProfile by loading the path to the SDB file of the CPU profile.
RZ_API bool rz_platform_target_index_init(RzPlatformTargetIndex *t, RZ_NONNULL const char *arch, RZ_NONNULL const char *cpu, const char *platform, RZ_NONNULL const char *platforms_dir)
Initialize Platform Profiles by setting the path to the corresponding SDB file.
RZ_API bool rz_debug_use(RzDebug *dbg, const char *str)
Definition: plugin.c:17
RZ_API void rz_print_set_flags(RzPrint *p, int _flags)
Definition: print.c:117
#define eprintf(x, y...)
Definition: rlcc.c:7
static RzSocket * s
Definition: rtr.c:28
#define RZ_ANALYSIS_ARCHINFO_ALIGN
Definition: rz_analysis.h:100
@ RZ_ANALYSIS_CPP_ABI_ITANIUM
Definition: rz_analysis.h:542
@ RZ_ANALYSIS_CPP_ABI_MSVC
Definition: rz_analysis.h:543
#define rz_warn_if_reached()
Definition: rz_assert.h:29
#define rz_return_if_fail(expr)
Definition: rz_assert.h:100
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
#define RZ_BASEFIND_BASE_MAX_ADDRESS
Definition: rz_basefind.h:15
#define RZ_BASEFIND_STRING_MIN_LENGTH
Definition: rz_basefind.h:13
#define RZ_BASEFIND_SCORE_MIN_VALUE
Definition: rz_basefind.h:17
#define RZ_BASEFIND_BASE_MIN_ADDRESS
Definition: rz_basefind.h:14
#define RZ_BASEFIND_BASE_ALIGNMENT
Definition: rz_basefind.h:16
#define RZ_BIN_REQ_STRINGS
Definition: rz_bin.h:52
@ RZ_CMD_ESCAPE_ONE_ARG
The string should be escaped so that it appears as one single argument.
Definition: rz_cmd.h:79
#define SETBPREF(x, y, z)
Definition: rz_config.h:32
#define NODEICB(w, x, y)
Definition: rz_config.h:24
#define SETOPTIONS(x,...)
Definition: rz_config.h:26
#define SETCB(w, x, y, z)
Definition: rz_config.h:31
static bool rz_config_node_is_ro(RzConfigNode *node)
Definition: rz_config.h:123
#define SETI(x, y, z)
Definition: rz_config.h:27
#define SETICB(w, x, y, z)
Definition: rz_config.h:29
#define SETDESC(x, y)
Definition: rz_config.h:25
#define SETPREF(x, y, z)
Definition: rz_config.h:30
bool(* RzConfigCallback)(void *user, void *data)
Definition: rz_config.h:34
#define NODECB(w, x, y)
Definition: rz_config.h:23
#define SETB(x, y, z)
Definition: rz_config.h:28
@ RZ_VIRT_TERM_MODE_COMPLETE
All the sequences goes through VT (Windows Terminal, mintty, all OSs)
Definition: rz_cons.h:451
@ RZ_VIRT_TERM_MODE_OUTPUT_ONLY
Windows only: Use console c api for input, but output on VT (Windows >= 10)
Definition: rz_cons.h:450
@ RZ_VIRT_TERM_MODE_DISABLE
Windows only: Use console c api for everything (Windows <= 8)
Definition: rz_cons.h:449
@ COLOR_MODE_16
Definition: rz_cons.h:443
@ COLOR_MODE_16M
Definition: rz_cons.h:445
@ COLOR_MODE_DISABLED
Definition: rz_cons.h:442
@ RZ_CORE_VISUAL_MODE_CD
Print in string format.
Definition: rz_core.h:102
@ RZ_CORE_VISUAL_MODE_PX
Hexadecimal view.
Definition: rz_core.h:98
RZ_API const char * rz_file_basename(const char *path)
Definition: file.c:83
RZ_API char * rz_file_tmpdir(void)
Definition: file.c:1132
RZ_API bool rz_file_is_directory(const char *str)
Definition: file.c:167
RZ_API bool rz_file_exists(const char *str)
Definition: file.c:192
RZ_API bool rz_file_is_regular(const char *str)
Definition: file.c:159
@ RZ_FLIRT_NODE_OPTIMIZE_MAX
optimize the tree structure and drops the tail bytes
Definition: rz_flirt.h:188
#define RZ_FLIRT_LIBRARY_NAME_DFL
Definition: rz_flirt.h:19
RZ_API char * rz_io_system(RzIO *io, const char *cmd)
Definition: io.c:411
RZ_API int rz_io_fd_get_tid(RzIO *io, int fd)
Definition: io_fd.c:100
RZ_API int rz_io_fd_get_pid(RzIO *io, int fd)
Definition: io_fd.c:92
RZ_API void rz_io_desc_cache_fini_all(RzIO *io)
Definition: p_cache.c:362
int(* RzListComparator)(const void *value, const void *list_data)
Definition: rz_list.h:33
RZ_API void rz_log_set_file(const char *filename)
Definition: log.c:37
RZ_API void rz_log_set_level(RzLogLevel level)
Definition: log.c:29
RZ_API void rz_log_set_traplevel(RzLogLevel level)
Definition: log.c:33
#define RZ_DEFAULT_LOGLVL
Definition: rz_log.h:30
@ RZ_LOGLVL_FATAL
Definition: rz_log.h:23
RZ_API void rz_log_set_srcinfo(bool show_info)
Definition: log.c:42
RZ_API void rz_log_set_colors(bool show_colors)
Definition: log.c:46
RZ_API bool rz_name_filter(char *name, int len, bool strict)
Definition: name.c:43
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
Definition: unum.c:456
RZ_API RZ_OWN char * rz_path_home_config_rc(void)
Return the path of the rizinrc file in the home config directory.
Definition: path.c:226
RZ_API RZ_OWN char * rz_path_home_prefix(RZ_NULLABLE const char *path)
Return path prefixed by the home prefix.
Definition: path.c:182
RZ_API RZ_OWN char * rz_path_system(RZ_NULLABLE const char *path)
Return the full system path of the given subpath path.
Definition: path.c:162
RZ_API RZ_OWN char * rz_path_prefix(RZ_NULLABLE const char *path)
Return path prefixed by the Rizin install prefix.
Definition: path.c:121
RZ_API RZ_OWN char * rz_path_home_config_rcdir(void)
Return the home directory of config rizinrc.d.
Definition: path.c:233
RZ_API RZ_OWN char * rz_path_home_rc(void)
Return the path of the rizinrc file in the home directory.
Definition: path.c:219
RZ_API PJ * pj_ka(PJ *j, const char *k)
Definition: pj.c:163
RZ_API PJ * pj_kb(PJ *j, const char *k, bool v)
Definition: pj.c:177
RZ_API PJ * pj_end(PJ *j)
Definition: pj.c:87
RZ_API PJ * pj_o(PJ *j)
Definition: pj.c:75
RZ_API PJ * pj_s(PJ *j, const char *k)
Definition: pj.c:197
RZ_API PJ * pj_ks(PJ *j, const char *k, const char *v)
Definition: pj.c:170
RZ_API PJ * pj_kn(PJ *j, const char *k, ut64 n)
Definition: pj.c:121
RZ_API PJ * pj_a(PJ *j)
Definition: pj.c:81
#define RZ_PRINT_FLAGS_BGFILL
Definition: rz_print.h:35
#define RZ_PRINT_FLAGS_SECSUB
Definition: rz_print.h:28
#define RZ_PRINT_FLAGS_ADDRDEC
Definition: rz_print.h:24
#define RZ_PRINT_FLAGS_ALIGN
Definition: rz_print.h:33
#define RZ_PRINT_FLAGS_NONHEX
Definition: rz_print.h:27
#define RZ_PRINT_FLAGS_RAINBOW
Definition: rz_print.h:29
#define RZ_PRINT_FLAGS_HDROFF
Definition: rz_print.h:30
#define RZ_PRINT_FLAGS_COLOR
Definition: rz_print.h:15
#define RZ_PRINT_FLAGS_NONASCII
Definition: rz_print.h:32
#define RZ_PRINT_FLAGS_COMMENT
Definition: rz_print.h:25
#define RZ_PRINT_FLAGS_HEADER
Definition: rz_print.h:18
#define RZ_PRINT_FLAGS_SEGOFF
Definition: rz_print.h:20
#define RZ_PRINT_FLAGS_STYLE
Definition: rz_print.h:31
#define RZ_PRINT_FLAGS_SECTION
Definition: rz_print.h:36
#define RZ_PRINT_FLAGS_COMPACT
Definition: rz_print.h:26
#define RZ_PRINT_FLAGS_UNALLOC
Definition: rz_print.h:34
#define RZ_STR_ISNOTEMPTY(x)
Definition: rz_str.h:68
RZ_API bool rz_str_is_false(const char *s)
Definition: str.c:3904
RZ_API bool rz_str_cmp_list(const char *list, const char *item, char sep)
Definition: str.c:953
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API bool rz_str_is_true(const char *s)
Definition: str.c:3900
RZ_API RZ_OWN char * rz_str_escape(RZ_NONNULL const char *buf)
Definition: str.c:1550
RZ_API const char * rz_str_bool(int b)
Definition: str.c:3896
RZ_API void rz_str_case(char *str, bool up)
Definition: str.c:341
RZ_API RzList * rz_str_split_duplist(const char *str, const char *c, bool trim)
Split the string str according to the substring c and returns a RzList with the result.
Definition: str.c:3464
#define RZ_STR_ISEMPTY(x)
Definition: rz_str.h:67
RZ_API void rz_str_filter(char *str)
Convert all non-printable characters in str with '.'.
Definition: str.c:2359
RZ_API bool rz_str_isnumber(const char *str)
Definition: str.c:3550
RZ_API bool rz_str_is_bool(const char *val)
Definition: str.c:3908
RZ_API bool rz_str_startswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle)
Checks if a string starts with a specifc sequence of characters (case sensitive)
Definition: str.c:3286
RZ_API const char * rz_str_word_get0(const char *str, int idx)
Definition: str.c:598
RZ_API size_t rz_str_split(char *str, char ch)
Split string str in place by using ch as a delimiter.
Definition: str.c:406
RZ_API char * rz_sys_getenv(const char *key)
Get the value of an environment variable named key or NULL if none exists.
Definition: sys.c:483
RZ_API int rz_sys_setenv(const char *key, const char *value)
Set an environment variable in the calling process.
Definition: sys.c:405
RZ_API char * rz_sys_whoami(char *buf)
Definition: sys.c:1153
RZ_API bool rz_sys_getenv_asbool(const char *key)
Return true if the environment variable has the value 1, false otherwise.
Definition: sys.c:511
RZ_API RzList * rz_sys_dir(const char *path)
Definition: sys.c:216
#define RZ_THREAD_POOL_ALL_CORES
Definition: rz_th.h:19
#define PFMT64d
Definition: rz_types.h:394
#define RZ_PERM_R
Definition: rz_types.h:93
#define RZ_NULLABLE
Definition: rz_types.h:65
#define RZ_OWN
Definition: rz_types.h:62
#define RZ_SYS_BITS
Definition: rz_types.h:520
#define RZ_SYS_TMP
Definition: rz_types.h:221
#define RZ_NONNULL
Definition: rz_types.h:64
#define RZ_PERM_W
Definition: rz_types.h:94
#define RZ_SYS_HOME
Definition: rz_types.h:220
#define RZ_SYS_ARCH
Definition: rz_types.h:519
#define RZ_SYS_OS
Definition: rz_types.h:587
RzOutputMode
Enum to describe the way data are printed.
Definition: rz_types.h:38
@ RZ_OUTPUT_MODE_LONG
Definition: rz_types.h:44
@ RZ_OUTPUT_MODE_JSON
Definition: rz_types.h:40
@ RZ_OUTPUT_MODE_QUIET
Definition: rz_types.h:42
@ RZ_OUTPUT_MODE_LONG_JSON
Definition: rz_types.h:45
@ RZ_OUTPUT_MODE_RIZIN
Definition: rz_types.h:41
@ RZ_OUTPUT_MODE_STANDARD
Definition: rz_types.h:39
#define RZ_ARRAY_SIZE(x)
Definition: rz_types.h:300
#define RZ_FREE(x)
Definition: rz_types.h:369
#define RZ_MIN(x, y)
#define UT32_MAX
Definition: rz_types_base.h:99
#define RZ_MAX(x, y)
#define UT64_MAX
Definition: rz_types_base.h:86
#define RZ_PLUGINS
Definition: rz_userconf.h:72
#define RZ_SDB_ARCH_PLATFORMS
Definition: rz_userconf.h:81
#define RZ_SDB_ARCH_CPUS
Definition: rz_userconf.h:82
#define RZ_PROJECTS
Definition: rz_userconf.h:89
#define RZ_SDB_MAGIC
Definition: rz_userconf.h:86
#define RZ_PDB
Definition: rz_userconf.h:88
#define RZ_WWWROOT
Definition: rz_userconf.h:70
static int
Definition: sfsocketcall.h:114
#define b(i)
Definition: sha256.c:42
#define c(i)
Definition: sha256.c:43
#define a(i)
Definition: sha256.c:41
#define h(i)
Definition: sha256.c:48
Definition: gzappend.c:170
Definition: z80asm.h:102
const char * name
Definition: cconfig.c:887
const char * aliases
Definition: cconfig.c:888
Definition: names.h:123
Definition: getopt.h:84
Definition: rz_pj.h:12
RzAnalysis * analysis
Definition: rz_analysis.h:1043
bool(* cmd)(ANALYSIS_ESIL *esil, const char *name, ut64 a0, ut64 a1)
Definition: rz_analysis.h:1089
RzListComparator columnSort
Definition: rz_analysis.h:611
RzPlatformTarget * arch_target
Definition: rz_analysis.h:622
RzAnalysisCPPABI cpp_abi
Definition: rz_analysis.h:560
bool recursive_noreturn
Definition: rz_analysis.h:593
struct rz_analysis_plugin_t * cur
Definition: rz_analysis.h:586
struct rz_analysis_esil_t * esil
Definition: rz_analysis.h:584
RzSyscall * syscall
Definition: rz_analysis.h:570
RzPlatformTargetIndex * platform_target
Definition: rz_analysis.h:623
RzAnalysisOptions opt
Definition: rz_analysis.h:608
RzList * plugins
Definition: rz_analysis.h:588
RzTypeDB * typedb
Definition: rz_analysis.h:602
bool utf8
Definition: rz_asm.h:123
bool pseudo
Definition: rz_asm.h:126
int pcalign
Definition: rz_asm.h:118
int invhex
Definition: rz_asm.h:117
char * features
Definition: rz_asm.h:115
int bits
Definition: rz_asm.h:100
RzList * plugins
Definition: rz_asm.h:108
int seggrn
Definition: rz_asm.h:125
bool immdisp
Definition: rz_asm.h:122
char * platforms
Definition: rz_asm.h:116
_RzAsmPlugin * cur
Definition: rz_asm.h:106
XX curplugin == o->plugin.
Definition: rz_bin.h:298
RzBinObject * o
Definition: rz_bin.h:305
int filter
Definition: rz_bin.h:352
bool strseach_check_ascii_freq
Definition: rz_bin.h:361
int debase64
Definition: rz_bin.h:335
ut64 maxstrbuf
Definition: rz_bin.h:338
char * strpurge
Definition: rz_bin.h:354
ut64 filter_rules
Definition: rz_bin.h:358
char * srcdir
Definition: rz_bin.h:355
char * strenc
Definition: rz_bin.h:357
bool want_dbginfo
Definition: rz_bin.h:351
int maxstrlen
Definition: rz_bin.h:337
bool verbose
Definition: rz_bin.h:359
int is_debugger
Definition: rz_bin.h:350
char * prefix
Definition: rz_bin.h:356
bool use_xtr
Definition: rz_bin.h:360
const char * file
Definition: rz_bin.h:329
char strfilter
Definition: rz_bin.h:353
int minstrlen
Definition: rz_bin.h:336
bool bpinmaps
Definition: rz_bp.h:83
int endian
Definition: rz_bp.h:82
Represent the output state of a command handler.
Definition: rz_cmd.h:91
RzList * options
Definition: rz_config.h:47
RzNum * num
Definition: rz_config.h:55
RzList * nodes
Definition: rz_config.h:56
bool is_interactive
Definition: rz_cons.h:485
struct rz_line_t * line
Definition: rz_cons.h:553
int pagesize
Definition: rz_cons.h:563
const char * teefile
Definition: rz_cons.h:519
int echo
Definition: rz_cons.h:509
bool grep_highlight
Definition: rz_cons.h:568
bool show_autocomplete_widget
Definition: rz_cons.h:516
void * user_fgets_user
Definition: rz_cons.h:521
int null
Definition: rz_cons.h:550
bool grep_color
Definition: rz_cons.h:567
int linesleep
Definition: rz_cons.h:562
bool use_utf8_curvy
Definition: rz_cons.h:560
bool flush
Definition: rz_cons.h:558
RzConsContext * context
Definition: rz_cons.h:502
bool dotted_lines
Definition: rz_cons.h:561
bool is_html
Definition: rz_cons.h:505
RzVirtTermMode vtmode
Definition: rz_cons.h:557
int force_columns
Definition: rz_cons.h:512
int fix_columns
Definition: rz_cons.h:514
int force_rows
Definition: rz_cons.h:511
int rows
Definition: rz_cons.h:508
bool break_lines
Definition: rz_cons.h:515
int fix_rows
Definition: rz_cons.h:513
char * pager
Definition: rz_cons.h:546
int(* user_fgets)(char *buf, int len, void *user)
Definition: rz_cons.h:520
RzCons * cons
Definition: rz_core.h:312
bool scr_gadgets
Definition: rz_core.h:385
RzCoreVisualMode printidx
Definition: rz_core.h:357
int cmdrepeat
Definition: rz_core.h:341
RzSearch * search
Definition: rz_core.h:331
RzEgg * egg
Definition: rz_core.h:332
RzBin * bin
Definition: rz_core.h:298
RzAsm * rasm
Definition: rz_core.h:323
int max_cmd_depth
Definition: rz_core.h:363
RzAnalysis * analysis
Definition: rz_core.h:322
RzDebug * dbg
Definition: rz_core.h:329
RzIO * io
Definition: rz_core.h:313
const char * cmdtimes
Definition: rz_core.h:342
RzNum * num
Definition: rz_core.h:316
bool binat
Definition: rz_core.h:374
bool log_events
Definition: rz_core.h:386
RzParse * parser
Definition: rz_core.h:326
Sdb * sdb
Definition: rz_core.h:365
RzFlag * flags
Definition: rz_core.h:330
RzPrint * print
Definition: rz_core.h:327
RzCoreFile * file
Definition: rz_core.h:314
RzConfig * config
Definition: rz_core.h:300
bool verbose
Definition: rz_debug.h:319
int stop_all_threads
Definition: rz_debug.h:262
bool create_new_console
Definition: rz_debug.h:268
char * malloc
Definition: rz_debug.h:253
int trace_execs
Definition: rz_debug.h:264
bool consbreak
Definition: rz_debug.h:271
int regcols
Definition: rz_debug.h:260
int trace_clone
Definition: rz_debug.h:266
int follow_child
Definition: rz_debug.h:267
int swstep
Definition: rz_debug.h:261
char * glob_unlibs
Definition: rz_debug.h:270
int btdepth
Definition: rz_debug.h:259
RzDebugTrace * trace
Definition: rz_debug.h:281
char * glob_libs
Definition: rz_debug.h:269
char * btalgo
Definition: rz_debug.h:258
int trace_aftersyscall
Definition: rz_debug.h:265
bool trace_continue
Definition: rz_debug.h:309
int hitinfo
XXX: MUST SET ///.
Definition: rz_debug.h:244
int trace_forks
Definition: rz_debug.h:263
RzBreakpoint * bp
Definition: rz_debug.h:288
bool realnames
Definition: rz_flag.h:49
struct rz_io_plugin_t * plugin
Definition: rz_io.h:103
const char * name
Definition: rz_io.h:115
int ff
Definition: rz_io.h:64
bool cachemode
Definition: rz_io.h:70
int Oxff
Definition: rz_io.h:65
int autofd
Definition: rz_io.h:68
int cached
Definition: rz_io.h:69
int aslr
Definition: rz_io.h:67
char * args
Definition: rz_io.h:89
struct rz_io_desc_t * desc
Definition: rz_io.h:60
int p_cache
Definition: rz_io.h:71
int va
Definition: rz_io.h:63
size_t args_limit
Definition: rz_cons.h:1045
RzLineCompletion completion
Definition: rz_cons.h:1089
RzVirtTermMode vtmode
Definition: rz_cons.h:1122
bool prompt_mode
Definition: rz_cons.h:1115
int echo
Definition: rz_cons.h:1101
bool enable_vi_mode
Definition: rz_cons.h:1113
RzListFree free
Definition: rz_list.h:21
ut64 value
Definition: rz_num.h:63
RzList * parsers
Definition: rz_parse.h:35
bool subtail
Definition: rz_parse.h:27
int maxflagnamelen
Definition: rz_parse.h:30
int minval
Definition: rz_parse.h:31
int addrmod
Definition: rz_print.h:140
int big_endian
Definition: rz_print.h:124
const char * cfmt
Definition: rz_print.h:114
bool scr_prompt
Definition: rz_print.h:121
const char * strconv_mode
Definition: rz_print.h:163
int cols
Definition: rz_print.h:136
int datezone
Definition: rz_print.h:116
int flags
Definition: rz_print.h:137
RzPrintZoom * zoom
Definition: rz_print.h:146
int pairs
Definition: rz_print.h:144
bool esc_bslash
Definition: rz_print.h:161
char io_unalloc_ch
Definition: rz_print.h:165
bool histblock
Definition: rz_print.h:128
bool wide_offsets
Definition: rz_print.h:162
bool pava
Definition: rz_print.h:112
int bits
Definition: rz_print.h:127
int seggrn
Definition: rz_print.h:138
char datefmt[32]
Definition: rz_print.h:115
RzList * roregs
Definition: rz_reg.h:152
int contiguous
Definition: rz_search.h:69
Definition: dis.h:43
uint64_t streams
Definition: list.c:103
RZ_API bool rz_syscall_setup(RzSyscall *s, const char *arch, int bits, const char *cpu, const char *os)
Definition: syscall.c:234
#define bool
Definition: sysdefs.h:146
#define fail(test)
Definition: tests.h:29
RZ_API void rz_type_db_set_endian(RzTypeDB *typedb, bool big_endian)
Set the RzType target architecture CPU.
Definition: type.c:202
static int option
Definition: vmenus.c:2426
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING
Definition: tty.c:64
DWORD * HANDLE
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
DWORD
static int comma
Definition: z80asm.c:76
static int file
Definition: z80asm.c:58
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)