mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-02 03:32:04 +00:00
more pcache config
This commit is contained in:
parent
254ad5d156
commit
0d0e94aa3b
@ -1150,13 +1150,53 @@ static int cb_iopcache(void *user, void *data) {
|
||||
RCore *core = (RCore *) user;
|
||||
RConfigNode *node = (RConfigNode *) data;
|
||||
if ((bool)node->i_value) {
|
||||
if (core && core->io) {
|
||||
core->io->p_cache = true;
|
||||
if (core) {
|
||||
r_config_eval (core->config, "io.pcacheread=true");
|
||||
r_config_eval (core->config, "io.pcachewrite=true");
|
||||
}
|
||||
} else {
|
||||
if (core && core->io) {
|
||||
r_io_desc_cache_fini_all (core->io);
|
||||
core->io->p_cache = false;
|
||||
r_config_eval (core->config, "io.pcacheread=false");
|
||||
r_config_eval (core->config, "io.pcachewrite=false");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static int cb_iopcacheread(void *user, void *data) {
|
||||
RCore *core = (RCore *) user;
|
||||
RConfigNode *node = (RConfigNode *) data;
|
||||
if ((bool)node->i_value) {
|
||||
if (core && core->io) {
|
||||
core->io->p_cache |= 1;
|
||||
}
|
||||
} else {
|
||||
if (core && core->io && core->io->p_cache) {
|
||||
core->io->p_cache &= 2;
|
||||
if (!(core->io->p_cache & 2)) {
|
||||
r_io_desc_cache_fini_all (core->io);
|
||||
r_config_eval (core->config, "io.pcache=false");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static int cb_iopcachewrite(void *user, void *data) {
|
||||
RCore *core = (RCore *) user;
|
||||
RConfigNode *node = (RConfigNode *) data;
|
||||
if ((bool)node->i_value) {
|
||||
if (core && core->io) {
|
||||
core->io->p_cache |= 2;
|
||||
}
|
||||
} else {
|
||||
if (core && core->io && core->io->p_cache) {
|
||||
core->io->p_cache &= 1;
|
||||
if (!(core->io->p_cache & 1)) {
|
||||
r_io_desc_cache_fini_all (core->io);
|
||||
r_config_eval (core->config, "io.pcache=false");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -2570,6 +2610,8 @@ R_API int r_core_config_init(RCore *core) {
|
||||
SETI ("io.buffer.to", 0, "Higher address of buffered cache");
|
||||
SETCB ("io.cache", "false", &cb_iocache, "Enable cache for io changes");
|
||||
SETCB ("io.pcache", "false", &cb_iopcache, "io.cache for p-level");
|
||||
SETCB ("io.pcachewrite", "false", &cb_iopcachewrite, "Enable write-cache");
|
||||
SETCB ("io.pcacheread", "false", &cb_iopcacheread, "Enable read-cache");
|
||||
SETCB ("io.ff", "true", &cb_ioff, "Fill invalid buffers with 0xff instead of returning error");
|
||||
SETICB ("io.0xff", 0xff, &cb_io_oxff, "Use this value instead of 0xff to fill unallocated areas");
|
||||
SETCB ("io.aslr", "false", &cb_ioaslr, "Disable ASLR for spawn and such");
|
||||
|
@ -63,7 +63,7 @@ typedef struct r_io_t {
|
||||
int autofd;
|
||||
bool cached;
|
||||
bool cached_read;
|
||||
bool p_cache;
|
||||
int p_cache;
|
||||
int buffer_enabled;
|
||||
int debug;
|
||||
//#warning remove debug from RIO
|
||||
|
@ -143,7 +143,7 @@ R_API int r_io_desc_write(RIODesc *desc, const ut8* buf, int len) {
|
||||
return 0;
|
||||
}
|
||||
//check pointers and pcache
|
||||
if (desc->io && desc->io->p_cache) {
|
||||
if (desc->io && (desc->io->p_cache & 2)) {
|
||||
return r_io_desc_cache_write (desc,
|
||||
r_io_desc_seek (desc, 0LL, R_IO_SEEK_CUR), buf, len);
|
||||
}
|
||||
@ -165,7 +165,7 @@ R_API int r_io_desc_read(RIODesc *desc, ut8 *buf, int len) {
|
||||
}
|
||||
seek = r_io_desc_seek (desc, 0LL, R_IO_SEEK_CUR);
|
||||
ret = desc->plugin->read (desc->io, desc, buf, len);
|
||||
if ((ret > 0) && desc->io && desc->io->p_cache) {
|
||||
if ((ret > 0) && desc->io && (desc->io->p_cache & 1)) {
|
||||
ret = r_io_desc_cache_read (desc, seek, buf, ret);
|
||||
}
|
||||
return ret;
|
||||
|
@ -557,7 +557,7 @@ R_API bool r_io_write_at(RIO* io, ut64 addr, const ut8* buf, int len) {
|
||||
}
|
||||
}
|
||||
if (io->cached) {
|
||||
ret = !!r_io_cache_write (io, addr, mybuf, len);
|
||||
r_io_cache_write (io, addr, mybuf, len); //can be ignored for the return
|
||||
} else if (io->va) {
|
||||
ret = r_io_vwrite_at (io, addr, mybuf, len);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user