more AccessLog sugar for esil, and typo fixes

This commit is contained in:
condret 2017-08-26 19:25:40 +00:00
parent 816c5ee244
commit f403481e9f
3 changed files with 50 additions and 3 deletions

View File

@ -219,6 +219,7 @@ typedef RIODesc *(*RIOOpen) (RIO *io, const char *uri, int flags, int mode);
typedef RIODesc *(*RIOOpenAt) (RIO *io, const char *uri, int flags, int mode, ut64 at);
typedef bool (*RIOClose) (RIO *io, int fd);
typedef bool (*RIOReadAt) (RIO *io, ut64 addr, ut8 *buf, int len);
typedef RIOAccessLog *(*RIOAlReadAt) (RIO *io, ut64 addr, ut8 *buf, int len);
typedef bool (*RIOWriteAt) (RIO *io, ut64 addr, const ut8 *buf, int len);
typedef int (*RIOSystem) (RIO *io, const char* cmd);
typedef int (*RIOFdOpen) (RIO *io, const char *uri, int flags, int mode);
@ -231,6 +232,9 @@ typedef int (*RIOFdReadAt) (RIO *io, int fd, ut64 addr, ut8 *buf, int len);
typedef int (*RIOFdWriteAt) (RIO *io, int fd, ut64 addr, const ut8 *buf, int len);
typedef bool (*RIOFdIsDbg) (RIO *io, int fd);
typedef const char *(*RIOFdGetName) (RIO *io, int fd);
typedef void (*RIOAlSort) (RIOAccessLog *log);
typedef void (*RIOAlFree) (RIOAccessLog *log);
typedef ut8 *(*RIOAlGetFbufByflags) (RIOAccessLog *log, int flags, ut64 *addr, int *len);
typedef bool (*RIOIsValidOff) (RIO *io, ut64 addr, int hasperm);
typedef SdbList *(*RIOSectionVgetSecsAt) (RIO *io, ut64 vaddr);
typedef RIOSection *(*RIOSectionVgetSec) (RIO *io, ut64 vaddr);
@ -246,6 +250,7 @@ typedef struct r_io_bind_t {
RIOOpenAt open_at;
RIOClose close;
RIOReadAt read_at;
RIOAlReadAt al_read_at; //needed for esil
RIOWriteAt write_at;
RIOSystem system;
RIOFdOpen fd_open;
@ -258,6 +263,9 @@ typedef struct r_io_bind_t {
RIOFdWriteAt fd_write_at;
RIOFdIsDbg fd_is_dbg;
RIOFdGetName fd_get_name;
RIOAlSort al_sort; //needed for esil
RIOAlFree al_free; //needed for esil
RIOAlGetFbufByflags al_buf_byflags; //needed for esil
RIOIsValidOff is_valid_offset;
RIOSectionVgetSecsAt sections_vget;
RIOSectionVgetSec sect_vget;
@ -301,6 +309,7 @@ R_API bool r_io_vwrite_at (RIO *io, ut64 vaddr, const ut8 *buf, int len);
R_API RIOAccessLog *r_io_al_vread_at (RIO *io, ut64 vaddr, ut8 *buf, int len);
R_API RIOAccessLog *r_io_al_vwrite_at (RIO *io, ut64 vaddr, const ut8 *buf, int len);
R_API bool r_io_read_at (RIO *io, ut64 addr, ut8 *buf, int len);
R_API RIOAccessLog *r_io_al_read_at (RIO *io, ut64 addr, ut8 *buf, int len);
R_API void r_io_alprint(RList *ls);
R_API bool r_io_write_at (RIO *io, ut64 addr, const ut8 *buf, int len);
R_API bool r_io_read (RIO *io, ut8 *buf, int len);
@ -452,7 +461,7 @@ R_API bool r_io_read_i (RIO* io, ut64 addr, ut64 *val, int size, bool endian);
R_API bool r_io_write_i (RIO* io, ut64 addr, ut64 *val, int size, bool endian);
R_API RIOAccessLog *r_io_accesslog_new ();
R_API void r_io_accesslog_free (RIOAccessLog *log);
R_API void r_io_acccesslog_sort (RIOAccessLog *log);
R_API void r_io_accesslog_sort (RIOAccessLog *log);
R_API void r_io_accesslog_sqash_ignore_gaps (RIOAccessLog *log);
R_API void r_io_accesslog_sqash_byflags (RIOAccessLog *log, int flags);
R_API ut8 *r_io_accesslog_getf_buf_byflags (RIOAccessLog *log, int flags, ut64 *addr, int *len);

View File

@ -381,6 +381,40 @@ R_API bool r_io_read_at(RIO* io, ut64 addr, ut8* buf, int len) {
return ret;
}
R_API RIOAccessLog *r_io_al_read_at(RIO* io, ut64 addr, ut8* buf, int len) {
RIOAccessLog *log;
RIOAccessLogElement *ale = R_NEW0(RIOAccessLogElement);
int rlen;
if (!io || !buf || (len < 1)) {
return NULL;
}
if (io->va) {
return r_io_al_vread_at (io, addr, buf, len);
}
if (!(log = r_io_accesslog_new ())) {
return NULL;
}
log->buf = buf;
if (io->ff) {
memset (buf, 0xff, len);
}
rlen = r_io_pread_at (io, addr, buf, len);
if (io->cached_read) {
(void)r_io_cache_read (io, addr, buf, len);
}
if (!(ale = R_NEW0 (RIOAccessLogElement))) {
log->allocation_failed = true;
} else {
ale->paddr = ale->vaddr = addr;
ale->len = rlen;
ale->expect_len = len;
ale->flags = io->desc ? io->desc->flags : 0;
ale->fd = io->desc ? io->desc->fd : 0; //xxx
r_list_append (log->log, ale);
}
return log;
}
R_API bool r_io_write_at(RIO* io, ut64 addr, const ut8* buf, int len) {
int i;
bool ret = false;
@ -539,6 +573,7 @@ R_API int r_io_bind(RIO* io, RIOBind* bnd) {
bnd->open_at = r_io_open_at;
bnd->close = r_io_fd_close;
bnd->read_at = r_io_read_at;
bnd->al_read_at = r_io_al_read_at;
bnd->write_at = r_io_write_at;
bnd->system = r_io_system;
bnd->fd_open = r_io_fd_open;
@ -551,6 +586,9 @@ R_API int r_io_bind(RIO* io, RIOBind* bnd) {
bnd->fd_write_at = r_io_fd_write_at;
bnd->fd_is_dbg = r_io_fd_is_dbg;
bnd->fd_get_name = r_io_fd_get_name;
bnd->al_sort = r_io_accesslog_sort;
bnd->al_free = r_io_accesslog_free;
bnd->al_buf_byflags = r_io_accesslog_getf_buf_byflags;
bnd->is_valid_offset = r_io_is_valid_offset;
bnd->sections_vget = r_io_sections_vget;
bnd->section_add = r_io_section_add;

View File

@ -94,7 +94,7 @@ R_API void r_io_accesslog_free(RIOAccessLog *log) {
free (log);
}
R_API void r_io_acccesslog_sort(RIOAccessLog *log) {
R_API void r_io_accesslog_sort(RIOAccessLog *log) {
if (!log || !log->log) {
return;
}
@ -154,7 +154,7 @@ R_API void r_io_accesslog_sqash_byflags(RIOAccessLog *log, int flags) {
}
//gets first buffer that matches with the flags and frees the element
R_API ut8 *r_io_accessilog_getf_buf_byflags(RIOAccessLog *log, int flags, ut64 *addr, int *len) {
R_API ut8 *r_io_accesslog_getf_buf_byflags(RIOAccessLog *log, int flags, ut64 *addr, int *len) {
RListIter *iter;
RIOAccessLogElement *ale;
ut8 *ret;