2013-04-16 02:01:39 +00:00
|
|
|
/* radare - LGPL - Copyright 2010-2013 - pancake */
|
2010-06-18 09:09:19 +00:00
|
|
|
|
2010-07-13 08:56:56 +00:00
|
|
|
// XXX: All this stuff must be linked to the code injection api
|
|
|
|
|
2010-06-18 09:09:19 +00:00
|
|
|
#include <r_debug.h>
|
|
|
|
|
2011-07-25 02:49:54 +00:00
|
|
|
R_API RDebugDesc *r_debug_desc_new (int fd, char* path, int perm, int type, int off) {
|
|
|
|
RDebugDesc *desc = R_NEW (RDebugDesc);
|
|
|
|
if (desc) {
|
|
|
|
desc->fd = fd;
|
|
|
|
desc->path = strdup (path);
|
|
|
|
desc->perm = perm;
|
|
|
|
desc->type = type;
|
|
|
|
desc->off = off;
|
|
|
|
}
|
|
|
|
return desc;
|
|
|
|
}
|
|
|
|
|
|
|
|
R_API void r_debug_desc_free (RDebugDesc *p) {
|
|
|
|
if (p) {
|
|
|
|
if (p->path)
|
|
|
|
free (p->path);
|
|
|
|
free (p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-18 09:09:19 +00:00
|
|
|
R_API int r_debug_desc_open(RDebug *dbg, const char *path) {
|
|
|
|
if (dbg && dbg->h && dbg->h->desc.open)
|
|
|
|
return dbg->h->desc.open (path);
|
2016-07-12 20:15:19 +00:00
|
|
|
return false;
|
2010-06-18 09:09:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
R_API int r_debug_desc_close(RDebug *dbg, int fd) {
|
|
|
|
if (dbg && dbg->h && dbg->h->desc.close)
|
|
|
|
return dbg->h->desc.close (fd);
|
2016-07-12 20:15:19 +00:00
|
|
|
return false;
|
2010-06-18 09:09:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
R_API int r_debug_desc_dup(RDebug *dbg, int fd, int newfd) {
|
|
|
|
if (dbg && dbg->h && dbg->h->desc.dup)
|
|
|
|
return dbg->h->desc.dup (fd, newfd);
|
2016-07-12 20:15:19 +00:00
|
|
|
return false;
|
2010-06-18 09:09:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
R_API int r_debug_desc_read(RDebug *dbg, int fd, ut64 addr, int len) {
|
|
|
|
if (dbg && dbg->h && dbg->h->desc.read)
|
|
|
|
return dbg->h->desc.read (fd, addr, len);
|
2016-07-12 20:15:19 +00:00
|
|
|
return false;
|
2010-06-18 09:09:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
R_API int r_debug_desc_seek(RDebug *dbg, int fd, ut64 addr) {
|
|
|
|
if (dbg && dbg->h && dbg->h->desc.seek)
|
|
|
|
return dbg->h->desc.seek (fd, addr);
|
2016-07-12 20:15:19 +00:00
|
|
|
return false;
|
2010-06-18 09:09:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
R_API int r_debug_desc_write(RDebug *dbg, int fd, ut64 addr, int len) {
|
|
|
|
if (dbg && dbg->h && dbg->h->desc.write)
|
|
|
|
return dbg->h->desc.write (fd, addr, len);
|
2016-07-12 20:15:19 +00:00
|
|
|
return false;
|
2010-06-18 09:09:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
R_API int r_debug_desc_list(RDebug *dbg, int rad) {
|
2010-08-16 15:48:47 +00:00
|
|
|
int count = 0;
|
2011-07-25 02:49:54 +00:00
|
|
|
RList *list;
|
|
|
|
RListIter *iter;
|
|
|
|
RDebugDesc *p;
|
|
|
|
|
|
|
|
if (rad) {
|
2015-08-08 18:15:13 +00:00
|
|
|
if (dbg && dbg->cb_printf)
|
|
|
|
dbg->cb_printf ("TODO \n");
|
2011-07-25 02:49:54 +00:00
|
|
|
} else {
|
|
|
|
if (dbg && dbg->h && dbg->h->desc.list) {
|
|
|
|
list = dbg->h->desc.list (dbg->pid);
|
|
|
|
r_list_foreach (list, iter, p) {
|
2015-08-08 18:15:13 +00:00
|
|
|
dbg->cb_printf ("%i 0x%"PFMT64x" %c%c%c %s\n", p->fd, p->off,
|
2011-07-25 02:49:54 +00:00
|
|
|
(p->perm & R_IO_READ)?'r':'-',
|
|
|
|
(p->perm & R_IO_WRITE)?'w':'-',
|
|
|
|
p->type, p->path);
|
|
|
|
}
|
2014-05-02 14:54:27 +00:00
|
|
|
r_list_purge (list);
|
2011-07-25 02:49:54 +00:00
|
|
|
free (list);
|
|
|
|
}
|
|
|
|
}
|
2010-06-18 09:09:19 +00:00
|
|
|
return count;
|
|
|
|
}
|