mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-14 16:59:08 +00:00
enable switching to vio at runtime
This commit is contained in:
parent
213d7f92ca
commit
b93d08ebb7
@ -609,6 +609,13 @@ static int cb_ioautofd(void *user, void *data) {
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
static int cb_iovio(void *user, void *data) {
|
||||
RCore *core = (RCore *) user;
|
||||
RConfigNode *node = (RConfigNode *) data;
|
||||
core->io->vio = node->i_value;
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
static int cb_pager(void *user, void *data) {
|
||||
RCore *core = (RCore *) user;
|
||||
RConfigNode *node = (RConfigNode *) data;
|
||||
@ -1220,6 +1227,7 @@ R_API int r_core_config_init(RCore *core) {
|
||||
SETCB("io.va", "true", &cb_iova, "If enabled virtual address layout can be used");
|
||||
SETCB("io.zeromap", "0", &cb_iozeromap, "Double map the last opened file to address zero");
|
||||
SETCB("io.autofd", "true", &cb_ioautofd, "change fd when opening new file automatically");
|
||||
SETCB("io.vio", "false", &cb_iovio, "enable this for testing the new vio (reading only)");
|
||||
|
||||
/* file */
|
||||
SETPREF("file.analyze", "false", "Analyze file on load. Same as r2 -c aa ..");
|
||||
|
@ -118,6 +118,7 @@ typedef struct r_io_t {
|
||||
int raised;
|
||||
int va;
|
||||
int raw;
|
||||
int vio; //remove that when vio replaces the old stuff
|
||||
int sectonly;
|
||||
char *referer;
|
||||
char *redirect;
|
||||
|
41
libr/io/io.c
41
libr/io/io.c
@ -8,7 +8,7 @@ R_LIB_VERSION (r_io);
|
||||
|
||||
// XXX: this is buggy. must use seek+read
|
||||
#define USE_CACHE 1
|
||||
// the new io is buggy
|
||||
// the new io is buggy //liar
|
||||
#define USE_NEW_IO 0
|
||||
#define DO_THE_IO_DBG 0
|
||||
#define IO_IFDBG if (DO_THE_IO_DBG == 1)
|
||||
@ -356,9 +356,9 @@ int r_io_read_cr (RIO *io, ut64 addr, ut8 *buf, int len) {
|
||||
}
|
||||
|
||||
R_API int r_io_read_at(RIO *io, ut64 addr, ut8 *buf, int len) {
|
||||
#if USE_NEW_IO
|
||||
return r_io_read_cr (io, addr, buf, len);
|
||||
#else
|
||||
if (io && io->vio)
|
||||
return r_io_read_cr (io, addr, buf, len);
|
||||
|
||||
ut64 paddr, last, last2;
|
||||
int ms, ret, l = 0, olen = len, w = 0;
|
||||
|
||||
@ -524,7 +524,6 @@ if (len>0) {
|
||||
//break;
|
||||
}
|
||||
return olen;
|
||||
#endif
|
||||
}
|
||||
|
||||
R_API ut64 r_io_read_i(RIO *io, ut64 addr, int sz, int endian) {
|
||||
@ -947,20 +946,24 @@ R_API int r_io_is_valid_offset (RIO *io, ut64 offset) {
|
||||
r_sys_backtrace ();
|
||||
return R_FAIL;
|
||||
}
|
||||
switch (io->va) {
|
||||
case 0:
|
||||
return (offset < r_io_size (io));
|
||||
#if USE_NEW_IO
|
||||
case 1:
|
||||
return r_io_map_exists_for_offset (io, offset);
|
||||
case 2:
|
||||
return (r_io_map_exists_for_offset (io, offset) ||
|
||||
r_io_section_exists_for_vaddr (io, offset));
|
||||
#else
|
||||
case 1:
|
||||
return (r_io_map_exists_for_offset (io, offset) ||
|
||||
r_io_section_exists_for_vaddr (io, offset));
|
||||
#endif
|
||||
if (io->vio) {
|
||||
switch (io->va) {
|
||||
case 0:
|
||||
return (offset < r_io_size (io));
|
||||
case 1:
|
||||
return r_io_map_exists_for_offset (io, offset);
|
||||
case 2:
|
||||
return (r_io_map_exists_for_offset (io, offset) ||
|
||||
r_io_section_exists_for_vaddr (io, offset));
|
||||
}
|
||||
} else {
|
||||
switch (io->va) {
|
||||
case 0:
|
||||
return (offset < r_io_size (io));
|
||||
case 1:
|
||||
return (r_io_map_exists_for_offset (io, offset) ||
|
||||
r_io_section_exists_for_vaddr (io, offset));
|
||||
}
|
||||
}
|
||||
eprintf ("r_io_is_valid_offset: io->va is %i\n", io->va);
|
||||
r_sys_backtrace ();
|
||||
|
Loading…
Reference in New Issue
Block a user