mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-01 00:51:19 +00:00
More reindent and use R_EMPTY instead of {0}
This commit is contained in:
parent
a93424a3db
commit
7db1a11d33
@ -43,7 +43,7 @@ static int valueInTextSection(RCore *core, ut64 curAddress) {
|
||||
}
|
||||
|
||||
static int isVtableStart(RCore *core, ut64 curAddress) {
|
||||
RAsmOp asmop = {0};
|
||||
RAsmOp asmop = R_EMPTY;
|
||||
RAnalRef *xref;
|
||||
RListIter *xrefIter;
|
||||
ut8 buf[VTABLE_BUFF_SIZE];
|
||||
|
@ -221,7 +221,7 @@ static void add_hit_to_hits(RList* hits, ut64 addr, int len, ut8 is_valid) {
|
||||
}
|
||||
|
||||
static int prune_hits_in_addr_range(RList *hits, ut64 addr, ut64 len, ut8 is_valid) {
|
||||
RCoreAsmHit hit = {0};
|
||||
RCoreAsmHit hit = R_EMPTY;
|
||||
hit.addr = addr;
|
||||
hit.len = len;
|
||||
hit.valid = is_valid;
|
||||
|
@ -1442,7 +1442,7 @@ R_API int r_core_anal_fcn_clean(RCore *core, ut64 addr) {
|
||||
#define FMT_GV 1
|
||||
#define FMT_JS 2
|
||||
R_API void r_core_anal_coderefs(RCore *core, ut64 addr, int fmt) {
|
||||
RAnalFunction fakefr = {0};
|
||||
RAnalFunction fakefr = R_EMPTY;
|
||||
const char *font = r_config_get (core->config, "graph.font");
|
||||
const char *format = r_config_get (core->config, "graph.format");
|
||||
int is_html = r_cons_singleton ()->is_html;
|
||||
@ -2416,7 +2416,7 @@ R_API int r_core_anal_search(RCore *core, ut64 from, ut64 to, ut64 ref) {
|
||||
ut8 *buf = (ut8 *)malloc (core->blocksize);
|
||||
int ptrdepth = r_config_get_i (core->config, "anal.ptrdepth");
|
||||
int ret, i, count = 0;
|
||||
RAnalOp op = {0};
|
||||
RAnalOp op = R_EMPTY;
|
||||
ut64 at;
|
||||
char bckwrds, do_bckwrd_srch;
|
||||
// TODO: get current section range here or gtfo
|
||||
@ -3362,7 +3362,7 @@ static void getpcfromstack(RCore *core, RAnalEsil *esil) {
|
||||
ut64 size;
|
||||
int idx;
|
||||
RAnalEsil esil_cpy;
|
||||
RAnalOp op = {0};
|
||||
RAnalOp op = R_EMPTY;
|
||||
RAnalFunction *fcn = NULL;
|
||||
ut8 *buf = NULL;
|
||||
char *tmp_esil_str = NULL;
|
||||
@ -3472,7 +3472,7 @@ R_API void r_core_anal_esil(RCore *core, const char *str, const char *target) {
|
||||
#if 0
|
||||
RAsmOp asmop;
|
||||
#endif
|
||||
RAnalOp op = {0};
|
||||
RAnalOp op = R_EMPTY;
|
||||
ut8 *buf = NULL;
|
||||
bool end_address_set = false;
|
||||
int i, iend;
|
||||
|
@ -888,7 +888,7 @@ static int bin_dwarf(RCore *core, int mode) {
|
||||
}
|
||||
|
||||
static int bin_pdb(RCore *core, int mode) {
|
||||
R_PDB pdb = {0};
|
||||
R_PDB pdb = R_EMPTY;
|
||||
ut64 baddr = r_bin_get_baddr (core->bin);
|
||||
|
||||
pdb.cb_printf = r_cons_printf;
|
||||
@ -2444,12 +2444,12 @@ static void bin_pe_versioninfo(RCore *r) {
|
||||
const char *format_string = "%s/string%d";
|
||||
r_cons_printf ("=== VS_VERSIONINFO ===\n\n");
|
||||
do {
|
||||
char path_version[256] = {0};
|
||||
char path_version[256] = R_EMPTY;
|
||||
snprintf (path_version, sizeof (path_version), format_version, num_version);
|
||||
if (!(sdb = sdb_ns_path (r->sdb, path_version, 0)))
|
||||
break;
|
||||
r_cons_printf ("# VS_FIXEDFILEINFO\n\n");
|
||||
char path_fixedfileinfo[256] = {0};
|
||||
char path_fixedfileinfo[256] = R_EMPTY;
|
||||
snprintf (path_fixedfileinfo, sizeof (path_fixedfileinfo), "%s/fixed_file_info", path_version);
|
||||
if (!(sdb = sdb_ns_path (r->sdb, path_fixedfileinfo, 0)))
|
||||
break;
|
||||
@ -2481,11 +2481,11 @@ static void bin_pe_versioninfo(RCore *r) {
|
||||
r_cons_newline ();
|
||||
r_cons_println ("# StringTable\n");
|
||||
for (num_stringtable = 0; sdb; ++num_stringtable) {
|
||||
char path_stringtable[256] = {0};
|
||||
char path_stringtable[256] = R_EMPTY;
|
||||
snprintf (path_stringtable, sizeof (path_stringtable), format_stringtable, path_version, num_stringtable);
|
||||
sdb = sdb_ns_path (r->sdb, path_stringtable, 0);
|
||||
for (num_string = 0; sdb; ++num_string) {
|
||||
char path_string[256] = {0};
|
||||
char path_string[256] = R_EMPTY;
|
||||
snprintf (path_string, sizeof (path_string), format_string, path_stringtable, num_string);
|
||||
sdb = sdb_ns_path (r->sdb, path_string, 0);
|
||||
if (sdb) {
|
||||
@ -2516,7 +2516,7 @@ static void bin_pe_versioninfo(RCore *r) {
|
||||
|
||||
static void bin_elf_versioninfo(RCore *r) {
|
||||
const char *format = "bin/cur/info/versioninfo/%s%d";
|
||||
char path[256] = {0};
|
||||
char path[256] = R_EMPTY;
|
||||
int num_versym = 0;
|
||||
int num_verneed = 0;
|
||||
int num_entry = 0;
|
||||
@ -2539,7 +2539,7 @@ static void bin_elf_versioninfo(RCore *r) {
|
||||
|
||||
do {
|
||||
int num_val = 0;
|
||||
char path_entry[256] = {0};
|
||||
char path_entry[256] = R_EMPTY;
|
||||
snprintf (path_entry, sizeof (path_entry), "%s/entry%d", path, num_entry++);
|
||||
if (!(sdb = sdb_ns_path (r->sdb, path_entry, 0)))
|
||||
break;
|
||||
@ -2548,7 +2548,7 @@ static void bin_elf_versioninfo(RCore *r) {
|
||||
const char *value = NULL;
|
||||
|
||||
do {
|
||||
char key[32] = {0};
|
||||
char key[32] = R_EMPTY;
|
||||
snprintf (key, sizeof (key), "value%d", num_val++);
|
||||
|
||||
if ((value = sdb_const_get (sdb, key, 0)))
|
||||
@ -2561,7 +2561,7 @@ static void bin_elf_versioninfo(RCore *r) {
|
||||
|
||||
do {
|
||||
int num_version = 0;
|
||||
char path_version[256] = {0};
|
||||
char path_version[256] = R_EMPTY;
|
||||
snprintf (path, sizeof (path), format, "verneed", num_verneed++);
|
||||
if (!(sdb = sdb_ns_path (r->sdb, path, 0)))
|
||||
break;
|
||||
@ -2578,7 +2578,7 @@ static void bin_elf_versioninfo(RCore *r) {
|
||||
do {
|
||||
snprintf (path_version, sizeof (path_version), "%s/version%d", path, num_version++);
|
||||
const char *filename = NULL;
|
||||
char path_vernaux[256] = {0};
|
||||
char path_vernaux[256] = R_EMPTY;
|
||||
int num_vernaux = 0;
|
||||
if (!(sdb = sdb_ns_path (r->sdb, path_version, 0)))
|
||||
break;
|
||||
|
@ -2797,7 +2797,7 @@ static bool cmd_aea(RCore* core, int mode, ut64 addr, int length) {
|
||||
ut64 addr_end;
|
||||
AeaStats stats;
|
||||
const char *esilstr;
|
||||
RAnalOp aop = {0};
|
||||
RAnalOp aop = R_EMPTY;
|
||||
ut8 *buf;
|
||||
RList* regnow;
|
||||
if (!core)
|
||||
@ -3284,7 +3284,7 @@ static void cmd_anal_esil(RCore *core, const char *input) {
|
||||
r_core_set_asm_configs (core, new_arch, new_bits, segoff);
|
||||
}
|
||||
int ret, bufsz;
|
||||
RAnalOp aop = {0};
|
||||
RAnalOp aop = R_EMPTY;
|
||||
bufsz = r_hex_str2bin (hex, (ut8*)hex);
|
||||
ret = r_anal_op (core->anal, &aop, core->offset,
|
||||
(const ut8*)hex, bufsz);
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "r_core.h"
|
||||
|
||||
static void showhelp(RCore *core) {
|
||||
const char* help_msg[] = {
|
||||
const char *help_msg[] = {
|
||||
"Usage:", "c[?dfx] [argument]", " # Compare",
|
||||
"c", " [string]", "Compare a plain with escaped chars string",
|
||||
"c*", " [string]", "Compare a plain with escaped chars string (output r2 commands)",
|
||||
@ -13,10 +13,10 @@ static void showhelp(RCore *core) {
|
||||
"cc", " [at] [(at)]", "Compares in two hexdump columns of block size",
|
||||
"ccc", " [at] [(at)]", "Same as above, but only showing different lines",
|
||||
"ccd", " [at] [(at)]", "Compares in two disasm columns of block size",
|
||||
//"cc", " [offset]", "code bindiff current block against offset"
|
||||
//"cD", " [file]", "like above, but using radiff -b",
|
||||
// "cc", " [offset]", "code bindiff current block against offset"
|
||||
// "cD", " [file]", "like above, but using radiff -b",
|
||||
"cf", " [file]", "Compare contents of file at current seek",
|
||||
"cg", "[?] [o] [file]","Graphdiff current file and [file]",
|
||||
"cg", "[?] [o] [file]", "Graphdiff current file and [file]",
|
||||
"cl|cls|clear", "", "Clear screen, (clear0 to goto 0, 0 only)",
|
||||
"cu", "[?] [addr] @at", "Compare memory hexdumps of $$ and dst in unified diff",
|
||||
"cud", " [addr] @at", "Unified diff disasm from $$ and given address",
|
||||
@ -29,30 +29,34 @@ static void showhelp(RCore *core) {
|
||||
};
|
||||
r_core_cmd_help (core, help_msg);
|
||||
}
|
||||
R_API void r_core_cmpwatch_free (RCoreCmpWatcher *w) {
|
||||
R_API void r_core_cmpwatch_free(RCoreCmpWatcher *w) {
|
||||
free (w->ndata);
|
||||
free (w->odata);
|
||||
free (w);
|
||||
}
|
||||
|
||||
R_API RCoreCmpWatcher* r_core_cmpwatch_get(RCore *core, ut64 addr) {
|
||||
R_API RCoreCmpWatcher *r_core_cmpwatch_get(RCore *core, ut64 addr) {
|
||||
RListIter *iter;
|
||||
RCoreCmpWatcher *w;
|
||||
r_list_foreach (core->watchers, iter, w) {
|
||||
if (addr == w->addr)
|
||||
if (addr == w->addr) {
|
||||
return w;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
R_API int r_core_cmpwatch_add (RCore *core, ut64 addr, int size, const char *cmd) {
|
||||
R_API int r_core_cmpwatch_add(RCore *core, ut64 addr, int size, const char *cmd) {
|
||||
RCoreCmpWatcher *cmpw;
|
||||
if (size<1) return false;
|
||||
if (size < 1) {
|
||||
return false;
|
||||
}
|
||||
cmpw = r_core_cmpwatch_get (core, addr);
|
||||
if (!cmpw) {
|
||||
cmpw = R_NEW (RCoreCmpWatcher);
|
||||
if (!cmpw)
|
||||
if (!cmpw) {
|
||||
return false;
|
||||
}
|
||||
cmpw->addr = addr;
|
||||
}
|
||||
cmpw->size = size;
|
||||
@ -68,7 +72,7 @@ R_API int r_core_cmpwatch_add (RCore *core, ut64 addr, int size, const char *cmd
|
||||
return true;
|
||||
}
|
||||
|
||||
R_API int r_core_cmpwatch_del (RCore *core, ut64 addr) {
|
||||
R_API int r_core_cmpwatch_del(RCore *core, ut64 addr) {
|
||||
int ret = false;
|
||||
RCoreCmpWatcher *w;
|
||||
RListIter *iter, *iter2;
|
||||
@ -81,7 +85,7 @@ R_API int r_core_cmpwatch_del (RCore *core, ut64 addr) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
R_API int r_core_cmpwatch_show (RCore *core, ut64 addr, int mode) {
|
||||
R_API int r_core_cmpwatch_show(RCore *core, ut64 addr, int mode) {
|
||||
char cmd[128];
|
||||
RListIter *iter;
|
||||
RCoreCmpWatcher *w;
|
||||
@ -89,17 +93,18 @@ R_API int r_core_cmpwatch_show (RCore *core, ut64 addr, int mode) {
|
||||
int is_diff = w->odata? memcmp (w->odata, w->ndata, w->size): 0;
|
||||
switch (mode) {
|
||||
case '*':
|
||||
r_cons_printf ("cw 0x%08"PFMT64x" %d %s%s\n",
|
||||
w->addr, w->size, w->cmd, is_diff? " # differs":"");
|
||||
r_cons_printf ("cw 0x%08"PFMT64x " %d %s%s\n",
|
||||
w->addr, w->size, w->cmd, is_diff? " # differs": "");
|
||||
break;
|
||||
case 'd': // diff
|
||||
if (is_diff)
|
||||
r_cons_printf ("0x%08"PFMT64x" has changed\n", w->addr);
|
||||
if (is_diff) {
|
||||
r_cons_printf ("0x%08"PFMT64x " has changed\n", w->addr);
|
||||
}
|
||||
case 'o': // old contents
|
||||
// use tmpblocksize
|
||||
// use tmpblocksize
|
||||
default:
|
||||
r_cons_printf ("0x%08"PFMT64x"%s\n", w->addr, is_diff? " modified":"");
|
||||
snprintf (cmd, sizeof (cmd), "%s@%"PFMT64d"!%d",
|
||||
r_cons_printf ("0x%08"PFMT64x "%s\n", w->addr, is_diff? " modified": "");
|
||||
snprintf (cmd, sizeof (cmd), "%s@%"PFMT64d "!%d",
|
||||
w->cmd, w->addr, w->size);
|
||||
r_core_cmd0 (core, cmd);
|
||||
break;
|
||||
@ -108,21 +113,22 @@ R_API int r_core_cmpwatch_show (RCore *core, ut64 addr, int mode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
R_API int r_core_cmpwatch_update (RCore *core, ut64 addr) {
|
||||
R_API int r_core_cmpwatch_update(RCore *core, ut64 addr) {
|
||||
RCoreCmpWatcher *w;
|
||||
RListIter *iter;
|
||||
r_list_foreach (core->watchers, iter, w) {
|
||||
free (w->odata);
|
||||
w->odata = w->ndata;
|
||||
w->ndata = malloc (w->size);
|
||||
if (!w->ndata)
|
||||
if (!w->ndata) {
|
||||
return false;
|
||||
}
|
||||
r_io_read_at (core->io, w->addr, w->ndata, w->size);
|
||||
}
|
||||
return !r_list_empty (core->watchers);
|
||||
}
|
||||
|
||||
R_API int r_core_cmpwatch_revert (RCore *core, ut64 addr) {
|
||||
R_API int r_core_cmpwatch_revert(RCore *core, ut64 addr) {
|
||||
RCoreCmpWatcher *w;
|
||||
int ret = false;
|
||||
RListIter *iter;
|
||||
@ -142,11 +148,13 @@ R_API int r_core_cmpwatch_revert (RCore *core, ut64 addr) {
|
||||
static int radare_compare_unified(RCore *core, ut64 of, ut64 od, int len) {
|
||||
int i, min, inc = 16;
|
||||
ut8 *f, *d;
|
||||
if (len<1)
|
||||
if (len < 1) {
|
||||
return false;
|
||||
}
|
||||
f = malloc (len);
|
||||
if (!f)
|
||||
if (!f) {
|
||||
return false;
|
||||
}
|
||||
d = malloc (len);
|
||||
if (!d) {
|
||||
free (f);
|
||||
@ -155,62 +163,66 @@ static int radare_compare_unified(RCore *core, ut64 of, ut64 od, int len) {
|
||||
r_io_read_at (core->io, of, f, len);
|
||||
r_io_read_at (core->io, od, d, len);
|
||||
int headers = B_IS_SET (core->print->flags, R_PRINT_FLAGS_HEADER);
|
||||
if (headers)
|
||||
if (headers) {
|
||||
B_UNSET (core->print->flags, R_PRINT_FLAGS_HEADER);
|
||||
for (i=0; i<len; i+=inc) {
|
||||
min = R_MIN (16, (len-i));
|
||||
if (!memcmp (f+i, d+i, min)) {
|
||||
}
|
||||
for (i = 0; i < len; i += inc) {
|
||||
min = R_MIN (16, (len - i));
|
||||
if (!memcmp (f + i, d + i, min)) {
|
||||
r_cons_printf (" ");
|
||||
r_print_hexdiff (core->print, of+i, f+i, of+i, f+i, min, 0);
|
||||
r_print_hexdiff (core->print, of + i, f + i, of + i, f + i, min, 0);
|
||||
} else {
|
||||
r_cons_printf ("- ");
|
||||
r_print_hexdiff (core->print, of+i, f+i, od+i, d+i, min, 0);
|
||||
r_print_hexdiff (core->print, of + i, f + i, od + i, d + i, min, 0);
|
||||
r_cons_printf ("+ ");
|
||||
r_print_hexdiff (core->print, od+i, d+i, of+i, f+i, min, 0);
|
||||
r_print_hexdiff (core->print, od + i, d + i, of + i, f + i, min, 0);
|
||||
}
|
||||
}
|
||||
if (headers)
|
||||
if (headers) {
|
||||
B_SET (core->print->flags, R_PRINT_FLAGS_HEADER);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static int radare_compare(RCore *core, const ut8 *f, const ut8 *d, int len, int mode) {
|
||||
int i, eq = 0;
|
||||
if (len < 1)
|
||||
if (len < 1) {
|
||||
return 0;
|
||||
for (i=0; i<len; i++) {
|
||||
if (f[i]==d[i]) {
|
||||
}
|
||||
for (i = 0; i < len; i++) {
|
||||
if (f[i] == d[i]) {
|
||||
eq++;
|
||||
continue;
|
||||
}
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
r_cons_printf ("0x%08"PFMT64x" (byte=%.2d) %02x '%c' -> %02x '%c'\n",
|
||||
core->offset+i, i+1,
|
||||
f[i], (IS_PRINTABLE(f[i]))?f[i]:' ',
|
||||
d[i], (IS_PRINTABLE(d[i]))?d[i]:' ');
|
||||
break;
|
||||
case '*':
|
||||
r_cons_printf ("wx %02x @ 0x%08"PFMT64x"\n",
|
||||
d[i],
|
||||
core->offset+i);
|
||||
break;
|
||||
case 0:
|
||||
r_cons_printf ("0x%08"PFMT64x " (byte=%.2d) %02x '%c' -> %02x '%c'\n",
|
||||
core->offset + i, i + 1,
|
||||
f[i], (IS_PRINTABLE (f[i]))? f[i]: ' ',
|
||||
d[i], (IS_PRINTABLE (d[i]))? d[i]: ' ');
|
||||
break;
|
||||
case '*':
|
||||
r_cons_printf ("wx %02x @ 0x%08"PFMT64x "\n",
|
||||
d[i],
|
||||
core->offset + i);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
if (mode == 0)
|
||||
if (mode == 0) {
|
||||
eprintf ("Compare %d/%d equal bytes (%d%%)\n", eq, len, (eq / len) * 100);
|
||||
return len-eq;
|
||||
}
|
||||
return len - eq;
|
||||
}
|
||||
|
||||
static void cmd_cmp_watcher (RCore *core, const char *input) {
|
||||
static void cmd_cmp_watcher(RCore *core, const char *input) {
|
||||
char *p, *q, *r = NULL;
|
||||
int size = 0;
|
||||
ut64 addr = 0;
|
||||
switch (*input) {
|
||||
case ' ':
|
||||
p = strdup (input+1);
|
||||
p = strdup (input + 1);
|
||||
q = strchr (p, ' ');
|
||||
if (q) {
|
||||
*q++ = 0;
|
||||
@ -221,16 +233,18 @@ static void cmd_cmp_watcher (RCore *core, const char *input) {
|
||||
size = atoi (q);
|
||||
}
|
||||
r_core_cmpwatch_add (core, addr, size, r);
|
||||
//eprintf ("ADD (%llx) %d (%s)\n", addr, size, r);
|
||||
} else eprintf ("Missing parameters\n");
|
||||
// eprintf ("ADD (%llx) %d (%s)\n", addr, size, r);
|
||||
} else {
|
||||
eprintf ("Missing parameters\n");
|
||||
}
|
||||
free (p);
|
||||
break;
|
||||
case 'r':
|
||||
addr = input[1]? r_num_math (core->num, input+1): UT64_MAX;
|
||||
addr = input[1]? r_num_math (core->num, input + 1): UT64_MAX;
|
||||
r_core_cmpwatch_revert (core, addr);
|
||||
break;
|
||||
case 'u':
|
||||
addr = input[1]? r_num_math (core->num, input+1): UT64_MAX;
|
||||
addr = input[1]? r_num_math (core->num, input + 1): UT64_MAX;
|
||||
r_core_cmpwatch_update (core, addr);
|
||||
break;
|
||||
case '*':
|
||||
@ -240,20 +254,20 @@ static void cmd_cmp_watcher (RCore *core, const char *input) {
|
||||
r_core_cmpwatch_show (core, UT64_MAX, 0);
|
||||
break;
|
||||
case '?': {
|
||||
const char * help_message[] = {
|
||||
"Usage: cw", "", "Watcher commands",
|
||||
"cw", "", "List all compare watchers",
|
||||
"cw", " addr", "List all compare watchers",
|
||||
"cw", " addr sz cmd", "Add a memory watcher",
|
||||
//"cws", " [addr]", "Show watchers",
|
||||
"cw", "*", "List compare watchers in r2 cmds",
|
||||
"cwr", " [addr]", "Reset/revert watchers",
|
||||
"cwu", " [addr]", "Update watchers",
|
||||
NULL
|
||||
};
|
||||
r_core_cmd_help(core, help_message);
|
||||
}
|
||||
break;
|
||||
const char *help_message[] = {
|
||||
"Usage: cw", "", "Watcher commands",
|
||||
"cw", "", "List all compare watchers",
|
||||
"cw", " addr", "List all compare watchers",
|
||||
"cw", " addr sz cmd", "Add a memory watcher",
|
||||
// "cws", " [addr]", "Show watchers",
|
||||
"cw", "*", "List compare watchers in r2 cmds",
|
||||
"cwr", " [addr]", "Reset/revert watchers",
|
||||
"cwu", " [addr]", "Update watchers",
|
||||
NULL
|
||||
};
|
||||
r_core_cmd_help (core, help_message);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -264,74 +278,83 @@ static int cmd_cmp_disasm(RCore *core, const char *input, int mode) {
|
||||
int hascolor = r_config_get_i (core->config, "scr.color");
|
||||
int cols = r_config_get_i (core->config, "hex.cols") * 2;
|
||||
ut64 off = r_num_math (core->num, input);
|
||||
ut8 *buf = calloc (core->blocksize+32, 1);
|
||||
if (!buf) return false;
|
||||
r_core_read_at (core, off, buf, core->blocksize+32);
|
||||
ut8 *buf = calloc (core->blocksize + 32, 1);
|
||||
if (!buf) {
|
||||
return false;
|
||||
}
|
||||
r_core_read_at (core, off, buf, core->blocksize + 32);
|
||||
switch (mode) {
|
||||
case 'c': // columns
|
||||
for (i=j=0; i<core->blocksize && j<core->blocksize; ) {
|
||||
for (i = j = 0; i < core->blocksize && j < core->blocksize;) {
|
||||
// dis A
|
||||
r_asm_set_pc (core->assembler, core->offset+i);
|
||||
(void)r_asm_disassemble (core->assembler, &op,
|
||||
core->block+i, core->blocksize-i);
|
||||
r_asm_set_pc (core->assembler, core->offset + i);
|
||||
(void) r_asm_disassemble (core->assembler, &op,
|
||||
core->block + i, core->blocksize - i);
|
||||
|
||||
// dis B
|
||||
r_asm_set_pc (core->assembler, off+i);
|
||||
(void)r_asm_disassemble (core->assembler, &op2,
|
||||
buf+j, core->blocksize-j);
|
||||
r_asm_set_pc (core->assembler, off + i);
|
||||
(void) r_asm_disassemble (core->assembler, &op2,
|
||||
buf + j, core->blocksize - j);
|
||||
|
||||
// show output
|
||||
iseq = (!strcmp (op.buf_asm, op2.buf_asm));
|
||||
memset (colpad, ' ', sizeof(colpad));
|
||||
{
|
||||
int pos = strlen (op.buf_asm);
|
||||
pos = (pos>cols)? 0: cols-pos;
|
||||
colpad[pos] = 0;
|
||||
int pos = strlen (op.buf_asm);
|
||||
pos = (pos > cols)? 0: cols - pos;
|
||||
colpad[pos] = 0;
|
||||
}
|
||||
if (hascolor) {
|
||||
r_cons_printf (iseq?Color_GREEN:Color_RED);
|
||||
r_cons_printf (iseq? Color_GREEN: Color_RED);
|
||||
}
|
||||
r_cons_printf (" 0x%08"PFMT64x" %s %s",
|
||||
core->offset +i, op.buf_asm, colpad);
|
||||
r_cons_printf ("%c 0x%08"PFMT64x" %s\n",
|
||||
iseq?'=':'!', off+j, op2.buf_asm);
|
||||
r_cons_printf (" 0x%08"PFMT64x " %s %s",
|
||||
core->offset + i, op.buf_asm, colpad);
|
||||
r_cons_printf ("%c 0x%08"PFMT64x " %s\n",
|
||||
iseq? '=': '!', off + j, op2.buf_asm);
|
||||
if (hascolor) {
|
||||
r_cons_printf (Color_RESET);
|
||||
}
|
||||
if (op.size<1) op.size =1;
|
||||
i+= op.size;
|
||||
if (op2.size<1) op2.size =1;
|
||||
j+= op2.size;
|
||||
if (op.size < 1) {
|
||||
op.size = 1;
|
||||
}
|
||||
i += op.size;
|
||||
if (op2.size < 1) {
|
||||
op2.size = 1;
|
||||
}
|
||||
j += op2.size;
|
||||
}
|
||||
break;
|
||||
case 'u': // unified
|
||||
for (i=j=0; i< core->blocksize && j<core->blocksize; ) {
|
||||
for (i = j = 0; i < core->blocksize && j < core->blocksize;) {
|
||||
// dis A
|
||||
r_asm_set_pc (core->assembler, core->offset+i);
|
||||
(void)r_asm_disassemble (core->assembler, &op,
|
||||
core->block+i, core->blocksize-i);
|
||||
r_asm_set_pc (core->assembler, core->offset + i);
|
||||
(void) r_asm_disassemble (core->assembler, &op,
|
||||
core->block + i, core->blocksize - i);
|
||||
|
||||
// dis B
|
||||
r_asm_set_pc (core->assembler, off+i);
|
||||
(void)r_asm_disassemble (core->assembler, &op2,
|
||||
buf+j, core->blocksize-j);
|
||||
r_asm_set_pc (core->assembler, off + i);
|
||||
(void) r_asm_disassemble (core->assembler, &op2,
|
||||
buf + j, core->blocksize - j);
|
||||
|
||||
// show output
|
||||
iseq = (!strcmp (op.buf_asm, op2.buf_asm));
|
||||
if (iseq) {
|
||||
r_cons_printf (" 0x%08"PFMT64x" %s\n",
|
||||
core->offset +i, op.buf_asm);
|
||||
r_cons_printf (" 0x%08"PFMT64x " %s\n",
|
||||
core->offset + i, op.buf_asm);
|
||||
} else {
|
||||
if (hascolor)
|
||||
if (hascolor) {
|
||||
r_cons_printf (Color_RED);
|
||||
r_cons_printf ("-0x%08"PFMT64x" %s\n",
|
||||
core->offset +i, op.buf_asm);
|
||||
if (hascolor)
|
||||
}
|
||||
r_cons_printf ("-0x%08"PFMT64x " %s\n",
|
||||
core->offset + i, op.buf_asm);
|
||||
if (hascolor) {
|
||||
r_cons_printf (Color_GREEN);
|
||||
r_cons_printf ("+0x%08"PFMT64x" %s\n",
|
||||
off+j, op2.buf_asm);
|
||||
if (hascolor)
|
||||
}
|
||||
r_cons_printf ("+0x%08"PFMT64x " %s\n",
|
||||
off + j, op2.buf_asm);
|
||||
if (hascolor) {
|
||||
r_cons_printf (Color_RESET);
|
||||
}
|
||||
}
|
||||
if (op.size < 1) {
|
||||
op.size = 1;
|
||||
@ -371,7 +394,7 @@ static int cmd_cmp(void *data, const char *input) {
|
||||
int ret = 0, i, mode = 0;
|
||||
RCore *core = data;
|
||||
ut64 val = UT64_MAX;
|
||||
char * filled;
|
||||
char *filled;
|
||||
ut8 *buf;
|
||||
ut16 v16;
|
||||
ut32 v32;
|
||||
@ -391,24 +414,24 @@ static int cmd_cmp(void *data, const char *input) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'w': cmd_cmp_watcher (core, input+1); break;
|
||||
case 'w': cmd_cmp_watcher (core, input + 1); break;
|
||||
case '*':
|
||||
if (!input[2]) {
|
||||
eprintf ("Usage: cx* 00..22'\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
val = radare_compare (core, core->block, (ut8*)input + 2,
|
||||
val = radare_compare (core, core->block, (ut8 *) input + 2,
|
||||
strlen (input + 2) + 1, '*');
|
||||
break;
|
||||
case ' ':
|
||||
{
|
||||
char *str = strdup (input + 1);
|
||||
int len = r_str_unescape (str);
|
||||
val = radare_compare (core, core->block, (ut8*)str, len, 0);
|
||||
free (str);
|
||||
}
|
||||
break;
|
||||
{
|
||||
char *str = strdup (input + 1);
|
||||
int len = r_str_unescape (str);
|
||||
val = radare_compare (core, core->block, (ut8 *) str, len, 0);
|
||||
free (str);
|
||||
}
|
||||
break;
|
||||
case 'x':
|
||||
switch (input[1]) {
|
||||
case ' ':
|
||||
@ -427,15 +450,15 @@ static int cmd_cmp(void *data, const char *input) {
|
||||
eprintf ("Usage: cx 00..22'\n");
|
||||
return 0;
|
||||
}
|
||||
if (!(filled = (char*) malloc (strlen (input) + 1))) {
|
||||
if (!(filled = (char *) malloc (strlen (input) + 1))) {
|
||||
return false;
|
||||
}
|
||||
memcpy (filled, input, strlen (input) + 1);
|
||||
if (!(buf = (ut8*)malloc (strlen (input) + 1))) {
|
||||
if (!(buf = (ut8 *) malloc (strlen (input) + 1))) {
|
||||
free (filled);
|
||||
return false;
|
||||
}
|
||||
ret = r_hex_bin2str (core->block, strlen (input) / 2, (char *)buf);
|
||||
ret = r_hex_bin2str (core->block, strlen (input) / 2, (char *) buf);
|
||||
for (i = 0; i < ret * 2; i++) {
|
||||
if (filled[i] == '.') {
|
||||
filled[i] = buf[i];
|
||||
@ -455,7 +478,7 @@ static int cmd_cmp(void *data, const char *input) {
|
||||
buf = malloc (core->blocksize);
|
||||
if (buf) {
|
||||
if (!r_io_read_at (core->io, r_num_math (core->num,
|
||||
input + 1), buf, core->blocksize)) {
|
||||
input + 1), buf, core->blocksize)) {
|
||||
eprintf ("Cannot read hexdump\n");
|
||||
} else {
|
||||
val = radare_compare (core, core->block, buf, ret, mode);
|
||||
@ -465,21 +488,23 @@ static int cmd_cmp(void *data, const char *input) {
|
||||
return false;
|
||||
break;
|
||||
case 'f':
|
||||
if (input[1]!=' ') {
|
||||
if (input[1] != ' ') {
|
||||
eprintf ("Please. use 'cf [file]'\n");
|
||||
return false;
|
||||
}
|
||||
fd = r_sandbox_fopen (input+2, "rb");
|
||||
fd = r_sandbox_fopen (input + 2, "rb");
|
||||
if (!fd) {
|
||||
eprintf ("Cannot open file '%s'\n", input+2);
|
||||
eprintf ("Cannot open file '%s'\n", input + 2);
|
||||
return false;
|
||||
}
|
||||
buf = (ut8 *)malloc (core->blocksize);
|
||||
buf = (ut8 *) malloc (core->blocksize);
|
||||
if (buf) {
|
||||
if (fread (buf, 1, core->blocksize, fd) <1) {
|
||||
if (fread (buf, 1, core->blocksize, fd) < 1) {
|
||||
eprintf ("Cannot read file %s\n", input + 2);
|
||||
} else val = radare_compare (core, core->block,
|
||||
buf, core->blocksize, 0);
|
||||
} else {
|
||||
val = radare_compare (core, core->block,
|
||||
buf, core->blocksize, 0);
|
||||
}
|
||||
fclose (fd);
|
||||
free (buf);
|
||||
} else {
|
||||
@ -488,13 +513,13 @@ static int cmd_cmp(void *data, const char *input) {
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
while (input[1]==' ') input++;
|
||||
while (input[1] == ' ') input++;
|
||||
if (input[1]) {
|
||||
if (!strcmp (input+1, "-")) {
|
||||
if (!strcmp (input + 1, "-")) {
|
||||
if (oldcwd) {
|
||||
char *newdir = oldcwd;
|
||||
oldcwd = r_sys_getdir ();
|
||||
if (r_sandbox_chdir (newdir)==-1) {
|
||||
if (r_sandbox_chdir (newdir) == -1) {
|
||||
eprintf ("Cannot chdir to %s\n", newdir);
|
||||
free (oldcwd);
|
||||
oldcwd = newdir;
|
||||
@ -504,26 +529,29 @@ static int cmd_cmp(void *data, const char *input) {
|
||||
} else {
|
||||
// nothing to do here
|
||||
}
|
||||
} else if (input[1]=='~' && input[2]=='/') {
|
||||
char *homepath = r_str_home (input+3);
|
||||
} else if (input[1] == '~' && input[2] == '/') {
|
||||
char *homepath = r_str_home (input + 3);
|
||||
if (homepath) {
|
||||
if (*homepath) {
|
||||
free (oldcwd);
|
||||
oldcwd = r_sys_getdir ();
|
||||
if (r_sandbox_chdir (homepath)==-1)
|
||||
if (r_sandbox_chdir (homepath) == -1) {
|
||||
eprintf ("Cannot chdir to %s\n", homepath);
|
||||
}
|
||||
}
|
||||
free (homepath);
|
||||
} else eprintf ("Cannot find home\n");
|
||||
} else {
|
||||
eprintf ("Cannot find home\n");
|
||||
}
|
||||
} else {
|
||||
free (oldcwd);
|
||||
oldcwd = r_sys_getdir ();
|
||||
if (r_sandbox_chdir (input+1)==-1) {
|
||||
eprintf ("Cannot chdir to %s\n", input+1);
|
||||
if (r_sandbox_chdir (input + 1) == -1) {
|
||||
eprintf ("Cannot chdir to %s\n", input + 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
char* home = r_sys_getenv (R_SYS_HOME);
|
||||
char *home = r_sys_getenv (R_SYS_HOME);
|
||||
if (!home || r_sandbox_chdir (home) == -1) {
|
||||
eprintf ("Cannot find home.\n");
|
||||
}
|
||||
@ -531,134 +559,137 @@ static int cmd_cmp(void *data, const char *input) {
|
||||
}
|
||||
break;
|
||||
case '2':
|
||||
v16 = (ut16) r_num_math (core->num, input+1);
|
||||
val = radare_compare (core, core->block, (ut8*)&v16, sizeof (v16), 0);
|
||||
v16 = (ut16) r_num_math (core->num, input + 1);
|
||||
val = radare_compare (core, core->block, (ut8 *) &v16, sizeof (v16), 0);
|
||||
break;
|
||||
case '4':
|
||||
v32 = (ut32) r_num_math (core->num, input+1);
|
||||
val = radare_compare (core, core->block, (ut8*)&v32, sizeof (v32), 0);
|
||||
v32 = (ut32) r_num_math (core->num, input + 1);
|
||||
val = radare_compare (core, core->block, (ut8 *) &v32, sizeof (v32), 0);
|
||||
break;
|
||||
case '8':
|
||||
v64 = (ut64) r_num_math (core->num, input+1);
|
||||
val = radare_compare (core, core->block, (ut8*)&v64, sizeof (v64), 0);
|
||||
v64 = (ut64) r_num_math (core->num, input + 1);
|
||||
val = radare_compare (core, core->block, (ut8 *) &v64, sizeof (v64), 0);
|
||||
break;
|
||||
case 'c': // "cc"
|
||||
if (input[1] == 'd') {
|
||||
cmd_cmp_disasm (core, input+2, 'c');
|
||||
cmd_cmp_disasm (core, input + 2, 'c');
|
||||
} else {
|
||||
ut32 oflags = core->print->flags;
|
||||
ut64 addr = 0; // TOTHINK: Not sure what default address should be
|
||||
if (input[1]=='c') { // "ccc"
|
||||
if (input[1] == 'c') { // "ccc"
|
||||
core->print->flags |= R_PRINT_FLAGS_DIFFOUT;
|
||||
addr = r_num_math (core->num, input+2);
|
||||
addr = r_num_math (core->num, input + 2);
|
||||
} else {
|
||||
if (*input && input[1])
|
||||
addr = r_num_math (core->num, input+2);
|
||||
if (*input && input[1]) {
|
||||
addr = r_num_math (core->num, input + 2);
|
||||
}
|
||||
}
|
||||
int col = core->cons->columns>123;
|
||||
int col = core->cons->columns > 123;
|
||||
ut8 *b = malloc (core->blocksize);
|
||||
if (b != NULL) {
|
||||
memset (b, 0xff, core->blocksize);
|
||||
r_core_read_at (core, addr, b, core->blocksize);
|
||||
r_print_hexdiff (core->print, core->offset, core->block,
|
||||
addr, b, core->blocksize, col);
|
||||
addr, b, core->blocksize, col);
|
||||
free (b);
|
||||
}
|
||||
core->print->flags = oflags;
|
||||
}
|
||||
break;
|
||||
case 'g': // "cg"
|
||||
{ // XXX: this is broken
|
||||
int diffops = 0;
|
||||
RCore *core2;
|
||||
char *file2 = NULL;
|
||||
switch (input[1]) {
|
||||
case 'o': // "cgo"
|
||||
file2 = (char*)r_str_chop_ro (input+2);
|
||||
r_anal_diff_setup (core->anal, true, -1, -1);
|
||||
break;
|
||||
case 'f': // "cgf"
|
||||
eprintf ("TODO: agf is experimental\n");
|
||||
r_anal_diff_setup (core->anal, true, -1, -1);
|
||||
r_core_gdiff_fcn (core, core->offset,
|
||||
r_num_math (core->num, input +2));
|
||||
return false;
|
||||
case ' ':
|
||||
file2 = (char*)r_str_chop_ro (input+2);
|
||||
r_anal_diff_setup (core->anal, false, -1, -1);
|
||||
break;
|
||||
default: {
|
||||
const char * help_message[] = {
|
||||
{ // XXX: this is broken
|
||||
int diffops = 0;
|
||||
RCore *core2;
|
||||
char *file2 = NULL;
|
||||
switch (input[1]) {
|
||||
case 'o': // "cgo"
|
||||
file2 = (char *) r_str_chop_ro (input + 2);
|
||||
r_anal_diff_setup (core->anal, true, -1, -1);
|
||||
break;
|
||||
case 'f': // "cgf"
|
||||
eprintf ("TODO: agf is experimental\n");
|
||||
r_anal_diff_setup (core->anal, true, -1, -1);
|
||||
r_core_gdiff_fcn (core, core->offset,
|
||||
r_num_math (core->num, input + 2));
|
||||
return false;
|
||||
case ' ':
|
||||
file2 = (char *) r_str_chop_ro (input + 2);
|
||||
r_anal_diff_setup (core->anal, false, -1, -1);
|
||||
break;
|
||||
default: {
|
||||
const char *help_message[] = {
|
||||
"Usage: cg", "", "Graph code commands",
|
||||
"cg", "", "diff ratio among functions (columns: off-A, match-ratio, off-B)",
|
||||
"cg", "", "diff ratio among functions (columns: off-A, match-ratio, off-B)",
|
||||
"cgf", "[fcn]", "Compare functions (curseek vs fcn)",
|
||||
"cgo", "", "Opcode-bytes code graph diff",
|
||||
NULL
|
||||
};
|
||||
r_core_cmd_help(core, help_message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
r_core_cmd_help (core, help_message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (r_file_size (file2) <= 0) {
|
||||
eprintf ("Cannot compare with file %s\n", file2);
|
||||
return false;
|
||||
}
|
||||
if (r_file_size (file2) <= 0) {
|
||||
eprintf ("Cannot compare with file %s\n", file2);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(core2 = r_core_new ())) {
|
||||
eprintf ("Cannot init diff core\n");
|
||||
return false;
|
||||
}
|
||||
r_core_loadlibs (core2, R_CORE_LOADLIBS_ALL, NULL);
|
||||
core2->io->va = core->io->va;
|
||||
core2->anal->split = core->anal->split;
|
||||
if (!r_core_file_open (core2, file2, 0, 0LL)) {
|
||||
eprintf ("Cannot open diff file '%s'\n", file2);
|
||||
r_core_free (core2);
|
||||
return false;
|
||||
}
|
||||
// TODO: must replicate on core1 too
|
||||
r_config_set_i (core2->config, "io.va", true);
|
||||
r_config_set_i (core2->config, "anal.split", true);
|
||||
r_anal_diff_setup (core->anal, diffops, -1, -1);
|
||||
r_anal_diff_setup (core2->anal, diffops, -1, -1);
|
||||
|
||||
r_core_bin_load (core2, file2,
|
||||
r_config_get_i (core->config, "bin.baddr"));
|
||||
r_core_gdiff (core, core2);
|
||||
r_core_diff_show (core, core2);
|
||||
/* exchange a segfault with a memleak */
|
||||
core2->config = NULL;
|
||||
if (!(core2 = r_core_new ())) {
|
||||
eprintf ("Cannot init diff core\n");
|
||||
return false;
|
||||
}
|
||||
r_core_loadlibs (core2, R_CORE_LOADLIBS_ALL, NULL);
|
||||
core2->io->va = core->io->va;
|
||||
core2->anal->split = core->anal->split;
|
||||
if (!r_core_file_open (core2, file2, 0, 0LL)) {
|
||||
eprintf ("Cannot open diff file '%s'\n", file2);
|
||||
r_core_free (core2);
|
||||
}
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
// TODO: must replicate on core1 too
|
||||
r_config_set_i (core2->config, "io.va", true);
|
||||
r_config_set_i (core2->config, "anal.split", true);
|
||||
r_anal_diff_setup (core->anal, diffops, -1, -1);
|
||||
r_anal_diff_setup (core2->anal, diffops, -1, -1);
|
||||
|
||||
r_core_bin_load (core2, file2,
|
||||
r_config_get_i (core->config, "bin.baddr"));
|
||||
r_core_gdiff (core, core2);
|
||||
r_core_diff_show (core, core2);
|
||||
/* exchange a segfault with a memleak */
|
||||
core2->config = NULL;
|
||||
r_core_free (core2);
|
||||
}
|
||||
break;
|
||||
case 'u':
|
||||
switch (input[1]) {
|
||||
case ' ':
|
||||
radare_compare_unified (core, core->offset,
|
||||
r_num_math (core->num, input+1),
|
||||
r_num_math (core->num, input + 1),
|
||||
core->blocksize);
|
||||
break;
|
||||
case 'd':
|
||||
cmd_cmp_disasm (core, input+2, 'u');
|
||||
cmd_cmp_disasm (core, input + 2, 'u');
|
||||
break;
|
||||
default: {
|
||||
const char* help_msg[] = {
|
||||
"Usage: cu", " [offset]", "# Creates a unified hex patch",
|
||||
"cu", " $$+1 > p", "Compare current seek and +1",
|
||||
"cud", " $$+1 > p", "Compare disasm current seek and +1",
|
||||
"wu", " p", "Apply unified hex patch",
|
||||
NULL};
|
||||
r_core_cmd_help (core, help_msg); }
|
||||
const char *help_msg[] = {
|
||||
"Usage: cu", " [offset]", "# Creates a unified hex patch",
|
||||
"cu", " $$+1 > p", "Compare current seek and +1",
|
||||
"cud", " $$+1 > p", "Compare disasm current seek and +1",
|
||||
"wu", " p", "Apply unified hex patch",
|
||||
NULL
|
||||
};
|
||||
r_core_cmd_help (core, help_msg);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
showhelp (core);
|
||||
break;
|
||||
case 'v': // "cv"
|
||||
{
|
||||
{
|
||||
int sz = input[1];
|
||||
if (sz== ' ') {
|
||||
if (sz == ' ') {
|
||||
switch (r_config_get_i (core->config, "asm.bits")) {
|
||||
case 8: sz = '1'; break;
|
||||
case 16: sz = '2'; break;
|
||||
@ -670,36 +701,52 @@ static int cmd_cmp(void *data, const char *input) {
|
||||
// TODO: honor endian
|
||||
switch (sz) {
|
||||
case '1':
|
||||
{ ut8 n = (ut8)r_num_math (core->num, input+2);
|
||||
if (core->block[0] == n) r_cons_printf ("0x%08"PFMT64x"\n", core->offset); }
|
||||
break;
|
||||
{
|
||||
ut8 n = (ut8) r_num_math (core->num, input + 2);
|
||||
if (core->block[0] == n) {
|
||||
r_cons_printf ("0x%08"PFMT64x "\n", core->offset);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '2':
|
||||
{ ut16 *b = (ut16*)core->block, n = (ut16)r_num_math (core->num, input+2);
|
||||
if (*b == n) r_cons_printf ("0x%08"PFMT64x"\n", core->offset); }
|
||||
break;
|
||||
{
|
||||
ut16 *b = (ut16 *) core->block, n = (ut16) r_num_math (core->num, input + 2);
|
||||
if (*b == n) {
|
||||
r_cons_printf ("0x%08"PFMT64x "\n", core->offset);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '4':
|
||||
{ ut32 *b = (ut32*)core->block, n = (ut32)r_num_math (core->num, input+2);
|
||||
if (*b == n) r_cons_printf ("0x%08"PFMT64x"\n", core->offset); }
|
||||
break;
|
||||
{
|
||||
ut32 *b = (ut32 *) core->block, n = (ut32) r_num_math (core->num, input + 2);
|
||||
if (*b == n) {
|
||||
r_cons_printf ("0x%08"PFMT64x "\n", core->offset);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '8':
|
||||
{ ut64 *b = (ut64*)core->block, n = (ut64)r_num_math (core->num, input+2);
|
||||
if (*b == n) r_cons_printf ("0x%08"PFMT64x"\n", core->offset); }
|
||||
break;
|
||||
{
|
||||
ut64 *b = (ut64 *) core->block, n = (ut64) r_num_math (core->num, input + 2);
|
||||
if (*b == n) {
|
||||
r_cons_printf ("0x%08"PFMT64x "\n", core->offset);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case '?':
|
||||
eprintf ("Usage: cv[1248] [num]\n"
|
||||
"Show offset if current value equals to the one specified\n"
|
||||
" /v 18312 # serch for a known value\n"
|
||||
" dc\n"
|
||||
" cv4 18312 @@ hit*\n"
|
||||
" dc\n");
|
||||
"Show offset if current value equals to the one specified\n"
|
||||
" /v 18312 # serch for a known value\n"
|
||||
" dc\n"
|
||||
" cv4 18312 @@ hit*\n"
|
||||
" dc\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
if (strchr (input, 'f')) {
|
||||
r_cons_flush();
|
||||
r_cons_flush ();
|
||||
} else if (!strchr (input, '0')) {
|
||||
r_cons_clear ();
|
||||
#if 0
|
||||
@ -707,16 +754,17 @@ static int cmd_cmp(void *data, const char *input) {
|
||||
write (1, "\x1b[0;0H", 6);
|
||||
write (1, "\x1b[0m", 4);
|
||||
#endif
|
||||
//r_cons_clear();
|
||||
// r_cons_clear();
|
||||
}
|
||||
r_cons_gotoxy (0, 0);
|
||||
// r_cons_flush ();
|
||||
// r_cons_flush ();
|
||||
break;
|
||||
default:
|
||||
showhelp (core);
|
||||
}
|
||||
if (val != UT64_MAX)
|
||||
if (val != UT64_MAX) {
|
||||
core->num->value = val;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -894,7 +894,7 @@ static void get_hash_debug_file(const char *path, char *hash, int hash_len) {
|
||||
RBinSection *s;
|
||||
RCore *core = r_core_new ();
|
||||
RList * sects = NULL;
|
||||
char buf[20] = {0};
|
||||
char buf[20] = R_EMPTY;
|
||||
int offset, err, i, j = 0;
|
||||
|
||||
if (!core) {
|
||||
@ -3354,7 +3354,7 @@ static int cmd_debug_step (RCore *core, const char *input) {
|
||||
break;
|
||||
case 's': // "dss"
|
||||
{
|
||||
char delb[128] = {0};
|
||||
char delb[128] = R_EMPTY;
|
||||
addr = r_debug_reg_get (core->dbg, "PC");
|
||||
RBreakpointItem *bpi = r_bp_get_at (core->dbg->bp, addr);
|
||||
sprintf(delb, "db 0x%"PFMT64x"", addr);
|
||||
@ -3376,7 +3376,7 @@ static int cmd_debug_step (RCore *core, const char *input) {
|
||||
}
|
||||
case 'o': // "dso"
|
||||
{
|
||||
char delb[128] = {0};
|
||||
char delb[128] = R_EMPTY;
|
||||
addr = r_debug_reg_get (core->dbg, "PC");
|
||||
RBreakpointItem *bpi = r_bp_get_at (core->dbg->bp, addr);
|
||||
sprintf(delb, "db 0x%"PFMT64x"", addr);
|
||||
|
@ -76,7 +76,7 @@ R_API void r_core_clippy(const char *msg) {
|
||||
static int cmd_help(void *data, const char *input) {
|
||||
RCore *core = (RCore *)data;
|
||||
const char *k;
|
||||
char *p, out[128] = {0};
|
||||
char *p, out[128] = R_EMPTY;
|
||||
ut64 n, n2;
|
||||
int i;
|
||||
RList *tmp;
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "r_cons.h"
|
||||
#include "r_core.h"
|
||||
|
||||
static int textlog_chat (RCore *core) {
|
||||
static int textlog_chat(RCore *core) {
|
||||
char prompt[64];
|
||||
char buf[1024];
|
||||
int lastmsg = 0;
|
||||
@ -13,40 +13,43 @@ static int textlog_chat (RCore *core) {
|
||||
char msg[1024];
|
||||
|
||||
eprintf ("Type '/help' for commands:\n");
|
||||
snprintf (prompt, sizeof (prompt)-1, "[%s]> ", me);
|
||||
snprintf (prompt, sizeof (prompt) - 1, "[%s]> ", me);
|
||||
r_line_set_prompt (prompt);
|
||||
for (;;) {
|
||||
r_core_log_list (core, lastmsg, 0, 0);
|
||||
lastmsg = core->log->last;
|
||||
if (r_cons_fgets (buf, sizeof (buf)-1, 0, NULL)<0)
|
||||
if (r_cons_fgets (buf, sizeof (buf) - 1, 0, NULL) < 0) {
|
||||
return 1;
|
||||
if (!*buf) continue;
|
||||
}
|
||||
if (!*buf) {
|
||||
continue;
|
||||
}
|
||||
if (!strcmp (buf, "/help")) {
|
||||
eprintf ("/quit quit the chat (same as ^D)\n");
|
||||
eprintf ("/name <nick> set cfg.user name\n");
|
||||
eprintf ("/log show full log\n");
|
||||
eprintf ("/clear clear text log messages\n");
|
||||
} else if (!strncmp (buf, "/name ", 6)) {
|
||||
snprintf (msg, sizeof (msg)-1, "* '%s' is now known as '%s'", me, buf+6);
|
||||
snprintf (msg, sizeof (msg) - 1, "* '%s' is now known as '%s'", me, buf + 6);
|
||||
r_core_log_add (core, msg);
|
||||
r_config_set (core->config, "cfg.user", buf+6);
|
||||
r_config_set (core->config, "cfg.user", buf + 6);
|
||||
me = r_config_get (core->config, "cfg.user");
|
||||
snprintf (prompt, sizeof (prompt)-1, "[%s]> ", me);
|
||||
snprintf (prompt, sizeof (prompt) - 1, "[%s]> ", me);
|
||||
r_line_set_prompt (prompt);
|
||||
return 0;
|
||||
} else if (!strcmp (buf, "/log")) {
|
||||
r_core_log_list (core, 0, 0, 0);
|
||||
return 0;
|
||||
} else if (!strcmp (buf, "/clear")) {
|
||||
//r_core_log_del (core, 0);
|
||||
// r_core_log_del (core, 0);
|
||||
r_core_cmd0 (core, "T-");
|
||||
return 0;
|
||||
} else if (!strcmp (buf, "/quit")) {
|
||||
return 0;
|
||||
} else if (*buf=='/') {
|
||||
} else if (*buf == '/') {
|
||||
eprintf ("Unknown command: %s\n", buf);
|
||||
} else {
|
||||
snprintf (msg, sizeof (msg)-1, "[%s] %s", me, buf);
|
||||
snprintf (msg, sizeof (msg) - 1, "[%s] %s", me, buf);
|
||||
r_core_log_add (core, msg);
|
||||
}
|
||||
}
|
||||
@ -54,40 +57,45 @@ static int textlog_chat (RCore *core) {
|
||||
}
|
||||
|
||||
static int cmd_log(void *data, const char *input) {
|
||||
RCore *core = (RCore *)data;
|
||||
RCore *core = (RCore *) data;
|
||||
const char *arg, *input2;
|
||||
int n, n2;
|
||||
|
||||
if (!input)
|
||||
if (!input) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
input2 = (input && *input) ? input+1 : "";
|
||||
input2 = (input && *input)? input + 1: "";
|
||||
arg = strchr (input2, ' ');
|
||||
n = atoi (input2);
|
||||
n2 = arg ? atoi (arg+1) : 0;
|
||||
n2 = arg? atoi (arg + 1): 0;
|
||||
|
||||
switch (*input) {
|
||||
case 'e': // shell: less
|
||||
{
|
||||
{
|
||||
char *p = strchr (input, ' ');
|
||||
if (p) {
|
||||
char *b = r_file_slurp (p+1, NULL);
|
||||
char *b = r_file_slurp (p + 1, NULL);
|
||||
if (b) {
|
||||
r_cons_less_str (b, NULL);
|
||||
free (b);
|
||||
} else eprintf ("File not found\n");
|
||||
} else eprintf ("Usage: less [filename]\n");
|
||||
} else {
|
||||
eprintf ("File not found\n");
|
||||
}
|
||||
} else {
|
||||
eprintf ("Usage: less [filename]\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
r_cons_printf ("%d\n", core->log->last-1);
|
||||
r_cons_printf ("%d\n", core->log->last - 1);
|
||||
break;
|
||||
case '-':
|
||||
r_core_log_del (core, n);
|
||||
break;
|
||||
case '?':{
|
||||
const char* help_msg[] = {
|
||||
"Usage:", "T","[-][ num|msg]",
|
||||
case '?': {
|
||||
const char *help_msg[] = {
|
||||
"Usage:", "T", "[-][ num|msg]",
|
||||
"T", "", "List all Text log messages",
|
||||
"T", " message", "Add new log message",
|
||||
"T", " 123", "List log from 123",
|
||||
@ -101,14 +109,17 @@ static int cmd_log(void *data, const char *input) {
|
||||
"Ts", "", "List files in current directory (see pwd, cd)",
|
||||
"Tp", "[?] [-plug]", "List, load, unload plugins",
|
||||
"TT", "", "Enter into the text log chat console",
|
||||
NULL};
|
||||
NULL
|
||||
};
|
||||
r_core_cmd_help (core, help_msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'T':
|
||||
if (r_config_get_i (core->config, "scr.interactive")) {
|
||||
textlog_chat (core);
|
||||
} else eprintf ("Only available when the screen is interactive\n");
|
||||
} else {
|
||||
eprintf ("Only available when the screen is interactive\n");
|
||||
}
|
||||
break;
|
||||
case 'p':
|
||||
switch (input[1]) {
|
||||
@ -116,32 +127,33 @@ static int cmd_log(void *data, const char *input) {
|
||||
r_lib_list (core->lib);
|
||||
break;
|
||||
case '-':
|
||||
r_lib_close (core->lib, input+2);
|
||||
r_lib_close (core->lib, input + 2);
|
||||
break;
|
||||
case ' ':
|
||||
r_lib_open (core->lib, input+2);
|
||||
r_lib_open (core->lib, input + 2);
|
||||
break;
|
||||
case '?': {
|
||||
const char* help_msg[] = {
|
||||
"Usage:", "Tp", "[-name][ file]",
|
||||
"Tp", "", "List all plugins loaded by RCore.lib",
|
||||
"Tp-", "duk", "Unload plugin matching in filename",
|
||||
"Tp", " blah."R_LIB_EXT, "Load plugin file",
|
||||
NULL};
|
||||
r_core_cmd_help(core, help_msg);
|
||||
}
|
||||
break;
|
||||
const char *help_msg[] = {
|
||||
"Usage:", "Tp", "[-name][ file]",
|
||||
"Tp", "", "List all plugins loaded by RCore.lib",
|
||||
"Tp-", "duk", "Unload plugin matching in filename",
|
||||
"Tp", " blah."R_LIB_EXT, "Load plugin file",
|
||||
NULL
|
||||
};
|
||||
r_core_cmd_help (core, help_msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case ' ':
|
||||
if (n>0) {
|
||||
if (n > 0) {
|
||||
r_core_log_list (core, n, n2, *input);
|
||||
} else {
|
||||
r_core_log_add (core, input+1);
|
||||
r_core_log_add (core, input + 1);
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
if (n>0) {
|
||||
if (n > 0) {
|
||||
r_core_log_list (core, n, 1, 't');
|
||||
} else {
|
||||
r_core_log_list (core, n, 0, 't');
|
||||
|
@ -513,7 +513,7 @@ static int cmd_meta_hsdmf(RCore *core, const char *input) {
|
||||
break;
|
||||
}
|
||||
} else if (type == 's') { //Cs
|
||||
char tmp[256] = {0};
|
||||
char tmp[256] = R_EMPTY;
|
||||
int i, j, name_len = 0;
|
||||
(void)r_core_read_at (core, addr, (ut8*)tmp, sizeof (tmp) - 3);
|
||||
name_len = r_str_nlen_w (tmp, sizeof (tmp) - 3);
|
||||
|
@ -389,7 +389,7 @@ static ut64 num_callback(RNum *userptr, const char *str, int *ok) {
|
||||
}
|
||||
// pop state
|
||||
if (ok) *ok = 1;
|
||||
ut8 buf[sizeof (ut64)] = {0};
|
||||
ut8 buf[sizeof (ut64)] = R_EMPTY;
|
||||
(void)r_io_read_at (core->io, n, buf, refsz);
|
||||
switch (refsz) {
|
||||
case 8:
|
||||
|
@ -1681,7 +1681,7 @@ static void ds_print_lines_left(RDisasmState *ds) {
|
||||
free (sect);
|
||||
}
|
||||
if (ds->show_symbols) {
|
||||
static RFlagItem sfi = {0};
|
||||
static RFlagItem sfi = R_EMPTY;
|
||||
const char *name = "";
|
||||
int delta = 0;
|
||||
if (ds->fcn) {
|
||||
@ -1764,7 +1764,7 @@ static void ds_print_offset(RDisasmState *ds) {
|
||||
|
||||
r_print_set_screenbounds (core->print, at);
|
||||
if (ds->show_offset) {
|
||||
static RFlagItem sfi = {0};
|
||||
static RFlagItem sfi = R_EMPTY;
|
||||
const char *label = NULL;
|
||||
RFlagItem *fi;
|
||||
int delta = -1;
|
||||
|
@ -41,11 +41,11 @@ static const char *mousemodes[] = {
|
||||
#define BODY_OFFSETS 0x1
|
||||
#define BODY_SUMMARY 0x2
|
||||
|
||||
#define hash_set(sdb,k,v) (sdb_num_set (sdb, sdb_fmt (0, "%"PFMT64u, (ut64) (size_t) k), (ut64) (size_t) v, 0))
|
||||
#define hash_get(sdb,k) (sdb_num_get (sdb, sdb_fmt (0, "%"PFMT64u, (ut64) (size_t) k), NULL))
|
||||
#define hash_get_rnode(sdb,k) ((RGraphNode *) (size_t) hash_get (sdb, k))
|
||||
#define hash_get_rlist(sdb,k) ((RList *) (size_t) hash_get (sdb, k))
|
||||
#define hash_get_int(sdb,k) ((int) hash_get (sdb, k))
|
||||
#define hash_set(sdb, k, v) (sdb_num_set (sdb, sdb_fmt (0, "%"PFMT64u, (ut64) (size_t) k), (ut64) (size_t) v, 0))
|
||||
#define hash_get(sdb, k) (sdb_num_get (sdb, sdb_fmt (0, "%"PFMT64u, (ut64) (size_t) k), NULL))
|
||||
#define hash_get_rnode(sdb, k) ((RGraphNode *) (size_t) hash_get (sdb, k))
|
||||
#define hash_get_rlist(sdb, k) ((RList *) (size_t) hash_get (sdb, k))
|
||||
#define hash_get_int(sdb, k) ((int) hash_get (sdb, k))
|
||||
/* dont use macros for this */
|
||||
#define get_anode(gn) (gn? (RANode *) gn->data: NULL)
|
||||
|
||||
@ -92,12 +92,12 @@ struct agraph_refresh_data {
|
||||
int fs;
|
||||
};
|
||||
|
||||
#define G(x,y) r_cons_canvas_gotoxy (g->can, x, y)
|
||||
#define G(x, y) r_cons_canvas_gotoxy (g->can, x, y)
|
||||
#define W(x) r_cons_canvas_write (g->can, x)
|
||||
#define B(x,y,w,h) r_cons_canvas_box (g->can, x,y,w,h, g->color_box)
|
||||
#define B1(x,y,w,h) r_cons_canvas_box (g->can, x,y,w,h, g->color_box2)
|
||||
#define B2(x,y,w,h) r_cons_canvas_box (g->can, x,y,w,h, g->color_box3)
|
||||
#define F(x,y,x2,y2,c) r_cons_canvas_fill (g->can, x,y,x2,y2,c,0)
|
||||
#define B(x, y, w, h) r_cons_canvas_box (g->can, x, y, w, h, g->color_box)
|
||||
#define B1(x, y, w, h) r_cons_canvas_box (g->can, x, y, w, h, g->color_box2)
|
||||
#define B2(x, y, w, h) r_cons_canvas_box (g->can, x, y, w, h, g->color_box3)
|
||||
#define F(x, y, x2, y2, c) r_cons_canvas_fill (g->can, x, y, x2, y2, c, 0)
|
||||
|
||||
static bool is_offset(const RAGraph *g) {
|
||||
return g->mode == R_AGRAPH_MODE_OFFSET;
|
||||
@ -188,12 +188,12 @@ static void update_node_dimension(const RGraph *g, int is_mini, int zoom) {
|
||||
}
|
||||
|
||||
static void mini_RANode_print(const RAGraph *g, const RANode *n,
|
||||
int cur, bool print_details) {
|
||||
int cur, bool print_details) {
|
||||
char title[TITLE_LEN];
|
||||
int x, delta_x = 0;
|
||||
|
||||
if (!G (n->x + MINIGRAPH_NODE_CENTER_X, n->y) &&
|
||||
!G (n->x + MINIGRAPH_NODE_CENTER_X + n->w, n->y)) {
|
||||
!G (n->x + MINIGRAPH_NODE_CENTER_X + n->w, n->y)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -229,7 +229,7 @@ static void mini_RANode_print(const RAGraph *g, const RANode *n,
|
||||
}
|
||||
} else {
|
||||
snprintf (title, sizeof (title) - 1,
|
||||
cur ? "[ %s ]" : " %s ", n->title);
|
||||
cur? "[ %s ]": " %s ", n->title);
|
||||
W (title);
|
||||
}
|
||||
return;
|
||||
@ -279,7 +279,7 @@ static void normal_RANode_print(const RAGraph *g, const RANode *n, int cur) {
|
||||
}
|
||||
|
||||
if (G (n->x + MARGIN_TEXT_X + delta_x + center_x - delta_txt_x,
|
||||
n->y + MARGIN_TEXT_Y + delta_y + center_y - delta_txt_y)) {
|
||||
n->y + MARGIN_TEXT_Y + delta_y + center_y - delta_txt_y)) {
|
||||
unsigned int body_x = center_x >= delta_x? 0: delta_x - center_x;
|
||||
unsigned int body_y = center_y >= delta_y? 0: delta_y - center_y;
|
||||
unsigned int body_h = BORDER_HEIGHT >= n->h? 1: n->h - BORDER_HEIGHT;
|
||||
@ -458,15 +458,16 @@ static int layer_sweep(const RGraph *g, const struct layer_t layers[],
|
||||
}
|
||||
|
||||
/* update position in the layer of each node. During the swap of some
|
||||
* elements we didn't swap also the pos_in_layer because the cross_matrix
|
||||
* is indexed by it, so do it now! */
|
||||
* elements we didn't swap also the pos_in_layer because the cross_matrix
|
||||
* is indexed by it, so do it now! */
|
||||
for (j = 0; j < layers[i].n_nodes; ++j) {
|
||||
RANode *n = get_anode (layers[i].nodes[j]);
|
||||
n->pos_in_layer = j;
|
||||
}
|
||||
|
||||
for (j = 0; j < n_rows; ++j)
|
||||
for (j = 0; j < n_rows; ++j) {
|
||||
free (cross_matrix[j]);
|
||||
}
|
||||
free (cross_matrix);
|
||||
return changed;
|
||||
}
|
||||
@ -666,8 +667,9 @@ static void minimize_crossings(const RAGraph *g) {
|
||||
cross_changed = false;
|
||||
--max_changes;
|
||||
|
||||
for (i = 0; i < g->n_layers; ++i)
|
||||
for (i = 0; i < g->n_layers; ++i) {
|
||||
cross_changed |= layer_sweep (g->graph, g->layers, g->n_layers, i, true);
|
||||
}
|
||||
} while (cross_changed && max_changes);
|
||||
|
||||
max_changes = 4096;
|
||||
@ -676,8 +678,9 @@ static void minimize_crossings(const RAGraph *g) {
|
||||
cross_changed = false;
|
||||
--max_changes;
|
||||
|
||||
for (i = g->n_layers - 1; i >= 0; --i)
|
||||
for (i = g->n_layers - 1; i >= 0; --i) {
|
||||
cross_changed |= layer_sweep (g->graph, g->layers, g->n_layers, i, false);
|
||||
}
|
||||
} while (cross_changed && max_changes);
|
||||
}
|
||||
|
||||
@ -838,8 +841,8 @@ static RList **compute_classes(const RAGraph *g, Sdb *v_nodes, int is_left, int
|
||||
c = i;
|
||||
|
||||
for (j = is_left? 0: g->layers[i].n_nodes - 1;
|
||||
(is_left && j < g->layers[i].n_nodes) || (!is_left && j >= 0);
|
||||
j = is_left? j + 1: j - 1) {
|
||||
(is_left && j < g->layers[i].n_nodes) || (!is_left && j >= 0);
|
||||
j = is_left? j + 1: j - 1) {
|
||||
const RGraphNode *gj = g->layers[i].nodes[j];
|
||||
const RANode *aj = get_anode (gj);
|
||||
|
||||
@ -947,7 +950,7 @@ static void adjust_class(const RAGraph *g, int is_left, RList **classes, Sdb *re
|
||||
|
||||
graph_foreach_anode (classes[c], it, gn, an) {
|
||||
const int old_val = hash_get_int (res, gn);
|
||||
const int new_val = is_left? old_val + dist: old_val - dist;
|
||||
const int new_val = is_left? old_val + dist: old_val - dist;
|
||||
hash_set (res, gn, new_val);
|
||||
}
|
||||
}
|
||||
@ -1163,7 +1166,7 @@ static void place_single(const RAGraph *g, int l, const RGraphNode *bm, const RG
|
||||
int len;
|
||||
|
||||
neigh = from_up
|
||||
? r_graph_innodes (g->graph, v)
|
||||
? r_graph_innodes (g->graph, v)
|
||||
: r_graph_get_neighbours (g->graph, v);
|
||||
|
||||
len = r_list_length (neigh);
|
||||
@ -1212,8 +1215,8 @@ static void collect_changes(const RAGraph *g, int l, const RGraphNode *b, int fr
|
||||
lcmp = is_left? (RListComparator) RM_listcmp: (RListComparator) RP_listcmp;
|
||||
|
||||
for (i = is_left? s: e - 1;
|
||||
(is_left && i < e) || (!is_left && i >= s);
|
||||
i = is_left? i + 1: i - 1) {
|
||||
(is_left && i < e) || (!is_left && i >= s);
|
||||
i = is_left? i + 1: i - 1) {
|
||||
const RGraphNode *v, *vi = g->layers[l].nodes[i];
|
||||
const RANode *av, *avi = get_anode (vi);
|
||||
const RList *neigh;
|
||||
@ -1224,7 +1227,7 @@ static void collect_changes(const RAGraph *g, int l, const RGraphNode *b, int fr
|
||||
continue;
|
||||
}
|
||||
neigh = from_up
|
||||
? r_graph_innodes (g->graph, vi)
|
||||
? r_graph_innodes (g->graph, vi)
|
||||
: r_graph_get_neighbours (g->graph, vi);
|
||||
|
||||
graph_foreach_anode (neigh, it, v, av) {
|
||||
@ -1363,8 +1366,8 @@ static void original_traverse_l(const RAGraph *g, Sdb *D, Sdb *P, int from_up) {
|
||||
int i, k, va, vr;
|
||||
|
||||
for (i = from_up? 0: g->n_layers - 1;
|
||||
(from_up && i < g->n_layers) || (!from_up && i >= 0);
|
||||
i = from_up? i + 1: i - 1) {
|
||||
(from_up && i < g->n_layers) || (!from_up && i >= 0);
|
||||
i = from_up? i + 1: i - 1) {
|
||||
int j;
|
||||
const RGraphNode *bm = NULL;
|
||||
const RANode *bma = NULL;
|
||||
@ -1401,8 +1404,9 @@ static void original_traverse_l(const RAGraph *g, Sdb *D, Sdb *P, int from_up) {
|
||||
va = bma->pos_in_layer + 1;
|
||||
vr = g->layers[bma->layer].n_nodes;
|
||||
place_sequence (g, i, bm, NULL, from_up, va, vr);
|
||||
for (k = va; k < vr - 1; ++k)
|
||||
for (k = va; k < vr - 1; ++k) {
|
||||
set_dist_nodes (g, i, k, k + 1);
|
||||
}
|
||||
|
||||
if (is_valid_pos (g, i, va)) {
|
||||
set_dist_nodes (g, i, bma->pos_in_layer, va);
|
||||
@ -1549,7 +1553,7 @@ static void analyze_back_edges(const RAGraph *g, RANode *an) {
|
||||
|
||||
neigh = r_graph_get_neighbours (g->graph, an->gnode);
|
||||
/* traverse all neighbours and analyze only the ones that create back
|
||||
* edges. */
|
||||
* edges. */
|
||||
graph_foreach_anode (neigh, itk, gk, ak) {
|
||||
RGraphNode *fn, *ln;
|
||||
RANode *first, *last;
|
||||
@ -1599,7 +1603,7 @@ static void remove_dummy_nodes(const RAGraph *g) {
|
||||
int i, j;
|
||||
|
||||
/* traverse all dummy nodes to keep track
|
||||
* of the path long edges should go by. */
|
||||
* of the path long edges should go by. */
|
||||
for (i = 0; i < g->n_layers; ++i) {
|
||||
for (j = 0; j < g->layers[i].n_nodes; ++j) {
|
||||
RGraphNode *n = g->layers[i].nodes[j];
|
||||
@ -1655,8 +1659,8 @@ static void set_layout(RAGraph *g) {
|
||||
}
|
||||
|
||||
/* x-coordinate assignment: algorithm based on:
|
||||
* A Fast Layout Algorithm for k-Level Graphs
|
||||
* by C. Buchheim, M. Junger, S. Leipert */
|
||||
* A Fast Layout Algorithm for k-Level Graphs
|
||||
* by C. Buchheim, M. Junger, S. Leipert */
|
||||
place_dummies (g);
|
||||
place_original (g);
|
||||
|
||||
@ -1997,7 +2001,7 @@ static int get_cgnodes(RAGraph *g, RCore *core, RAnalFunction *fcn) {
|
||||
|
||||
r_list_foreach (fcn->refs, iter, ref) {
|
||||
/* XXX: something is broken, why there are duplicated
|
||||
* nodes here?! goto check fcn->refs!! */
|
||||
* nodes here?! goto check fcn->refs!! */
|
||||
/* avoid dups wtf */
|
||||
title = get_title (ref->addr);
|
||||
if (r_agraph_get_node (g, title) != NULL) {
|
||||
@ -2087,8 +2091,8 @@ static const RGraphNode *find_near_of(const RAGraph *g, const RGraphNode *cur, i
|
||||
graph_foreach_anode (nodes, it, gn, n) {
|
||||
// tab in horizontal layout is not correct, lets force vertical nextnode for now (g->layout == 0)
|
||||
bool isNear = true
|
||||
? is_near (n, start_x, start_y, is_next)
|
||||
: is_near_h (n, start_x, start_y, is_next);
|
||||
? is_near (n, start_x, start_y, is_next)
|
||||
: is_near_h (n, start_x, start_y, is_next);
|
||||
if (isNear) {
|
||||
const RANode *resn;
|
||||
|
||||
@ -2101,7 +2105,7 @@ static const RGraphNode *find_near_of(const RAGraph *g, const RGraphNode *cur, i
|
||||
if ((is_next && resn->y > n->y) || (!is_next && resn->y < n->y)) {
|
||||
resgn = gn;
|
||||
} else if ((is_next && resn->y == n->y && resn->x > n->x) ||
|
||||
(!is_next && resn->y == n->y && resn->x < n->x)) {
|
||||
(!is_next && resn->y == n->y && resn->x < n->x)) {
|
||||
resgn = gn;
|
||||
}
|
||||
}
|
||||
@ -2210,7 +2214,7 @@ static void update_graph_sizes(RAGraph *g) {
|
||||
sdb_num_set (g->db, "agraph.w", g->w, 0);
|
||||
sdb_num_set (g->db, "agraph.h", g->h, 0);
|
||||
/* delta_x, delta_y are needed to make every other x,y coordinates
|
||||
* unsigned, so that we can use sdb_num_ API */
|
||||
* unsigned, so that we can use sdb_num_ API */
|
||||
delta_x = g->x < 0? -g->x: 0;
|
||||
delta_y = g->y < 0? -g->y: 0;
|
||||
sdb_num_set (g->db, "agraph.delta_x", delta_x, 0);
|
||||
@ -2366,7 +2370,7 @@ static void agraph_print_edge(const RAGraph *g, RANode *a, RANode *b, int nth) {
|
||||
len = r_list_length (edg->x);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
//r_cons_canvas_line (g->can, x, y, x2, y2, &style);
|
||||
// r_cons_canvas_line (g->can, x, y, x2, y2, &style);
|
||||
x = a->x + a->w;
|
||||
y = a->y + (a->h / 2);
|
||||
style.symbol = LINE_NONE;
|
||||
@ -2395,8 +2399,8 @@ static void agraph_print_edges(const RAGraph *g) {
|
||||
int cur_nth = nth;
|
||||
if (g->is_callgraph) {
|
||||
/* hack: we don't support more than two exit edges from a node
|
||||
* yet, so set nth to zero, to make every edge appears as the
|
||||
* "true" edge of the node */
|
||||
* yet, so set nth to zero, to make every edge appears as the
|
||||
* "true" edge of the node */
|
||||
cur_nth = 0;
|
||||
} else if (exit_edges == 1) {
|
||||
cur_nth = -1;
|
||||
@ -2451,10 +2455,10 @@ static void agraph_merge_child(RAGraph *g, int idx) {
|
||||
free (ann->body);
|
||||
// TODO: do not merge nodes if those have edges targeting them
|
||||
// TODO: Add children neighbours to current one
|
||||
//nn->body
|
||||
//r_agraph_set_curnode (g, get_anode (cn));
|
||||
//agraph_refresh (grd);
|
||||
//r_agraph_add_edge (g, from, to);
|
||||
// nn->body
|
||||
// r_agraph_set_curnode (g, get_anode (cn));
|
||||
// agraph_refresh (grd);
|
||||
// r_agraph_add_edge (g, from, to);
|
||||
|
||||
char *neis = sdb_get (g->db, K_NEIGHBOURS (ann), 0);
|
||||
sdb_set_owned (g->db, K_NEIGHBOURS (ann), neis, 0);
|
||||
@ -2462,7 +2466,7 @@ static void agraph_merge_child(RAGraph *g, int idx) {
|
||||
agraph_print_nodes (g);
|
||||
agraph_print_edges (g);
|
||||
}
|
||||
//agraph_update_seek (g, get_anode (g->curnode), false);
|
||||
// agraph_update_seek (g, get_anode (g->curnode), false);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -2537,7 +2541,7 @@ static int check_changes(RAGraph *g, int is_interactive,
|
||||
char *title = get_title (off);
|
||||
RANode *cur_anode = get_anode (g->curnode);
|
||||
if (fcn && ((is_interactive && !cur_anode) ||
|
||||
(cur_anode && strcmp (cur_anode->title, title) != 0))) {
|
||||
(cur_anode && strcmp (cur_anode->title, title) != 0))) {
|
||||
g->update_seek_on = r_agraph_get_node (g, title);
|
||||
if (g->update_seek_on) {
|
||||
r_agraph_set_curnode (g, g->update_seek_on);
|
||||
@ -2586,7 +2590,7 @@ static int agraph_print(RAGraph *g, int is_interactive, RCore *core, RAnalFuncti
|
||||
h = is_interactive? h: g->h + 1;
|
||||
w = is_interactive? w: g->w;
|
||||
r_cons_canvas_resize (g->can, w, h);
|
||||
//r_cons_canvas_clear (g->can);
|
||||
// r_cons_canvas_clear (g->can);
|
||||
if (!is_interactive) {
|
||||
g->can->sx = -g->x;
|
||||
g->can->sy = -g->y + 1;
|
||||
@ -2674,7 +2678,7 @@ static void agraph_init(RAGraph *g) {
|
||||
g->graph = r_graph_new ();
|
||||
g->nodes = sdb_new0 ();
|
||||
g->zoom = ZOOM_DEFAULT;
|
||||
g->movspeed = DEFAULT_SPEED; //r_config_get_i (g->core->config, "graph.scroll");
|
||||
g->movspeed = DEFAULT_SPEED; // r_config_get_i (g->core->config, "graph.scroll");
|
||||
g->db = sdb_new0 ();
|
||||
}
|
||||
|
||||
@ -3221,7 +3225,7 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int
|
||||
ut64 off = r_core_anal_get_bbaddr (core, core->offset);
|
||||
r_core_seek (core, off, 0);
|
||||
if ((key == 'x' && !r_core_visual_xrefs_x (core)) ||
|
||||
(key == 'X' && !r_core_visual_xrefs_X (core))) {
|
||||
(key == 'X' && !r_core_visual_xrefs_X (core))) {
|
||||
r_core_seek (core, old_off, 0);
|
||||
}
|
||||
break;
|
||||
@ -3468,7 +3472,7 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int
|
||||
const RGraphNode *gn = find_near_of (g, NULL, false);
|
||||
g->update_seek_on = get_anode (gn);
|
||||
} else {
|
||||
// agraph_merge_child (g, 1);
|
||||
// agraph_merge_child (g, 1);
|
||||
r_core_visual_trackflags (core);
|
||||
}
|
||||
break;
|
||||
|
@ -3,26 +3,26 @@
|
||||
#include "r_core.h"
|
||||
#include "../config.h"
|
||||
|
||||
#define CB(x,y) \
|
||||
static int __lib_##x##_cb(RLibPlugin *pl, void *user, void *data) { \
|
||||
struct r_##x##_plugin_t *hand = (struct r_##x##_plugin_t *)data; \
|
||||
RCore *core = (RCore *)user; \
|
||||
r_##x##_add (core->y, hand); \
|
||||
return true; \
|
||||
}\
|
||||
static int __lib_##x##_dt(RLibPlugin *pl, void *p, void *u) { return true; }
|
||||
#define CB(x, y)\
|
||||
static int __lib_ ## x ## _cb (RLibPlugin * pl, void *user, void *data) {\
|
||||
struct r_ ## x ## _plugin_t *hand = (struct r_ ## x ## _plugin_t *)data;\
|
||||
RCore *core = (RCore *) user;\
|
||||
r_ ## x ## _add (core->y, hand);\
|
||||
return true;\
|
||||
}\
|
||||
static int __lib_ ## x ## _dt (RLibPlugin * pl, void *p, void *u) { return true; }
|
||||
|
||||
#define CB_COPY(x,y) \
|
||||
static int __lib_##x##_cb(RLibPlugin *pl, void *user, void *data) { \
|
||||
struct r_##x##_plugin_t *hand = (struct r_##x##_plugin_t *)data; \
|
||||
struct r_##x##_plugin_t *instance; \
|
||||
RCore *core = (RCore *)user; \
|
||||
instance = R_NEW (struct r_##x##_plugin_t); \
|
||||
memcpy (instance, hand, sizeof (struct r_##x##_plugin_t)); \
|
||||
r_##x##_add (core->y, instance); \
|
||||
return true; \
|
||||
}\
|
||||
static int __lib_##x##_dt(RLibPlugin *pl, void *p, void *u) { return true; }
|
||||
#define CB_COPY(x, y)\
|
||||
static int __lib_ ## x ## _cb (RLibPlugin * pl, void *user, void *data) {\
|
||||
struct r_ ## x ## _plugin_t *hand = (struct r_ ## x ## _plugin_t *)data;\
|
||||
struct r_ ## x ## _plugin_t *instance;\
|
||||
RCore *core = (RCore *) user;\
|
||||
instance = R_NEW (struct r_ ## x ## _plugin_t);\
|
||||
memcpy (instance, hand, sizeof (struct r_ ## x ## _plugin_t));\
|
||||
r_ ## x ## _add (core->y, instance);\
|
||||
return true;\
|
||||
}\
|
||||
static int __lib_ ## x ## _dt (RLibPlugin * pl, void *p, void *u) { return true; }
|
||||
|
||||
// XXX api consistency issues
|
||||
#define r_io_add r_io_plugin_add
|
||||
@ -42,8 +42,8 @@ CB (egg, egg)
|
||||
CB (fs, fs)
|
||||
|
||||
R_API void r_core_loadlibs_init(RCore *core) {
|
||||
ut64 prev = r_sys_now();
|
||||
#define DF(x,y,z) r_lib_add_handler(core->lib, R_LIB_TYPE_##x,y,&__lib_##z##_cb, &__lib_##z##_dt, core);
|
||||
ut64 prev = r_sys_now ();
|
||||
#define DF(x, y, z) r_lib_add_handler (core->lib, R_LIB_TYPE_ ## x, y, &__lib_ ## z ## _cb, &__lib_ ## z ## _dt, core);
|
||||
core->lib = r_lib_new ("radare_plugin");
|
||||
DF (IO, "io plugins", io);
|
||||
DF (CORE, "core plugins", core);
|
||||
@ -61,26 +61,31 @@ R_API void r_core_loadlibs_init(RCore *core) {
|
||||
|
||||
R_API int r_core_loadlibs(RCore *core, int where, const char *path) {
|
||||
char *p = NULL;
|
||||
ut64 prev = r_sys_now();
|
||||
ut64 prev = r_sys_now ();
|
||||
#if R2_LOADLIBS
|
||||
/* TODO: all those default plugin paths should be defined in r_lib */
|
||||
if (!r_config_get_i (core->config, "cfg.plugins")) {
|
||||
core->times->loadlibs_time = 0;
|
||||
return false;
|
||||
}
|
||||
if (!where) where = -1;
|
||||
if (path) r_lib_opendir (core->lib, path);
|
||||
if (!where) {
|
||||
where = -1;
|
||||
}
|
||||
if (path) {
|
||||
r_lib_opendir (core->lib, path);
|
||||
}
|
||||
if (where & R_CORE_LOADLIBS_CONFIG) {
|
||||
r_lib_opendir (core->lib, r_config_get (core->config, "dir.plugins"));
|
||||
}
|
||||
if (where & R_CORE_LOADLIBS_ENV) {
|
||||
p = r_sys_getenv (R_LIB_ENV);
|
||||
if (p && *p)
|
||||
if (p && *p) {
|
||||
r_lib_opendir (core->lib, p);
|
||||
}
|
||||
free (p);
|
||||
}
|
||||
if (where & R_CORE_LOADLIBS_HOME) {
|
||||
char *homeplugindir = r_str_home (R2_HOMEDIR"/plugins");
|
||||
char *homeplugindir = r_str_home (R2_HOMEDIR "/plugins");
|
||||
// eprintf ("OPENDIR (%s)\n", homeplugindir);
|
||||
r_lib_opendir (core->lib, homeplugindir);
|
||||
free (homeplugindir);
|
||||
@ -88,14 +93,14 @@ R_API int r_core_loadlibs(RCore *core, int where, const char *path) {
|
||||
if (where & R_CORE_LOADLIBS_SYSTEM) {
|
||||
#if __WINDOWS__
|
||||
r_lib_opendir (core->lib, "plugins");
|
||||
r_lib_opendir (core->lib, "share/radare2/"R2_VERSION"/plugins");
|
||||
r_lib_opendir (core->lib, "share/radare2/"R2_VERSION "/plugins");
|
||||
#else
|
||||
r_lib_opendir (core->lib, R2_LIBDIR"/radare2/"R2_VERSION);
|
||||
r_lib_opendir (core->lib, R2_LIBDIR"/radare2-extras/"R2_VERSION);
|
||||
r_lib_opendir (core->lib, R2_LIBDIR"/radare2-bindings/"R2_VERSION);
|
||||
r_lib_opendir (core->lib, R2_LIBDIR "/radare2/"R2_VERSION);
|
||||
r_lib_opendir (core->lib, R2_LIBDIR "/radare2-extras/"R2_VERSION);
|
||||
r_lib_opendir (core->lib, R2_LIBDIR "/radare2-bindings/"R2_VERSION);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
core->times->loadlibs_time = r_sys_now() - prev;
|
||||
core->times->loadlibs_time = r_sys_now () - prev;
|
||||
return true;
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ static bool GH(r_resolve_main_arena)(RCore *core, GHT *m_arena, GH(RHeap_MallocS
|
||||
const char *dir_build_id = "/.build-id";
|
||||
const char *symname = "main_arena";
|
||||
const char *libc_ver_end = NULL;
|
||||
char hash[64] = {0}, *path = NULL;
|
||||
char hash[64] = R_EMPTY, *path = NULL;
|
||||
bool is_debug_file[6];
|
||||
GHT libc_addr = GHT_MAX, vaddr = GHT_MAX;
|
||||
|
||||
@ -649,7 +649,7 @@ static void GH(print_mmap_graph)(RCore *core, GH(RHeap_MallocState) *malloc_stat
|
||||
w = r_cons_get_size (&h);
|
||||
RConsCanvas *can = r_cons_canvas_new (w, h);
|
||||
RAGraph *g = r_agraph_new (can);
|
||||
RANode *top = {0}, *chunk_node = {0}, *prev_node = {0};
|
||||
RANode *top = R_EMPTY, *chunk_node = R_EMPTY, *prev_node = R_EMPTY;
|
||||
GH(RHeapChunk) *cnk = R_NEW0 (GH(RHeapChunk)),*prev_c = R_NEW0 (GH(RHeapChunk));
|
||||
if (!cnk || !prev_c || !g || !can) {
|
||||
free (cnk);
|
||||
@ -728,7 +728,7 @@ static void GH(print_heap_graph)(RCore *core, GH(RHeap_MallocState) *main_arena,
|
||||
RConsCanvas *can = r_cons_canvas_new (w, h);
|
||||
can->color = r_config_get_i (core->config, "scr.color");
|
||||
RAGraph *g = r_agraph_new (can);
|
||||
RANode *top = {0}, *chunk_node = {0}, *prev_node = {0};
|
||||
RANode *top = R_EMPTY, *chunk_node = R_EMPTY, *prev_node = R_EMPTY;
|
||||
GH(RHeapChunk) *cnk = R_NEW0 (GH(RHeapChunk)), *prev_c = R_NEW0 (GH(RHeapChunk));
|
||||
|
||||
if (!cnk || !prev_c) {
|
||||
|
@ -8,7 +8,9 @@
|
||||
#include <r_list.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static RCorePlugin *cmd_static_plugins[] = { R_CORE_STATIC_PLUGINS };
|
||||
static RCorePlugin *cmd_static_plugins[] = {
|
||||
R_CORE_STATIC_PLUGINS
|
||||
};
|
||||
|
||||
R_API int r_core_plugin_deinit(RCmd *cmd) {
|
||||
RListIter *iter;
|
||||
@ -38,7 +40,7 @@ R_API int r_core_plugin_add(RCmd *cmd, RCorePlugin *plugin) {
|
||||
R_API int r_core_plugin_init(RCmd *cmd) {
|
||||
int i;
|
||||
cmd->plist = r_list_newf (NULL); // memleak or dblfree
|
||||
for (i=0; cmd_static_plugins[i]; i++) {
|
||||
for (i = 0; cmd_static_plugins[i]; i++) {
|
||||
if (!r_core_plugin_add (cmd, cmd_static_plugins[i])) {
|
||||
eprintf ("Error loading cmd plugin\n");
|
||||
return false;
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <r_core.h>
|
||||
#include <spp/spp.h>
|
||||
|
||||
static bool is_valid_project_name (const char *name) {
|
||||
static bool is_valid_project_name(const char *name) {
|
||||
int i;
|
||||
if (r_str_endswith (name, ".zip")) {
|
||||
return false;
|
||||
@ -26,7 +26,7 @@ static bool is_valid_project_name (const char *name) {
|
||||
if (name[i] >= 'A' && name[i] <= 'Z') {
|
||||
continue;
|
||||
}
|
||||
if (IS_DIGIT(name[i])) {
|
||||
if (IS_DIGIT (name[i])) {
|
||||
continue;
|
||||
}
|
||||
return false;
|
||||
@ -44,7 +44,7 @@ static char *projectScriptPath(RCore *core, const char *file) {
|
||||
return NULL;
|
||||
}
|
||||
prjfile = r_file_abspath (r_config_get (
|
||||
core->config, "dir.projects"));
|
||||
core->config, "dir.projects"));
|
||||
prjfile = r_str_append (prjfile, R_SYS_DIR);
|
||||
prjfile = r_str_append (prjfile, file);
|
||||
if (!r_file_exists (prjfile) || r_file_is_directory (prjfile)) {
|
||||
@ -63,7 +63,7 @@ static char *projectScriptPath(RCore *core, const char *file) {
|
||||
|
||||
static int projectInit(RCore *core) {
|
||||
char *prjdir = r_file_abspath (r_config_get (
|
||||
core->config, "dir.projects"));
|
||||
core->config, "dir.projects"));
|
||||
int ret = r_sys_mkdirp (prjdir);
|
||||
if (!ret) {
|
||||
eprintf ("Cannot mkdir dir.projects\n");
|
||||
@ -122,7 +122,7 @@ R_API int r_core_project_list(RCore *core, int mode) {
|
||||
// todo. escape string
|
||||
if (r_core_is_project (core, foo)) {
|
||||
r_cons_printf ("%s\"%s\"",
|
||||
isfirst ?"":",", foo);
|
||||
isfirst? "": ",", foo);
|
||||
isfirst = false;
|
||||
}
|
||||
}
|
||||
@ -163,7 +163,7 @@ R_API int r_core_project_delete(RCore *core, const char *prjfile) {
|
||||
RList *files = r_sys_dir (path);
|
||||
r_list_foreach (files, iter, f) {
|
||||
char *filepath = r_str_append (strdup (path), R_SYS_DIR);
|
||||
filepath =r_str_append (filepath, f);
|
||||
filepath = r_str_append (filepath, f);
|
||||
if (!r_file_is_directory (filepath)) {
|
||||
eprintf ("rm %s\n", filepath);
|
||||
r_file_rm (filepath);
|
||||
@ -205,7 +205,7 @@ static bool projectLoadRop(RCore *core, const char *prjfile) {
|
||||
// XXX
|
||||
eprintf ("ENDS WITH\n");
|
||||
path = strdup (prjfile);
|
||||
path [strlen (path) - 3] = 0;
|
||||
path[strlen (path) - 3] = 0;
|
||||
} else if (r_file_fexists ("%s" R_SYS_DIR "rc", prjDir, prjfile)) {
|
||||
path = r_str_newf ("%s" R_SYS_DIR, prjDir, prjfile);
|
||||
} else {
|
||||
@ -329,7 +329,7 @@ R_API RThread *r_core_project_load_bg(RCore *core, const char *prjName, const ch
|
||||
ps->core = core;
|
||||
ps->prjName = strdup (prjName);
|
||||
ps->rcPath = strdup (rcPath);
|
||||
RThread* th = r_th_new (projectLoadBackground, ps, false);
|
||||
RThread *th = r_th_new (projectLoadBackground, ps, false);
|
||||
r_th_start (th, true);
|
||||
return th;
|
||||
}
|
||||
@ -351,7 +351,7 @@ R_API int r_core_project_open(RCore *core, const char *prjfile, bool thready) {
|
||||
return false;
|
||||
}
|
||||
filepath = r_core_project_info (core, prj);
|
||||
//eprintf ("OPENING (%s) from %s\n", prj, r_config_get (core->config, "file.path"));
|
||||
// eprintf ("OPENING (%s) from %s\n", prj, r_config_get (core->config, "file.path"));
|
||||
/* if it is not an URI */
|
||||
if (!filepath) {
|
||||
eprintf ("Cannot retrieve information for project '%s'\n", prj);
|
||||
@ -369,7 +369,7 @@ R_API int r_core_project_open(RCore *core, const char *prjfile, bool thready) {
|
||||
}
|
||||
oldbin = strdup (r_config_get (core->config, "file.path"));
|
||||
if (!strcmp (prjfile, r_config_get (core->config, "prj.name"))) {
|
||||
//eprintf ("Reloading project\n");
|
||||
// eprintf ("Reloading project\n");
|
||||
askuser = 0;
|
||||
#if 0
|
||||
free (prj);
|
||||
@ -404,7 +404,7 @@ R_API int r_core_project_open(RCore *core, const char *prjfile, bool thready) {
|
||||
}
|
||||
}
|
||||
if (thready) {
|
||||
(void)r_core_project_load_bg (core, prjfile, prj);
|
||||
(void) r_core_project_load_bg (core, prjfile, prj);
|
||||
ret = true;
|
||||
} else {
|
||||
/* load sdb stuff in here */
|
||||
@ -562,7 +562,7 @@ static bool projectSaveScript(RCore *core, const char *file, int opts) {
|
||||
}
|
||||
if (opts & R_CORE_PRJ_ANAL_SEEK) {
|
||||
r_cons_printf ("# seek\n"
|
||||
"s 0x%08"PFMT64x"\n", core->offset);
|
||||
"s 0x%08"PFMT64x "\n", core->offset);
|
||||
r_cons_flush ();
|
||||
}
|
||||
|
||||
@ -714,11 +714,11 @@ R_API bool r_core_project_save(RCore *core, const char *prjName) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
R_API char *r_core_project_notes_file (RCore *core, const char *prjName) {
|
||||
R_API char *r_core_project_notes_file(RCore *core, const char *prjName) {
|
||||
char *notes_txt;
|
||||
const char *prjdir = r_config_get (core->config, "dir.projects");
|
||||
char *prjpath = r_file_abspath (prjdir);
|
||||
notes_txt = r_str_newf ("%s"R_SYS_DIR"%s"R_SYS_DIR"notes.txt", prjpath, prjName);
|
||||
notes_txt = r_str_newf ("%s"R_SYS_DIR "%s"R_SYS_DIR "notes.txt", prjpath, prjName);
|
||||
free (prjpath);
|
||||
return notes_txt;
|
||||
}
|
||||
@ -759,7 +759,7 @@ static bool projectLoadXrefs(RCore *core, const char *prjName) {
|
||||
sdb_free (DB);
|
||||
}
|
||||
const char *xrefs_path = r_file_fexists ("%s" R_SYS_DIR "xrefs.sdb", path)
|
||||
? "xrefs.sdb": "xrefs";
|
||||
? "xrefs.sdb": "xrefs";
|
||||
DB = sdb_new (path, xrefs_path, 0);
|
||||
if (!DB) {
|
||||
free (db);
|
||||
@ -777,8 +777,8 @@ R_API bool r_core_project_load(RCore *core, const char *prjName, const char *rcp
|
||||
const bool cfg_fortunes = r_config_get_i (core->config, "cfg.fortunes");
|
||||
const bool scr_interactive = r_config_get_i (core->config, "scr.interactive");
|
||||
const bool scr_prompt = r_config_get_i (core->config, "scr.prompt");
|
||||
(void)projectLoadRop (core, prjName);
|
||||
(void)projectLoadXrefs (core, prjName);
|
||||
(void) projectLoadRop (core, prjName);
|
||||
(void) projectLoadXrefs (core, prjName);
|
||||
bool ret = r_core_cmd_file (core, rcpath);
|
||||
r_config_set_i (core->config, "cfg.fortunes", cfg_fortunes);
|
||||
r_config_set_i (core->config, "scr.interactive", scr_interactive);
|
||||
|
@ -385,7 +385,7 @@ static void activateDieTime (RCore *core) {
|
||||
// return 1 on error
|
||||
static int r_core_rtr_http_run(RCore *core, int launch, const char *path) {
|
||||
RConfig *newcfg = NULL, *origcfg = NULL;
|
||||
char headers[128] = {0};
|
||||
char headers[128] = R_EMPTY;
|
||||
RSocketHTTPRequest *rs;
|
||||
char buf[32];
|
||||
int ret = 0;
|
||||
|
@ -2410,7 +2410,7 @@ static bool isDisasmPrint(int mode) {
|
||||
static void handleHints(RCore *core) {
|
||||
//TODO extend for more anal hints
|
||||
int i = 0;
|
||||
char ch[64] = {0};
|
||||
char ch[64] = R_EMPTY;
|
||||
const char *lines[] = {"[dh]- Define anal hint:"
|
||||
," b [16,32,64] set bits hint"
|
||||
, NULL};
|
||||
|
Loading…
Reference in New Issue
Block a user