mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-01 17:40:34 +00:00
Add support for io-plugin initialization via null system command =! (#14915) ##io
* Useful for r2frida to automatically run .=!i*
This commit is contained in:
parent
cf6801d663
commit
17a9f66900
@ -857,7 +857,6 @@ R_API RCoreFile *r_core_file_open(RCore *r, const char *file, int flags, ut64 lo
|
||||
fh->alive = 1;
|
||||
fh->core = r;
|
||||
fh->fd = fd->fd;
|
||||
|
||||
{
|
||||
const char *cp = r_config_get (r->config, "cmd.open");
|
||||
if (cp && *cp) {
|
||||
@ -890,6 +889,7 @@ R_API RCoreFile *r_core_file_open(RCore *r, const char *file, int flags, ut64 lo
|
||||
if (loadaddr != UT64_MAX) {
|
||||
r_config_set_i (r->config, "bin.laddr", loadaddr);
|
||||
}
|
||||
r_core_cmd0 (r, "=!");
|
||||
beach:
|
||||
r->times->file_open_time = r_sys_now () - prev;
|
||||
return fh;
|
||||
|
@ -1530,6 +1530,9 @@ repeat:
|
||||
} else if (ch == 'G') {
|
||||
skip = 9999;
|
||||
goto repeat;
|
||||
} else if (ch == '/') {
|
||||
r_core_cmd0 (core, "?i highlight;e scr.highlight=`yp`");
|
||||
goto repeat;
|
||||
} else if (ch == ';') {
|
||||
addComment (core, cur_ref_addr);
|
||||
goto repeat;
|
||||
|
@ -216,7 +216,10 @@ static char *__system(RIO *io, RIODesc *fd, const char *cmd) {
|
||||
if (!desc) {
|
||||
return NULL;
|
||||
}
|
||||
if (!cmd[0] || cmd[0] == '?' || !strcmp (cmd, "help")) {
|
||||
if (!*cmd) {
|
||||
return NULL;
|
||||
}
|
||||
if (cmd[0] == '?' || !strcmp (cmd, "help")) {
|
||||
eprintf ("Usage: =!cmd args\n"
|
||||
" =!pid - show targeted pid\n"
|
||||
" =!pkt s - send packet 's'\n"
|
||||
|
@ -489,6 +489,9 @@ static char *__system(RIO *io, RIODesc *fd, const char *cmd) {
|
||||
|
||||
task_t task = pid_to_task (fd, iodd->tid);
|
||||
/* XXX ugly hack for testing purposes */
|
||||
if (!strcmp (cmd, "")) {
|
||||
return NULL;
|
||||
}
|
||||
if (!strncmp (cmd, "perm", 4)) {
|
||||
int perm = r_str_rwx (cmd + 4);
|
||||
if (perm) {
|
||||
|
@ -258,6 +258,9 @@ static char *__system(RIO *io, RIODesc *fd, const char *cmd) {
|
||||
RIOPtrace *iop = (RIOPtrace*)fd->data;
|
||||
//printf("ptrace io command (%s)\n", cmd);
|
||||
/* XXX ugly hack for testing purposes */
|
||||
if (!strcmp (cmd, "")) {
|
||||
return NULL;
|
||||
}
|
||||
if (!strcmp (cmd, "help")) {
|
||||
eprintf ("Usage: =!cmd args\n"
|
||||
" =!ptrace - use ptrace io\n"
|
||||
|
@ -84,6 +84,9 @@ static bool r2k__plugin_open(RIO *io, const char *pathname, bool many) {
|
||||
}
|
||||
|
||||
static char *r2k__system(RIO *io, RIODesc *fd, const char *cmd) {
|
||||
if (!strcmp (cmd, "")) {
|
||||
return NULL;
|
||||
}
|
||||
if (!strncmp (cmd, "mod", 3)) {
|
||||
#if __WINDOWS__
|
||||
GetSystemModules (io);
|
||||
|
@ -135,6 +135,9 @@ static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) {
|
||||
}
|
||||
|
||||
static char *__system(RIO *io, RIODesc *fd, const char *command) {
|
||||
if (!*command) {
|
||||
return NULL;
|
||||
}
|
||||
int code, rlen;
|
||||
char *cmd = r_str_uri_encode (command);
|
||||
char *url = r_str_newf ("%s/%s", rURL(fd), cmd);
|
||||
|
@ -175,7 +175,9 @@ static char *__system(RIO *io, RIODesc *fd, const char *cmd) {
|
||||
RIOW32Dbg *iop = fd->data;
|
||||
//printf("w32dbg io command (%s)\n", cmd);
|
||||
/* XXX ugly hack for testing purposes */
|
||||
if (!strncmp (cmd, "pid", 3)) {
|
||||
if (!strcmp (cmd, "")) {
|
||||
// do nothing
|
||||
} else if (!strncmp (cmd, "pid", 3)) {
|
||||
if (cmd[3] == ' ') {
|
||||
int pid = atoi (cmd + 3);
|
||||
if (pid > 0 && pid != iop->pi.dwProcessId) {
|
||||
|
@ -224,6 +224,9 @@ static struct winedbg_x86_32 regState() {
|
||||
}
|
||||
|
||||
static char *__system(RIO *io, RIODesc *fd, const char *cmd) {
|
||||
if (!strcmp (cmd, "")) {
|
||||
return NULL;
|
||||
}
|
||||
if (!strncmp (cmd, "?", 1)) {
|
||||
eprintf ("dr : show registers\n");
|
||||
eprintf ("dr* : show registers as flags\n");
|
||||
|
@ -1257,6 +1257,7 @@ R_API int r_main_radare2(int argc, char **argv) {
|
||||
const char *fstype = r.bin->cur->o->info->bclass;
|
||||
r_core_cmdf (&r, "m /root %s @ 0", fstype);
|
||||
}
|
||||
r_core_cmd0 (&r, "=!"); // initalize io subsystem
|
||||
iod = r.io ? r_io_desc_get (r.io, fh->fd) : NULL;
|
||||
#if USE_THREADS
|
||||
if (iod && load_bin == LOAD_BIN_ALL && threaded) {
|
||||
|
Loading…
Reference in New Issue
Block a user