mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-23 21:29:49 +00:00
* Added linux-arm syscalls
* Lot of syntax cleanup (reduce locs, unify syntax)
This commit is contained in:
parent
7e5e81e3cd
commit
a19c5c6197
@ -2,15 +2,7 @@
|
||||
|
||||
#include "r_core.h"
|
||||
|
||||
#if 0
|
||||
int r_core_shift()
|
||||
{
|
||||
/* like rsc move does .. but optimal :) */
|
||||
}
|
||||
#endif
|
||||
|
||||
R_API int r_core_write_op(struct r_core_t *core, const char *arg, char op)
|
||||
{
|
||||
R_API int r_core_write_op(RCore *core, const char *arg, char op) {
|
||||
char *str;
|
||||
ut8 *buf;
|
||||
int i,j;
|
||||
@ -28,11 +20,9 @@ R_API int r_core_write_op(struct r_core_t *core, const char *arg, char op)
|
||||
memcpy (buf, core->block, core->blocksize);
|
||||
len = r_hex_str2bin (arg, (ut8 *)str);
|
||||
|
||||
switch (op) {
|
||||
case '2':
|
||||
case '4':
|
||||
if (op=='2' || op=='4') {
|
||||
op -= '0';
|
||||
for (i=0;i<core->blocksize;i+=op) {
|
||||
for (i=0; i<core->blocksize; i+=op) {
|
||||
/* endian swap */
|
||||
ut8 tmp = buf[i];
|
||||
buf[i] = buf[i+3];
|
||||
@ -43,23 +33,21 @@ R_API int r_core_write_op(struct r_core_t *core, const char *arg, char op)
|
||||
buf[i+2]=tmp;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
} else {
|
||||
for (i=j=0; i<core->blocksize; i++) {
|
||||
switch (op) {
|
||||
case 'x': buf[i] ^= str[j]; break;
|
||||
case 'a': buf[i] += str[j]; break;
|
||||
case 's': buf[i] -= str[j]; break;
|
||||
case 'm': buf[i] *= str[j]; break;
|
||||
case 'd': buf[i] /= str[j]; break;
|
||||
case 'r': buf[i] >>= str[j]; break;
|
||||
case 'l': buf[i] <<= str[j]; break;
|
||||
case 'o': buf[i] |= str[j]; break;
|
||||
case 'A': buf[i] &= str[j]; break;
|
||||
case 'x': buf[i] ^= str[j]; break;
|
||||
case 'a': buf[i] += str[j]; break;
|
||||
case 's': buf[i] -= str[j]; break;
|
||||
case 'm': buf[i] *= str[j]; break;
|
||||
case 'd': buf[i] /= str[j]; break;
|
||||
case 'r': buf[i] >>= str[j]; break;
|
||||
case 'l': buf[i] <<= str[j]; break;
|
||||
case 'o': buf[i] |= str[j]; break;
|
||||
case 'A': buf[i] &= str[j]; break;
|
||||
}
|
||||
j++; if (j>=len) j=0; /* cyclic key */
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ret = r_core_write_at (core, core->offset, buf, core->blocksize);
|
||||
@ -67,8 +55,7 @@ R_API int r_core_write_op(struct r_core_t *core, const char *arg, char op)
|
||||
return ret;
|
||||
}
|
||||
|
||||
R_API int r_core_seek(struct r_core_t *core, ut64 addr, int rb)
|
||||
{
|
||||
R_API int r_core_seek(RCore *core, ut64 addr, int rb) {
|
||||
ut64 old = core->offset;
|
||||
|
||||
/* XXX unnecesary call */
|
||||
@ -89,8 +76,7 @@ R_API int r_core_seek(struct r_core_t *core, ut64 addr, int rb)
|
||||
return core->offset;
|
||||
}
|
||||
|
||||
R_API int r_core_write_at(struct r_core_t *core, ut64 addr, const ut8 *buf, int size)
|
||||
{
|
||||
R_API int r_core_write_at(RCore *core, ut64 addr, const ut8 *buf, int size) {
|
||||
int ret = r_io_set_fd(&core->io, core->file->fd);
|
||||
if (ret != -1) {
|
||||
ret = r_io_write_at (&core->io, addr, buf, size);
|
||||
@ -100,8 +86,7 @@ R_API int r_core_write_at(struct r_core_t *core, ut64 addr, const ut8 *buf, int
|
||||
return (ret==-1)?R_FALSE:R_TRUE;
|
||||
}
|
||||
|
||||
R_API int r_core_block_read(struct r_core_t *core, int next)
|
||||
{
|
||||
R_API int r_core_block_read(RCore *core, int next) {
|
||||
if (core->file == NULL)
|
||||
return -1;
|
||||
r_io_set_fd (&core->io, core->file->fd);
|
||||
@ -109,8 +94,7 @@ R_API int r_core_block_read(struct r_core_t *core, int next)
|
||||
return r_io_read (&core->io, core->block, core->blocksize);
|
||||
}
|
||||
|
||||
R_API int r_core_read_at(struct r_core_t *core, ut64 addr, ut8 *buf, int size)
|
||||
{
|
||||
R_API int r_core_read_at(RCore *core, ut64 addr, ut8 *buf, int size) {
|
||||
int ret = r_io_set_fd (&core->io, core->file->fd);
|
||||
ret = r_io_read_at (&core->io, addr, buf, size);
|
||||
if (addr>=core->offset && addr<=core->offset+core->blocksize)
|
||||
|
@ -126,8 +126,7 @@ R_API int r_core_loadlibs_init(struct r_core_t *core) {
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API int r_core_loadlibs(struct r_core_t *core)
|
||||
{
|
||||
R_API int r_core_loadlibs(struct r_core_t *core) {
|
||||
/* TODO: all those default plugin paths should be defined in r_lib */
|
||||
char *homeplugindir = r_str_home (".radare/plugins");
|
||||
static int singleton = R_TRUE;
|
||||
|
@ -14,7 +14,7 @@ static int flags = R_PRINT_FLAGS_ADDRMOD;
|
||||
static int marks_init = 0;
|
||||
static ut64 marks[256];
|
||||
|
||||
static void r_core_visual_mark(struct r_core_t *core, ut8 ch) {
|
||||
static void r_core_visual_mark(RCore *core, ut8 ch) {
|
||||
if (!marks_init) {
|
||||
int i;
|
||||
for(i=0;i<255;i++)
|
||||
@ -24,7 +24,7 @@ static void r_core_visual_mark(struct r_core_t *core, ut8 ch) {
|
||||
marks[ch] = core->offset;
|
||||
}
|
||||
|
||||
static void r_core_visual_mark_seek(struct r_core_t *core, ut8 ch) {
|
||||
static void r_core_visual_mark_seek(RCore *core, ut8 ch) {
|
||||
if (!marks_init) {
|
||||
int i;
|
||||
for(i=0;i<255;i++)
|
||||
@ -35,7 +35,7 @@ static void r_core_visual_mark_seek(struct r_core_t *core, ut8 ch) {
|
||||
r_core_seek(core, marks[ch], 1);
|
||||
}
|
||||
|
||||
R_API int r_core_visual_trackflags(struct r_core_t *core) {
|
||||
R_API int r_core_visual_trackflags(RCore *core) {
|
||||
char cmd[1024];
|
||||
struct list_head *pos;
|
||||
#define MAX_FORMAT 2
|
||||
@ -58,31 +58,7 @@ R_API int r_core_visual_trackflags(struct r_core_t *core) {
|
||||
if (ptr&&ptr[0])
|
||||
r_core_cmd (core, ptr, 0);
|
||||
|
||||
switch (menu) {
|
||||
case 0: // flag space
|
||||
r_cons_printf ("\n Flag spaces:\n\n");
|
||||
hit = 0;
|
||||
for (j=i=0;i<R_FLAG_SPACES_MAX;i++) {
|
||||
if (core->flags.space[i]) {
|
||||
if (option==i) {
|
||||
fs = core->flags.space[i];
|
||||
hit = 1;
|
||||
}
|
||||
if( (i >=option-delta) && ((i<option+delta)||((option<delta)&&(i<(delta<<1))))) {
|
||||
r_cons_printf(" %c %02d %c %s\n",
|
||||
(option==i)?'>':' ', j,
|
||||
(i==core->flags.space_idx)?'*':' ',
|
||||
core->flags.space[i]);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!hit && j>0) {
|
||||
option = j-1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 1: // flag selection
|
||||
if (menu) {
|
||||
r_cons_printf ("\n Flags in flagspace '%s'. Press '?' for help.\n\n",
|
||||
core->flags.space[core->flags.space_idx]);
|
||||
hit = 0;
|
||||
@ -131,6 +107,28 @@ R_API int r_core_visual_trackflags(struct r_core_t *core) {
|
||||
#endif
|
||||
if (cmd[0])
|
||||
r_core_cmd (core, cmd, 0);
|
||||
} else {
|
||||
r_cons_printf ("\n Flag spaces:\n\n");
|
||||
hit = 0;
|
||||
for (j=i=0;i<R_FLAG_SPACES_MAX;i++) {
|
||||
if (core->flags.space[i]) {
|
||||
if (option==i) {
|
||||
fs = core->flags.space[i];
|
||||
hit = 1;
|
||||
}
|
||||
if( (i >=option-delta) && ((i<option+delta)||((option<delta)&&(i<(delta<<1))))) {
|
||||
r_cons_printf(" %c %02d %c %s\n",
|
||||
(option==i)?'>':' ', j,
|
||||
(i==core->flags.space_idx)?'*':' ',
|
||||
core->flags.space[i]);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!hit && j>0) {
|
||||
option = j-1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
r_cons_flush ();
|
||||
ch = r_cons_readchar ();
|
||||
@ -235,7 +233,7 @@ R_API int r_core_visual_trackflags(struct r_core_t *core) {
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
static void config_visual_hit_i(struct r_core_t *core, const char *name, int delta) {
|
||||
static void config_visual_hit_i(RCore *core, const char *name, int delta) {
|
||||
struct r_config_node_t *node;
|
||||
node = r_config_node_get(&core->config, name);
|
||||
if (node && ((node->flags & CN_INT) || (node->flags & CN_OFFT)))
|
||||
@ -243,29 +241,28 @@ static void config_visual_hit_i(struct r_core_t *core, const char *name, int del
|
||||
}
|
||||
|
||||
/* Visually activate the config variable */
|
||||
static void config_visual_hit(struct r_core_t *core, const char *name) {
|
||||
static void config_visual_hit(RCore *core, const char *name) {
|
||||
char buf[1024];
|
||||
struct r_config_node_t *node;
|
||||
RConfigNode *node;
|
||||
|
||||
node = r_config_node_get(&core->config, name);
|
||||
if (node) {
|
||||
if (node->flags & CN_BOOL) {
|
||||
/* TOGGLE */
|
||||
node->i_value = !node->i_value;
|
||||
node->value = r_str_dup(node->value, node->i_value?"true":"false");
|
||||
} else {
|
||||
// FGETS AND SO
|
||||
r_cons_printf("New value (old=%s): ", node->value);
|
||||
r_cons_flush();
|
||||
r_cons_set_raw(0);
|
||||
r_cons_fgets(buf, 1023, 0, 0);
|
||||
r_cons_set_raw(1);
|
||||
node->value = r_str_dup(node->value, buf);
|
||||
}
|
||||
if (!(node = r_config_node_get(&core->config, name)))
|
||||
return;
|
||||
if (node->flags & CN_BOOL) {
|
||||
/* TOGGLE */
|
||||
node->i_value = !node->i_value;
|
||||
node->value = r_str_dup(node->value, node->i_value?"true":"false");
|
||||
} else {
|
||||
// FGETS AND SO
|
||||
r_cons_printf("New value (old=%s): ", node->value);
|
||||
r_cons_flush();
|
||||
r_cons_set_raw(0);
|
||||
r_cons_fgets(buf, 1023, 0, 0);
|
||||
r_cons_set_raw(1);
|
||||
node->value = r_str_dup(node->value, buf);
|
||||
}
|
||||
}
|
||||
|
||||
R_API void r_core_visual_config(struct r_core_t *core) {
|
||||
R_API void r_core_visual_config(RCore *core) {
|
||||
char cmd[1024];
|
||||
struct list_head *pos;
|
||||
#define MAX_FORMAT 2
|
||||
@ -443,7 +440,7 @@ R_API void r_core_visual_config(struct r_core_t *core) {
|
||||
}
|
||||
|
||||
/* TODO: use r_cmd here in core->vcmd..optimize over 255 table */
|
||||
R_API int r_core_visual_cmd(struct r_core_t *core, int ch) {
|
||||
R_API int r_core_visual_cmd(RCore *core, int ch) {
|
||||
char buf[1024];
|
||||
ch = r_cons_arrow_to_hjkl(ch);
|
||||
|
||||
@ -629,28 +626,26 @@ R_API int r_core_visual_cmd(struct r_core_t *core, int ch) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
R_API void r_core_visual_prompt(struct r_core_t *core, int color) {
|
||||
if (color)
|
||||
r_cons_printf(Color_YELLOW"[0x%08llx] %s\n"Color_RESET,
|
||||
core->offset, printfmt[printidx%NPF]);
|
||||
else r_cons_printf("[0x%08llx] %s\n", core->offset, printfmt[printidx%NPF]);
|
||||
R_API void r_core_visual_prompt(RCore *core, int color) {
|
||||
if (color) r_cons_printf (Color_YELLOW"[0x%08llx] %s\n"Color_RESET,
|
||||
core->offset, printfmt[printidx%NPF]);
|
||||
else r_cons_printf ("[0x%08llx] %s\n", core->offset, printfmt[printidx%NPF]);
|
||||
}
|
||||
|
||||
R_API int r_core_visual(struct r_core_t *core, const char *input)
|
||||
{
|
||||
R_API int r_core_visual(RCore *core, const char *input) {
|
||||
const char *cmdprompt;
|
||||
const char *vi;
|
||||
ut64 scrseek;
|
||||
int ch;
|
||||
|
||||
vi = r_config_get(&core->config, "cmd.vprompt");
|
||||
if (vi) r_core_cmd(core, vi, 0);
|
||||
vi = r_config_get (&core->config, "cmd.vprompt");
|
||||
if (vi) r_core_cmd (core, vi, 0);
|
||||
|
||||
while (input[0]) {
|
||||
if (!r_core_visual_cmd (core, input[0])) {
|
||||
r_cons_clear00 ();
|
||||
r_core_cmd (core, printfmt[printidx%NPF], 0);
|
||||
r_cons_visual_flush();
|
||||
r_cons_visual_flush ();
|
||||
r_cons_any_key ();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
/* radare - LGPL - Copyright 2009 pancake<nopcode.org> */
|
||||
/* radare - LGPL - Copyright 2009-2010 pancake<nopcode.org> */
|
||||
|
||||
#include "r_core.h"
|
||||
|
||||
int r_core_yank(struct r_core_t *core, ut64 addr, int len)
|
||||
{
|
||||
R_API int r_core_yank(struct r_core_t *core, ut64 addr, int len) {
|
||||
ut64 curseek = core->offset;
|
||||
free(core->yank);
|
||||
core->yank = (ut8 *)malloc(len);
|
||||
@ -21,8 +20,7 @@ int r_core_yank(struct r_core_t *core, ut64 addr, int len)
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
int r_core_yank_paste(struct r_core_t *core, ut64 addr, int len)
|
||||
{
|
||||
R_API int r_core_yank_paste(struct r_core_t *core, ut64 addr, int len) {
|
||||
if (len == 0)
|
||||
len = core->yank_len;
|
||||
if (len > core->yank_len)
|
||||
|
@ -271,8 +271,7 @@ static struct hunklist diff(struct line *a, int an, struct line *b, int bn)
|
||||
|
||||
//--
|
||||
// TODO: implement the r_diff_lines // we need to implement r_file_line_at (file, off);
|
||||
R_API int r_diff_buffers_delta(RDiff *d, const char *sa, int la, const char *sb, int lb)
|
||||
{
|
||||
R_API int r_diff_buffers_delta(RDiff *d, const ut8 *sa, int la, const ut8 *sb, int lb) {
|
||||
RDiffOp dop;
|
||||
char *rb;
|
||||
struct line *al, *bl;
|
||||
@ -281,8 +280,8 @@ R_API int r_diff_buffers_delta(RDiff *d, const char *sa, int la, const char *sb,
|
||||
int an, bn, offa, rlen, offb, len = 0;
|
||||
int hits = 0;
|
||||
|
||||
an = splitlines(sa, la, &al);
|
||||
bn = splitlines(sb, lb, &bl);
|
||||
an = splitlines((const char *)sa, la, &al);
|
||||
bn = splitlines((const char*)sb, lb, &bl);
|
||||
if (!al || !bl) {
|
||||
eprintf ("bindiff_buffers: Out of memory.\n");
|
||||
return -1;
|
||||
|
@ -2,15 +2,7 @@
|
||||
|
||||
#include <r_diff.h>
|
||||
|
||||
R_API struct r_diff_t *r_diff_new(ut64 off_a, ut64 off_b)
|
||||
{
|
||||
struct r_diff_t *d = MALLOC_STRUCT(struct r_diff_t);
|
||||
r_diff_init(d, off_a, off_b);
|
||||
return d;
|
||||
}
|
||||
|
||||
R_API int r_diff_init(struct r_diff_t *d, ut64 off_a, ut64 off_b)
|
||||
{
|
||||
R_API int r_diff_init(RDiff *d, ut64 off_a, ut64 off_b) {
|
||||
d->delta = 1;
|
||||
d->user = NULL;
|
||||
d->off_a = off_a;
|
||||
@ -18,29 +10,29 @@ R_API int r_diff_init(struct r_diff_t *d, ut64 off_a, ut64 off_b)
|
||||
return 1;
|
||||
}
|
||||
|
||||
R_API struct r_diff_t *r_diff_free(struct r_diff_t *d)
|
||||
{
|
||||
free(d);
|
||||
R_API RDiff *r_diff_new(ut64 off_a, ut64 off_b) {
|
||||
RDiff *d = R_NEW (RDiff);
|
||||
r_diff_init (d, off_a, off_b);
|
||||
return d;
|
||||
}
|
||||
|
||||
R_API RDiff *r_diff_free(RDiff *d) {
|
||||
free (d);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
R_API int r_diff_set_callback(struct r_diff_t *d,
|
||||
int (*callback)(struct r_diff_t *d, void *user, struct r_diff_op_t *op),
|
||||
void *user)
|
||||
{
|
||||
R_API int r_diff_set_callback(RDiff *d, RDiffCallback callback, void *user) {
|
||||
d->callback = callback;
|
||||
d->user = user;
|
||||
return 1;
|
||||
}
|
||||
|
||||
R_API int r_diff_set_delta(struct r_diff_t *d, int delta)
|
||||
{
|
||||
R_API int r_diff_set_delta(RDiff *d, int delta) {
|
||||
d->delta = delta;
|
||||
return 1;
|
||||
}
|
||||
|
||||
R_API int r_diff_buffers_static(struct r_diff_t *d, const ut8 *a, int la, const ut8 *b, int lb)
|
||||
{
|
||||
R_API int r_diff_buffers_static(RDiff *d, const ut8 *a, int la, const ut8 *b, int lb) {
|
||||
int i, len;
|
||||
int hit = 0;
|
||||
la = R_ABS(la);
|
||||
@ -76,8 +68,7 @@ R_API int r_diff_buffers_static(struct r_diff_t *d, const ut8 *a, int la, const
|
||||
return 0;
|
||||
}
|
||||
|
||||
R_API int r_diff_buffers_radiff(struct r_diff_t *d, const ut8 *a, int la, const ut8 *b, int lb)
|
||||
{
|
||||
R_API int r_diff_buffers_radiff(RDiff *d, const ut8 *a, int la, const ut8 *b, int lb) {
|
||||
char *ptr, *str, buf[64];
|
||||
FILE *fd;
|
||||
char oop = 0;
|
||||
@ -180,7 +171,7 @@ R_API int r_diff_buffers_radiff(struct r_diff_t *d, const ut8 *a, int la, const
|
||||
.b_off = oob, .b_buf = bt, .b_len = btl
|
||||
};
|
||||
if (!d->callback (d, d->user, &o))
|
||||
return NULL;
|
||||
return 0;
|
||||
atl = btl = 0;
|
||||
hit = 0;
|
||||
}
|
||||
@ -191,24 +182,24 @@ R_API int r_diff_buffers_radiff(struct r_diff_t *d, const ut8 *a, int la, const
|
||||
return 0;
|
||||
}
|
||||
|
||||
R_API int r_diff_buffers(struct r_diff_t *d, const ut8 *a, ut32 la, const ut8 *b, ut32 lb) {
|
||||
R_API int r_diff_buffers(RDiff *d, const ut8 *a, ut32 la, const ut8 *b, ut32 lb) {
|
||||
if (d->delta)
|
||||
return r_diff_buffers_delta (d, a, la, b, lb);
|
||||
return r_diff_buffers_static (d, a, la, b, lb);
|
||||
}
|
||||
|
||||
/* TODO: Move into r_util maybe? */
|
||||
R_API int r_diff_buffers_distance(struct r_diff_t *d, const ut8 *a, ut32 la, const ut8 *b, ut32 lb, ut32 *distance, double *similarity)
|
||||
{
|
||||
R_API int r_diff_buffers_distance(RDiff *d, const ut8 *a, ut32 la, const ut8 *b, ut32 lb,
|
||||
ut32 *distance, double *similarity) {
|
||||
int i, j, cost, tmin, **m;
|
||||
|
||||
if (la < 1 || lb < 1)
|
||||
return R_FALSE;
|
||||
|
||||
if ((m = malloc(la * sizeof(int*))) == NULL)
|
||||
if ((m = malloc (la * sizeof(int*))) == NULL)
|
||||
return R_FALSE;
|
||||
for(i = 0; i <= la; i++)
|
||||
if ((m[i] = malloc(lb * sizeof(int))) == NULL)
|
||||
if ((m[i] = malloc (lb * sizeof(int))) == NULL)
|
||||
return R_FALSE;
|
||||
|
||||
for (i = 0; i <= la; i++)
|
||||
@ -221,9 +212,8 @@ R_API int r_diff_buffers_distance(struct r_diff_t *d, const ut8 *a, ut32 la, con
|
||||
if (a[i-1] == b[j-1])
|
||||
cost = 0;
|
||||
else cost = 1;
|
||||
|
||||
tmin = R_MIN(m[i-1][j] + 1, m[i][j-1] + 1);
|
||||
m[i][j] = R_MIN(tmin, m[i-1][j-1] + cost);
|
||||
tmin = R_MIN (m[i-1][j] + 1, m[i][j-1] + 1);
|
||||
m[i][j] = R_MIN (tmin, m[i-1][j-1] + cost);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ static ut32 count = 0;
|
||||
static int cb(struct r_diff_t *d, void *user,
|
||||
struct r_diff_op_t *op)
|
||||
{
|
||||
int i, rad = (int)user;
|
||||
int i, rad = (int)(size_t)user;
|
||||
if (count) {
|
||||
count++;
|
||||
return 1;
|
||||
@ -26,8 +26,7 @@ static int cb(struct r_diff_t *d, void *user,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int show_help(int line)
|
||||
{
|
||||
static int show_help(int line) {
|
||||
printf ("Usage: radiff2 [-nsdl] [file] [file]\n");
|
||||
if (!line) printf (
|
||||
// " -l diff lines of text\n"
|
||||
@ -45,8 +44,7 @@ enum {
|
||||
MODE_LOCS,
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int main(int argc, char **argv) {
|
||||
struct r_diff_t d;
|
||||
int c, delta = 0;
|
||||
char *file, *file2;
|
||||
@ -102,7 +100,7 @@ int main(int argc, char **argv)
|
||||
case MODE_DIFF:
|
||||
r_diff_init (&d, 0LL, 0LL);
|
||||
r_diff_set_delta (&d, delta);
|
||||
r_diff_set_callback (&d, &cb, (void *)rad);
|
||||
r_diff_set_callback (&d, &cb, (void *)(size_t)rad);
|
||||
r_diff_buffers (&d, bufa, sza, bufb, szb);
|
||||
break;
|
||||
case MODE_DIST:
|
||||
|
@ -7,10 +7,9 @@
|
||||
|
||||
#if USE_BTREE
|
||||
/* compare names */
|
||||
static int ncmp(const void *a, const void *b)
|
||||
{
|
||||
struct r_flag_item_t *fa = (struct r_flag_item_t *)a;
|
||||
struct r_flag_item_t *fb = (struct r_flag_item_t *)b;
|
||||
static int ncmp(const void *a, const void *b) {
|
||||
RFlagItem *fa = (RFlagItem *)a;
|
||||
RFlagItem *fb = (RFlagItem *)b;
|
||||
int ret = 0;
|
||||
/* we cannot use a simple substraction coz ut64 > s32 :) */
|
||||
if (fa->namehash > fb->namehash) ret = 1;
|
||||
@ -19,10 +18,9 @@ static int ncmp(const void *a, const void *b)
|
||||
}
|
||||
|
||||
/* compare offsets */
|
||||
static int cmp(const void *a, const void *b)
|
||||
{
|
||||
struct r_flag_item_t *fa = (struct r_flag_item_t *)a;
|
||||
struct r_flag_item_t *fb = (struct r_flag_item_t *)b;
|
||||
static int cmp(const void *a, const void *b) {
|
||||
RFlagItem *fa = (RFlagItem *)a;
|
||||
RFlagItem *fb = (RFlagItem *)b;
|
||||
int ret = 0;
|
||||
/* we cannot use a simple substraction coz ut64 > s32 :) */
|
||||
if (fa->offset > fb->offset) ret = 1;
|
||||
@ -31,8 +29,7 @@ static int cmp(const void *a, const void *b)
|
||||
}
|
||||
#endif
|
||||
|
||||
R_API int r_flag_init(struct r_flag_t *f)
|
||||
{
|
||||
R_API int r_flag_init(RFlag *f) {
|
||||
int i;
|
||||
INIT_LIST_HEAD(&f->flags);
|
||||
f->space_idx = -1;
|
||||
@ -41,24 +38,22 @@ R_API int r_flag_init(struct r_flag_t *f)
|
||||
btree_init(&f->tree);
|
||||
btree_init(&f->ntree);
|
||||
#endif
|
||||
for(i=0;i<R_FLAG_SPACES_MAX;i++)
|
||||
for (i=0;i<R_FLAG_SPACES_MAX;i++)
|
||||
f->space[i] = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
R_API struct r_flag_t * r_flag_new()
|
||||
{
|
||||
struct r_flag_t *f = MALLOC_STRUCT (struct r_flag_t);
|
||||
R_API RFlag * r_flag_new() {
|
||||
RFlag *f = R_NEW (RFlag);
|
||||
r_flag_init (f);
|
||||
return f;
|
||||
}
|
||||
|
||||
R_API struct r_flag_item_t *r_flag_list(struct r_flag_t *f, int rad)
|
||||
{
|
||||
R_API RFlagItem *r_flag_list(RFlag *f, int rad) {
|
||||
struct list_head *pos;
|
||||
list_for_each_prev(pos, &f->flags) {
|
||||
struct r_flag_item_t *flag = list_entry(pos, struct r_flag_item_t, list);
|
||||
if (rad) r_cons_printf("f %s %lld @ 0x%08llx\n",
|
||||
list_for_each_prev (pos, &f->flags) {
|
||||
RFlagItem *flag = list_entry (pos, RFlagItem, list);
|
||||
if (rad) r_cons_printf ("f %s %lld @ 0x%08llx\n",
|
||||
flag->name, flag->size, flag->offset);
|
||||
else r_cons_printf("0x%08llx %lld %s\n",
|
||||
flag->offset, flag->size, flag->name);
|
||||
@ -66,44 +61,41 @@ R_API struct r_flag_item_t *r_flag_list(struct r_flag_t *f, int rad)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
R_API struct r_flag_item_t *r_flag_get(struct r_flag_t *f, const char *name)
|
||||
{
|
||||
R_API RFlagItem *r_flag_get(RFlag *f, const char *name) {
|
||||
#if USE_BTREE
|
||||
struct r_flag_item_t *i;
|
||||
struct r_flag_item_t tmp;
|
||||
RFlagItem tmp;
|
||||
#else
|
||||
RFlagItem *flag;
|
||||
struct list_head *pos;
|
||||
#endif
|
||||
if (name==NULL || name[0]=='\0' || (name[0]>='0'&& name[0]<='9'))
|
||||
return NULL;
|
||||
#if USE_BTREE
|
||||
tmp.namehash = r_str_hash(name);
|
||||
i = btree_get(f->ntree, &tmp, ncmp);
|
||||
//eprintf("GET_I (0x%08llx) = %p\n", off, i);
|
||||
return i;
|
||||
tmp.namehash = r_str_hash (name);
|
||||
//eprintf("GET_I (0x%08llx) = %p\n", off, flag);
|
||||
return btree_get (f->ntree, &tmp, ncmp);
|
||||
#else
|
||||
list_for_each_prev(pos, &f->flags) {
|
||||
struct r_flag_item_t *flag = list_entry(pos, struct r_flag_item_t, list);
|
||||
if (!strcmp(name, flag->name))
|
||||
list_for_each_prev (pos, &f->flags) {
|
||||
flag = list_entry (pos, RFlagItem, list);
|
||||
if (!strcmp (name, flag->name))
|
||||
return flag;
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
R_API struct r_flag_item_t *r_flag_get_i(struct r_flag_t *f, ut64 off)
|
||||
{
|
||||
R_API RFlagItem *r_flag_get_i(RFlag *f, ut64 off) {
|
||||
#if USE_BTREE
|
||||
struct r_flag_item_t *i;
|
||||
struct r_flag_item_t tmp = { .offset = off };
|
||||
i = btree_get(f->tree, &tmp, cmp);
|
||||
RFlagItem *i;
|
||||
RFlagItem tmp = { .offset = off };
|
||||
i = btree_get (f->tree, &tmp, cmp);
|
||||
//eprintf("GET_N (0x%08llx) = %p\n", off, i);
|
||||
return i;
|
||||
#else
|
||||
/* slow workaround */
|
||||
struct list_head *pos;
|
||||
list_for_each_prev(pos, &f->flags) {
|
||||
struct r_flag_item_t *flag = list_entry(pos, struct r_flag_item_t, list);
|
||||
list_for_each_prev (pos, &f->flags) {
|
||||
RFlagItem *flag = list_entry (pos, RFlagItem, list);
|
||||
if (off == flag->offset)
|
||||
return flag;
|
||||
}
|
||||
@ -111,51 +103,45 @@ R_API struct r_flag_item_t *r_flag_get_i(struct r_flag_t *f, ut64 off)
|
||||
#endif
|
||||
}
|
||||
|
||||
R_API int r_flag_unset(struct r_flag_t *f, const char *name)
|
||||
{
|
||||
struct r_flag_item_t *item;
|
||||
item = r_flag_get(f, name);
|
||||
R_API int r_flag_unset(RFlag *f, const char *name) {
|
||||
RFlagItem *item = r_flag_get (f, name);
|
||||
/* MARK: entrypoint to remove flags */
|
||||
if (item) {
|
||||
#if USE_BTREE
|
||||
btree_del(f->tree, item, cmp, NULL);
|
||||
btree_del(f->ntree, item, ncmp, NULL);
|
||||
btree_del (f->tree, item, cmp, NULL);
|
||||
btree_del (f->ntree, item, ncmp, NULL);
|
||||
#endif
|
||||
list_del(&item->list);
|
||||
list_del (&item->list);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
R_API int r_flag_set(struct r_flag_t *fo, const char *name, ut64 addr, ut32 size, int dup)
|
||||
{
|
||||
R_API int r_flag_set(RFlag *fo, const char *name, ut64 addr, ut32 size, int dup) {
|
||||
const char *ptr;
|
||||
struct r_flag_item_t *flag = NULL;
|
||||
RFlagItem *flag = NULL;
|
||||
#if !USE_BTREE
|
||||
struct list_head *pos;
|
||||
#endif
|
||||
|
||||
if (!dup) {
|
||||
/* show flags as radare commands */
|
||||
if (!r_flag_name_check(name)) {
|
||||
fprintf(stderr, "invalid flag name '%s'.\n", name);
|
||||
if (!r_flag_name_check (name)) {
|
||||
eprintf ("invalid flag name '%s'.\n", name);
|
||||
return R_FALSE;
|
||||
}
|
||||
|
||||
for (ptr = name + 1; *ptr != '\0'; ptr = ptr +1) {
|
||||
if (!IS_PRINTABLE(*ptr)) {
|
||||
fprintf(stderr, "invalid flag name\n");
|
||||
if (!IS_PRINTABLE (*ptr)) {
|
||||
eprintf ("invalid flag name\n");
|
||||
return R_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if USE_BTREE
|
||||
{
|
||||
/* XXX : This is not working properly!! */
|
||||
struct r_flag_item_t tmp;
|
||||
tmp.namehash = r_str_hash(name);
|
||||
RFlagItem tmp;
|
||||
tmp.namehash = r_str_hash (name);
|
||||
//eprintf("NAME(%s) HASH(%x)\n", name, tmp.namehash);
|
||||
flag = btree_get(fo->ntree, &tmp, ncmp);
|
||||
flag = btree_get (fo->ntree, &tmp, ncmp);
|
||||
if (flag) {
|
||||
if (dup) {
|
||||
/* ignore dupped name+offset */
|
||||
@ -174,9 +160,9 @@ R_API int r_flag_set(struct r_flag_t *fo, const char *name, ut64 addr, ut32 size
|
||||
// else eprintf("NOT REGISTERED(%s)\n", name);
|
||||
}
|
||||
#else
|
||||
list_for_each(pos, &fo->flags) {
|
||||
struct r_flag_item_t *f = (struct r_flag_item_t *)
|
||||
list_entry(pos, struct r_flag_item_t, list);
|
||||
list_for_each (pos, &fo->flags) {
|
||||
RFlagItem *f = (RFlagItem *)
|
||||
list_entry(pos, RFlagItem, list);
|
||||
if (!strcmp(f->name, name)) {
|
||||
if (dup) {
|
||||
/* ignore dupped name+offset */
|
||||
@ -187,32 +173,29 @@ R_API int r_flag_set(struct r_flag_t *fo, const char *name, ut64 addr, ut32 size
|
||||
f->offset = addr;
|
||||
f->size = size; // XXX
|
||||
f->format = 0; // XXX
|
||||
//eprintf("update '%s'\n", f->name);
|
||||
return R_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (flag == NULL) {
|
||||
/* MARK: entrypoint for flag addition */
|
||||
flag = malloc(sizeof(struct r_flag_item_t));
|
||||
memset(flag,'\0', sizeof(struct r_flag_item_t));
|
||||
flag = R_NEW (RFlagItem);
|
||||
memset (flag,'\0', sizeof (RFlagItem));
|
||||
flag->offset = addr;
|
||||
strncpy(flag->name, name, R_FLAG_NAME_SIZE);
|
||||
strncpy(flag->name, r_str_chop(flag->name), R_FLAG_NAME_SIZE);
|
||||
strncpy (flag->name, name, R_FLAG_NAME_SIZE);
|
||||
strncpy (flag->name, r_str_chop (flag->name), R_FLAG_NAME_SIZE);
|
||||
flag->name[R_FLAG_NAME_SIZE-1]='\0';
|
||||
flag->namehash = r_str_hash(flag->name);
|
||||
flag->namehash = r_str_hash (flag->name);
|
||||
#if USE_BTREE
|
||||
btree_add(&fo->tree, flag, cmp);
|
||||
btree_add(&fo->ntree, flag, ncmp);
|
||||
btree_add (&fo->tree, flag, cmp);
|
||||
btree_add (&fo->ntree, flag, ncmp);
|
||||
#endif
|
||||
list_add_tail(&(flag->list), &fo->flags);
|
||||
list_add_tail (&(flag->list), &fo->flags);
|
||||
if (flag==NULL)
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
//eprintf("NAME(%s) HASH(%x)\n", flag->name, flag->namehash);
|
||||
flag->offset = addr;
|
||||
flag->space = fo->space_idx;
|
||||
flag->size = size; // XXX
|
||||
|
@ -19,38 +19,36 @@ static int r_flag_name_validate_char(const char ch) {
|
||||
default:
|
||||
if (((ch >= '0') && (ch <= '9')))
|
||||
return 1;
|
||||
if (!IS_PRINTABLE(ch))
|
||||
if (!IS_PRINTABLE (ch))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
R_API int r_flag_name_check(const char *name)
|
||||
{
|
||||
R_API int r_flag_name_check(const char *name) {
|
||||
if (name[0]=='\0')
|
||||
return 0;
|
||||
for(;*name!='\0'; name = name +1) {
|
||||
if (!r_flag_name_validate_char(*name))
|
||||
for (;*name!='\0'; name = name +1) {
|
||||
if (!r_flag_name_validate_char (*name))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
R_API int r_flag_name_filter(char *name)
|
||||
{
|
||||
R_API int r_flag_name_filter(char *name) {
|
||||
int i;
|
||||
char *oname;
|
||||
for(;*name==' ';name=name+1);
|
||||
oname=name;
|
||||
for(i=0;*name!='\0'; name = name +1,i++) {
|
||||
for (i=0;*name!='\0'; name = name +1,i++) {
|
||||
if (i>R_FLAG_NAME_SIZE) {
|
||||
name[0] = '\0';
|
||||
break;
|
||||
}
|
||||
if (!r_flag_name_validate_char(*name)) {
|
||||
strcpy(name, name+1);
|
||||
if (!r_flag_name_validate_char (*name)) {
|
||||
strcpy (name, name+1);
|
||||
name = name -1;
|
||||
}
|
||||
}
|
||||
return r_flag_name_check(oname);
|
||||
return r_flag_name_check (oname);
|
||||
}
|
||||
|
@ -3,8 +3,7 @@
|
||||
#include "r_hash.h"
|
||||
|
||||
/* returns 0-100 */
|
||||
R_API int r_hash_pcprint(const ut8 *buffer, ut64 len)
|
||||
{
|
||||
R_API int r_hash_pcprint(const ut8 *buffer, ut64 len) {
|
||||
const ut8 *end = buffer + len;
|
||||
int n;
|
||||
|
||||
@ -15,8 +14,7 @@ R_API int r_hash_pcprint(const ut8 *buffer, ut64 len)
|
||||
return ((100*n)/len);
|
||||
}
|
||||
|
||||
R_API int r_hash_parity(const ut8 *buf, ut64 len)
|
||||
{
|
||||
R_API int r_hash_parity(const ut8 *buf, ut64 len) {
|
||||
const ut8 *end = buf+len;
|
||||
ut32 ones = 0;
|
||||
for(;buf<end;buf++) {
|
||||
@ -29,8 +27,7 @@ R_API int r_hash_parity(const ut8 *buf, ut64 len)
|
||||
|
||||
/* These functions comes from 0xFFFF */
|
||||
/* fmi: nopcode.org/0xFFFF */
|
||||
R_API ut16 r_hash_xorpair(const ut8 *a, ut64 len)
|
||||
{
|
||||
R_API ut16 r_hash_xorpair(const ut8 *a, ut64 len) {
|
||||
ut16 *b = (ut16 *)a;
|
||||
ut16 result = 0;
|
||||
for(len>>=1;len--;b=b+1)
|
||||
@ -38,16 +35,14 @@ R_API ut16 r_hash_xorpair(const ut8 *a, ut64 len)
|
||||
return result;
|
||||
}
|
||||
|
||||
R_API ut8 r_hash_xor(const ut8 *b, ut64 len)
|
||||
{
|
||||
R_API ut8 r_hash_xor(const ut8 *b, ut64 len) {
|
||||
ut8 res = 0;
|
||||
for(;len--;b=b+1)
|
||||
for (;len--;b=b+1)
|
||||
res^=b[0];
|
||||
return res;
|
||||
}
|
||||
|
||||
R_API ut8 r_hash_mod255(const ut8 *b, ut64 len)
|
||||
{
|
||||
R_API ut8 r_hash_mod255(const ut8 *b, ut64 len) {
|
||||
int i, c = 0;
|
||||
/* from gdb */
|
||||
for (i = 0; i < len; i++)
|
||||
@ -56,8 +51,7 @@ R_API ut8 r_hash_mod255(const ut8 *b, ut64 len)
|
||||
}
|
||||
|
||||
/* TODO: rewrite in a non-spaguetty way */
|
||||
R_API const char *r_hash_name(int bit)
|
||||
{
|
||||
R_API const char *r_hash_name(int bit) {
|
||||
if (bit & R_HASH_MD4) return "md4";
|
||||
if (bit & R_HASH_MD5) return "md5";
|
||||
if (bit & R_HASH_SHA1) return "sha1";
|
||||
@ -73,40 +67,39 @@ R_API const char *r_hash_name(int bit)
|
||||
}
|
||||
|
||||
/* TODO: ignore case.. we have to use strcasestr */
|
||||
R_API ut64 r_hash_name_to_bits(const char *name)
|
||||
{
|
||||
R_API ut64 r_hash_name_to_bits(const char *name) {
|
||||
ut64 bits = R_HASH_NONE;
|
||||
if (strstr(name, "all"))
|
||||
if (strstr (name, "all"))
|
||||
return 0xffffffff;
|
||||
if (strstr(name, "md4"))
|
||||
if (strstr (name, "md4"))
|
||||
bits |= R_HASH_MD4;
|
||||
if (strstr(name, "md5"))
|
||||
if (strstr (name, "md5"))
|
||||
bits |= R_HASH_MD5;
|
||||
if (strstr(name, "sha1"))
|
||||
if (strstr (name, "sha1"))
|
||||
bits |= R_HASH_SHA1;
|
||||
if (strstr(name, "sha256"))
|
||||
if (strstr (name, "sha256"))
|
||||
bits |= R_HASH_SHA256;
|
||||
if (strstr(name, "sha384"))
|
||||
if (strstr (name, "sha384"))
|
||||
bits |= R_HASH_SHA384;
|
||||
if (strstr(name, "sha512"))
|
||||
if (strstr (name, "sha512"))
|
||||
bits |= R_HASH_SHA512;
|
||||
if (strstr(name, "crc16"))
|
||||
if (strstr (name, "crc16"))
|
||||
bits |= R_HASH_CRC16;
|
||||
if (strstr(name, "crc32"))
|
||||
if (strstr (name, "crc32"))
|
||||
bits |= R_HASH_CRC32;
|
||||
if (strstr(name, "xorpair"))
|
||||
if (strstr (name, "xorpair"))
|
||||
bits |= R_HASH_XORPAIR;
|
||||
else if (strstr(name, "xor")) /* XXX: hacky elsif solution */
|
||||
else if (strstr (name, "xor")) /* XXX: hacky elsif solution */
|
||||
bits |= R_HASH_XOR;
|
||||
if (strstr(name, "parity"))
|
||||
if (strstr (name, "parity"))
|
||||
bits |= R_HASH_PARITY;
|
||||
if (strstr(name, "entropy"))
|
||||
if (strstr (name, "entropy"))
|
||||
bits |= R_HASH_ENTROPY;
|
||||
if (strstr(name, "hamdist"))
|
||||
if (strstr (name, "hamdist"))
|
||||
bits |= R_HASH_HAMDIST;
|
||||
if (strstr(name, "pcprint"))
|
||||
if (strstr (name, "pcprint"))
|
||||
bits |= R_HASH_PCPRINT;
|
||||
if (strstr(name, "mod255"))
|
||||
if (strstr (name, "mod255"))
|
||||
bits |= R_HASH_MOD255;
|
||||
return bits;
|
||||
}
|
||||
|
@ -98,7 +98,6 @@ R_API int r_core_seek_delta(struct r_core_t *core, st64 addr);
|
||||
R_API int r_core_write_at(struct r_core_t *core, ut64 addr, const ut8 *buf, int size);
|
||||
R_API int r_core_write_op(struct r_core_t *core, const char *arg, char op);
|
||||
|
||||
/* yank */
|
||||
R_API int r_core_yank(struct r_core_t *core, ut64 addr, int len);
|
||||
R_API int r_core_yank_paste(struct r_core_t *core, ut64 addr, int len);
|
||||
|
||||
|
@ -16,15 +16,18 @@ typedef struct r_diff_op_t {
|
||||
int b_len;
|
||||
} RDiffOp;
|
||||
|
||||
//typedef struct r_diff_t RDiff;
|
||||
|
||||
typedef struct r_diff_t {
|
||||
ut64 off_a;
|
||||
ut64 off_b;
|
||||
int delta;
|
||||
void *user;
|
||||
int (*callback)(struct r_diff_t *d, void *user,
|
||||
struct r_diff_op_t *op);
|
||||
int (*callback)(struct r_diff_t *diff, void *user, RDiffOp *op);
|
||||
} RDiff;
|
||||
|
||||
typedef int (*RDiffCallback)(RDiff *diff, void *user, RDiffOp *op);
|
||||
|
||||
/* XXX: this api needs to be reviewed , constructor with offa+offb?? */
|
||||
#ifdef R_API
|
||||
R_API struct r_diff_t *r_diff_new(ut64 off_a, ut64 off_b);
|
||||
@ -34,11 +37,9 @@ R_API struct r_diff_t *r_diff_free(struct r_diff_t *d);
|
||||
R_API int r_diff_buffers(struct r_diff_t *d, const ut8 *a, ut32 la, const ut8 *b, ut32 lb);
|
||||
R_API int r_diff_buffers_static(struct r_diff_t *d, const ut8 *a, int la, const ut8 *b, int lb);
|
||||
R_API int r_diff_buffers_radiff(struct r_diff_t *d, const ut8 *a, int la, const ut8 *b, int lb);
|
||||
R_API int r_diff_buffers_delta(RDiff *diff, const char *sa, int la, const char *sb, int lb);
|
||||
R_API int r_diff_buffers_delta(RDiff *diff, const ut8 *sa, int la, const ut8 *sb, int lb);
|
||||
R_API int r_diff_buffers(struct r_diff_t *d, const ut8 *a, ut32 la, const ut8 *b, ut32 lb);
|
||||
R_API int r_diff_set_callback(struct r_diff_t *d,
|
||||
int (*callback)(struct r_diff_t *d, void *user, struct r_diff_op_t *op),
|
||||
void *user);
|
||||
R_API int r_diff_set_callback(RDiff *d, RDiffCallback callback, void *user);
|
||||
R_API int r_diff_buffers_distance(struct r_diff_t *d,
|
||||
const ut8 *a, ut32 la, const ut8 *b, ut32 lb, ut32 *distance,
|
||||
double *similarity);
|
||||
|
@ -43,3 +43,53 @@ RSyscallItem syscalls_linux_x86[] = {
|
||||
{ "exit_group", 0x80, 252, 1},
|
||||
{ NULL, 0, 0, 0 }
|
||||
};
|
||||
|
||||
// http://lxr.oss.org.cn/source/include/asm-arm/unistd.h
|
||||
/* syscall-linux */
|
||||
// XXX: same as in linux-x86 ?
|
||||
RSyscallItem syscalls_linux_arm[] = {
|
||||
{ "exit", 0x900000, 1, 1, "i" },
|
||||
{ "fork", 0x900000, 2, 0, NULL },
|
||||
{ "read", 0x900000, 3, 3, "ipi" },
|
||||
{ "write", 0x900000, 4, 3, "izi" },
|
||||
{ "open", 0x900000, 5, 3, "zxx" },
|
||||
{ "close", 0x900000, 6, 1, "i" },
|
||||
{ "waitpid", 0x900000, 7, 3, "ipx"},
|
||||
{ "creat", 0x900000, 8, 2, "zx" },
|
||||
{ "link", 0x900000, 9, 2, "zz" },
|
||||
{ "unlink", 0x900000, 10, 1, "z" },
|
||||
{ "execve", 0x900000, 11, 3, "zzz" }, // XXX this is char**
|
||||
{ "chdir", 0x900000, 12, 1, "z" },
|
||||
{ "time", 0x900000, 13, 1, "p" },
|
||||
{ "mknod", 0x900000, 14, 1, "zxi" },
|
||||
{ "chmod", 0x900000, 15, 1, "zx" },
|
||||
{ "lchown", 0x900000, 16, 1, "zii" },
|
||||
{ "getpid", 0x900000, 20, 0, NULL},
|
||||
{ "setuid", 0x900000, 23, 1, "i" },
|
||||
{ "getuid", 0x900000, 24, 0, NULL },
|
||||
{ "ptrace", 0x900000, 26, 4 },
|
||||
{ "utime", 0x900000, 30, 2 },
|
||||
{ "access", 0x900000, 33, 2 },
|
||||
{ "kill", 0x900000, 37,2 },
|
||||
{ "dup", 0x900000, 41, 2 },
|
||||
{ "brk", 0x900000, 45, 1 },
|
||||
{ "signal", 0x900000, 48, 2 },
|
||||
{ "ioctl", 0x900000, 54, 3 },
|
||||
{ "mmap", 0x900000, 90, 6 },
|
||||
{ "munmap", 0x900000, 91, 1 },
|
||||
{ "socketcall", 0x900000, 102, 2 },
|
||||
{ "sigreturn", 0x900000, 119, 1 },
|
||||
{ "clone", 0x900000, 120, 4 },
|
||||
{ "mprotect", 0x900000, 125, 3},
|
||||
{ "rt_sigaction", 0x900000, 174, 3},
|
||||
{ "rt_sigprocmask", 0x900000, 175, 3},
|
||||
{ "sysctl", 0x900000, 149, 1 },
|
||||
{ "mmap2", 0x900000, 192, 6},
|
||||
{ "fstat64", 0x900000, 197, 2},
|
||||
{ "fcntl64", 0x900000, 221, 3},
|
||||
{ "gettid", 0x900000, 224, 0},
|
||||
{ "set_thread_area", 0x900000, 243, 2},
|
||||
{ "get_thread_area", 0x900000, 244, 2},
|
||||
{ "exit_group", 0x900000, 252, 1},
|
||||
{ NULL, 0, 0, 0 }
|
||||
};
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
extern RSyscallItem syscalls_netbsd_x86[];
|
||||
extern RSyscallItem syscalls_linux_x86[];
|
||||
extern RSyscallItem syscalls_linux_arm[];
|
||||
extern RSyscallItem syscalls_freebsd_x86[];
|
||||
extern RSyscallItem syscalls_darwin_x86[];
|
||||
extern RSyscallItem syscalls_win7_x86[];
|
||||
@ -22,20 +23,28 @@ R_API RSyscall* r_syscall_new() {
|
||||
return ctx;
|
||||
}
|
||||
|
||||
R_API void r_syscall_init(struct r_syscall_t *ctx) {
|
||||
R_API void r_syscall_init(RSyscall *ctx) {
|
||||
ctx->fd = NULL;
|
||||
ctx->sysptr = syscalls_linux_x86;
|
||||
}
|
||||
|
||||
R_API void r_syscall_free(struct r_syscall_t *ctx) {
|
||||
R_API void r_syscall_free(RSyscall *ctx) {
|
||||
free (ctx);
|
||||
}
|
||||
|
||||
R_API int r_syscall_setup(struct r_syscall_t *ctx, const char *arch, const char *os) {
|
||||
R_API int r_syscall_setup(RSyscall *ctx, const char *arch, const char *os) {
|
||||
if (os == NULL)
|
||||
os = R_SYS_OS;
|
||||
if (arch == NULL)
|
||||
arch = R_SYS_ARCH;
|
||||
if (!strcmp (arch, "arm")) {
|
||||
if (!strcmp (os, "linux"))
|
||||
ctx->sysptr = syscalls_linux_arm;
|
||||
else {
|
||||
eprintf ("r_syscall_setup: Unknown arch '%s'\n", arch);
|
||||
return R_FALSE;
|
||||
}
|
||||
} else
|
||||
if (!strcmp (arch, "x86")) {
|
||||
if (!strcmp (os, "linux"))
|
||||
ctx->sysptr = syscalls_linux_x86;
|
||||
@ -63,7 +72,7 @@ R_API int r_syscall_setup(struct r_syscall_t *ctx, const char *arch, const char
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API int r_syscall_setup_file(struct r_syscall_t *ctx, const char *path) {
|
||||
R_API int r_syscall_setup_file(RSyscall *ctx, const char *path) {
|
||||
if (ctx->fd)
|
||||
fclose (ctx->fd);
|
||||
ctx->fd = fopen (path, "r");
|
||||
@ -92,14 +101,14 @@ R_API int r_syscall_get_num(RSyscall *ctx, const char *str) {
|
||||
}
|
||||
|
||||
/* XXX: ugly iterator implementation */
|
||||
R_API RSyscallItem *r_syscall_get_n(struct r_syscall_t *ctx, int n) {
|
||||
R_API RSyscallItem *r_syscall_get_n(RSyscall *ctx, int n) {
|
||||
int i;
|
||||
for (i=0; ctx->sysptr[i].num && i!=n; i++)
|
||||
return &ctx->sysptr[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
R_API const char *r_syscall_get_i(struct r_syscall_t *ctx, int num, int swi) {
|
||||
R_API const char *r_syscall_get_i(RSyscall *ctx, int num, int swi) {
|
||||
int i;
|
||||
for (i=0; ctx->sysptr[i].num; i++) {
|
||||
if (num == ctx->sysptr[i].num && \
|
||||
@ -109,7 +118,7 @@ R_API const char *r_syscall_get_i(struct r_syscall_t *ctx, int num, int swi) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
R_API void r_syscall_list(struct r_syscall_t *ctx) {
|
||||
R_API void r_syscall_list(RSyscall *ctx) {
|
||||
int i;
|
||||
for (i=0; ctx->sysptr[i].num; i++) {
|
||||
printf ("%02x: %d = %s\n",
|
||||
|
Loading…
Reference in New Issue
Block a user