Added some checks for the gs command

This commit is contained in:
invictus1306 2018-01-07 18:52:14 +01:00 committed by radare
parent a904f171b5
commit ac091ff05a
2 changed files with 29 additions and 4 deletions

View File

@ -138,7 +138,9 @@ static int cmd_egg(void *data, const char *input) {
buf = r_core_syscall (core, oa, "");
}
free (oa);
showBuffer (buf);
if (buf) {
showBuffer (buf);
}
egg->lang.nsyscalls = 0;
} else {
eprintf ("Usage: gs [syscallname] [parameters]\n");

View File

@ -2516,10 +2516,33 @@ R_API RBuffer *r_core_syscall (RCore *core, const char *name, const char *args)
char code[1024];
int num;
num = r_syscall_get_num (core->anal->syscall, name);
if (!num) {
num = atoi (name);
//arch check
if (strcmp (core->anal->cur->arch, "x86")) {
eprintf ("architecture not yet supported!\n");
return 0;
}
num = r_syscall_get_num (core->anal->syscall, name);
//bits check
switch (core->assembler->bits) {
case 32:
if (strcmp (name, "setup") && !num ) {
eprintf ("syscall not found!\n");
return 0;
}
break;
case 64:
if (strcmp (name, "read") && !num ) {
eprintf ("syscall not found!\n");
return 0;
}
break;
default:
eprintf ("syscall not found!\n");
return 0;
}
snprintf (code, sizeof (code),
"sc@syscall(%d);\n"
"main@global(0) { sc(%s);\n"