本文整理汇总了C++中r_num_get函数的典型用法代码示例。如果您正苦于以下问题:C++ r_num_get函数的具体用法?C++ r_num_get怎么用?C++ r_num_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了r_num_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reil_flag_spew_inst
void reil_flag_spew_inst(RAnalEsil *esil, const char *flag) {
ut8 bit;
switch (flag[0]) {
case 'z': // zero-flag
r_anal_esil_push(esil, esil->Reil->cur);
break;
case 'b':
bit = (ut8)r_num_get(NULL, &flag[1]);
reil_generate_borrow_flag(esil, bit);
break;
case 'c':
bit = (ut8)r_num_get(NULL, &flag[1]);
reil_generate_carry_flag(esil, bit);
break;
case 'o':
reil_generate_overflow_flag(esil);
break;
case 'p':
reil_generate_partity_flag(esil);
break;
case 'r':
r_anal_esil_pushnum(esil, esil->anal->bits / 8);
break;
case 's':
reil_generate_signature(esil);
break;
default:
return;
}
return;
}
示例2: R_NEW0
R_API RSyscallItem *r_syscall_item_new_from_string(const char *name, const char *s) {
RSyscallItem *si;
char *o;
if (!name || !s) {
return NULL;
}
si = R_NEW0 (RSyscallItem);
if (!si) {
return NULL;
}
o = strdup (s);
r_str_split (o, ',');
si->name = strdup (name);
si->swi = r_num_get (NULL, r_str_word_get0 (o, 0));
si->num = r_num_get (NULL, r_str_word_get0 (o, 1));
si->args = r_num_get (NULL, r_str_word_get0 (o, 2));
//in a definition such as syscall=0x80,0,4,
//the string at index 3 is 0 causing oob read afterwards
si->sargs = calloc (si->args + 1, sizeof (char));
if (!si->sargs) {
free (si);
free (o);
return NULL;
}
strncpy (si->sargs, r_str_word_get0 (o, 3), si->args);
free (o);
return si;
}
示例3: R_NEW0
R_API RSyscallItem *r_syscall_item_new_from_string(const char *name, const char *s) {
RSyscallItem *si;
char *o;
if (!s) return NULL;
si = R_NEW0 (RSyscallItem);
o = strdup (s);
r_str_split (o, ',');
/*
return r_syscall_item_new (name,
r_num_get (NULL, r_str_word_get0 (o, 0)),
r_num_get (NULL, r_str_word_get0 (o, 1)),
r_num_get (NULL, r_str_word_get0 (o, 2)),
r_str_word_get0 (o, 3));
*/
si->name = strdup (name);
si->swi = r_num_get (NULL, r_str_word_get0 (o, 0));
si->num = r_num_get (NULL, r_str_word_get0 (o, 1));
si->args = r_num_get (NULL, r_str_word_get0 (o, 2));
si->sargs = strdup (r_str_word_get0 (o, 3));
free (o);
return si;
}
示例4: gb_parse_ld2
static bool gb_parse_ld2 (ut8 *buf, char *buf_asm) {
int i;
ut64 num;
if (strlen (buf_asm) < 6)
return false;
if (buf_asm[4] == ',') {
if ((i = gb_reg_idx (buf_asm[3])) == (-1))
return false;
buf[0] = 0x6 + (ut8)(i * 8);
num = r_num_get (NULL, &buf_asm[5]);
buf[1] = (ut8)(num & 0xff);
return true;
} else if (buf_asm[3] == '['
&& buf_asm[4] == 'h'
&& buf_asm[5] == 'l'
&& buf_asm[6] == ']'
&& buf_asm[7] == ','
&& buf_asm[8] != '\0') {
buf[0] = 0x36;
num = r_num_get (NULL, &buf_asm[8]);
buf[1] = (ut8)(num & 0xff);
return true;
}
return false;
}
示例5: cmp
static int cmp(const void *a, const void *b) {
char *da = NULL;
char *db = NULL;
const char *ca = r_str_trim_ro (a);
const char *cb = r_str_trim_ro (b);
if (!a || !b) {
return (int) (size_t) ((char*) a - (char*) b);
}
if (sorted_column > 0) {
da = strdup (ca);
db = strdup (cb);
int colsa = r_str_word_set0 (da);
int colsb = r_str_word_set0 (db);
ca = (colsa > sorted_column)? r_str_word_get0 (da, sorted_column): "";
cb = (colsb > sorted_column)? r_str_word_get0 (db, sorted_column): "";
}
if (IS_DIGIT (*ca) && IS_DIGIT (*cb)) {
ut64 na = r_num_get (NULL, ca);
ut64 nb = r_num_get (NULL, cb);
int ret = na > nb;
free (da);
free (db);
return ret;
}
if (da && db) {
int ret = strcmp (ca, cb);
free (da);
free (db);
return ret;
}
free (da);
free (db);
return strcmp (a, b);
}
示例6: getpid
static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
int pid = getpid ();
self_sections_count = 0;
#if __APPLE__
mach_port_t task;
kern_return_t rc;
rc = task_for_pid (mach_task_self(),pid, &task);
if (rc) {
eprintf ("task_for_pid failed\n");
return NULL;
}
macosx_debug_regions (task, (void*)(size_t)1, 1000);
io->va = R_TRUE; // nop
return r_io_desc_new (&r_io_plugin_self,
pid, file, rw, mode, NULL);
#elif __linux__
char *pos_c;
char null[64];
char path[1024], line[1024];
char region[100], region2[100], perms[5];
snprintf (path, sizeof (path)-1, "/proc/%d/maps", pid);
FILE *fd = fopen (file, "r");
if (!fd)
return NULL;
while (!feof (fd)) {
line[0]='\0';
fgets (line, sizeof (line)-1, fd);
if (line[0]=='\0')
break;
path[0]='\0';
sscanf (line, "%s %s %s %s %s %s",
®ion[2], perms, null, null, null, path);
pos_c = strchr (®ion[2], '-');
if (pos_c) strncpy (path, pos_c, sizeof (path)-1);
else path[0] = 0;
int i, perm = 0;
for (i = 0; perms[i] && i < 4; i++)
switch (perms[i]) {
case 'r': perm |= R_IO_READ; break;
case 'w': perm |= R_IO_WRITE; break;
case 'x': perm |= R_IO_EXEC; break;
}
self_sections[self_sections_count].from = r_num_get (NULL, region);
self_sections[self_sections_count].to = r_num_get (NULL, region2);
self_sections[self_sections_count].perm = perm;
self_sections_count++;
r_num_get (NULL, region2);
if (!pos_c)
continue;
}
return r_io_desc_new (&r_io_plugin_self,
pid, file, rw, mode, NULL);
#else
#warning not yet implemented for this platform
#endif
return NULL;
}
示例7: xrefs_list_cb_rad
static void xrefs_list_cb_rad(RAnal *anal, const char *k, const char *v) {
ut64 dst, src = r_num_get (NULL, v);
if (!strncmp (k, "ref.", 4)) {
char *p = strchr (k+4, '.');
if (p) {
dst = r_num_get (NULL, p+1);
anal->printf ("ar 0x%"PFMT64x" 0x%"PFMT64x"\n", src, dst);
}
}
}
示例8: r_debug_bochs_breakpoint
static int r_debug_bochs_breakpoint (RBreakpointItem *bp, int set, void *user) {
char cmd[64];
char num[4];
char addr[19];
char bufcmd[100];
ut64 a;
int n,i,lenRec;
//eprintf ("bochs_breakpoint\n");
if (!bp) {
return false;
}
if (set) {
//eprintf("[set] bochs_breakpoint %016"PFMT64x"\n",bp->addr);
sprintf (cmd, "lb 0x%x", (ut32)bp->addr);
bochs_send_cmd (desc, cmd, true);
bCapturaRegs = true;
} else {
//eprintf("[unset] bochs_breakpoint %016"PFMT64x"\n",bp->addr);
/*
Num Type Disp Enb Address
1 lbreakpoint keep y 0x0000000000007c00
2 lbreakpoint keep y 0x0000000000007c00
<bochs:39>
*/
bochs_send_cmd (desc,"blist",true);
lenRec = strlen (desc->data);
a = -1;
n = 0;
if (!strncmp (desc->data, "Num Type", 8)) {
i = 37;
do {
if (desc->data[i + 24] == 'y') {
strncpy(num, &desc->data[i], 3);
num[3] = 0;
strncpy(addr, &desc->data[i + 28], 18);
addr[18] = 0;
n = r_num_get (NULL,num);
a = r_num_get (NULL,addr);
//eprintf("parseado %x %016"PFMT64x"\n",n,a);
if (a == bp->addr) {
break;
}
}
i += 48;
} while (desc->data[i] != '<' && i<lenRec-4);
}
if (a == bp->addr) {
snprintf (bufcmd, sizeof (bufcmd), "d %i", n);
//eprintf("[unset] Break point localizado indice = %x (%x) %s \n",n,(DWORD)a,bufcmd);
bochs_send_cmd (desc, bufcmd, true);
}
}
return true;
}
示例9: xrefs_list_cb_rad
static int xrefs_list_cb_rad(RAnal *anal, const char *k, const char *v) {
ut64 dst, src = r_num_get (NULL, v);
if (!strncmp (k, "ref.", 4)) {
const char *p = r_str_rchr (k, NULL, '.');
if (p) {
dst = r_num_get (NULL, p + 1);
anal->cb_printf ("ax 0x%"PFMT64x" 0x%"PFMT64x"\n", src, dst);
}
}
return 1;
}
示例10: xrefs_list_cb_json
static void xrefs_list_cb_json(RAnal *anal, const char *k, const char *v) {
ut64 dst, src = r_num_get (NULL, v);
if (!strncmp (k, "ref.", 4) && (strlen (k)>8)) {
char *p = strchr (k+4, '.');
if (p) {
dst = r_num_get (NULL, p+1);
sscanf (p+1, "0x%"PFMT64x, &dst);
anal->printf ("%"PFMT64d":%"PFMT64d",", src, dst);
}
}
}
示例11: xrefs_list_cb_any
static int xrefs_list_cb_any(RAnal *anal, const char *k, const char *v) {
//ut64 dst, src = r_num_get (NULL, v);
if (!strncmp (_kpfx, k, strlen (_kpfx))) {
RAnalRef *ref = r_anal_ref_new ();
if (ref) {
ref->addr = r_num_get (NULL, k + strlen (_kpfx) + 1);
ref->at = r_num_get (NULL, v); // XXX
ref->type = _type;
r_list_append (_list, ref);
}
}
return true;
}
示例12: gb_parse_arith1
static int gb_parse_arith1 (ut8 *buf, const int minlen, char *buf_asm, ut8 base, ut8 alt) {
int i;
ut64 num;
if (strlen (buf_asm) < minlen)
return 0;
buf[0] = base;
i = strlen (&buf_asm[minlen - 1]);
r_str_replace_in (&buf_asm[minlen - 1], (ut32)i, "[ ", "[", R_TRUE);
r_str_replace_in (&buf_asm[minlen - 1], (ut32)i, " ]", "]", R_TRUE);
r_str_do_until_token (str_op, buf_asm, ' ');
i = gb_reg_idx (buf_asm[minlen-1]);
if (i != (-1))
buf[0] |= (ut8)i;
else if (buf_asm[minlen - 1] == '['
&& buf_asm[minlen] == 'h'
&& buf_asm[minlen + 1] == 'l'
&& buf_asm[minlen + 2] == ']' )
buf[0] |= 6;
else {
buf[0] = alt;
num = r_num_get (NULL, &buf_asm[minlen - 1]);
buf[1] = (ut8)(num & 0xff);
return 2;
}
return 1;
}
示例13: R_NEW0
R_API RIO *r_io_new() {
RIO *io = R_NEW0 (RIO);
if (!io) {
return NULL;
}
io->buffer = r_cache_new (); // RCache is a list of ranged buffers. maybe rename?
io->write_mask_fd = -1;
io->cb_printf = (void *)printf;
io->bits = (sizeof (void *) == 8)? 64: 32;
io->ff = true;
io->Oxff = 0xff;
io->aslr = 0;
io->pava = false;
io->raised = -1;
io->autofd = true;
r_io_map_init (io);
r_io_desc_init (io);
r_io_undo_init (io);
r_io_cache_init (io);
r_io_plugin_init (io);
r_io_section_init (io);
{
char *env = r_sys_getenv ("R_IO_MAX_ALLOC");
if (env) {
io->maxalloc = r_num_get (NULL, env);
free (env);
}
}
return io;
}
示例14: r_anal_xrefs_from
R_API int r_anal_xrefs_from (RAnal *anal, RList *list, const char *kind, const RAnalRefType type, ut64 addr) {
char *next, *s, *str, *ptr, key[256];
RAnalRef *ref = NULL;
if (addr == UT64_MAX) {
_type = type;
_list = list;
_kpfx = r_str_newf ("xref.%s", analref_toString (type));
sdb_foreach (DB, (SdbForeachCallback)xrefs_list_cb_any, anal);
free (_kpfx);
return true;
}
XREFKEY(key, sizeof (key), kind, type, addr);
str = sdb_get (DB, key, 0);
if (!str) {
return false;
}
for (next = ptr = str; next; ptr = next) {
s = sdb_anext (ptr, &next);
if (!(ref = r_anal_ref_new ())) {
return false;
}
ref->addr = r_num_get (NULL, s);
ref->at = addr;
ref->type = type;
r_list_append (list, ref);
}
free (str);
return true;
}
示例15: cin_get_num
static int cin_get_num(RNum *num, RNumCalc *nc, RNumCalcValue *n) {
double d;
char str[R_NUMCALC_STRSZ]; // TODO: move into the heap?
int i = 0;
char c;
str[0] = 0;
while (cin_get (num, nc, &c)) {
if (c != '_' && c!=':' && c!='.' && !isalnum ((ut8)c)) {
cin_putback (num, nc, c);
break;
}
if (i < R_NUMCALC_STRSZ) {
str[i++] = c;
}
}
str[i] = 0;
*n = Nset (r_num_get (num, str));
if (IS_DIGIT (*str) && strchr (str, '.')) {
if (sscanf (str, "%lf", &d) < 1) {
return 0;
}
if (n->n < d) {
*n = Nsetf (d);
}
n->d = d;
}
return 1;
}