mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-15 09:21:00 +00:00
More handlers for dd command
This commit is contained in:
parent
37e3db9407
commit
a8800bab29
@ -2604,24 +2604,67 @@ static int cmd_debug(void *data, const char *input) {
|
||||
r_debug_desc_list (core->dbg, 1);
|
||||
break;
|
||||
case 's':
|
||||
// r_debug_desc_seek()
|
||||
// TODO: handle read, readwrite, append
|
||||
{
|
||||
ut64 off = UT64_MAX;
|
||||
int fd = atoi (input+2);
|
||||
char *str = strchr (input+2, ' ');
|
||||
if (str) off = r_num_math (core->num, str+1);
|
||||
if (off == UT64_MAX || !r_debug_desc_seek (core->dbg, fd, off))
|
||||
if (!r_core_syscallf (core, "lseek", "%d, 0x%"PFMT64x", %d", fd, off, 0))
|
||||
eprintf ("Cannot seek\n");
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
// r_debug_desc_dup()
|
||||
{
|
||||
ut64 newfd = UT64_MAX;
|
||||
int fd = atoi (input+2);
|
||||
char *str = strchr (input+2, ' ');
|
||||
if (str) newfd = r_num_math (core->num, str+1);
|
||||
if (newfd == UT64_MAX || !r_debug_desc_dup (core->dbg, fd, newfd))
|
||||
if (!r_core_syscallf (core, "dup2", "%d, %d", fd, (int)newfd))
|
||||
eprintf ("Cannot dup %d %d\n", fd, (int)newfd);
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
// r_debug_desc_read()
|
||||
{
|
||||
ut64 off = UT64_MAX;
|
||||
ut64 len = UT64_MAX;
|
||||
int fd = atoi (input+2);
|
||||
char *str = strchr (input+2, ' ');
|
||||
if (str) off = r_num_math (core->num, str+1);
|
||||
str = strchr (str+1, ' ');
|
||||
if (str) len = r_num_math (core->num, str+1);
|
||||
if (len == UT64_MAX || off == UT64_MAX || \
|
||||
!r_debug_desc_read (core->dbg, fd, off, len))
|
||||
if (!r_core_syscallf (core, "read", "%d, 0x%"PFMT64x", %d",
|
||||
fd, off, (int)len))
|
||||
eprintf ("Cannot read\n");
|
||||
}
|
||||
break;
|
||||
case 'w':
|
||||
// r_debug_desc_write()
|
||||
{
|
||||
ut64 off = UT64_MAX;
|
||||
ut64 len = UT64_MAX;
|
||||
int fd = atoi (input+2);
|
||||
char *str = strchr (input+2, ' ');
|
||||
if (str) off = r_num_math (core->num, str+1);
|
||||
str = strchr (str+1, ' ');
|
||||
if (str) len = r_num_math (core->num, str+1);
|
||||
if (len == UT64_MAX || off == UT64_MAX || \
|
||||
!r_debug_desc_write (core->dbg, fd, off, len))
|
||||
if (!r_core_syscallf (core, "write", "%d, 0x%"PFMT64x", %d",
|
||||
fd, off, (int)len))
|
||||
eprintf ("Cannot write\n");
|
||||
}
|
||||
break;
|
||||
case '-': // "dd-"
|
||||
// close file
|
||||
//r_core_syscallf (core, "close", "%d", atoi (input+2));
|
||||
r_core_cmdf (core, "dxs close %d", (int)r_num_math (
|
||||
core->num, input+2));
|
||||
// TODO: run
|
||||
{
|
||||
int fd = atoi (input+2);
|
||||
//r_core_cmdf (core, "dxs close %d", (int)r_num_math ( core->num, input+2));
|
||||
r_core_syscallf (core, "close", "%d", fd);
|
||||
}
|
||||
break;
|
||||
case ' ':
|
||||
// TODO: handle read, readwrite, append
|
||||
|
Loading…
Reference in New Issue
Block a user