- Removed warnings
  - Added error handling to rasm2
* r_lang
  - Fixed "print help" bug
This commit is contained in:
Nibble 2009-02-19 18:13:34 +01:00
parent ab956379ea
commit bda701d02f
7 changed files with 28 additions and 13 deletions

View file

@ -3029,7 +3029,7 @@ void print_disp(dis_buffer_t *dbuf, int disp, int sz, int rel, int dd)
disp = (int)((short)disp);
if (rel == -1) {
/*phx - use sval to print real destination address */
nv = disp + (u_int)dbuf->sval + 2*(dd+1);
nv = disp + (u_long)dbuf->sval + 2*(dd+1);
printu(dbuf, nv, SIZE_LONG);
}
else {

View file

@ -5,7 +5,7 @@
#define BYTE unsigned char
#define WORD unsigned short
#define DWORD unsigned int
#define __stdcall __attribute__((stdcall))
#define __stdcall
#endif
#define INSTRUCT_LENGTH 64

View file

@ -1,6 +1,5 @@
CFLAGS=-I../../include -I../arch/ -I../arch/include -w -fPIC -shared -Wl,-R..
CFLAGS=-I../../include -I../arch/ -I../arch/include -Wall -fPIC -shared -Wl,-R..
# XXX
# -Wall
CFLAGS+=-DLIL_ENDIAN=1 -D__UNIX__
## X86

View file

@ -67,7 +67,10 @@ static int rasm_asm(char *buf, u64 offset)
/* TODO: Arch, syntax... */
r_asm_set(&a, "asm_x86_olly");
if (!r_asm_set(&a, "asm_x86_olly")) {
fprintf(stderr, "Error: Cannot find asm_x86 plugin\n");
return 1;
}
r_asm_set_pc(&a, offset);
ret = r_asm_assemble(&a, &aop, buf);
@ -90,11 +93,11 @@ static int __lib_asm_dt(struct r_lib_plugin_t *pl, void *p, void *u) { return R_
int main(int argc, char *argv[])
{
char *arch = NULL;
u64 offset = 0x8048000;
int dis = 0, str = 0, c;
r_asm_init(&a);
r_asm_set(&a, "asm_x86");
r_lib_init(&l, "radare_plugin");
r_lib_add_handler(&l, R_LIB_TYPE_ASM, "(dis)assembly plugins",
&__lib_asm_cb, &__lib_asm_dt, NULL);
@ -107,10 +110,7 @@ int main(int argc, char *argv[])
{
switch( c ) {
case 'a':
if (!r_asm_set(&a, optarg))
r_asm_set(&a, "asm_x86");
if (!strcmp(optarg, "asm_bf"))
str = 1;
arch = optarg;
break;
case 'b':
r_asm_set_bits(&a, r_num_math(NULL, optarg));
@ -134,6 +134,19 @@ int main(int argc, char *argv[])
}
}
if (arch) {
if (!r_asm_set(&a, arch)) {
fprintf(stderr, "Error: Unknown plugin\n");
return 1;
}
if (!strcmp(arch, "asm_bf"))
str = 1;
} else if (!r_asm_set(&a, "asm_x86")) {
fprintf(stderr, "Error: Cannot find asm_x86 plugin\n");
return 1;
}
if (argv[optind]) {
if (!strcmp(argv[optind], "-")) {
char buf[1024];

View file

@ -94,9 +94,10 @@ int r_lang_prompt(struct r_lang_t *lang)
buf[strlen(buf)-1]='\0';
if (!strcmp(buf, "q"))
return R_TRUE;
if (!strcmp(buf, "?"))
printf(*lang->cur->help);
else r_lang_run(lang, buf, strlen(buf));
if (!strcmp(buf, "?")) {
if (lang->cur->help)
printf(*lang->cur->help);
} else r_lang_run(lang, buf, strlen(buf));
}
return R_TRUE;
}

View file

@ -12,6 +12,7 @@ static int dummy_run(void *user, const char *code, int len)
static struct r_lang_handle_t r_lang_plugin_dummy = {
.name = "dummy",
.desc = "Dummy language extension",
.help = NULL,
.run = &dummy_run,
.run_file = NULL,
.set_argv = NULL,

View file

@ -12,6 +12,7 @@ static int lua_run(void *user, const char *code, int len)
static struct r_lang_handle_t r_lang_plugin_lua = {
.name = "lua",
.desc = "LUA language extension",
.help = NULL,
.run = &lua_run,
.run_file = NULL,
.set_argv = NULL,