Rewrite r_io_p2v ##io

This commit is contained in:
condret 2024-11-25 00:02:29 +01:00
parent b4ccc0f55a
commit 34bc40fd91
4 changed files with 12 additions and 20 deletions

View File

@ -2532,10 +2532,7 @@ static void annotated_hexdump(RCore *core, const char *str, int len) {
echars = chars;
ut64 ea = addr;
if (core->print->pava) {
ut64 va = r_io_p2v (core->io, addr);
if (va != UT64_MAX) {
ea = va;
}
r_io_p2v (core->io, addr, &ea);
}
if (usecolor) {
append (ebytes, core->cons->context->pal.offset);
@ -6163,10 +6160,7 @@ static void cmd_print_pxb(RCore *core, int len, const char *input) {
if (c == 0) {
ut64 ea = core->offset + i;
if (core->print->pava) {
ut64 va = r_io_p2v (core->io, ea);
if (va != UT64_MAX) {
ea = va;
}
r_io_p2v (core->io, ea, &ea);
}
r_print_section (core->print, ea);
r_print_offset (core->print, ea, 0, 0, NULL);

View File

@ -284,7 +284,7 @@ typedef bool (*RIOFdClose)(RIO *io, int fd);
typedef ut64 (*RIOFdSeek)(RIO *io, int fd, ut64 addr, int whence);
typedef ut64 (*RIOFdSize)(RIO *io, int fd);
typedef bool (*RIOFdResize)(RIO *io, int fd, ut64 newsize);
typedef ut64 (*RIOP2V)(RIO *io, ut64 pa);
typedef bool (*RIOP2V)(RIO *io, ut64 p, ut64 *v);
typedef ut64 (*RIOV2P)(RIO *io, ut64 va);
typedef int (*RIOFdRead)(RIO *io, int fd, ut8 *buf, int len);
typedef int (*RIOFdWrite)(RIO *io, int fd, const ut8 *buf, int len);
@ -384,7 +384,7 @@ R_API bool r_io_map_locate(RIO *io, ut64 *addr, const ut64 size, ut64 load_align
// p2v/v2p
R_API ut64 r_io_p2v(RIO *io, ut64 pa);
R_API bool r_io_p2v(RIO *io, ut64 p, ut64 *v);
R_API ut64 r_io_v2p(RIO *io, ut64 va);
//io_submap.c

View File

@ -449,13 +449,14 @@ R_API bool r_io_set_write_mask(RIO* io, const ut8* mask, int len) {
return true;
}
R_API ut64 r_io_p2v(RIO *io, ut64 pa) {
R_RETURN_VAL_IF_FAIL (io, 0);
RIOMap *map = r_io_map_get_paddr (io, pa);
if (map) {
return pa - map->delta + r_io_map_begin (map);
R_API bool r_io_p2v(RIO *io, ut64 p, ut64 *v) {
R_RETURN_VAL_IF_FAIL (io && v, false);
RIOMap *map = r_io_map_get_paddr (io, p);
if (!map) {
return false;
}
return UT64_MAX;
*v = p - map->delta + r_io_map_begin (map);
return true;
}
R_API ut64 r_io_v2p(RIO *io, ut64 va) {

View File

@ -444,10 +444,7 @@ R_API void r_print_addr(RPrint *p, ut64 addr) {
ch = '|';
}
if (p && p->pava) {
ut64 va = p->iob.p2v (p->iob.io, addr);
if (va != UT64_MAX) {
addr = va;
}
p->iob.p2v (p->iob.io, addr, &addr);
}
if (use_segoff) {
ut32 s, a;