Multiple refactors in io and util ##io ##util ##refactor

* Add r_io_map macros throughout code base
* Update string NULL-checking with renamed functions r_str_get() and r_str_getf()
* Change string NULL-checks throughout code base to use functions
* Add r_str_get_fail() to specify a custom string to return if NULL-check fails
* Mark JSON to be updated with PJ with "TODO PJ"
* Incidental style updates such as missing spaces
This commit is contained in:
Lazula 2020-12-08 08:57:08 -06:00 committed by condret
parent d179c5719a
commit 243bc871c3
92 changed files with 426 additions and 327 deletions

View File

@ -1142,9 +1142,9 @@ R_API char *r2r_test_name(R2RTest *test) {
}
return strdup ("<unnamed>");
case R2R_TEST_TYPE_ASM:
return r_str_newf ("<asm> %s", test->asm_test->disasm ? test->asm_test->disasm : "");
return r_str_newf ("<asm> %s", r_str_get (test->asm_test->disasm));
case R2R_TEST_TYPE_JSON:
return r_str_newf ("<json> %s", test->json_test->cmd ? test->json_test->cmd: "");
return r_str_newf ("<json> %s", r_str_get (test->json_test->cmd));
case R2R_TEST_TYPE_FUZZ:
return r_str_newf ("<fuzz> %s", test->fuzz_test->file);
}

View File

@ -82,7 +82,7 @@ R_API char *r_anal_cc_get(RAnal *anal, const char *name) {
}
RStrBuf *sb = r_strbuf_new (NULL);
const char *self = r_anal_cc_self (anal, name);
r_strbuf_appendf (sb, "%s %s%s%s (", ret, self? self: "", self? ".": "", name);
r_strbuf_appendf (sb, "%s %s%s%s (", ret, r_str_get (self), self? ".": "", name);
bool isFirst = true;
for (i = 0; i < R_ANAL_CC_MAXARG; i++) {
const char *k = sdb_fmt ("cc.%s.arg%d", name, i);

View File

@ -3161,7 +3161,7 @@ R_API bool r_anal_esil_runword(RAnalEsil *esil, const char *word) {
}
int ew = evalWord (esil, word, &str);
eprintf ("ew %d\n", ew);
eprintf ("--> %s\n", r_str_get (str));
eprintf ("--> %s\n", r_str_getf (str));
}
return true;
}

View File

