mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-25 06:09:50 +00:00
Fix #1726 - ESIL brainfuck is back (and fix io.maps test case) - Thanks @trndr
This commit is contained in:
parent
f0e5c584ba
commit
bcf7d46e36
@ -303,6 +303,7 @@ R_API int r_io_use_desc(RIO *io, RIODesc *fd);
|
||||
R_API const ut8* r_io_get_raw (RIO *io, ut64 addr, int *len);
|
||||
R_API RBuffer *r_io_read_buf(RIO *io, ut64 addr, int len);
|
||||
R_API int r_io_vread (RIO *io, ut64 vaddr, ut8 *buf, int len);
|
||||
R_API int r_io_read_internal(RIO *io, ut8 *buf, int len);
|
||||
R_API int r_io_mread (RIO *io, int fd, ut64 maddr, ut8 *buf, int len);
|
||||
R_API int r_io_pread (RIO *io, ut64 paddr, ut8 *buf, int len);
|
||||
R_API int r_io_read(RIO *io, ut8 *buf, int len);
|
||||
|
@ -105,14 +105,21 @@ R_API int r_io_cache_write(RIO *io, ut64 addr, const ut8 *buf, int len) {
|
||||
RIOCache *ch;
|
||||
if (io->cached == 2) // magic hackaround
|
||||
return 0;
|
||||
ch = R_NEW (RIOCache);
|
||||
ch = R_NEW0 (RIOCache);
|
||||
ch->from = addr;
|
||||
ch->to = addr + len;
|
||||
ch->size = len;
|
||||
ch->odata = (ut8*)malloc (len);
|
||||
ch->data = (ut8*)malloc (len);
|
||||
r_io_read_at (io, addr, ch->odata, len);
|
||||
ch->written = io->cached? 0: 1;
|
||||
#if 1
|
||||
// we must use raw io here to avoid calling to cacheread and get wrong reads
|
||||
if (r_io_seek (io, addr, R_IO_SEEK_SET)==UT64_MAX)
|
||||
memset (ch->odata, 0xff, len);
|
||||
r_io_read_internal (io, ch->odata, len);
|
||||
#else
|
||||
r_io_read_at (io, addr, ch->odata, len);
|
||||
#endif
|
||||
memcpy (ch->data, buf, len);
|
||||
r_list_append (io->cache, ch);
|
||||
return len;
|
||||
|
@ -286,8 +286,7 @@ R_API RIODesc *r_io_use_fd (RIO *io, int fd) {
|
||||
return desc;
|
||||
}
|
||||
|
||||
#if !USE_P_API
|
||||
static inline int r_io_read_internal(RIO *io, ut8 *buf, int len) {
|
||||
R_API int r_io_read_internal(RIO *io, ut8 *buf, int len) {
|
||||
int bytes_read = 0;
|
||||
const char *read_from = NULL;
|
||||
if (io->desc && io->desc->plugin && io->desc->plugin->read){
|
||||
@ -309,7 +308,6 @@ static inline int r_io_read_internal(RIO *io, ut8 *buf, int len) {
|
||||
}
|
||||
return bytes_read;
|
||||
}
|
||||
#endif
|
||||
|
||||
R_API int r_io_read(RIO *io, ut8 *buf, int len) {
|
||||
int ret;
|
||||
@ -605,9 +603,6 @@ R_API int r_io_write(RIO *io, const ut8 *buf, int len) {
|
||||
buf += ret;
|
||||
}
|
||||
}
|
||||
if (1) { //io->history) {
|
||||
r_io_cache_write (io, io->off, buf, len);
|
||||
}
|
||||
|
||||
/* TODO: implement IO cache here. to avoid dupping work on vm for example */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user