fix returnvalue for getbase^

This commit is contained in:
condret 2017-09-01 01:10:32 +00:00
parent 2d7f857542
commit 5cb0e7050d
5 changed files with 20 additions and 24 deletions

View File

@ -1530,7 +1530,8 @@ R_API ut64 r_debug_get_baddr(RDebug *dbg, const char *file) {
return 0LL;
}
#if __WINDOWS__
return r_io_desc_get_base (dbg->iob.io->desc);
ut64 base;
return r_io_desc_get_base (dbg->iob.io->desc, &base), base;
#else
r_debug_select (dbg, pid, tid);
r_debug_map_sync (dbg);

View File

@ -138,7 +138,7 @@ typedef struct r_io_plugin_t {
bool (*is_blockdevice)(RIODesc *desc);
int (*getpid)(RIODesc *desc);
int (*gettid)(RIODesc *desc);
ut64 (*getbase)(RIODesc *desc);
bool (*getbase)(RIODesc *desc, ut64 *base);
bool (*resize)(RIO *io, RIODesc *fd, ut64 size);
int (*extend)(RIO *io, RIODesc *fd, ut64 size);
bool (*accept)(RIO *io, RIODesc *desc, int fd);
@ -387,7 +387,7 @@ R_API bool r_io_desc_exchange (RIO *io, int fd, int fdx); //this should get 2 de
R_API bool r_io_desc_is_dbg (RIODesc *desc);
R_API int r_io_desc_get_pid (RIODesc *desc);
R_API int r_io_desc_get_tid (RIODesc *desc);
R_API ut64 r_io_desc_get_base (RIODesc *desc);
R_API bool r_io_desc_get_base (RIODesc *desc, ut64 *base);
R_API int r_io_desc_read_at (RIODesc *desc, ut64 addr, ut8 *buf, int len);
R_API int r_io_desc_write_at (RIODesc *desc, ut64 addr, const ut8 *buf, int len);
R_API bool r_io_desc_fini (RIO *io);
@ -458,7 +458,7 @@ R_API int r_io_fd_write_at (RIO *io, int fd, ut64 addr, const ut8 *buf, int len)
R_API bool r_io_fd_is_dbg (RIO *io, int fd);
R_API int r_io_fd_get_pid (RIO *io, int fd);
R_API int r_io_fd_get_tid (RIO *io, int fd);
R_API int r_io_fd_get_base (RIO *io, int fd);
R_API bool r_io_fd_get_base (RIO *io, int fd, ut64 *base);
R_API const char *r_io_fd_get_name (RIO *io, int fd);
R_API int r_io_fd_get_current(RIO *io);
R_API bool r_io_use_fd (RIO *io, int fd);

View File

@ -287,21 +287,11 @@ R_API int r_io_desc_get_tid(RIODesc *desc) {
return desc->plugin->gettid (desc);
}
R_API ut64 r_io_desc_get_base (RIODesc *desc) {
//-1 and -2 are reserved
if (!desc) {
return -3;
R_API bool r_io_desc_get_base (RIODesc *desc, ut64 *base) {
if (!base || !desc || !desc->plugin || !desc->plugin->isdbg || !desc->plugin->getbase) {
return false;
}
if (!desc->plugin) {
return -4;
}
if (!desc->plugin->isdbg) {
return -5;
}
if (!desc->plugin->getbase) {
return -6;
}
return desc->plugin->getbase (desc);
return desc->plugin->getbase (desc, base);
}
R_API int r_io_desc_read_at(RIODesc *desc, ut64 addr, ut8 *buf, int len) {

View File

@ -92,14 +92,15 @@ R_API int r_io_fd_get_tid(RIO *io, int fd) {
return r_io_desc_get_tid (desc);
}
R_API int r_io_fd_get_base (RIO *io, int fd) {
R_API bool r_io_fd_get_base (RIO *io, int fd, ut64 *base) {
RIODesc *desc;
if (!io || !io->files) {
return -2;
if (!io || !io->files || !base) {
return false;
}
desc = r_io_desc_get (io, fd);
return r_io_desc_get_base (desc);
return r_io_desc_get_base (desc, base);
}
R_API const char *r_io_fd_get_name(RIO *io, int fd) {
RIODesc *desc;
if (!io || !io->files || !(desc = r_io_desc_get (io, fd))) {

View File

@ -143,9 +143,13 @@ static int __gettid (RIODesc *fd) {
return iow? iow->tid: -1;
}
static int __getbase (RIODesc *fd) {
static bool __getbase (RIODesc *fd, ut64 *base) {
RIOW32Dbg *iow = (RIOW32Dbg *)(fd ? fd->data : NULL);
return iow ? iow->winbase: -1;
if (base && iow) {
*base = iow->winbase;
return true;
}
return false;
}
RIOPlugin r_io_plugin_w32dbg = {