R_API RSyscallItem *r_syscall_get(RSyscall *s, int num, int swi) { const char *ret, *ret2, *key; if (!s || !s->db) { eprintf ("Syscall database not loaded\n"); return NULL; } swi = getswi (s, swi); if (swi < 16) { key = sdb_fmt (0, "%d.%d", swi, num); } else { key = sdb_fmt (0, "0x%02x.%d", swi, num); } ret = sdb_const_get (s->db, key, 0); if (!ret) { key = sdb_fmt (0, "0x%02x.0x%02x", swi, num); // Workaround until Syscall SDB is fixed ret = sdb_const_get (s->db, key, 0); if (!ret) { return NULL; } } ret2 = sdb_const_get (s->db, ret, 0); if (!ret2) { return NULL; } return r_syscall_item_new_from_string (ret, ret2); }
R_API RList *r_syscall_list(RSyscall *ctx) { RListIter *iter; RPairItem *o; RList *list = r_pair_list (ctx->syspair, NULL); RList *olist = r_list_new (); olist->free = (RListFree)r_syscall_item_free; r_list_foreach (list, iter, o) { RSyscallItem *si = r_syscall_item_new_from_string (o->k, o->v); if (!strchr (si->name, '.')) r_list_append (olist, si); }
static int callback_list(void *u, const char *k, const char *v) { RList *list = (RList*)u; if (!strchr (k, '.')) { RSyscallItem *si = r_syscall_item_new_from_string (k, v); if (!si) { return 0; } if (!strchr (si->name, '.')) { r_list_append (list, si); } } return 1; // continue loop }
R_API RSyscallItem *r_syscall_get(RSyscall *ctx, int num, int swi) { char *ret, *ret2, foo[32]; RSyscallItem *si; if (!ctx->syspair) return NULL; swi = getswi (ctx->syspair, swi); snprintf (foo, sizeof (foo), "0x%02x.%d", swi, num); ret = r_pair_get (ctx->syspair, foo); if (ret == NULL) return NULL; ret2 = r_pair_get (ctx->syspair, ret); if (ret2 == NULL) return NULL; si = r_syscall_item_new_from_string (ret, ret2); free (ret); free (ret2); return si; }
R_API RList *r_syscall_list(RSyscall *s) { if (!s || !s->db) return NULL; sdb_foreach (s->db, callback_list, s); // XXX: this method must be deprecated.. we have to use sdb to access this info return NULL; #if 0 RListIter *iter; RPairItem *o; RList *list = r_pair_list (s->db, NULL); RList *olist = r_list_new (); olist->free = (RListFree)r_syscall_item_free; r_list_foreach (list, iter, o) { RSyscallItem *si = r_syscall_item_new_from_string (o->k, o->v); if (!strchr (si->name, '.')) r_list_append (olist, si); }
R_API RSyscallItem *r_syscall_get(RSyscall *s, int num, int swi) { char *ret, *ret2, foo[32]; RSyscallItem *si; if (!s || !s->db) return NULL; swi = getswi (s->db, swi); snprintf (foo, sizeof (foo), "0x%02x.%d", swi, num); ret = sdb_get (s->db, foo, 0); if (ret == NULL) return NULL; // TODO: optimize with sdb_const_get ret2 = sdb_get (s->db, ret, 0); if (ret2 == NULL) return NULL; si = r_syscall_item_new_from_string (ret, ret2); free (ret); free (ret2); return si; }