@ -997,7 +997,7 @@ repeat:
bool must_eob = true;
RIOMap *map = anal->iob.map_get (anal->iob.io, addr);
if (map) {
must_eob = (op.jump < map->itv.addr || op.jump >= map->itv.addr + map->itv.size);
must_eob = ( ! r_io_map_contain (map, op.jump) );
}
if (must_eob) {
op.jump = UT64_MAX;

View File

@ -17,20 +17,20 @@
#define INSOP64(x) insn->detail->arm64.operands[x]
/* arm32 */
#define REG(x) r_str_get (cs_reg_name (*handle, insn->detail->arm.operands[x].reg))
#define REG64(x) r_str_get (cs_reg_name (*handle, insn->detail->arm64.operands[x].reg))
#define REG(x) r_str_getf (cs_reg_name (*handle, insn->detail->arm.operands[x].reg))
#define REG64(x) r_str_getf (cs_reg_name (*handle, insn->detail->arm64.operands[x].reg))
#define REGID64(x) insn->detail->arm64.operands[x].reg
#define REGID(x) insn->detail->arm.operands[x].reg
#define IMM(x) (ut32)(insn->detail->arm.operands[x].imm)
#define INSOP(x) insn->detail->arm.operands[x]
#define MEMBASE(x) r_str_get (cs_reg_name (*handle, insn->detail->arm.operands[x].mem.base))
#define MEMBASE64(x) r_str_get (cs_reg_name (*handle, insn->detail->arm64.operands[x].mem.base))
#define MEMBASE(x) r_str_getf (cs_reg_name (*handle, insn->detail->arm.operands[x].mem.base))
#define MEMBASE64(x) r_str_getf (cs_reg_name (*handle, insn->detail->arm64.operands[x].mem.base))
#define REGBASE(x) insn->detail->arm.operands[x].mem.base
#define REGBASE64(x) insn->detail->arm64.operands[x].mem.base
// s/index/base|reg/
#define MEMINDEX(x) r_str_get (cs_reg_name (*handle, insn->detail->arm.operands[x].mem.index))
#define MEMINDEX(x) r_str_getf (cs_reg_name (*handle, insn->detail->arm.operands[x].mem.index))
#define HASMEMINDEX(x) (insn->detail->arm.operands[x].mem.index != ARM_REG_INVALID)
#define MEMINDEX64(x) r_str_get (cs_reg_name (*handle, insn->detail->arm64.operands[x].mem.index))
#define MEMINDEX64(x) r_str_getf (cs_reg_name (*handle, insn->detail->arm64.operands[x].mem.index))
#define HASMEMINDEX64(x) (insn->detail->arm64.operands[x].mem.index != ARM64_REG_INVALID)
#define MEMDISP(x) insn->detail->arm.operands[x].mem.disp
#define MEMDISP64(x) (ut64)insn->detail->arm64.operands[x].mem.disp
@ -223,6 +223,7 @@ static const char *cc_name(arm_cc cc) {
}
}
//TODO PJ
static void opex(RStrBuf *buf, csh handle, cs_insn *insn) {
int i;
r_strbuf_init (buf);
@ -835,12 +836,12 @@ static const char *arg(RAnal *a, csh *handle, cs_insn *insn, char *buf, int n) {
if (ISSHIFTED (n)) {
sprintf (buf, "%u,%s,%s",
LSHIFT2 (n),
r_str_get (cs_reg_name (*handle,
r_str_getf (cs_reg_name (*handle,
insn->detail->arm.operands[n].reg)),
DECODE_SHIFT (n));
} else {
sprintf (buf, "%s",
r_str_get (cs_reg_name (*handle,
r_str_getf (cs_reg_name (*handle,
insn->detail->arm.operands[n].reg)));
}
break;
@ -3157,13 +3158,13 @@ jmp $$ + 4 + ( [delta] * 2 )
op->type = R_ANAL_OP_TYPE_UJMP;
op->cycles = 2;
op->ptrsize = 2;
op->ireg = r_str_get (cs_reg_name (handle, INSOP (0).mem.index));
op->ireg = r_str_getf (cs_reg_name (handle, INSOP (0).mem.index));
break;
case ARM_INS_TBB: // byte jump table
op->type = R_ANAL_OP_TYPE_UJMP;
op->cycles = 2;
op->ptrsize = 1;
op->ireg = r_str_get (cs_reg_name (handle, INSOP (0).mem.index));
op->ireg = r_str_getf (cs_reg_name (handle, INSOP (0).mem.index));
break;
case ARM_INS_PLD:
op->type = R_ANAL_OP_TYPE_LEA; // not really a lea, just a prefetch
@ -3255,7 +3256,7 @@ jmp $$ + 4 + ( [delta] * 2 )
op->jump = ((addr & ~3LL) + (thumb? 4: 8) + MEMDISP(1)) & UT64_MAX;
op->ptr = (addr & ~3LL) + (thumb? 4: 8) + MEMDISP(1);
op->refptr = 4;
op->reg = r_str_get (cs_reg_name (handle, INSOP (2).reg));
op->reg = r_str_getf (cs_reg_name (handle, INSOP (2).reg));
break;
}
}
@ -3346,7 +3347,7 @@ jmp $$ + 4 + ( [delta] * 2 )
if (ISIMM(1)) {
op->ptr = IMM(1);
}
op->reg = r_str_get (cs_reg_name (handle, INSOP (0).reg));
op->reg = r_str_getf (cs_reg_name (handle, INSOP (0).reg));
/* fall-thru */
case ARM_INS_VCMP:
op->type = R_ANAL_OP_TYPE_CMP;
@ -3454,7 +3455,7 @@ jmp $$ + 4 + ( [delta] * 2 )
op->type = R_ANAL_OP_TYPE_UCJMP;
op->fail = addr+op->size;
op->jump = ((addr & ~3LL) + (thumb? 4: 8) + MEMDISP(1)) & UT64_MAX;
op->ireg = r_str_get (cs_reg_name (handle, INSOP (1).mem.index));
op->ireg = r_str_getf (cs_reg_name (handle, INSOP (1).mem.index));
break;
}
}
@ -3786,9 +3787,9 @@ static void op_fillval (RAnal *anal, RAnalOp *op, csh handle, cs_insn *insn, int
break;
}
if ((bits == 64) && HASMEMINDEX64 (1)) {
op->ireg = r_str_get (cs_reg_name (handle, INSOP64 (1).mem.index));
op->ireg = r_str_getf (cs_reg_name (handle, INSOP64 (1).mem.index));
} else if (HASMEMINDEX (1)) {
op->ireg = r_str_get (cs_reg_name (handle, INSOP (1).mem.index));
op->ireg = r_str_getf (cs_reg_name (handle, INSOP (1).mem.index));
op->scale = INSOP (1).mem.scale;
}
}

View File

@ -59,6 +59,7 @@ static inline void handle_jump_instruction(RAnalOp *op, ut64 addr, cs_m68k *m68k
op->fail = make_64bits_address (addr + op->size);
}
//TODO PJ
static void opex(RStrBuf *buf, csh handle, cs_insn *insn) {
int i;
r_strbuf_init (buf);

View File

@ -121,6 +121,7 @@ static inline void es_add_ck(RAnalOp *op, const char *a1, const char *a2, const
ARG(1), REG(0));\
}
//TODO PJ
static void opex(RStrBuf *buf, csh handle, cs_insn *insn) {
int i;
r_strbuf_init (buf);

View File

@ -160,6 +160,7 @@ static const char* getspr(struct Getarg *gop, int n) {
return cspr;
}
//TODO PJ
static void opex(RStrBuf *buf, csh handle, cs_insn *insn) {
int i;
r_strbuf_init (buf);

View File

@ -101,6 +101,7 @@
ARG(1), REG(0));\
}
//TODO PJ
static void opex(RStrBuf *buf, csh handle, cs_insn *insn) {
int i;
r_strbuf_init (buf);

View File

@ -13,6 +13,7 @@
#define INSOP(n) insn->detail->sparc.operands[n]
#define INSCC insn->detail->sparc.cc
//TODO PJ
static void opex(RStrBuf *buf, csh handle, cs_insn *insn) {
int i;
r_strbuf_init (buf);

View File

@ -13,6 +13,7 @@
#define esilprintf(op, fmt, ...) r_strbuf_setf (&op->esil, fmt, ##__VA_ARGS__)
#define INSOP(n) insn->detail->sysz.operands[n]
//TODO PJ
static void opex(RStrBuf *buf, csh handle, cs_insn *insn) {
int i;
r_strbuf_init (buf);

View File

@ -22,6 +22,7 @@
#define INSOP(n) insn->detail->tms320c64x.operands[n]
#define INSCC insn->detail->tms320c64x.cc
//TODO PJ
static void opex(RStrBuf *buf, csh handle, cs_insn *insn) {
int i;
r_strbuf_init (buf);

View File

@ -106,6 +106,7 @@ static void hidden_op(cs_insn *insn, cs_x86 *x, int mode) {
}
}
//TODO PJ
static void opex(RStrBuf *buf, cs_insn *insn, int mode) {
int i;
r_strbuf_init (buf);
@ -232,7 +233,7 @@ static bool is_xmm_reg(cs_x86_op op) {
static char *getarg(struct Getarg* gop, int n, int set, char *setop, int sel, ut32 *bitsize) {
static char buf[AR_DIM][BUF_SZ];
char *out = buf[sel];
char *setarg = setop ? setop : "";
const char *setarg = r_str_get (setop);
cs_insn *insn = gop->insn;
csh handle = gop->handle;
cs_x86_op op;

View File

@ -12,6 +12,7 @@
#define esilprintf(op, fmt, ...) r_strbuf_setf (&op->esil, fmt, ##__VA_ARGS__)
#define INSOP(n) insn->detail->xcore.operands[n]
//TODO PJ
static void opex(RStrBuf *buf, csh handle, cs_insn *insn) {
int i;
r_strbuf_init (buf);

View File

@ -298,6 +298,7 @@ static void rtti_msvc_print_complete_object_locator(rtti_complete_object_locator
prefix, col->object_base);
}
//TODO PJ
static void rtti_msvc_print_complete_object_locator_json(rtti_complete_object_locator *col) {
r_cons_printf ("{\"signature\":%"PFMT32u",\"vftable_offset\":%"PFMT32u",\"cd_offset\":%"PFMT32u","
"\"type_desc_addr\":%"PFMT32u",\"class_desc_addr\":%"PFMT32u",\"object_base\":%"PFMT32u"}",
@ -316,6 +317,7 @@ static void rtti_msvc_print_type_descriptor(rtti_type_descriptor *td, ut64 addr,
prefix, td->name);
}
//TODO PJ
static void rtti_msvc_print_type_descriptor_json(rtti_type_descriptor *td) {
r_cons_printf ("{\"vtable_addr\":%"PFMT64u",\"spare\":%"PFMT64u",\"name\":\"%s\"}",
td->vtable_addr, td->spare, td->name);
@ -334,6 +336,7 @@ static void rtti_msvc_print_class_hierarchy_descriptor(rtti_class_hierarchy_desc
prefix, chd->base_class_array_addr);
}
//TODO
static void rtti_msvc_print_class_hierarchy_descriptor_json(rtti_class_hierarchy_descriptor *chd) {
r_cons_printf ("{\"signature\":%"PFMT32u",\"attributes\":%"PFMT32u",\"num_base_classes\":%"PFMT32u","
"\"base_class_array_addr\":%"PFMT32u"}",
@ -359,6 +362,7 @@ static void rtti_msvc_print_base_class_descriptor(rtti_base_class_descriptor *bc
prefix, bcd->attributes);
}
//TODO PJ
static void rtti_msvc_print_base_class_descriptor_json(rtti_base_class_descriptor *bcd) {
r_cons_printf ("{\"type_desc_addr\":%"PFMT32u",\"num_contained_bases\":%"PFMT32u","
"\"where\":{\"mdisp\":%"PFMT32d",\"pdisp\":%"PFMT32d",\"vdisp\":%"PFMT32d"},"
@ -517,6 +521,7 @@ static bool rtti_msvc_print_complete_object_locator_recurse(RVTableContext *cont
}
//TODO PJ
// print
if (use_json) {
r_cons_print ("{\"complete_object_locator\":");

View File

@ -294,6 +294,7 @@ R_API void r_anal_list_vtables(RAnal *anal, int rad) {
RList *vtables = r_anal_vtable_search (&context);
//TODO PJ
if (rad == 'j') {
bool isFirstElement = true;
r_cons_print ("[");

View File

@ -319,6 +319,7 @@ static ut32 arm_disasm_blocktrans(struct winedbg_arm_insn *arminsn, ut32 inst) {
}
}
//TODO PJ
arminsn->str_asm = r_str_appendf (arminsn->str_asm, "%s%s%s %s%s, {", load ? "ldm" : "stm", tbl_addrmode[addrmode],
get_cond (inst), tbl_regs[get_nibble (inst, 4)], writeback ? "!" : "");
for (i=0;i<=15;i++) {
@ -441,6 +442,7 @@ static ut16 thumb_disasm_pushpop(struct winedbg_arm_insn *arminsn, ut16 inst) {
}
last = i;
//TODO PJ
arminsn->str_asm = r_str_appendf (arminsn->str_asm, "%s {", load ? "pop" : "push");
for (i=0;i<=7;i++) {
@ -473,6 +475,7 @@ static ut16 thumb_disasm_blocktrans(struct winedbg_arm_insn *arminsn, ut16 inst)
}
last = i;
//TODO PJ
arminsn->str_asm = r_str_appendf (arminsn->str_asm, "%s %s!, {", load ? "ldmia" : "stmia", tbl_regs[(inst >> 8) & 0x07]);
for (i=0;i<=7;i++) {

View File

@ -328,7 +328,7 @@ R_API bool r_asm_use(RAsm *a, const char *name) {
if (!strcmp (h->name, name) && h->arch) {
if (!a->cur || (a->cur && strcmp (a->cur->arch, h->arch))) {
char *r2prefix = r_str_r2_prefix (R2_SDB_OPCODES);
char *file = r_str_newf ("%s/%s.sdb", r_str_get (r2prefix), h->arch);
char *file = r_str_newf ("%s/%s.sdb", r_str_getf (r2prefix), h->arch);
if (file) {
r_asm_set_cpu (a, NULL);
sdb_free (a->pair);

View File

@ -484,6 +484,7 @@ static bool r_bin_print_plugin_details(RBin *bin, RBinPlugin *bp, int json) {
if (json == 'q') {
bin->cb_printf ("%s\n", bp->name);
} else if (json) {
//TODO PJ
bin->cb_printf (
"{\"name\":\"%s\",\"description\":\"%s\","
"\"license\":\"%s\"}\n",
@ -508,6 +509,7 @@ static void __printXtrPluginDetails(RBin *bin, RBinXtrPlugin *bx, int json) {
if (json == 'q') {
bin->cb_printf ("%s\n", bx->name);
} else if (json) {
//TODO PJ
bin->cb_printf (
"{\"name\":\"%s\",\"description\":\"%s\","
"\"license\":\"%s\"}\n",
@ -560,6 +562,7 @@ R_API void r_bin_list(RBin *bin, int format) {
bin->cb_printf ("%s\n", bx->name);
}
} else if (format) {
//TODO PJ
int i;
i = 0;
@ -596,8 +599,8 @@ R_API void r_bin_list(RBin *bin, int format) {
r_list_foreach (bin->plugins, it, bp) {
bin->cb_printf ("bin %-11s %s (%s) %s %s\n",
bp->name, bp->desc, bp->license? bp->license: "???",
bp->version? bp->version: "",
bp->author? bp->author: "");
r_str_get (bp->version),
r_str_get (bp->author));
}
r_list_foreach (bin->binxtrs, it, bx) {
const char *name = strncmp (bx->name, "xtr.", 4)? bx->name : bx->name + 3;

View File

@ -79,7 +79,7 @@ R_API int r_bin_load_languages(RBinFile *binfile) {
bool cxxIsChecked = false;
bool isMsvc = false;
char *ft = info->rclass? info->rclass: "";
const char *ft = r_str_get (info->rclass);
bool unknownType = info->rclass == NULL;
bool isMacho = strstr (ft, "mach");
bool isElf = strstr (ft, "elf");

View File

@ -56,9 +56,9 @@ R_API char *r_bin_addr2text(RBin *bin, ut64 addr, int origin) {
}
if (origin) {
char *res = r_str_newf ("%s:%d%s%s",
file_nopath? file_nopath: "",
r_str_get (file_nopath),
line, file_nopath? " ": "",
out? out: "");
r_str_get (out));
free (out);
out = res;
}
@ -88,7 +88,7 @@ R_API char *r_bin_addr2text(RBin *bin, ut64 addr, int origin) {
file_nopath = file;
}
}
return r_str_newf ("%s:%d", file_nopath? file_nopath: "", line);
return r_str_newf ("%s:%d", r_str_get (file_nopath), line);
}
out2 = malloc ((strlen (file) + 64 + strlen (out)) * sizeof (char));
if (origin > 1) {

View File

@ -512,7 +512,7 @@ static const ut8 *parse_line_header_source(RBinFile *bf, const ut8 *buf, const u
}
if (hdr->file_names) {
hdr->file_names[count].name = r_str_newf("%s/%s", include_dir ? include_dir : "", filename);
hdr->file_names[count].name = r_str_newf("%s/%s", r_str_get (include_dir), filename);
hdr->file_names[count].id_idx = id_idx;
hdr->file_names[count].mod_time = mod_time;
hdr->file_names[count].file_len = file_len;

View File

@ -538,7 +538,7 @@ RList *r_bin_le_get_relocs(r_bin_le_obj_t *bin) {
ut64 off = (ut64)h->impproc + nameoff + bin->headerOff;
char *proc_name = __read_nonnull_str_at (bin->buf, &off);
char *mod_name = __get_modname_by_ord (bin, ordinal);
imp->name = r_str_newf ("%s.%s", mod_name ? mod_name : "", proc_name ? proc_name : "");
imp->name = r_str_newf ("%s.%s", r_str_get (mod_name), r_str_get (proc_name));
rel->import = imp;
break;
}

View File

@ -4111,11 +4111,11 @@ void MACH0_(mach_headerfields)(RBinFile *bf) {
#if 0
{
char *id = r_buf_get_string (buf, addr + 20);
cb_printf ("0x%08"PFMT64x" id 0x%x\n", addr + 20, id? id: "");
cb_printf ("0x%08"PFMT64x" symooff 0x%x\n", addr + 20, id? id: "");
cb_printf ("0x%08"PFMT64x" nsyms %d\n", addr + 20, id? id: "");
cb_printf ("0x%08"PFMT64x" stroff 0x%x\n", addr + 20, id? id: "");
cb_printf ("0x%08"PFMT64x" strsize 0x%x\n", addr + 20, id? id: "");
cb_printf ("0x%08"PFMT64x" id 0x%x\n", addr + 20, r_str_get (id));
cb_printf ("0x%08"PFMT64x" symooff 0x%x\n", addr + 20, r_str_get (id));
cb_printf ("0x%08"PFMT64x" nsyms %d\n", addr + 20, r_str_get (id));
cb_printf ("0x%08"PFMT64x" stroff 0x%x\n", addr + 20, r_str_get (id));
cb_printf ("0x%08"PFMT64x" strsize 0x%x\n", addr + 20, r_str_get (id));
free (id);
}
#endif
@ -4130,8 +4130,10 @@ void MACH0_(mach_headerfields)(RBinFile *bf) {
pvaddr + 12, r_buf_read_le16_at (buf, addr + 14), r_buf_read8_at (buf, addr + 13),
r_buf_read8_at (buf, addr + 12));
cb_printf ("0x%08"PFMT64x" id %s\n",
pvaddr + str_off - 8, id? id: "");
free (id);
pvaddr + str_off - 8, r_str_get (id));
if (id) {
free (id);
}
break;
}
case LC_UUID:
@ -4175,15 +4177,19 @@ void MACH0_(mach_headerfields)(RBinFile *bf) {
pvaddr + 12, r_buf_read_le16_at (buf, addr + 14), r_buf_read8_at (buf, addr + 13),
r_buf_read8_at (buf, addr + 12));
cb_printf ("0x%08"PFMT64x" load_dylib %s\n",
pvaddr + str_off - 8, load_dylib? load_dylib: "");
free (load_dylib);
pvaddr + str_off - 8, r_str_get (load_dylib));
if (load_dylib) {
free (load_dylib);
}
break;
}
case LC_RPATH: {
char *rpath = r_buf_get_string (buf, addr + 4);
cb_printf ("0x%08" PFMT64x " rpath %s\n",
pvaddr + 4, rpath ? rpath : "");
free (rpath);
pvaddr + 4, r_str_get (rpath));
if (rpath) {
free (rpath);
}
break;
}
case LC_ENCRYPTION_INFO:

View File

@ -1155,7 +1155,7 @@ static bool extract_sections_symbols(pyc_object *obj, RList *sections, RList *sy
}
section = R_NEW0 (RBinSection);
symbol = R_NEW0 (RBinSymbol);
prefix = r_str_newf ("%s%s%s", prefix? prefix: "",
prefix = r_str_newf ("%s%s%s", r_str_get (prefix),
prefix? ".": "", (const char *)cobj->name->data);
if (!prefix || !section || !symbol) {
goto fail;

View File

@ -114,7 +114,7 @@ static RList* entries(RBinFile *bf) {
static void addsym(RList *ret, const char *name, ut64 addr) {
RBinSymbol *ptr = R_NEW0 (RBinSymbol);
if (ptr) {
ptr->name = strdup (name? name: "");
ptr->name = strdup (r_str_get (name));
ptr->paddr = ptr->vaddr = addr;
ptr->size = 0;
ptr->ordinal = 0;

View File

@ -488,8 +488,8 @@ static RList *patch_relocs(RBin *b) {
ut64 offset = 0;
r_pvector_foreach (&io->maps, it) {
RIOMap *map = *it;
if ((map->itv.addr + map->itv.size) > offset) {
offset = map->itv.addr + map->itv.size;
if (r_io_map_end (map) > offset) {
offset = r_io_map_end (map);
}
}
m_vaddr = R_ROUND (offset, 16);

View File

@ -1118,7 +1118,7 @@ static void parse_dex_class_fields(RBinFile *bf, RBinDexClass *c, RBinClass *cls
bin->cb_printf (" name : '%s'\n", fieldName);
bin->cb_printf (" type : '%s'\n", type_str);
bin->cb_printf (" access : 0x%04x (%s)\n",
(ut32)accessFlags, accessStr? accessStr: "");
(ut32)accessFlags, r_str_get (accessStr));
}
r_list_append (dex->methods_list, sym);
@ -1491,7 +1491,7 @@ static void parse_class(RBinFile *bf, RBinDexClass *c, int class_index, int *met
goto beach;
}
const char *str = createAccessFlagStr (c->access_flags, kAccessForClass);
cls->visibility_str = strdup (str? str: "");
cls->visibility_str = strdup (r_str_get (str));
r_list_append (dex->classes_list, cls);
if (dexdump) {
rbin->cb_printf (" Class descriptor : '%s;'\n", cls->name);

View File

@ -923,8 +923,8 @@ static RList* patch_relocs(RBin *b) {
void **it;
r_pvector_foreach (&io->maps, it) {
RIOMap *map = *it;
if (map->itv.addr > offset) {
offset = map->itv.addr;
if (r_io_map_begin (map) > offset) {
offset = r_io_map_begin (map);
g = map;
}
}

View File

@ -135,7 +135,7 @@ static RBinInfo *info(RBinFile *bf) {
info->cpu = strdup (bin->cpu);
info->os = strdup (bin->os);
info->arch = strdup (bin->arch);
info->file = strdup (bin->filename ? bin->filename : "");
info->file = strdup (r_str_get (bin->filename));
info->big_endian = h->worder;
info->has_va = true;
info->baddr = 0;

View File

@ -615,8 +615,8 @@ static RList* patch_relocs(RBin *b) {
void **vit;
r_pvector_foreach (&io->maps, vit) {
RIOMap *map = *vit;
if (map->itv.addr > offset) {
offset = map->itv.addr;
if (r_io_map_begin (map) > offset) {
offset = r_io_map_begin (map);
g = map;
}
}

View File

@ -45,7 +45,7 @@ static void addsym(RList *ret, const char *name, ut64 addr, ut32 size) {
if (!ptr) {
return;
}
ptr->name = strdup (name? name: "");
ptr->name = strdup (r_str_get (name));
ptr->paddr = ptr->vaddr = addr;
ptr->size = size;
ptr->ordinal = 0;

View File

@ -101,7 +101,7 @@ static void addsym(RList *ret, const char *name, ut64 addr, ut32 size) {
if (!ptr) {
return;
}
ptr->name = strdup (name? name: "");
ptr->name = strdup (r_str_get (name));
ptr->paddr = ptr->vaddr = addr;
ptr->size = size;
ptr->ordinal = 0;

View File

@ -132,7 +132,7 @@ static void addsym(RList *ret, const char *name, ut64 addr) {
if (!ptr) {
return;
}
ptr->name = strdup (name? name: "");
ptr->name = strdup (r_str_get (name));
ptr->paddr = ptr->vaddr = addr;
ptr->size = 0;
ptr->ordinal = 0;

View File

@ -201,6 +201,7 @@ int r_bin_pdb_download(RCore *core, int isradjson, int *actions_done, SPDBOption
init_pdb_downloader (&opt, &pdb_downloader);
ret = pdb_downloader.download ? pdb_downloader.download (&pdb_downloader) : 0;
if (isradjson && actions_done) {
//TODO PJ
printf ("%s\"pdb\":{\"file\":\"%s\",\"download\":%s}",
*actions_done ? "," : "", opt.dbg_file, ret ? "true" : "false");
} else {

View File

@ -302,10 +302,10 @@ R_API int r_bp_list(RBreakpoint *bp, int rad) {
b->trace ? "trace" : "break",
b->enabled ? "enabled" : "disabled",
r_bp_is_valid (bp, b) ? "valid" : "invalid",
r_str_get2 (b->data),
r_str_get2 (b->cond),
r_str_get2 (b->name),
r_str_get2 (b->module_name));
r_str_get (b->data),
r_str_get (b->cond),
r_str_get (b->name),
r_str_get (b->module_name));
break;
case 1:
case 'r':
@ -318,9 +318,10 @@ R_API int r_bp_list(RBreakpoint *bp, int rad) {
}
//b->trace? "trace": "break",
//b->enabled? "enabled": "disabled",
// b->data? b->data: "");
//r_str_get (b->data));
break;
case 'j':
//TODO PJ
bp->cb_printf ("%s{\"addr\":%"PFMT64d",\"size\":%d,"
"\"prot\":\"%c%c%c\",\"hw\":%s,"
"\"trace\":%s,\"enabled\":%s,"
@ -335,8 +336,8 @@ R_API int r_bp_list(RBreakpoint *bp, int rad) {
b->trace ? "true" : "false",
b->enabled ? "true" : "false",
r_bp_is_valid (bp, b) ? "true" : "false",
r_str_get2 (b->data),
r_str_get2 (b->cond));
r_str_get (b->data),
r_str_get (b->cond));
break;
}
/* TODO: Show list of pids and trace points, conditionals */

View File

@ -9,7 +9,7 @@ R_API RConfigNode* r_config_node_new(const char *name, const char *value) {
return NULL;
}
node->name = strdup (name);
node->value = strdup (value? value: "");
node->value = strdup (r_str_get (value));
node->flags = CN_RW | CN_STR;
node->i_value = r_num_get (NULL, value);
node->options = r_list_new ();
@ -23,8 +23,8 @@ R_API RConfigNode* r_config_node_clone(RConfigNode *n) {
return NULL;
}
cn->name = strdup (n->name);
cn->desc = n->desc? strdup (n->desc): NULL;
cn->value = strdup (n->value? n->value: "");
cn->desc = n->desc ? strdup (n->desc) : NULL;
cn->value = strdup (r_str_get (n->value));
cn->i_value = n->i_value;
cn->flags = n->flags;
cn->setter = n->setter;
@ -182,7 +182,7 @@ R_API void r_config_list(RConfig *cfg, const char *str, int rad) {
if (!str || (str && (!strncmp (str, node->name, len)))) {
if (!str || !strncmp (str, node->name, len)) {
cfg->cb_printf ("%20s: %s\n", node->name,
node->desc? node->desc: "");
r_str_get (node->desc));
}
}
}
@ -457,8 +457,10 @@ R_API RConfigNode* r_config_set(RConfig *cfg, const char *name, const char *valu
node->i_value = oi;
}
free (node->value);
node->value = strdup (ov? ov: "");
free (ov);
node->value = strdup (r_str_get (ov));
if (ov) {
free (ov);
}
return NULL;
}
}

View File

@ -734,7 +734,7 @@ R_API void r_line_autocomplete(void) {
I.buffer.index, strlen (I.buffer.data), ' ');
const char *t = end_word != NULL?
end_word: I.buffer.data + I.buffer.index;
int largv0 = strlen (argv[0]? argv[0]: "");
int largv0 = strlen (r_str_get (argv[0]));
size_t len_t = strlen (t);
p[largv0]='\0';

View File

@ -608,8 +608,8 @@ static bool r_anal_try_get_fcn(RCore *core, RAnalRef *ref, int fcndepth, int ref
if (map->perm & R_PERM_X) {
ut8 buf[64];
r_io_read_at (core->io, ref->addr, buf, sizeof (buf));
bool looksLikeAFunction = r_anal_check_fcn (core->anal, buf, sizeof (buf), ref->addr, map->itv.addr,
map->itv.addr + map->itv.size);
bool looksLikeAFunction = r_anal_check_fcn (core->anal, buf, sizeof (buf), ref->addr, r_io_map_begin (map),
r_io_map_end (map));
if (looksLikeAFunction) {
if (core->anal->limit) {
if (ref->addr < core->anal->limit->from ||
@ -1857,7 +1857,7 @@ static int core_anal_graph_nodes(RCore *core, RAnalFunction *fcn, int opts, PJ *
// TODO: show vars, refs and xrefs
char *fcn_name_escaped = r_str_escape_utf8_for_json (fcn->name, -1);
pj_o (pj);
pj_ks (pj, "name", r_str_get (fcn_name_escaped));
pj_ks (pj, "name", r_str_getf (fcn_name_escaped));
free (fcn_name_escaped);
pj_kn (pj, "offset", fcn->addr);
pj_ki (pj, "ninstr", fcn->ninstr);
@ -2448,6 +2448,7 @@ repeat:
break;
}
case R_GRAPH_FORMAT_JSON:
//TODO PJ
if (usenames) {
r_cons_printf ("%s{\"name\":\"%s\", "
"\"size\":%" PFMT64u ",\"imports\":[",
@ -2621,7 +2622,7 @@ R_API char *r_core_anal_fcn_name(RCore *core, RAnalFunction *fcn) {
bool demangle = r_config_get_i (core->config, "bin.demangle");
const char *lang = demangle ? r_config_get (core->config, "bin.lang") : NULL;
bool keep_lib = r_config_get_i (core->config, "bin.demangle.libs");
char *name = strdup (fcn->name ? fcn->name : "");
char *name = strdup (r_str_get (fcn->name));
if (demangle) {
char *tmp = r_bin_demangle (core->bin->cur, lang, name, fcn->addr, keep_lib);
if (tmp) {
@ -5085,7 +5086,7 @@ R_API void r_core_anal_esil(RCore *core, const char *str, const char *target) {
} else {
RIOMap *map = r_io_map_get (core->io, addr);
if (map) {
end = map->itv.addr + map->itv.size;
end = r_io_map_end (map);
} else {
end = addr + core->blocksize;
}

View File

@ -2,8 +2,8 @@
#include <r_core.h>
#include <r_config.h>
#include "r_util.h"
#include "r_util/r_time.h"
#include <r_util.h>
#include <r_util/r_time.h>
#define is_in_range(at, from, sz) ((at) >= (from) && (at) < ((from) + (sz)))
@ -131,7 +131,6 @@ static void pair_str(const char *key, const char *val, int mode, int last) {
}
}
#define STR(x) (x)? (x): ""
R_API int r_core_bin_set_cur(RCore *core, RBinFile *binfile);
static ut64 rva(RBin *bin, ut64 paddr, ut64 vaddr, int va) {
@ -475,7 +474,7 @@ static void _print_strings(RCore *r, RList *list, int mode, int va) {
pj_a (pj);
for (; *block_ptr != -1; block_ptr++) {
const char *utfName = r_utf_block_name (*block_ptr);
pj_s (pj, utfName? utfName: "");
pj_s (pj, r_str_get (utfName));
}
pj_end (pj);
R_FREE (block_list);
@ -539,7 +538,7 @@ static void _print_strings(RCore *r, RList *list, int mode, int va) {
r_strbuf_append (buf, ",");
}
const char *name = r_utf_block_name (*block_ptr);
r_strbuf_appendf (buf,"%s", name? name: "");
r_strbuf_appendf (buf, "%s", r_str_get (name));
}
free (block_list);
}
@ -986,6 +985,7 @@ static int bin_info(RCore *r, int mode, ut64 laddr) {
pair_str ("subsys", info->subsystem, mode, false);
pair_bool ("va", info->has_va, mode, true);
if (IS_MODE_JSON (mode)) {
//TODO PJ
r_cons_printf (",\"checksums\":{");
for (i = 0; info->sum[i].type; i++) {
RBinHash *h = &info->sum[i];
@ -1179,7 +1179,7 @@ static int bin_dwarf(RCore *core, int mode) {
// TODO: use CL here.. but its not necessary.. so better not do anything imho
// r_core_cmdf (core, "CL %s:%d 0x%08"PFMT64x, file, (int)row->line, row->address);
#if 0
char *cmt = r_str_newf ("%s:%d %s", file, (int)row->line, line? line: "");
char *cmt = r_str_newf ("%s:%d %s", file, (int)row->line, r_str_get (line));
r_meta_set_string (core->anal, R_META_TYPE_COMMENT, row->address, cmt);
free (cmt);
#endif
@ -1197,7 +1197,7 @@ static int bin_dwarf(RCore *core, int mode) {
pj_ks (j, "name", "CL");
pj_ks (j, "file", file);
pj_ki (j, "line_num", (int) row->line);
pj_ks (j, "line", line ? line : "");
pj_ks (j, "line", r_str_get (line));
pj_kn (j, "addr", row->address);
pj_end (j);
@ -1209,7 +1209,7 @@ static int bin_dwarf(RCore *core, int mode) {
r_cons_printf ("\"CC %s:%d %s\"@0x%" PFMT64x
"\n",
file, row->line,
line ? line : "", row->address);
r_str_get (line), row->address);
}
free (file);
free (line);
@ -1340,6 +1340,7 @@ static int bin_main(RCore *r, int mode, int va) {
r_cons_printf ("fs symbols\n");
r_cons_printf ("f main @ 0x%08"PFMT64x"\n", addr);
} else if (IS_MODE_JSON (mode)) {
//TODO PJ
r_cons_printf ("{\"vaddr\":%" PFMT64d
",\"paddr\":%" PFMT64d "}", addr, binmain->paddr);
} else {
@ -1428,6 +1429,7 @@ static int bin_entry(RCore *r, int mode, ut64 laddr, int va, bool inifin) {
} else if (IS_MODE_SIMPLE (mode)) {
r_cons_printf ("0x%08"PFMT64x"\n", at);
} else if (IS_MODE_JSON (mode)) {
//TODO PJ
r_cons_printf ("%s{\"vaddr\":%" PFMT64u ","
"\"paddr\":%" PFMT64u ","
"\"baddr\":%" PFMT64u ","
@ -1784,7 +1786,7 @@ static int bin_relocs(RCore *r, int mode, int va) {
if (relname && *relname) {
pj_ks (pj, "name", relname);
}
pj_ks (pj, "demname", mn ? mn : "");
pj_ks (pj, "demname", r_str_get (mn));
pj_ks (pj, "type", bin_reloc_type_name (reloc));
pj_kn (pj, "vaddr", reloc->vaddr);
pj_kn (pj, "paddr", reloc->paddr);
@ -1803,8 +1805,8 @@ static int bin_relocs(RCore *r, int mode, int va) {
} else if (IS_MODE_NORMAL (mode)) {
char *name = reloc->import
? strdup (reloc->import->name)
: reloc->symbol
? strdup (reloc->symbol->name)
: reloc->symbol
? strdup (reloc->symbol->name)
: NULL;
if (bin_demangle) {
char *mn = r_bin_demangle (r->bin->cur, NULL, name, addr, keep_lib);
@ -1814,7 +1816,7 @@ static int bin_relocs(RCore *r, int mode, int va) {
}
}
char *reloc_name = construct_reloc_name (reloc, name);
RStrBuf *buf = r_strbuf_new (reloc_name ? reloc_name : "");
RStrBuf *buf = r_strbuf_new (reloc_name);
free (reloc_name);
R_FREE (name);
if (reloc->addend) {
@ -2025,7 +2027,7 @@ static int bin_imports(RCore *r, int mode, int va, const char *name) {
}
} else if (IS_MODE_SIMPLE (mode)) {
r_cons_printf ("%s%s%s\n",
libname ? libname : "", libname ? " " : "", symname);
r_str_get (libname), libname ? " " : "", symname);
} else if (IS_MODE_SIMPLEST (mode)) {
r_cons_println (symname);
} else if (IS_MODE_JSON (mode)) {
@ -2059,9 +2061,11 @@ static int bin_imports(RCore *r, int mode, int va, const char *name) {
const char *bind = import->bind? import->bind: "NONE";
const char *type = import->type? import->type: "NONE";
if (import->classname && import->classname[0]) {
r_table_add_rowf (table, "nXssss", (ut64)import->ordinal, addr, bind, type, libname ? libname : "", sdb_fmt ("%s.%s", import->classname, symname));
r_table_add_rowf (table, "nXssss", (ut64)import->ordinal, addr, bind, type, r_str_get (libname),
sdb_fmt ("%s.%s", import->classname, symname));
} else {
r_table_add_rowf (table, "nXssss", (ut64)import->ordinal, addr, bind, type, libname ? libname : "", symname);
r_table_add_rowf (table, "nXssss", (ut64)import->ordinal, addr, bind, type, r_str_get (libname),
symname);
}
if (import->descriptor && import->descriptor[0]) {
@ -2124,7 +2128,7 @@ static const char *getPrefixFor(RBinSymbol *sym) {
#define MAXFLAG_LEN_DEFAULT 128
static char *construct_symbol_flagname(const char *pfx, const char *libname, const char *symname, int len) {
char *r = r_str_newf ("%s.%s%s%s", pfx, libname ? libname : "", libname ? "_" : "", symname);
char *r = r_str_newf ("%s.%s%s%s", pfx, r_str_get (libname), libname ? "_" : "", symname);
if (r) {
r_name_filter (r, len); // maybe unnecessary..
char *R = __filterQuotedShell (r);
@ -2377,7 +2381,7 @@ static int bin_symbols(RCore *r, int mode, ut64 laddr, int va, ut64 at, const ch
const char *fn = sn.demflag ? sn.demflag : sn.nameflag;
char *fnp = (r->bin->prefix) ?
r_str_newf ("%s.%s", r->bin->prefix, fn):
strdup (fn? fn: "");
strdup (r_str_get (fn));
RFlagItem *fi = r_flag_set (r->flags, fnp, addr, symbol->size);
if (fi) {
r_flag_item_set_realname (fi, n);
@ -2417,7 +2421,7 @@ static int bin_symbols(RCore *r, int mode, ut64 laddr, int va, ut64 at, const ch
const char *name = sn.demname? sn.demname: r_symbol_name;
r_cons_printf ("0x%08"PFMT64x" %d %s%s%s\n",
addr, (int)symbol->size,
sn.libname ? sn.libname : "", sn.libname ? " " : "",
r_str_get (sn.libname), sn.libname ? " " : "",
name);
} else if (IS_MODE_SIMPLEST (mode)) {
const char *name = sn.demname? sn.demname: r_symbol_name;
@ -2452,7 +2456,7 @@ static int bin_symbols(RCore *r, int mode, ut64 laddr, int va, ut64 at, const ch
goto next;
}
r_cons_printf ("\"f %s%s%s %u 0x%08" PFMT64x "\"\n",
r->bin->prefix ? r->bin->prefix : "", r->bin->prefix ? "." : "",
r_str_get (r->bin->prefix), r->bin->prefix ? "." : "",
flagname, symbol->size, addr);
free (flagname);
}
@ -2482,8 +2486,8 @@ static int bin_symbols(RCore *r, int mode, ut64 laddr, int va, ut64 at, const ch
} else {
const char *bind = symbol->bind? symbol->bind: "NONE";
const char *type = symbol->type? symbol->type: "NONE";
const char *name = r_str_get (sn.demname? sn.demname: sn.name);
// const char *fwd = r_str_get (symbol->forwarder);
const char *name = r_str_getf (sn.demname? sn.demname: sn.name);
// const char *fwd = r_str_getf (symbol->forwarder);
r_table_add_rowf (table, "dssssdss",
symbol->ordinal,
symbol->paddr == UT64_MAX ? " ----------": sdb_fmt (" 0x%08"PFMT64x, symbol->paddr),
@ -2491,7 +2495,7 @@ static int bin_symbols(RCore *r, int mode, ut64 laddr, int va, ut64 at, const ch
bind,
type,
symbol->size,
symbol->libname ? symbol->libname : "",
r_str_get (symbol->libname),
name);
}
next:
@ -2944,7 +2948,7 @@ static int bin_sections(RCore *r, int mode, ut64 laddr, int va, ut64 at, const c
char *pfx = r->bin->prefix;
str = r_str_newf ("[%02d] %s %s size %" PFMT64d" named %s%s%s",
i, perms, type, size,
pfx? pfx: "", pfx? ".": "", section->name);
r_str_get (pfx), pfx ? "." : "", section->name);
r_meta_set (r->anal, R_META_TYPE_COMMENT, addr, 1, str);
R_FREE (str);
}
@ -2987,7 +2991,7 @@ static int bin_sections(RCore *r, int mode, ut64 laddr, int va, ut64 at, const c
r_cons_printf ("0x%"PFMT64x" 0x%"PFMT64x" %s %s%s%s\n",
addr, addr + section->size,
perms,
hashstr ? hashstr : "", hashstr ? " " : "",
r_str_get (hashstr), hashstr ? " " : "",
section->name
);
free (hashstr);
@ -3004,6 +3008,7 @@ static int bin_sections(RCore *r, int mode, ut64 laddr, int va, ut64 at, const c
data, datalen);
free (data);
}
//TODO PJ
r_cons_printf ("%s{\"name\":\"%s\","
"\"size\":%"PFMT64d","
"\"vsize\":%"PFMT64d","
@ -3016,7 +3021,7 @@ static int bin_sections(RCore *r, int mode, ut64 laddr, int va, ut64 at, const c
section->size,
section->vsize,
perms,
hashstr ? hashstr : "",
r_str_get (hashstr),
section->paddr,
addr);
free (hashstr);
@ -3037,7 +3042,7 @@ static int bin_sections(RCore *r, int mode, ut64 laddr, int va, ut64 at, const c
}
if (section->arch || section->bits) {
snprintf (str, sizeof (str), "arch=%s bits=%d ",
r_str_get2 (arch), bits);
r_str_get (arch), bits);
} else {
str[0] = 0;
}
@ -3137,6 +3142,7 @@ static int bin_fields(RCore *r, int mode, int va) {
}
free (n);
} else if (IS_MODE_JSON (mode)) {
//TODO PJ
r_cons_printf ("%s{\"name\":\"%s\","
"\"vaddr\":%"PFMT64d","
"\"paddr\":%"PFMT64d,
@ -3459,7 +3465,7 @@ static int bin_classes(RCore *r, int mode) {
} else if (IS_MODE_SIMPLE (mode)) {
r_cons_printf ("0x%08"PFMT64x" [0x%08"PFMT64x" - 0x%08"PFMT64x"] %s%s%s\n",
c->addr, at_min, at_max, c->name, c->super ? " " : "",
c->super ? c->super : "");
r_str_get (c->super));
} else if (IS_MODE_CLASSDUMP (mode)) {
if (c) {
RBinFile *bf = r_bin_cur (r->bin);
@ -3533,10 +3539,11 @@ static int bin_classes(RCore *r, int mode) {
}
r_cons_printf ("};\"\n");
} else if (IS_MODE_JSON (mode)) {
//TODO PJ
if (c->super) {
r_cons_printf ("%s{\"classname\":\"%s\",\"addr\":%"PFMT64d",\"index\":%d,\"visibility\":\"%s\",\"super\":\"%s\",\"methods\":[",
iter->p ? "," : "", c->name, c->addr,
c->index, c->visibility_str? c->visibility_str: "", c->super);
c->index, r_str_get (c->visibility_str), c->super);
} else {
r_cons_printf ("%s{\"classname\":\"%s\",\"addr\":%"PFMT64d",\"index\":%d,\"methods\":[",
iter->p ? "," : "", c->name, c->addr,
@ -4141,6 +4148,7 @@ static int bin_signature(RCore *r, int mode) {
if (plg && plg->signature) {
const char *signature = plg->signature (cur, IS_MODE_JSON (mode));
if (IS_MODE_JSON (mode)) {
//TODO PJ
r_cons_printf ("{\"signature\":%s}\n", signature);
} else {
r_cons_println (signature);
@ -4369,15 +4377,19 @@ static bool r_core_bin_file_print(RCore *core, RBinFile *bf, int mode) {
break;
case 'j':
// XXX there's only one binobj for each bf...so we should change that json
// TODO: use pj API
// TODO PJ
r_cons_printf ("{\"name\":\"%s\",\"iofd\":%d,\"bfid\":%d,\"size\":%d,\"objs\":[",
name? name: "", bf->fd, bf->id, bin_sz);
r_str_get (name), bf->fd, bf->id, bin_sz);
{
RBinObject *obj = bf->o;
RBinInfo *info = obj->info;
ut8 bits = info ? info->bits : 0;
const char *asmarch = r_config_get (core->config, "asm.arch");
const char *arch = info ? info->arch ? info->arch: asmarch : "unknown";
const char *arch = info
? info->arch
? info->arch
: asmarch
: "unknown";
r_cons_printf ("{\"arch\":\"%s\",\"bits\":%d,\"binoffset\":%"
PFMT64d",\"objsize\":%"PFMT64d"}",
arch, bits, obj->boffset, obj->obj_size);

View File

@ -3340,7 +3340,7 @@ R_API int r_core_config_init(RCore *core) {
free (p);
// R2_LOGFILE / log.file
p = r_sys_getenv ("R2_LOGFILE");
SETCB ("log.file", p ? p : "", cb_log_config_file, "Logging output filename / path");
SETCB ("log.file", r_str_get (p), cb_log_config_file, "Logging output filename / path");
free (p);
// R2_LOGSRCINFO / log.srcinfo
p = r_sys_getenv ("R2_LOGSRCINFO");
@ -3393,7 +3393,7 @@ R_API int r_core_config_init(RCore *core) {
SETCB ("dir.home", p? p: "/", &cb_dirhome, "Path for the home directory");
free (p);
p = r_sys_getenv (R_SYS_TMP);
SETCB ("dir.tmp", p? p: "", &cb_dirtmp, "Path of the tmp directory");
SETCB ("dir.tmp", r_str_get (p), &cb_dirtmp, "Path of the tmp directory");
free (p);
#if __ANDROID__
SETPREF ("dir.projects", "/data/data/org.radare.radare2installer/radare2/projects", "Default path for projects");
@ -3578,7 +3578,7 @@ R_API int r_core_config_init(RCore *core) {
SETBPREF ("http.auth", "false", "Enable/Disable HTTP Authentification");
SETPREF ("http.authtok", "r2admin:r2admin", "HTTP Authentification user:password token");
p = r_sys_getenv ("R2_HTTP_AUTHFILE");
SETPREF ("http.authfile", p? p : "", "HTTP Authentification user file");
SETPREF ("http.authfile", r_str_get (p), "HTTP Authentification user file");
tmpdir = r_file_tmpdir ();
r_config_set (cfg, "http.uproot", tmpdir);
free (tmpdir);

View File

@ -1122,7 +1122,7 @@ R_API int r_core_file_list(RCore *core, int mode) {
char *absfile = r_file_abspath (desc->uri);
r_list_foreach (maps, iter, current_map) {
if (current_map) {
r_cons_printf ("on %s 0x%"PFMT64x "\n", absfile, current_map->itv.addr);
r_cons_printf ("on %s 0x%"PFMT64x "\n", absfile, r_io_map_begin (current_map));
}
}
r_list_free (maps);

View File

@ -429,7 +429,7 @@ R_API bool r_core_extend_at(RCore *core, ut64 addr, int size) {
if (io_va) {
RIOMap *map = r_io_map_get (core->io, core->offset);
if (map) {
addr = addr - map->itv.addr + map->delta;
addr = addr - r_io_map_begin (map) + map->delta;
}
r_config_set_i (core->config, "io.va", false);
}

View File

@ -3030,7 +3030,7 @@ static int r_core_cmd_subst(RCore *core, char *cmd) {
}
}
// TODO: store in core->cmdtimes to speedup ?
const char *cmdrep = core->cmdtimes ? core->cmdtimes: "";
const char *cmdrep = r_str_get (core->cmdtimes);
orep = rep;
r_cons_break_push (NULL, NULL);
@ -4257,8 +4257,8 @@ R_API int r_core_cmd_foreach3(RCore *core, const char *cmd, char *each) { // "@@
if (maps) {
RListIter *iter;
r_list_foreach (maps, iter, map) {
r_core_seek (core, map->itv.addr, true);
r_core_block_size (core, map->itv.size);
r_core_seek (core, r_io_map_begin (map), true);
r_core_block_size (core, r_io_map_size (map));
r_core_cmd0 (core, cmd);
}
r_list_free (maps);
@ -6650,8 +6650,8 @@ DEFINE_HANDLE_TS_FCN_AND_SYMBOL(foreach_iomap_command) {
if (maps) {
RListIter *iter;
r_list_foreach (maps, iter, map) {
r_core_seek (core, map->itv.addr, true);
r_core_block_size (core, map->itv.size);
r_core_seek (core, r_io_map_begin (map), true);
r_core_block_size (core, r_io_map_size (map));
RCmdStatus cmd_res = handle_ts_command_tmpseek (state, command);
UPDATE_CMD_STATUS_RES (res, cmd_res, err);
}
@ -7354,7 +7354,7 @@ R_API char *r_core_cmd_str(RCore *core, const char *cmd) {
}
r_cons_filter ();
const char *static_str = r_cons_get_buffer ();
char *retstr = strdup (static_str? static_str: "");
char *retstr = strdup (r_str_get (static_str));
r_cons_pop ();
r_cons_echo (NULL);
return retstr;

View File

@ -1293,6 +1293,7 @@ static int var_cmd(RCore *core, const char *str) {
}
if (str[0] == 'j') {
// "afvj"
//TODO PJ
r_cons_printf ("{\"sp\":");
r_core_cmd0 (core, "afvsj");
r_cons_printf (",\"bp\":");
@ -3050,8 +3051,8 @@ static void cmd_anal_fcn_sig(RCore *core, const char *input) {
int nargs = r_type_func_args_count (core->anal->sdb_types, key);
if (fcn_type) {
pj_o (j);
pj_ks (j, "name", r_str_get (key));
pj_ks (j, "return", r_str_get (fcn_type));
pj_ks (j, "name", r_str_getf (key));
pj_ks (j, "return", r_str_getf (fcn_type));
pj_k (j, "args");
pj_a (j);
if (nargs) {
@ -3072,7 +3073,7 @@ static void cmd_anal_fcn_sig(RCore *core, const char *input) {
free (key);
} else {
pj_o (j);
pj_ks (j, "name", r_str_get (fcn_name));
pj_ks (j, "name", r_str_getf (fcn_name));
pj_k (j, "args");
pj_a (j);
@ -3462,7 +3463,7 @@ static int cmd_anal_fcn(RCore *core, const char *input) {
}
r_config_set_i (core->config, "anal.from", a);
r_config_set_i (core->config, "anal.to", b);
r_config_set (core->config, "anal.limits", c? c: "");
r_config_set (core->config, "anal.limits", r_str_get (c));
}
}
break;
@ -6996,8 +6997,8 @@ static void cmd_anal_aftertraps(RCore *core, const char *input) {
RIOMap *map = r_io_map_get (core->io, addr);
if (map && (map->perm & R_PERM_X)) {
// search in current section
if (map->itv.size > bf->size) {
addr = map->itv.addr;
if (r_io_map_size (map) > bf->size) {
addr = r_io_map_begin (map);
if (bf->size > map->delta) {
len = bf->size - map->delta;
} else {
@ -7005,12 +7006,12 @@ static void cmd_anal_aftertraps(RCore *core, const char *input) {
return;
}
} else {
addr = map->itv.addr;
len = map->itv.size;
addr = r_io_map_begin (map);
len = r_io_map_size (map);
}
} else {
if (map && map->itv.addr != map->delta && bf->size > (core->offset - map->itv.addr + map->delta)) {
len = bf->size - (core->offset - map->itv.addr + map->delta);
if (map && r_io_map_begin (map) != map->delta && bf->size > (core->offset - r_io_map_begin (map) + map->delta)) {
len = bf->size - (core->offset - r_io_map_begin (map) + map->delta);
} else {
if (bf->size > core->offset) {
len = bf->size - core->offset;
@ -7082,8 +7083,8 @@ static void cmd_anal_blocks(RCore *core, const char *input) {
goto ctrl_c;
}
r_list_foreach (list, iter, map) {
from = map->itv.addr;
to = r_itv_end (map->itv);
from = r_io_map_begin (map);
to = r_io_map_end (map);
if (r_cons_is_breaked ()) {
goto ctrl_c;
}
@ -7244,8 +7245,8 @@ static void cmd_anal_calls(RCore *core, const char *input, bool printCommands, b
ranges = r_core_get_boundaries_prot (core, 0, NULL, "anal");
if (ranges) {
r_list_foreach (ranges, iter, map) {
ut64 addr = map->itv.addr;
_anal_calls (core, addr, r_itv_end (map->itv), printCommands, importsOnly);
ut64 addr = r_io_map_begin (map);
_anal_calls (core, addr, r_io_map_end (map), printCommands, importsOnly);
}
}
} else {
@ -9255,8 +9256,8 @@ R_API int r_core_anal_refs(RCore *core, const char *input) {
}
int nth = 0;
r_list_foreach (list, iter, map) {
from = map->itv.addr;
to = r_itv_end (map->itv);
from = r_io_map_begin (map);
to = r_io_map_end (map);
if (r_cons_is_breaked ()) {
break;
}
@ -9321,9 +9322,9 @@ static int compute_coverage(RCore *core) {
r_pvector_foreach (&core->io->maps, it) {
RIOMap *map = *it;
if (map->perm & R_PERM_X) {
ut64 section_end = map->itv.addr + map->itv.size;
ut64 section_end = r_io_map_end (map);
ut64 s = r_anal_function_realsize (fcn);
if (fcn->addr >= map->itv.addr && (fcn->addr + s) < section_end) {
if (fcn->addr >= r_io_map_begin (map) && (fcn->addr + s) < section_end) {
cov += s;
}
}
@ -9338,7 +9339,7 @@ static int compute_code (RCore* core) {
r_pvector_foreach (&core->io->maps, it) {
RIOMap *map = *it;
if (map->perm & R_PERM_X) {
code += map->itv.size;
code += r_io_map_size (map);
}
}
return code;
@ -9501,10 +9502,11 @@ static void cmd_anal_aav(RCore *core, const char *input) {
if (r_cons_is_breaked ()) {
break;
}
oldstr = r_print_rowlog (core->print, sdb_fmt ("from 0x%"PFMT64x" to 0x%"PFMT64x" (aav)", map->itv.addr, r_itv_end (map->itv)));
oldstr = r_print_rowlog (core->print, sdb_fmt ("from 0x%"PFMT64x" to 0x%"PFMT64x" (aav)", r_io_map_begin (map),
r_io_map_end (map)));
r_print_rowlog_done (core->print, oldstr);
(void)r_core_search_value_in_range (core, map->itv,
map->itv.addr, r_itv_end (map->itv), vsize, _CbInRangeAav, (void *)asterisk);
r_io_map_begin (map), r_io_map_end (map), vsize, _CbInRangeAav, (void *)asterisk);
}
r_list_free (list);
} else {
@ -9531,8 +9533,8 @@ static void cmd_anal_aav(RCore *core, const char *input) {
}
r_print_rowlog_done (core->print, oldstr);
r_list_foreach (list, iter, map) {
ut64 begin = map->itv.addr;
ut64 end = r_itv_end (map->itv);
ut64 begin = r_io_map_begin (map);
ut64 end = r_io_map_end (map);
if (r_cons_is_breaked ()) {
break;
}
@ -9681,7 +9683,7 @@ static int cmd_anal_all(RCore *core, const char *input) {
break;
}
r_list_foreach (list, iter, map) {
r_core_seek (core, map->itv.addr, true);
r_core_seek (core, r_io_map_begin (map), true);
r_config_set_i (core->config, "anal.hasnext", 1);
r_core_cmd0 (core, "afr");
r_config_set_i (core->config, "anal.hasnext", hasnext);
@ -10041,8 +10043,8 @@ static int cmd_anal_all(RCore *core, const char *input) {
} else {
r_list_foreach (list, iter, map) {
if (map->perm & R_PERM_X) {
char *ss = r_str_newf (" 0x%"PFMT64x, map->itv.size);
r_core_seek (core, map->itv.addr, true);
char *ss = r_str_newf (" 0x%"PFMT64x, r_io_map_size (map));
r_core_seek (core, r_io_map_begin (map), true);
r_core_anal_esil (core, ss, NULL);
free (ss);
}
@ -10601,9 +10603,9 @@ bool go_on = true;
int nargs = r_type_func_args_count (core->anal->sdb_types, key);
// remove other comments
if (fcn_type) {
r_strbuf_appendf (sb, "%s%s%s(", r_str_get (fcn_type),
r_strbuf_appendf (sb, "%s%s%s(", r_str_getf (fcn_type),
(*fcn_type && fcn_type[strlen (fcn_type) - 1] == '*') ? "" : " ",
r_str_get (key));
r_str_getf (key));
if (!nargs) {
r_strbuf_appendf (sb, "void)\n");
}

View File

@ -521,7 +521,7 @@ static size_t update_max_len(RCmdDesc *cd, size_t max_len) {
static void print_child_help(RStrBuf *sb, RCmdDesc *cd, size_t max_len, bool use_color) {
size_t str_len = calc_padding_len (cd);
int padding = str_len < max_len? max_len - str_len: 0;
const char *cd_summary = cd->help->summary? cd->help->summary: "";
const char *cd_summary = r_str_get (cd->help->summary);
RCons *cons = r_cons_singleton ();
const char *pal_args_color = use_color? cons->context->pal.args: "",
@ -602,7 +602,7 @@ static char *oldinput_get_help(RCmd *cmd, RCmdDesc *cd, RCmdParsedArgs *a) {
r_cons_filter ();
s = r_cons_get_buffer ();
}
char *res = strdup (s? s: "");
char *res = strdup (r_str_get (s));
r_cons_pop ();
return res;
}

View File

@ -2253,9 +2253,9 @@ static void __tableRegList (RCore *core, RReg *reg, const char *str) {
sdb_fmt ("%d", e->index),
sdb_fmt ("%d", i),
r_str_bool (e->is_float),
e->name? e->name: "",
e->flags? e->flags: "",
e->comment? e->comment: "",
r_str_get (e->name),
r_str_get (e->flags),
r_str_get (e->comment),
NULL
);
}
@ -3376,7 +3376,7 @@ static void r_core_cmd_bp(RCore *core, const char *input) {
r_cons_printf ("breakpoint %s %s %s\n",
r_str_rwx_i (bpi->perm),
bpi->enabled ? "enabled" : "disabled",
bpi->name ? bpi->name : "");
r_str_get (bpi->name));
}
}
break;
@ -3413,7 +3413,7 @@ static void r_core_cmd_bp(RCore *core, const char *input) {
} else {
RBreakpointItem *bp;
r_list_foreach (core->dbg->bp->bps, iter, bp) {
r_cons_printf ("0x%08"PFMT64x" %s\n", bp->addr, r_str_get2 (bp->expr));
r_cons_printf ("0x%08"PFMT64x" %s\n", bp->addr, r_str_get (bp->expr));
}
}
break;
@ -3470,14 +3470,15 @@ static void r_core_cmd_bp(RCore *core, const char *input) {
char *flagdesc, *flagdesc2, *pcstr, *spstr;
get_backtrace_info (core, frame, addr, &flagdesc, &flagdesc2, &pcstr, &spstr, hex_format);
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, frame->addr, 0);
//TODO PJ
r_cons_printf ("%s{\"idx\":%d,\"pc\":%s,\"sp\":%s,\"frame_size\":%d,"
"\"fname\":\"%s\",\"desc\":\"%s%s\"}", (i ? " ," : ""),
i,
pcstr, spstr,
(int)frame->size,
fcn ? fcn->name : "",
flagdesc ? flagdesc : "",
flagdesc2 ? flagdesc2 : "");
r_str_get (flagdesc),
r_str_get (flagdesc2));
i++;
free (flagdesc);
free (flagdesc2);
@ -3552,8 +3553,8 @@ static void r_core_cmd_bp(RCore *core, const char *input) {
pcstr, spstr,
(int)frame->size,
fcn ? fcn->name : "??",
flagdesc ? flagdesc : "",
flagdesc2 ? flagdesc2 : "");
r_str_get (flagdesc),
r_str_get (flagdesc2));
free (flagdesc);
free (flagdesc2);
free (pcstr);

View File

@ -527,7 +527,8 @@ static int cmd_eval(void *data, const char *input) {
}
r_meta_set_string (core->anal, R_META_TYPE_HIGHLIGHT, core->offset, "");
const char *str = r_meta_get_string (core->anal, R_META_TYPE_HIGHLIGHT, core->offset);
char *dup = r_str_newf ("%s \"%s%s\"", str?str:"", word?word:"", color_code?color_code:r_cons_singleton ()->context->pal.wordhl);
char *dup = r_str_newf ("%s \"%s%s\"", r_str_get (str), r_str_get (word),
color_code ? color_code : r_cons_singleton ()->context->pal.wordhl);
r_meta_set_string (core->anal, R_META_TYPE_HIGHLIGHT, core->offset, dup);
r_str_argv_free (argv);
R_FREE (word);

View File

@ -535,7 +535,7 @@ static int cmd_help(void *data, const char *input) {
return false;
}
r_list_foreach (tmp, iter, map) {
r_cons_printf ("0x%"PFMT64x" 0x%"PFMT64x"\n", map->itv.addr, r_itv_end (map->itv));
r_cons_printf ("0x%"PFMT64x" 0x%"PFMT64x"\n", r_io_map_begin (map), r_io_map_end (map));
}
r_list_free (tmp);
break;
@ -1108,7 +1108,7 @@ static int cmd_help(void *data, const char *input) {
r_num_math (core->num, input+2): core->offset;
RIOMap *map = r_io_map_get_paddr (core->io, n);
if (map) {
o = n + map->itv.addr - map->delta;
o = n + r_io_map_begin (map) - map->delta;
r_cons_printf ("0x%08"PFMT64x"\n", o);
} else {
r_cons_printf ("no map at 0x%08"PFMT64x"\n", n);
@ -1124,7 +1124,7 @@ static int cmd_help(void *data, const char *input) {
r_num_math (core->num, input + 2): core->offset;
RIOMap *map = r_io_map_get (core->io, n);
if (map) {
o = n - map->itv.addr + map->delta;
o = n - r_io_map_begin (map) + map->delta;
r_cons_printf ("0x%08"PFMT64x"\n", o);
} else {
r_cons_printf ("no map at 0x%08"PFMT64x"\n", n);

View File

@ -205,7 +205,7 @@ static void cmd_info_here(RCore *core, int mode) {
}
}
#define STR(x) (x)? (x): ""
//TODO PJ
static void r_core_file_info(RCore *core, int mode) {
const char *fn = NULL;
int dbg = r_config_get_i (core->config, "cfg.debug");
@ -229,7 +229,7 @@ static void r_core_file_info(RCore *core, int mode) {
fn = info->file;
if (mode == R_MODE_JSON) {
comma = ",";
r_cons_printf ("\"type\":\"%s\"", STR (info->type));
r_cons_printf ("\"type\":\"%s\"", r_str_get (info->type));
}
} else {
fn = desc ? desc->name: NULL;
@ -344,6 +344,7 @@ static int bin_is_executable(RBinObject *obj){
return false;
}
//TODO PJ
static void cmd_info_bin(RCore *core, int va, int mode) {
RBinObject *obj = r_bin_cur_object (core->bin);
int array = 0;
@ -964,7 +965,7 @@ static int cmd_info(void *data, const char *input) {
}
core->tmpseek = false;
r_core_cmdf (core, "e bin.str.purge=%s%s0x%" PFMT64x,
strpurge ? strpurge : "",
r_str_get (strpurge),
strpurge && *strpurge ? "," : "",
addr);
core->tmpseek = old_tmpseek;
@ -1107,6 +1108,7 @@ static int cmd_info(void *data, const char *input) {
input++;
break;
case 'j':
//TODO PJ
input++;
r_cons_printf ("\"class\":\"%s\"", cls->name);
r_cons_printf (",\"methods\":[");

View File

@ -370,6 +370,7 @@ static int cmd_plugins(void *data, const char *input) {
RCorePlugin *cp;
switch (input[1]) {
case 'j': {
//TODO PJ
r_cons_printf ("[");
bool is_first_element = true;
r_list_foreach (core->rcmd->plist, iter, cp) {

View File

@ -84,7 +84,7 @@ static int r_core_magic_at(RCore *core, const char *file, ut64 addr, int depth,
}
}
//repeat:
//if (v) r_cons_printf (" %d # pm %s @ 0x%"PFMT64x"\n", depth, file? file: "", addr);
//if (v) r_cons_printf (" %d # pm %s @ 0x%"PFMT64x"\n", depth, r_str_get (file), addr);
if (delta + 2 > core->blocksize) {
eprintf ("EOB\n");
ret = -1;
@ -131,6 +131,7 @@ static int r_core_magic_at(RCore *core, const char *file, ut64 addr, int depth,
if (!json) {
r_cons_printf ("0x%08"PFMT64x" %d %s\n", addr + adelta, magicdepth-depth, p);
} else {
//TODO PJ
if (found >= 1) {
r_cons_printf (",");
}

View File

@ -422,7 +422,7 @@ static void map_list(RIO *io, int mode, RPrint *print, int fd) {
switch (mode) {
case 'q':
if (fd == -2) {
print->cb_printf ("0x%08"PFMT64x"\n", r_io_map_get_from (map));
print->cb_printf ("0x%08"PFMT64x"\n", r_io_map_begin (map));
} else {
print->cb_printf ("%d %d\n", map->fd, map->id);
}
@ -432,10 +432,10 @@ static void map_list(RIO *io, int mode, RPrint *print, int fd) {
pj_ki (pj, "map", map->id);
pj_ki (pj, "fd", map->fd);
pj_kn (pj, "delta", map->delta);
pj_kn (pj, "from", r_io_map_get_from (map));
pj_kn (pj, "to", r_itv_end (map->itv));
pj_kn (pj, "from", r_io_map_begin (map));
pj_kn (pj, "to", r_io_map_end (map));
pj_ks (pj, "perm", r_str_rwx_i (map->perm));
pj_ks (pj, "name", r_str_get2 (map->name));
pj_ks (pj, "name", r_str_get (map->name));
pj_end (pj);
break;
case 1:
@ -443,8 +443,8 @@ static void map_list(RIO *io, int mode, RPrint *print, int fd) {
case 'r': {
// Need FIFO order here
char *om_cmd = r_str_newf ("om %d 0x%08"PFMT64x" 0x%08"PFMT64x" 0x%08"PFMT64x" %s%s%s\n",
map->fd, r_io_map_get_from (map), map->itv.size, map->delta, r_str_rwx_i(map->perm),
map->name ? " " : "", r_str_get2 (map->name));
map->fd, r_io_map_begin (map), r_io_map_size (map), map->delta, r_str_rwx_i(map->perm),
map->name ? " " : "", r_str_get (map->name));
if (om_cmd) {
om_cmds = r_str_prepend (om_cmds, om_cmd);
free (om_cmd);
@ -454,8 +454,8 @@ static void map_list(RIO *io, int mode, RPrint *print, int fd) {
default:
print->cb_printf ("%2d fd: %i +0x%08"PFMT64x" 0x%08"PFMT64x
" - 0x%08"PFMT64x" %s %s\n", map->id, map->fd,
map->delta, r_io_map_get_from (map), r_io_map_get_to (map),
r_str_rwx_i (map->perm), r_str_get2 (map->name));
map->delta, r_io_map_begin (map), r_io_map_to (map),
r_str_rwx_i (map->perm), r_str_get (map->name));
break;
}
}
@ -527,7 +527,7 @@ static void cmd_omf(RCore *core, const char *input) {
void **it;
r_pvector_foreach (&core->io->maps, it) {
RIOMap *map = *it;
if (r_itv_contain (map->itv, core->offset)) {
if (r_io_map_contain (map, core->offset)) {
map->perm = perm;
}
}
@ -548,7 +548,7 @@ static void r_core_cmd_omt(RCore *core, const char *arg) {
ut64 pa = m->delta;
ut64 pa_size = r_itv_size (m->itv);
ut64 pa_end = pa + pa_size;
const char *name = m->name? m->name: "";
const char *name = r_str_get (m->name);
r_table_add_rowf (t, "ddxxxxxss", m->id, m->fd, pa, pa_end, pa_size, va, va_end, r_str_rwx_i (m->perm), name);
}
@ -583,10 +583,10 @@ static void cmd_open_map(RCore *core, const char *input) {
pj_ki (pj, "map", map->id);
pj_ki (pj, "fd", map->fd);
pj_kn (pj, "delta", map->delta);
pj_kn (pj, "from", r_io_map_get_from (map));
pj_kn (pj, "to", r_itv_end (map->itv));
pj_kn (pj, "from", r_io_map_begin (map));
pj_kn (pj, "to", r_io_map_end (map));
pj_ks (pj, "perm", r_str_rwx_i (map->perm));
pj_ks (pj, "name", r_str_get2 (map->name));
pj_ks (pj, "name", r_str_get (map->name));
pj_end (pj);
core->print->cb_printf ("%s\n", pj_string (pj));
@ -595,8 +595,8 @@ static void cmd_open_map(RCore *core, const char *input) {
} else {
core->print->cb_printf ("%2d fd: %i +0x%08"PFMT64x" 0x%08"PFMT64x
" - 0x%08"PFMT64x" %s %s\n", map->id, map->fd,
map->delta, r_io_map_get_from (map), r_io_map_get_to (map),
r_str_rwx_i (map->perm), r_str_get2 (map->name));
map->delta, r_io_map_begin (map), r_io_map_to (map),
r_str_rwx_i (map->perm), r_str_get (map->name));
}
}
break;
@ -1195,7 +1195,7 @@ static bool desc_list_visual_cb(void *user, void *data, ut32 id) {
p->cb_printf (" +0x%"PFMT64x" 0x%"PFMT64x
" - 0x%"PFMT64x" : %s : %s : %s\n", map->delta,
map->from, map->to, r_str_rwx_i (map->flags), "",
r_str_get2 (map));
r_str_get (map));
}
}
}

View File

@ -660,7 +660,7 @@ static void cmd_prc(RCore *core, const ut8* block, int len) {
for (i = 0; i < len; i += cols) {
if (show_section) {
const char * name = r_core_get_section_name (core, core->offset + i);
r_cons_printf ("%20s ", name? name: "");
r_cons_printf ("%20s ", r_str_get (name));
}
if (show_offset) {
r_print_addr (core->print, core->offset + i);
@ -761,7 +761,7 @@ static void cmd_prc_zoom(RCore *core, const char *input) {
RIOMap* map1 = iter1->data;
from = map1->itv.addr;
r_list_foreach (list, iter, map) {
to = r_itv_end (map->itv);
to = r_io_map_end (map);
}
} else {
from = core->offset;
@ -2844,15 +2844,15 @@ static void disasm_strings(RCore *core, const char *input, RAnalFunction *fcn) {
r_cons_printf ("%s0x%08"PFMT64x" "Color_RESET, use_color? pal->offset: "", addr);
}
r_cons_printf ("%s%s%s%s%s%s%s\n",
linecolor? linecolor: "",
string2? string2: "", string2? " ": "", string,
r_str_get (linecolor),
r_str_get (string2), string2? " ": "", string,
flag? " ": "", flag? flag->name: "", Color_RESET);
} else {
if (show_offset) {
r_cons_printf ("0x%08"PFMT64x" ", addr);
}
r_cons_printf ("%s%s%s%s%s\n",
string2? string2: "", string2? " ": "", string,
r_str_get (string2), string2? " ": "", string,
flag? " ": "", flag? flag->name: "");
}
}
@ -3181,8 +3181,8 @@ static bool cmd_print_blocks(RCore *core, const char *input) {
RListIter *iter;
RIOMap *map;
r_list_foreach (list, iter, map) {
ut64 f = r_itv_begin (map->itv);
ut64 t = r_itv_end (map->itv);
ut64 f = r_io_map_begin (map);
ut64 t = r_io_map_end (map);
if (f < from) {
from = f;
}
@ -3537,7 +3537,7 @@ static void cmd_print_bars(RCore *core, const char *input) {
if (map1) {
from = map1->itv.addr;
r_list_foreach (list, iter, map) {
to = r_itv_end (map->itv);
to = r_io_map_end (map);
}
totalsize = to - from;
} else {
@ -4415,6 +4415,7 @@ static void print_json_string(RCore *core, const char* block, int len, const cha
r_cons_printf ("%s\n", pj_string (pj));
pj_free (pj);
#else
//TODO PJ (?)
r_cons_printf ("{\"string\":");
char *str = r_str_utf16_encode (block, len); // XXX just block + len should be fine, pj takes care of this
r_cons_printf ("\"%s\"", str);
@ -4485,7 +4486,7 @@ static void r_core_disasm_table(RCore * core, int l, const char *input) {
const char *esil = R_STRBUF_SAFEGET (&op->esil);
char *refs = __op_refs (core, op, 0);
char *xrefs = __op_refs (core, op, 1);
r_table_add_rowf (t, "sXssssss", fn, ea, sbytes, op->mnemonic, comment? comment: "", esil, refs, xrefs);
r_table_add_rowf (t, "sXssssss", fn, ea, sbytes, op->mnemonic, r_str_get (comment), esil, refs, xrefs);
free (sbytes);
free (bytes);
free (xrefs);
@ -6315,7 +6316,7 @@ l = use_blocksize;
r_print_section (core->print, core->offset +i);
r_cons_printf ("0x%08"PFMT64x " %s0x%08"PFMT64x "%s%s%s\n",
(ut64) core->offset + i, a, (ut64) v,
b, fn? " ": "", fn? fn: "");
b, fn? " ": "", r_str_get (fn));
} else {
r_cons_printf ("%s0x%08"PFMT64x "%s\n", a, (ut64) v, b);
}
@ -6391,7 +6392,7 @@ l = use_blocksize;
}
}
r_cons_printf ("0x%08"PFMT64x " %s0x%04"PFMT64x "%s %s\n",
(ut64) core->offset + i, a, v, b, fn? fn: "");
(ut64) core->offset + i, a, v, b, r_str_get (fn));
free (fn);
}
}
@ -6441,7 +6442,7 @@ l = use_blocksize;
if (printOffset) {
r_print_section (core->print, core->offset +i);
r_cons_printf ("0x%08"PFMT64x " %s0x%016"PFMT64x "%s %s\n",
(ut64) core->offset + i, a, v, b, fn? fn: "");
(ut64) core->offset + i, a, v, b, r_str_get (fn));
} else {
r_cons_printf ("%s0x%016"PFMT64x "%s\n", a, v, b);
}
@ -6820,7 +6821,7 @@ l = use_blocksize;
RIOMap* map1 = iter1->data;
from = map1->itv.addr;
r_list_foreach (list, iter, map) {
to = r_itv_end (map->itv);
to = r_io_map_end (map);
}
} else {
from = core->offset;

View File

@ -204,7 +204,8 @@ static int search_hash(RCore *core, const char *hashname, const char *hashstr, u
if (r_cons_is_breaked ()) {
break;
}
ut64 from = map->itv.addr, to = r_itv_end (map->itv);
ut64 from = r_io_map_begin (map);
ut64 to = r_io_map_end (map);
st64 bufsz;
bufsz = to - from;
if (len > bufsz) {
@ -507,6 +508,7 @@ static int _cb_hit(RSearchKeyword *kw, void *user, ut64 addr) {
}
if (param->outmode == R_MODE_JSON) {
//TODO PJ
if (core->search->nhits >= 1) {
r_cons_printf (",");
}
@ -525,6 +527,7 @@ static int _cb_hit(RSearchKeyword *kw, void *user, ut64 addr) {
free (str);
} else if (kw) {
if (param->outmode == R_MODE_JSON) {
//TODO PJ
if (core->search->nhits >= 1) {
r_cons_printf (",");
}
@ -589,7 +592,7 @@ static void append_bound(RList *list, RIO *io, RInterval search_itv, ut64 from,
r_list_append (list, map);
} else if (r_itv_overlap (itv, search_itv)) {
map->itv = r_itv_intersect (itv, search_itv);
if (map->itv.size) {
if (r_io_map_size (map)) {
r_list_append (list, map);
} else {
free (map);
@ -663,8 +666,8 @@ R_API RList *r_core_get_boundaries_prot(RCore *core, int perm, const char *mode,
void **it;
r_pvector_foreach (&core->io->maps, it) {
RIOMap *map = *it;
ut64 from = r_itv_begin (map->itv);
ut64 to = r_itv_end (map->itv);
ut64 from = r_io_map_begin (map);
ut64 to = r_io_map_end (map);
int rwx = map->perm;
#endif
// eprintf ("--------- %llx %llx (%llx %llx)\n", from, to, begin, end);
@ -695,13 +698,13 @@ R_API RList *r_core_get_boundaries_prot(RCore *core, int perm, const char *mode,
void **it;
r_pvector_foreach (&core->io->maps, it) {
RIOMap *map = *it;
ut64 from = r_itv_begin (map->itv);
//ut64 to = r_itv_end (map->itv);
ut64 from = r_io_map_begin (map);
//ut64 to = r_io_map_end (map);
int rwx = map->perm;
if ((rwx & mask) != mask) {
continue;
}
append_bound (list, core->io, search_itv, from, r_itv_size (map->itv), rwx);
append_bound (list, core->io, search_itv, from, r_io_map_size (map), rwx);
}
} else if (r_str_startswith (mode, "io.sky.")) {
int len = strlen ("io.sky.");
@ -783,8 +786,8 @@ R_API RList *r_core_get_boundaries_prot(RCore *core, int perm, const char *mode,
void **it;
r_pvector_foreach (&core->io->maps, it) {
RIOMap *map = *it;
ut64 from = r_itv_begin (map->itv);
ut64 size = r_itv_size (map->itv);
ut64 from = r_io_map_begin (map);
ut64 size = r_io_map_size (map);
int rwx = map->perm;
if ((rwx & mask) != mask) {
continue;
@ -901,8 +904,8 @@ R_API RList *r_core_get_boundaries_prot(RCore *core, int perm, const char *mode,
RIOMap *nmap = R_NEW0 (RIOMap);
if (nmap) {
// nmap->fd = core->io->desc->fd;
nmap->itv.addr = from;
nmap->itv.size = to - from;
r_io_map_set_begin(nmap, from);
r_io_map_set_size(nmap, to - from);
nmap->perm = perm;
nmap->delta = 0;
r_list_append (list, nmap);
@ -943,11 +946,11 @@ R_API RList *r_core_get_boundaries_prot(RCore *core, int perm, const char *mode,
if (!nmap) {
break;
}
nmap->itv.addr = map->addr;
nmap->itv.size = map->addr_end - map->addr;
if (nmap->itv.addr) {
from = R_MIN (from, nmap->itv.addr);
to = R_MAX (to - 1, r_itv_end (nmap->itv) - 1) + 1;
r_io_map_set_begin (nmap, map->addr);
r_io_map_set_size (nmap, map->addr_end - map->addr);
if (r_io_map_begin (nmap)) {
from = R_MIN (from, r_io_map_begin (nmap));
to = R_MAX (to, r_io_map_end (nmap));
}
nmap->perm = map->perm;
nmap->delta = 0;
@ -1185,6 +1188,7 @@ static void print_rop(RCore *core, RList *hitlist, char mode, bool *json_first)
switch (mode) {
case 'j':
//TODO PJ
// Handle comma between gadgets
if (*json_first) {
*json_first = 0;
@ -1645,8 +1649,8 @@ static void do_esil_search(RCore *core, struct search_parameters *param, const c
size_t hit_combo = 0;
char *res;
ut64 nres, addr;
ut64 from = map->itv.addr;
ut64 to = r_itv_end (map->itv);
ut64 from = r_io_map_begin (map);
ut64 to = r_io_map_end (map);
unsigned int addrsize = r_config_get_i (core->config, "esil.addr.size");
if (!core->anal->esil) {
core->anal->esil = r_anal_esil_new (stacksize, iotrap, addrsize);
@ -1846,8 +1850,8 @@ static void do_syscall_search(RCore *core, struct search_parameters *param) {
}
}
r_list_foreach (param->boundaries, iter, map) {
ut64 from = map->itv.addr;
ut64 to = r_itv_end (map->itv);
ut64 from = r_io_map_begin (map);
ut64 to = r_io_map_end (map);
if (from >= to) {
eprintf ("Error: from must be lower than to\n");
goto beach;
@ -2063,8 +2067,8 @@ static bool do_anal_search(RCore *core, struct search_parameters *param, const c
RIOMap* map;
RListIter *iter;
r_list_foreach (param->boundaries, iter, map) {
ut64 from = map->itv.addr;
ut64 to = r_itv_end (map->itv);
ut64 from = r_io_map_begin (map);
ut64 to = r_io_map_end (map);
for (i = 0, at = from; at < to; i++, at++) {
if (r_cons_is_breaked ()) {
break;
@ -2116,6 +2120,7 @@ static bool do_anal_search(RCore *core, struct search_parameters *param, const c
char *opstr = r_core_op_str (core, at);
switch (mode) {
case 'j':
//TODO PJ
r_cons_printf ("%s{\"addr\":%"PFMT64d ",\"size\":%d,\"opstr\":\"%s\"}",
firstItem? "": ",",
at, ret, opstr);
@ -2194,8 +2199,8 @@ static void do_section_search(RCore *core, struct search_parameters *param, cons
bool lastBlock = true;
r_cons_break_push (NULL, NULL);
r_list_foreach (param->boundaries, iter, map) {
ut64 from = map->itv.addr;
ut64 to = r_itv_end (map->itv);
ut64 from = r_io_map_begin (map);
ut64 to = r_io_map_end (map);
if (r_cons_is_breaked ()) {
break;
}
@ -2273,8 +2278,8 @@ static void do_asm_search(RCore *core, struct search_parameters *param, const ch
if (!r_itv_overlap (search_itv, map->itv)) {
continue;
}
ut64 from = map->itv.addr;
ut64 to = r_itv_end (map->itv);
ut64 from = r_io_map_begin (map);
ut64 to = r_io_map_end (map);
if (r_cons_is_breaked ()) {
break;
}
@ -2294,6 +2299,7 @@ static void do_asm_search(RCore *core, struct search_parameters *param, const ch
}
switch (param->outmode) {
case R_MODE_JSON:
//TODO PJ
if (count > 0) {
r_cons_printf (",");
}
@ -2485,6 +2491,7 @@ static void rop_kuery(void *data, const char *input) {
}
break;
case 'j':
//TODO PJ
r_cons_print ("{\"gadgets\":[");
ls_foreach (db_rop->ns, it, ns) {
sdb_list = sdb_foreach_list (ns->sdb, false);
@ -2632,6 +2639,7 @@ void _CbInRangeSearchV(RCore *core, ut64 from, ut64 to, int vsize, int count, vo
if (param->outmode != R_MODE_JSON) {
r_cons_printf ("0x%"PFMT64x ": 0x%"PFMT64x"\n", from, to);
} else {
//TODO PJ
if (count >= 1) {
r_cons_printf (",");
}
@ -2882,15 +2890,15 @@ static void __core_cmd_search_asm_infinite (RCore *core, const char *arg) {
RAnalOp analop;
ut64 at;
r_list_foreach (boundaries, iter, map) {
ut64 map_begin = map->itv.addr;
ut64 map_size = map->itv.size;
ut64 map_end = map_begin + map_size;
ut8 *buf = calloc (map_end - map_begin, 1);
ut64 map_begin = r_io_map_begin (map);
ut64 map_size = r_io_map_size (map);
ut64 map_end = r_io_map_end (map);
ut8 *buf = calloc (map_size, 1);
if (!buf) {
continue;
}
(void) r_io_read_at (core->io, map_begin, buf, map_size);
for (at = map->itv.addr; at + 24< map_end; at += 1) {
for (at = map_begin; at + 24 < map_end; at += 1) {
r_anal_op (core->anal, &analop, at, buf + (at - map_begin), 24, R_ANAL_OP_MASK_HINT);
if (at == analop.jump) {
r_cons_printf ("0x%08"PFMT64x"\n", at);
@ -3136,8 +3144,8 @@ reread:
RListIter *iter;
RIOMap *map;
r_list_foreach (param.boundaries, iter, map) {
eprintf ("-- 0x%"PFMT64x" 0x%"PFMT64x"\n", map->itv.addr, r_itv_end (map->itv));
r_core_anal_search (core, map->itv.addr, r_itv_end (map->itv), n, 'c');
eprintf ("-- 0x%"PFMT64x" 0x%"PFMT64x"\n", r_io_map_begin (map), r_io_map_end (map));
r_core_anal_search (core, r_io_map_begin (map), r_io_map_end (map), n, 'c');
}
}
break;
@ -3146,8 +3154,8 @@ reread:
RListIter *iter;
RIOMap *map;
r_list_foreach (param.boundaries, iter, map) {
eprintf ("-- 0x%"PFMT64x" 0x%"PFMT64x"\n", map->itv.addr, r_itv_end (map->itv));
r_core_anal_search (core, map->itv.addr, r_itv_end (map->itv), n, 0);
eprintf ("-- 0x%"PFMT64x" 0x%"PFMT64x"\n", r_io_map_begin (map), r_io_map_end (map));
r_core_anal_search (core, r_io_map_begin (map), r_io_map_end (map), n, 0);
}
}
break;
@ -3158,11 +3166,11 @@ reread:
RListIter *iter;
RIOMap *map;
r_list_foreach (param.boundaries, iter, map) {
eprintf ("-- 0x%"PFMT64x" 0x%"PFMT64x"\n", map->itv.addr, r_itv_end (map->itv));
eprintf ("-- 0x%"PFMT64x" 0x%"PFMT64x"\n", r_io_map_begin (map), r_io_map_end (map));
ut64 refptr = r_num_math (core->num, input + 2);
ut64 curseek = core->offset;
r_core_seek (core, map->itv.addr, true);
char *arg = r_str_newf (" %"PFMT64d, r_itv_end (map->itv) - map->itv.addr);
r_core_seek (core, r_io_map_begin (map), true);
char *arg = r_str_newf (" %"PFMT64d, r_io_map_size (map));
char *trg = refptr? r_str_newf (" %"PFMT64d, refptr): strdup ("");
r_core_anal_esil (core, arg, trg);
free (arg);
@ -3176,8 +3184,8 @@ reread:
RListIter *iter;
RIOMap *map;
r_list_foreach (param.boundaries, iter, map) {
eprintf ("-- 0x%"PFMT64x" 0x%"PFMT64x"\n", map->itv.addr, r_itv_end (map->itv));
r_core_anal_search (core, map->itv.addr, r_itv_end (map->itv), n, 'r');
eprintf ("-- 0x%"PFMT64x" 0x%"PFMT64x"\n", r_io_map_begin (map), r_io_map_end (map));
r_core_anal_search (core, r_io_map_begin (map), r_io_map_end (map), n, 'r');
}
}
break;
@ -3186,8 +3194,8 @@ reread:
RListIter *iter;
RIOMap *map;
r_list_foreach (param.boundaries, iter, map) {
eprintf ("-- 0x%"PFMT64x" 0x%"PFMT64x"\n", map->itv.addr, r_itv_end (map->itv));
r_core_anal_search (core, map->itv.addr, r_itv_end (map->itv), n, 'w');
eprintf ("-- 0x%"PFMT64x" 0x%"PFMT64x"\n", r_io_map_begin (map), r_io_map_end (map));
r_core_anal_search (core, r_io_map_begin (map), r_io_map_end (map), n, 'w');
}
}
break;
@ -3197,8 +3205,8 @@ reread:
RListIter *iter;
RIOMap *map;
r_list_foreach (param.boundaries, iter, map) {
ut64 from = map->itv.addr;
ut64 to = r_itv_end (map->itv);
ut64 from = r_io_map_begin (map);
ut64 to = r_io_map_end (map);
if (input[param_offset - 1] == ' ') {
r_core_anal_search (core, from, to,
r_num_math (core->num, input + 2), 0);
@ -3384,9 +3392,9 @@ reread:
int count = 0;
const int align = core->search->align;
r_list_foreach (param.boundaries, iter, map) {
// eprintf ("-- %llx %llx\n", map->itv.addr, r_itv_end (map->itv));
// eprintf ("-- %llx %llx\n", r_io_map_begin (map), r_io_map_end (map));
r_cons_break_push (NULL, NULL);
for (addr = map->itv.addr; addr < r_itv_end (map->itv); addr++) {
for (addr = r_io_map_begin (map); addr < r_io_map_end (map); addr++) {
if (r_cons_is_breaked ()) {
break;
}
@ -3422,10 +3430,10 @@ reread:
int hits = 0;
r_list_foreach (param.boundaries, iter, map) {
if (param.outmode != R_MODE_JSON) {
eprintf ("-- %llx %llx\n", map->itv.addr, r_itv_end (map->itv));
eprintf ("-- %llx %llx\n", r_io_map_begin (map), r_io_map_end (map));
}
r_cons_break_push (NULL, NULL);
for (addr = map->itv.addr; addr < r_itv_end (map->itv); addr++) {
for (addr = r_io_map_begin (map); addr < r_io_map_end (map); addr++) {
if (r_cons_is_breaked ()) {
break;
}
@ -3458,10 +3466,10 @@ reread:
RListIter *iter;
RIOMap *map;
r_list_foreach (param.boundaries, iter, map) {
eprintf ("-- %llx %llx\n", map->itv.addr, r_itv_end (map->itv));
eprintf ("-- %llx %llx\n", r_io_map_begin (map), r_io_map_end (map));
r_cons_break_push (NULL, NULL);
r_search_pattern_size (core->search, ps);
r_search_pattern (core->search, map->itv.addr, r_itv_end (map->itv));
r_search_pattern (core->search, r_io_map_begin (map), r_io_map_end (map));
r_cons_break_pop ();
}
break;

View File

@ -555,7 +555,7 @@ static int cmd_seek(void *data, const char *input) {
}
}
if (mode) {
r_cons_printf ("0x%"PFMT64x" %s\n", undo->off, name? name: "");
r_cons_printf ("0x%"PFMT64x" %s\n", undo->off, r_str_get (name));
} else {
if (!name) {
name = r_str_newf ("0x%"PFMT64x, undo->off);
@ -728,7 +728,7 @@ static int cmd_seek(void *data, const char *input) {
{
RIOMap *map = r_io_map_get (core->io, core->offset);
if (map) {
r_core_seek (core, map->itv.addr, true);
r_core_seek (core, r_io_map_begin (map), true);
} else {
r_core_seek (core, 0, true);
}
@ -742,7 +742,7 @@ static int cmd_seek(void *data, const char *input) {
RIOMap *map = r_io_map_get (core->io, core->offset);
// XXX: this +2 is a hack. must fix gap between sections
if (map) {
r_core_seek (core, map->itv.addr + map->itv.size + 2, true);
r_core_seek (core, r_io_map_end (map) + 2, true);
} else {
r_core_seek (core, r_io_fd_size (core->io, core->file->fd), true);
}

View File

@ -675,6 +675,7 @@ static bool print_link_cb(void *p, const char *k, const char *v) {
return true;
}
//TODO PJ
static bool print_link_json_cb(void *p, const char *k, const char *v) {
r_cons_printf ("{\"0x%s\":\"%s\"}", k + strlen ("link."), v);
return true;
@ -697,6 +698,7 @@ static bool print_link_readable_cb(void *p, const char *k, const char *v) {
return true;
}
//TODO PJ
static bool print_link_readable_json_cb(void *p, const char *k, const char *v) {
RCore *core = (RCore *)p;
char *fmt = r_type_format (core->anal->sdb_types, v);

View File

@ -1524,7 +1524,7 @@ static int wt_handler_old(void *data, const char *input) {
RIOMap *map = r_io_map_get (core->io, poff);
toend = true;
//use physical address
poff = map ? poff - map->itv.addr + map->delta : poff;
poff = map ? poff - r_io_map_begin (map) + map->delta : poff;
str++;
}
if (*str == 'f') { // "wtff"

View File

@ -851,8 +851,8 @@ static bool search(RCore *core, bool rad, bool only_func) {
return false;
}
r_list_foreach (list, iter, map) {
eprintf ("[+] searching 0x%08"PFMT64x" - 0x%08"PFMT64x"\n", map->itv.addr, r_itv_end (map->itv));
retval &= searchRange (core, map->itv.addr, r_itv_end (map->itv), rad, &bytes_search_ctx);
eprintf ("[+] searching 0x%08"PFMT64x" - 0x%08"PFMT64x"\n", r_io_map_begin (map), r_io_map_end (map));
retval &= searchRange (core, r_io_map_begin (map), r_io_map_end (map), rad, &bytes_search_ctx);
}
r_list_free (list);
}

View File

@ -657,8 +657,8 @@ static ut64 num_callback(RNum *userptr, const char *str, int *ok) {
ut64 size = 0LL;
RIOMap *map = r_io_map_get (core->io, core->offset);
if (map) {
lower = r_itv_begin (map->itv);
size = r_itv_size (map->itv);
lower = r_io_map_begin (map);
size = r_io_map_size (map);
}
if (str[1] == 'B') {
@ -2556,7 +2556,7 @@ static void cb_event_handler(REvent *ev, int event_type, void *user, void *data)
case R_EVENT_META_SET:
switch (rems->type) {
case 'C':
r_core_log_add (ev->user, sdb_fmt (":add-comment 0x%08"PFMT64x" %s\n", rems->addr, str? str: ""));
r_core_log_add (ev->user, sdb_fmt (":add-comment 0x%08"PFMT64x" %s\n", rems->addr, r_str_get (str)));
break;
default:
break;
@ -3090,7 +3090,7 @@ static void set_prompt (RCore *r) {
chop_prompt (filename, tmp, 128);
char *prompt = r_str_newf ("%s%s[%s%s]>%s ", filename, BEGIN, remote,
tmp, END);
r_line_set_prompt (prompt ? prompt : "");
r_line_set_prompt (r_str_get (prompt));
R_FREE (filename);
R_FREE (prompt);

View File

@ -347,7 +347,7 @@ R_API ut64 r_core_pava (RCore *core, ut64 addr) {
if (core->print->pava) {
RIOMap *map = r_io_map_get_paddr (core->io, addr);
if (map) {
return addr - map->delta + map->itv.addr;
return addr - map->delta + r_io_map_begin (map);
}
}
return addr;
@ -1643,7 +1643,7 @@ static void ds_show_functions_argvar(RDisasmState *ds, RAnalFunction *fcn, RAnal
r_str_endswith (var->type, "*") ? "" : " ",
var->name, COLOR_ARG (ds, color_func_var_addr),
constr? " { ":"",
constr? constr: "",
r_str_get (constr),
constr? "} ":"",
base, sign, delta);
if (ds->show_varsum == -1) {
@ -2671,7 +2671,7 @@ static void ds_print_lines_left(RDisasmState *ds) {
static void ds_print_family(RDisasmState *ds) {
if (ds->show_family) {
const char *familystr = r_anal_op_family_to_string (ds->analop.family);
r_cons_printf ("%5s ", familystr? familystr: "");
r_cons_printf ("%5s ", r_str_get (familystr));
}
}
@ -4374,10 +4374,10 @@ static int myregwrite(RAnalEsil *esil, const char *name, ut64 *val) {
if (ds->show_color) {
bool inv = ds->show_emu_strinv;
m = r_str_newf ("%s%s%s\"%s\"%s",
prefix, type ? type : "", inv ? Color_INVERT : "",
prefix, r_str_get (type), inv ? Color_INVERT : "",
escstr, inv ? Color_INVERT_RESET : "");
} else {
m = r_str_newf ("%s%s\"%s\"", prefix, type? type: "", escstr);
m = r_str_newf ("%s%s\"%s\"", prefix, r_str_get (type), escstr);
}
msg = r_str_append_owned (msg, m);
emu_str_printed = true;
@ -4731,9 +4731,9 @@ static void ds_print_esil_anal(RDisasmState *ds) {
// ds_comment_start (ds, "");
ds_comment_esil (ds, true, false, "%s", ds->show_color ? ds->pal_comment : "");
if (fcn_type) {
ds_comment_middle (ds, "; %s%s%s(", r_str_get (fcn_type),
ds_comment_middle (ds, "; %s%s%s(", r_str_getf (fcn_type),
(*fcn_type && fcn_type[strlen (fcn_type) - 1] == '*') ? "" : " ",
r_str_get (key));
r_str_getf (key));
if (!nargs) {
ds_comment_end (ds, "void)");
break;
@ -6297,6 +6297,7 @@ R_API int r_core_print_disasm_all(RCore *core, ut64 addr, int l, int len, int mo
}
break;
case 'j': {
//TODO PJ
char *op_hex = r_asm_op_get_hex (&asmop);
r_cons_printf ("{\"addr\":%08"PFMT64d",\"bytes\":\"%s\",\"inst\":\"%s\"}%s",
addr + i, op_hex, r_asm_op_get_asm (&asmop), ",");

View File

@ -226,8 +226,8 @@ static void GH(get_brks)(RCore *core, GHT *brk_start, GHT *brk_end) {
RIOMap *map = *it;
if (map->name) {
if (strstr (map->name, "[heap]")) {
*brk_start = map->itv.addr;
*brk_end = map->itv.addr + map->itv.size;
*brk_start = r_io_map_begin (map);
*brk_end = r_io_map_end (map);
break;
}
}
@ -421,8 +421,8 @@ static bool GH(r_resolve_main_arena)(RCore *core, GHT *m_arena) {
r_pvector_foreach (&core->io->maps, it) {
RIOMap *map = *it;
if (map->name && strstr (map->name, "arena")) {
libc_addr_sta = map->itv.addr;
libc_addr_end = map->itv.addr + map->itv.size;
libc_addr_sta = r_io_map_begin (map);
libc_addr_end = r_io_map_end (map);
break;
}
}
@ -1124,6 +1124,7 @@ static void GH(print_heap_segment)(RCore *core, MallocState *main_arena,
switch (format_out) {
case 'j':
//TODO PJ
r_cons_printf ("{\"chunks\":[");
break;
case '*':
@ -1151,6 +1152,7 @@ static void GH(print_heap_segment)(RCore *core, MallocState *main_arena,
(ut64)cnk->size, (ut64)cnk->fd, (ut64)cnk->bk);
break;
case 'j':
//TODO PJ
r_cons_printf ("%s{\"addr\":%"PFMT64d",\"size\":%"PFMT64d",\"status\":\"%s\",\"fd\":%"PFMT64d",\"bk\":%"PFMT64d"}",
comma, (ut64)next_chunk, (ut64)cnk->size, status, (ut64)cnk->fd, (ut64)cnk->bk);
comma = ",";
@ -1293,6 +1295,7 @@ static void GH(print_heap_segment)(RCore *core, MallocState *main_arena,
PRINTF_GA ("][%s]",status);
break;
case 'j':
//TODO PJ
r_cons_printf ("%s{\"addr\":0x%"PFMT64x",\"size\":0x%"PFMT64x",\"status\":\"%s\"}",
comma, prev_chunk_addr, prev_chunk_size, status);
comma = ",";

View File

@ -555,8 +555,8 @@ static bool store_files_and_maps (RCore *core, RIODesc *desc, ut32 id) {
if ((maps = r_io_map_get_for_fd (core->io, id))) {
r_list_foreach (maps, iter, map) {
r_cons_printf ("om %d 0x%"PFMT64x" 0x%"PFMT64x" 0x%"PFMT64x" %s%s%s\n", fdc,
map->itv.addr, map->itv.size, map->delta, r_str_rwx_i (map->perm),
map->name ? " " : "", map->name ? map->name : "");
r_io_map_begin (map), r_io_map_size (map), map->delta, r_str_rwx_i (map->perm),
map->name ? " " : "", r_str_get (map->name));
}
r_list_free (maps);
}

View File

@ -88,7 +88,7 @@ static int r_core_rtr_http_run(RCore *core, int launch, int browse, const char *
if (browse == 'H') {
const char *browser = r_config_get (core->config, "http.browser");
r_sys_cmdf ("%s http://%s:%d/%s &",
browser, host, atoi (port), path? path:"");
browser, host, atoi (port), r_str_get (path));
}
so.httpauth = r_config_get_i (core->config, "http.auth");

View File

@ -59,6 +59,7 @@ typedef struct oneshot_t {
R_API void r_core_task_print (RCore *core, RCoreTask *task, int mode) {
switch (mode) {
case 'j':
//TODO PJ
{
r_cons_printf ("{\"id\":%d,\"state\":\"", task->id);
switch (task->state) {
@ -92,7 +93,7 @@ R_API void r_core_task_print (RCore *core, RCoreTask *task, int mode) {
task->id,
task->transient ? "(t)" : "",
r_core_task_status (task),
info ? info : "");
r_str_get (info));
}
break;
}

View File

@ -240,7 +240,7 @@ static bool __core_visual_gogo(RCore *core, int ch) {
map = r_pvector_at (&core->io->maps, r_pvector_len (&core->io->maps) - 1);
}
if (map) {
r_core_seek (core, r_itv_begin (map->itv), true);
r_core_seek (core, r_io_map_begin (map), true);
}
} else {
r_core_seek (core, 0, true);
@ -260,7 +260,7 @@ static bool __core_visual_gogo(RCore *core, int ch) {
}
(void)p->consbind.get_size (&scr_rows);
ut64 scols = r_config_get_i (core->config, "hex.cols");
ret = r_core_seek (core, r_itv_end (map->itv) - (scr_rows - 2) * scols, true);
ret = r_core_seek (core, r_io_map_end (map) - (scr_rows - 2) * scols, true);
}
if (ret != -1) {
r_io_sundo_push (core->io, core->offset, r_print_get_cursor (core->print));
@ -2537,7 +2537,7 @@ R_API int r_core_visual_cmd(RCore *core, const char *arg) {
(void)r_config_set (core->config, "cmd.cprompt", "p=e $r-2");
} else {
R_FREE (I->line->contents);
(void)r_config_set (core->config, "cmd.cprompt", buf? buf: "");
(void)r_config_set (core->config, "cmd.cprompt", r_str_get (buf));
}
r_core_visual_showcursor (core, false);
}
@ -3397,7 +3397,7 @@ R_API int r_core_visual_cmd(RCore *core, const char *arg) {
} else {
RIOMap *map = r_pvector_pop (&core->io->maps);
if (map) {
entry = map->itv.addr;
entry = r_io_map_begin (map);
} else {
entry = r_config_get_i (core->config, "bin.baddr");
}

View File

@ -25,9 +25,9 @@ static char *__core_visual_tab_string(RCore *core, const char *kolor) {
RCoreVisualTab *tab = r_list_get_n (core->visual.tabs, i);
const char *name = (tab && *tab->name)? tab->name: NULL;
if (i == core->visual.tab) {
str = r_str_appendf (str, Color_WHITE"_/ %s \\_%s", name? name: "t=", kolor);
str = r_str_appendf (str, Color_WHITE"_/ %s \\_%s", name ? name: "t=", kolor);
} else {
str = r_str_appendf (str, "_%s(%d)_", name?name: "", i+ 1);
str = r_str_appendf (str, "_%s(%d)_", r_str_get (name), i + 1);
}
}
} else {
@ -41,9 +41,9 @@ static char *__core_visual_tab_string(RCore *core, const char *kolor) {
name = tab->name;
}
if (i==core->visual.tab) {
str = r_str_appendf (str, "_/ %d:%s \\_", i + 1, name? name: "'=");
str = r_str_appendf (str, "_/ %d:%s \\_", i + 1, name ? name : "'=");
} else {
str = r_str_appendf (str, "_(t%d%s%s)__", i + 1, name?":":"", name?name: "");
str = r_str_appendf (str, "_(t%d%s%s)__", i + 1, name ? ":" : "", r_str_get (name));
}
}
}

View File

@ -79,7 +79,7 @@ static char *colorize_asm_string(RCore *core, const char *buf_asm, int optype, u
char *s2 = strdup (spacer + 2);
char *scol1 = r_print_colorize_opcode (core->print, s1, color_reg, color_num, false, fcn ? fcn->addr : 0);
char *scol2 = r_print_colorize_opcode (core->print, s2, color_reg, color_num, false, fcn ? fcn->addr : 0);
char *source = r_str_newf ("%s||%s", r_str_get2 (scol1), r_str_get2 (scol2));
char *source = r_str_newf ("%s||%s", r_str_get (scol1), r_str_get (scol2));
free (scol1);
free (scol2);
free (s1);
@ -1159,7 +1159,7 @@ R_API int r_core_visual_classes(RCore *core) {
int cols;
r_cons_clear00 ();
if (grepmode) {
r_cons_printf ("Grep: %s\n", grep? grep: "");
r_cons_printf ("Grep: %s\n", r_str_get (grep));
}
ptr = show_class (core, mode, &index, cur, grep, list);
switch (mode) {
@ -1657,7 +1657,7 @@ R_API int r_core_visual_view_rop(RCore *core) {
int count = 0;
r_cons_flush ();
r_cons_gotoxy (0, 20);
r_cons_printf ("ROPChain:\n %s\n", chainstr? chainstr: "");
r_cons_printf ("ROPChain:\n %s\n", r_str_get (chainstr));
r_list_foreach (core->ropchain, iter, msg) {
int extra = strlen (chainstr) / scr_w;
r_cons_gotoxy (0, extra + 22 + count);

View File

@ -51,7 +51,7 @@ static int perform_mapped_file_yank(RCore *core, ut64 offset, ut64 len, const ch
yank_file_sz = r_io_size (core->io);
ut64 addr = r_io_map_next_available (core->io, 0, yank_file_sz, load_align);
map = r_io_map_new (core->io, yankdesc->fd, R_PERM_R, 0, addr, yank_file_sz);
loadaddr = map? map->itv.addr: -1;
loadaddr = map? r_io_map_begin (map): -1;
if (yankdesc && map && loadaddr != -1) {
// ***NOTE*** this is important, we need to
// address the file at its physical address!
@ -249,6 +249,7 @@ R_API bool r_core_yank_dump(RCore *core, ut64 pos, int format) {
r_cons_newline ();
break;
case 'j':
//TODO PJ
{
r_cons_printf ("{\"addr\":%"PFMT64u",\"bytes\":\"", core->yank_addr);
for (i = pos; i < r_buf_size (core->yank_buf); i++) {

View File

@ -97,6 +97,7 @@ static bool siglistjsoncb (void *p, const char *k, const char *v) {
} else {
r_cons_strcat (",");
}
//TODO PJ
r_cons_printf ("{\"signum\":\"%s\",\"name\":\"%s\",\"option\":", k, v);
if (opt & R_DBG_SIGNAL_CONT) {
r_cons_strcat ("\"cont\"");

View File

@ -9,7 +9,7 @@
#define _XNU_DEBUG_H
#define MACH_ERROR_STRING(ret) \
(mach_error_string (ret) ? r_str_get (mach_error_string (ret)) : "(unknown)")
(mach_error_string (ret) ? r_str_getf (mach_error_string (ret)) : "(unknown)")
#if TARGET_OS_IPHONE
// no ptrace

View File

@ -66,6 +66,7 @@ R_API int r_debug_plugin_list(RDebug *dbg, int mode) {
if (mode == 'q') {
dbg->cb_printf ("%s\n", h->name);
} else if (mode == 'j') {
//TODO PJ
dbg->cb_printf ("%s{\"name\":\"%s\",\"license\":\"%s\"}",
(count ? "," : ""),
h->name,

View File

@ -350,13 +350,13 @@ static bool print_flag_rad(RFlagItem *flag, void *user) {
u->f->cb_printf ("fa %s %s\n", flag->name, flag->alias);
if (comment_b64) {
u->f->cb_printf ("\"fC %s %s\"\n",
flag->name, comment_b64? comment_b64: "");
flag->name, r_str_get (comment_b64));
}
} else {
u->f->cb_printf ("f %s %" PFMT64d " 0x%08" PFMT64x "%s%s %s\n",
flag->name, flag->size, flag->offset,
u->pfx? "+": "", u->pfx? u->pfx: "",
comment_b64? comment_b64: "");
u->pfx? "+": "", r_str_get (u->pfx),
r_str_get (comment_b64));
}
free (comment_b64);

View File

@ -845,7 +845,7 @@ typedef struct r_bin_dwarf_loc_list_t {
ut64 offset;
} RBinDwarfLocList;
#define r_bin_dwarf_line_new(o,a,f,l) o->address=a, o->file = strdup (f?f:""), o->line = l, o->column =0,o
#define r_bin_dwarf_line_new(o,a,f,l) o->address=a, o->file = strdup (r_str_get (f)), o->line = l, o->column =0,o
R_API RList *r_bin_dwarf_parse_aranges(RBin *a, int mode);
R_API RList *r_bin_dwarf_parse_line(RBin *a, int mode);

View File

@ -15,8 +15,20 @@
#define R_IO_UNDOS 64
#define r_io_map_get_from(map) map->itv.addr
#define r_io_map_get_to(map) ( r_itv_end (map->itv) - 1 )
#define r_io_map_begin(map) r_itv_begin (map->itv)
#define r_io_map_to(map) ( r_itv_end (map->itv) - 1 )
#define r_io_map_end(map) r_itv_end (map->itv)
#define r_io_map_size(map) r_itv_size (map->itv)
#define r_io_map_contain(map, addr) r_itv_contain (map->itv, addr)
#define r_io_map_set_begin(map, new_addr) \
do { \
map->itv.addr = new_addr; \
} while (0)
#define r_io_map_set_size(map, new_size) \
do { \
map->itv.size = new_size; \
} while (0)
#if HAVE_PTRACE

View File

@ -125,7 +125,8 @@ R_API int r_str_casecmp(const char *dst, const char *orig);
R_API int r_str_ncasecmp(const char *dst, const char *orig, size_t n);
R_API int r_str_ccpy(char *dst, char *orig, int ch);
R_API const char *r_str_get(const char *str);
R_API const char *r_str_get2(const char *str);
R_API const char *r_str_get_fail(const char *str, const char *failstr);
R_API const char *r_str_getf(const char *str);
R_API char *r_str_ndup(const char *ptr, int len);
R_API char *r_str_dup(char *ptr, const char *string);
R_API int r_str_inject(char *begin, char *end, char *str, int maxlen);

View File

@ -65,7 +65,7 @@ static st64 on_map_skyline(RIO *io, ut64 vaddr, ut8 *buf, int len, int match_flg
RIOMap *map = part->user;
// The map satisfies the permission requirement or p_cache is enabled
if (((map->perm & match_flg) == match_flg || io->p_cache)) {
st64 result = op (io, map->fd, map->delta + addr - map->itv.addr,
st64 result = op (io, map->fd, map->delta + addr - r_io_map_begin(map),
buf + (addr - vaddr), len1, map, NULL);
if (prefix_mode) {
if (result < 0) {
@ -406,7 +406,7 @@ R_API bool r_io_resize(RIO* io, ut64 newsize) {
ut64 fd_size = r_io_fd_size (io, io->desc->fd);
r_list_foreach (maps, iter, current_map) {
// we just resize map of the same size of its fd
if (current_map->itv.size == fd_size) {
if (r_io_map_size (current_map) == fd_size) {
r_io_map_resize (io, current_map->id, newsize);
}
}
@ -485,7 +485,7 @@ R_API bool r_io_set_write_mask(RIO* io, const ut8* mask, int len) {
R_API ut64 r_io_p2v(RIO *io, ut64 pa) {
RIOMap *map = r_io_map_get_paddr (io, pa);
if (map) {
return pa - map->delta + map->itv.addr;
return pa - map->delta + r_io_map_begin (map);
}
return UT64_MAX;
}
@ -493,8 +493,8 @@ R_API ut64 r_io_p2v(RIO *io, ut64 pa) {
R_API ut64 r_io_v2p(RIO *io, ut64 va) {
RIOMap *map = r_io_map_get (io, va);
if (map) {
st64 delta = va - map->itv.addr;
return map->itv.addr + map->delta + delta;
st64 delta = va - r_io_map_begin (map);
return r_io_map_begin (map) + map->delta + delta;
}
return UT64_MAX;
}

View File

@ -36,7 +36,8 @@ RIOMap* io_map_new(RIO* io, int fd, int perm, ut64 delta, ut64 addr, ut64 size)
io_map_new (io, fd, perm, delta - addr, 0LL, size + addr);
size = -(st64)addr;
}
// RIOMap describes an interval of addresses (map->from; map->to)
// RIOMap describes an interval of addresses
// r_io_map_begin (map) -> r_io_map_to (map)
map->itv = (RInterval){ addr, size };
map->perm = perm;
map->delta = delta;
@ -53,10 +54,10 @@ R_API RIOMap *r_io_map_new(RIO *io, int fd, int perm, ut64 delta, ut64 addr, ut6
R_API bool r_io_map_remap(RIO *io, ut32 id, ut64 addr) {
RIOMap *map = r_io_map_resolve (io, id);
if (map) {
ut64 size = map->itv.size;
map->itv.addr = addr;
ut64 size = r_io_map_size (map);
r_io_map_set_begin (map, addr);
if (UT64_MAX - size + 1 < addr) {
map->itv.size = -addr;
r_io_map_set_size (map, -addr);
r_io_map_new (io, map->fd, map->perm, map->delta - addr, 0, size + addr);
}
io_map_calculate_skyline (io);
@ -154,7 +155,7 @@ R_API RIOMap* r_io_map_get_paddr(RIO* io, ut64 paddr) {
void **it;
r_pvector_foreach_prev (&io->maps, it) {
RIOMap *map = *it;
if (map->delta <= paddr && paddr <= map->delta + map->itv.size - 1) {
if (map->delta <= paddr && paddr < map->delta + r_io_map_size (map)) {
return map;
}
}
@ -340,12 +341,12 @@ R_API ut64 r_io_map_next_available(RIO* io, ut64 addr, ut64 size, ut64 load_alig
void **it;
r_pvector_foreach (&io->maps, it) {
RIOMap *map = *it;
ut64 to = r_itv_end (map->itv);
ut64 to = r_io_map_end (map);
next_addr = R_MAX (next_addr, to + (load_align - (to % load_align)) % load_align);
// XXX - This does not handle when file overflow 0xFFFFFFFF000 -> 0x00000FFF
// adding the check for the map's fd to see if this removes contention for
// memory mapping with multiple files. infinite loop ahead?
if ((map->itv.addr <= next_addr && next_addr < to) || r_itv_contain (map->itv, end_addr)) {
if ((r_io_map_begin (map) <= next_addr && next_addr < to) || r_io_map_contain (map, end_addr)) {
next_addr = to + (load_align - (to % load_align)) % load_align;
return r_io_map_next_available (io, next_addr, size, load_align);
}
@ -360,11 +361,11 @@ R_API ut64 r_io_map_next_address(RIO* io, ut64 addr) {
void **it;
r_pvector_foreach (&io->maps, it) {
RIOMap *map = *it;
ut64 from = r_itv_begin (map->itv);
ut64 from = r_io_map_begin (map);
if (from > addr && addr < lowest) {
lowest = from;
}
ut64 to = r_itv_end (map->itv);
ut64 to = r_io_map_end (map);
if (to > addr && to < lowest) {
lowest = to;
}
@ -392,13 +393,13 @@ R_API bool r_io_map_resize(RIO *io, ut32 id, ut64 newsize) {
if (!newsize || !(map = r_io_map_resolve (io, id))) {
return false;
}
ut64 addr = map->itv.addr;
ut64 addr = r_io_map_begin (map);
if (UT64_MAX - newsize + 1 < addr) {
map->itv.size = -addr;
r_io_map_set_size (map, -addr);
r_io_map_new (io, map->fd, map->perm, map->delta - addr, 0, newsize + addr);
return true;
}
map->itv.size = newsize;
r_io_map_set_size (map, newsize);
io_map_calculate_skyline (io);
return true;
}

View File

@ -27,6 +27,7 @@ static int __write(RIO *io, RIODesc *fd, const ut8 *buf, int count) {
snprintf (bufn, bufn_sz, "%s%d", i ? "," : "", buf[i]);
bufn += strlen (bufn);
}
//TODO PJ (?)
int len = snprintf (fmt, sizeof (fmt),
"{\"op\":\"write\",\"address\":%" PFMT64d ",\"data\":[%s]}",
io->off, bufnum);
@ -60,6 +61,7 @@ static int __read(RIO *io, RIODesc *fd, ut8 *buf, int count) {
if (count > 1024) {
count = 1024;
}
//TODO PJ (?)
snprintf (fmt, sizeof (fmt),
"{\"op\":\"read\",\"address\":%"PFMT64d",\"count\":%d}",
io->off, count);

View File

@ -48,10 +48,10 @@ R_API RIOUndos *r_io_sundo(RIO *io, ut64 offset) {
undo = &io->undo.seek[io->undo.idx];
RIOMap *map = r_io_map_get (io, undo->off);
if (!map || (map->delta == map->itv.addr)) {
if (!map || (map->delta == r_io_map_begin (map))) {
io->off = undo->off;
} else {
io->off = undo->off - (map->itv.addr + map->delta);
io->off = undo->off - (r_io_map_begin (map) + map->delta);
}
return undo;
}
@ -70,10 +70,10 @@ R_API RIOUndos *r_io_sundo_redo(RIO *io) {
undo = &io->undo.seek[io->undo.idx];
map = r_io_map_get (io, undo->off);
if (!map || (map->delta == map->itv.addr)) {
if (!map || (map->delta == r_io_map_begin (map))) {
io->off = undo->off;
} else {
io->off = undo->off - map->itv.addr + map->delta;
io->off = undo->off - r_io_map_begin (map) + map->delta;
}
return undo;
}

View File

@ -204,6 +204,7 @@ static int cb(RDiff *d, void *user, RDiffOp *op) {
}
return 1;
case 'j':
// TODO PJ
if (ro->disasm) {
eprintf ("JSON (-j) + disasm (-D) not yet implemented\n");
}
@ -835,7 +836,7 @@ static char *get_graph_commands(RCore *c, ut64 off) {
r_cons_push ();
r_core_anal_graph (c, off, R_CORE_ANAL_GRAPHBODY | R_CORE_ANAL_GRAPHDIFF | R_CORE_ANAL_STAR);
const char *static_str = r_cons_get_buffer ();
char *retstr = strdup (static_str? static_str: "");
char *retstr = strdup (r_str_get (static_str));
r_cons_pop ();
r_cons_echo (NULL);
r_cons_singleton ()->is_html = tmp_html;
@ -1089,11 +1090,11 @@ R_API int r_main_radiff2(int argc, const char **argv) {
case MODE_DIFF_IMPORTS:
c = opencore (&ro, ro.file);
if (!c) {
eprintf ("Cannot open '%s'\n", r_str_get (ro.file));
eprintf ("Cannot open '%s'\n", r_str_getf (ro.file));
}
c2 = opencore (&ro, ro.file2);
if (!c || !c2) {
eprintf ("Cannot open '%s'\n", r_str_get (ro.file2));
eprintf ("Cannot open '%s'\n", r_str_getf (ro.file2));
return 1;
}
c->c2 = c2;
@ -1194,13 +1195,13 @@ R_API int r_main_radiff2(int argc, const char **argv) {
bufa = slurp (&ro, &c, ro.file, &fsz);
sza = fsz;
if (!bufa) {
eprintf ("radiff2: Cannot open %s\n", r_str_get (ro.file));
eprintf ("radiff2: Cannot open %s\n", r_str_getf (ro.file));
return 1;
}
bufb = slurp (&ro, &c, ro.file2, &fsz);
szb = fsz;
if (!bufb) {
eprintf ("radiff2: Cannot open: %s\n", r_str_get (ro.file2));
eprintf ("radiff2: Cannot open: %s\n", r_str_getf (ro.file2));
free (bufa);
return 1;
}
@ -1233,6 +1234,7 @@ R_API int r_main_radiff2(int argc, const char **argv) {
d = r_diff_new ();
r_diff_set_delta (d, delta);
if (ro.diffmode == 'j') {
//TODO PJ
printf ("{\"files\":[{\"filename\":\"%s\", \"size\":%"PFMT64u", \"sha256\":\"", ro.file, sza);
handle_sha256 (bufa, (int)sza);
printf ("\"},\n{\"filename\":\"%s\", \"size\":%"PFMT64u", \"sha256\":\"", ro.file2, szb);

View File

@ -118,6 +118,7 @@ static int hit(RSearchKeyword *kw, void *user, ut64 addr) {
str[i] = 0;
}
if (ro->json) {
//TODO PJ
const char *type = "string";
printf ("%s{\"offset\":%"PFMT64d",\"type\":\"%s\",\"data\":\"%s\"}",
ro->comma, addr, type, str);

View File

@ -111,6 +111,7 @@ static void do_hash_print(RHash *ctx, ut64 hash, int dlen, int rad, int ule) {
do_hash_hexprint (c, dlen, ule, 'j');
break;
case 'j':
//TODO PJ
printf ("{\"name\":\"%s\",\"hash\":\"", hname);
do_hash_hexprint (c, dlen, ule, rad);
printf ("\"}");

View File

@ -1254,7 +1254,7 @@ R_API RList* r_file_globsearch (const char *_globbed_path, int maxdepth) {
glob_ptr = last_slash + 1;
if (globbed_path[0] == '~') {
char *rpath = r_str_newlen (globbed_path + 2, last_slash - globbed_path - 1);
path = r_str_home (rpath ? rpath : "");
path = r_str_home (r_str_get (rpath));
free (rpath);
} else {
path = r_str_newlen (globbed_path, last_slash - globbed_path + 1);

View File

@ -1230,11 +1230,11 @@ static void r_print_format_nulltermstring(const RPrint* p, int len, int endian,
? p->iob.map_get (p->iob.io, addr)
: p->iob.map_get_paddr (p->iob.io, addr))
&& map->perm & R_PERM_R) {
if (!map->itv.size) {
if (!r_io_map_size(map)) {
total_map_left = addr == 0 ? UT64_MAX : UT64_MAX - addr + 1;
break;
}
total_map_left += map->itv.size - (addr - (p->iob.io->va ? map->itv.addr : map->delta));
total_map_left += r_io_map_size (map) - (addr - (p->iob.io->va ? r_io_map_begin (map) : map->delta));
addr += total_map_left;
}
if (total_map_left < len) {
@ -1914,6 +1914,7 @@ static char *get_format_type(const char fmt, const char arg) {
return type;
}
//TODO PJ
#define MINUSONE ((void*)(size_t)-1)
#define ISSTRUCT (tmp == '?' || (tmp == '*' && *(arg+1) == '?'))
R_API int r_print_format(RPrint *p, ut64 seek, const ut8* b, const int len,

View File

@ -45,8 +45,8 @@ R_API char *r_graph_drawable_to_dot(RGraph /*RGraphNodeInfo*/ *graph, const char
"edge [arrowhead=normal, color=\"#3030c0\" style=bold weight=2 %s];\n"
"node [fillcolor=white, style=filled shape=box "
"fontsize=\"8\" %s];\n",
edge_properties? edge_properties: "",
node_properties? node_properties: "");
r_str_get (edge_properties),
r_str_get (node_properties));
r_list_foreach (nodes, it, node) {
RGraphNodeInfo *print_node = (RGraphNodeInfo *)node->data;

View File

@ -1165,7 +1165,7 @@ R_API void r_print_hexdump(RPrint *p, ut64 addr, const ut8 *buf, int len, int ba
const char *n = p->offname (p->user, addr + j);
r_print_section (p, at);
r_print_addr (p, addr + j * zoomsz);
printfmt ("..[ null bytes ].. 00000000 %s\n", n? n: "");
printfmt ("..[ null bytes ].. 00000000 %s\n", r_str_get (n));
}
}
r_print_cursor (p, j, sz_n, 0);
@ -1316,7 +1316,7 @@ R_API void r_print_hexdump(RPrint *p, ut64 addr, const ut8 *buf, int len, int ba
a = p->offname (p->user, addr + j);
if (p->colorfor && a && *a) {
const char *color = p->colorfor (p->user, addr + j, true);
printfmt ("%s ; %s%s", color ? color: "", a,
printfmt ("%s ; %s%s", r_str_get (color), a,
color ? Color_RESET : "");
}
}

View File

@ -820,11 +820,15 @@ R_API char *r_str_word_get_first(const char *text) {
}
R_API const char *r_str_get(const char *str) {
return str? str: nullstr_c;
return str? str: nullstr;
}
R_API const char *r_str_get2(const char *str) {
return str? str: nullstr;
R_API const char *r_str_get_fail(const char *str, const char *failstr) {
return str? str: failstr;
}
R_API const char *r_str_getf(const char *str) {
return str? str: nullstr_c;
}
R_API char *r_str_ndup(const char *ptr, int len) {

View File

@ -105,6 +105,7 @@ static char *showfile(char *res, const int nth, const char *fpath, const char *n
r_str_rwx_i (perm & 7),
uid, gid, sz, nn);
} else if (printfmt == FMT_JSON) {
//TODO PJ
if (nth > 0) {
res = r_str_append (res, ",");
}

View File

@ -196,7 +196,7 @@ R_API void r_table_add_rowf(RTable *t, const char *fmt, ...) {
case 's':
case 'z':
arg = va_arg (ap, const char *);
r_list_append (list, strdup (arg? arg: ""));
r_list_append (list, strdup (r_str_get (arg)));
break;
case 'b':
r_list_append (list, r_str_new (r_str_bool (va_arg (ap, int))));
@ -1046,7 +1046,7 @@ R_API bool r_table_query(RTable *t, const char *q) {
} else if (!strcmp (operation, "join")) {
// TODO: implement join operation with other command's tables
} else if (!strcmp (operation, "sum")) {
char *op = strdup (operand?operand: "");
char *op = strdup (r_str_get (operand));
RList *list = r_str_split_list (op, "/", 0);
r_list_prepend (list, strdup (columnName));
r_table_columns (t, list); // select/reorder columns
@ -1082,7 +1082,7 @@ R_API bool r_table_query(RTable *t, const char *q) {
r_table_filter (t, col, '~', operand);
}
} else if (!strcmp (operation, "cols")) {
char *op = strdup (operand?operand: "");
char *op = strdup (r_str_get (operand));
RList *list = r_str_split_list (op, "/", 0);
r_list_prepend (list, strdup (columnName));
r_table_columns (t, list); // select/reorder columns

View File

@ -550,7 +550,7 @@ R_API char *r_bin_java_unmangle_method(const char *flags, const char *name, cons
if (!r_val_str) {
r_val_str = strdup ("UNKNOWN");
}
f_val_str = strdup (flags ? flags : "");
f_val_str = strdup (r_str_get (flags));
r_list_foreach (the_list, iter, str) {
params_len += strlen (str);
if (params_idx > 0) {

View File

@ -104,6 +104,7 @@ SDB_API int sdb_json_unset (Sdb *s, const char *k, const char *p, ut32 cas) {
return sdb_json_set (s, k, p, NULL, cas);
}
//TODO PJ (?)
SDB_API bool sdb_json_set (Sdb *s, const char *k, const char *p, const char *v, ut32 cas) {
int l, idx, len[3], jslen = 0;
char *b, *str = NULL;