Add rax2 -n for binary numeric values

This commit is contained in:
pancake 2013-03-05 01:28:32 +01:00
parent 27c38164cf
commit cea398e345
4 changed files with 12 additions and 2 deletions

View File

@ -13,6 +13,7 @@ Broken stuff to fixe before release
0.9.4
=====
* libr/debug/p/drx.c <- not used .. debug must have a hw reg api for drx and gpio
* ah -> add hint to define calls that do not return
* pdr doesnt works well with antidisasm tricks, wtf
* continue execution until condition happen (reg, mem, ..)

View File

@ -50,6 +50,7 @@ static int help () {
" raw -> hex ; rax2 -S < /binfile\n"
" hex -> raw ; rax2 -s 414141\n"
" -e swap endianness ; rax2 -e 0x33\n"
" -n binary number ; rax2 -e 0x1234 # 34120000\n"
" -d force integer ; rax2 -d 3 -> 3 instead of 0x3\n"
" -f floating point ; rax2 -f 6.3+2.1\n"
" -b binstr -> bin ; rax2 -b 01000101 01110110\n"
@ -85,6 +86,7 @@ static int rax (char *str, int len, int last) {
case 'f': flags ^= 64; break;
case 'd': flags ^=128; break;
case 'k': flags ^=256; break;
case 'n': flags ^=512; break;
case 'v': printf ("rax2 v"R2_VERSION"\n"); break;
case '\0': return use_stdin ();
default:
@ -104,6 +106,14 @@ static int rax (char *str, int len, int last) {
return help ();
dotherax:
if (flags & 512) { // -k
ut32 n = r_num_math (num, str);
ut8 *np = (ut8*)&n;
if (flags & 1) write (1, &n, sizeof (n));
else printf ("%02x%02x%02x%02x\n",
np[0], np[1], np[2], np[3]);
return R_TRUE;
}
if (flags & 256) { // -k
int n = ((strlen (str))>>1)+1;
char *s;

View File

@ -204,7 +204,6 @@ R_API const char *r_anal_data_kind (RAnal *anal, ut64 addr, const ut8 *buf, int
}
r_anal_data_free (data);
}
eprintf ("J = %d\n", j);
if (j<1) return "unknown";
if ((inv*100/j)>60) return "invalid";
if ((unk*100/j)>60) return "code";

View File

@ -838,7 +838,7 @@ static int cmd_anal(void *data, const char *input) {
case 'k':
{
const char *r = r_anal_data_kind (core->anal,
core->offset, core->block, core->blocksize);
core->offset, core->block, core->blocksize);
r_cons_printf ("%s\n", r);
}
break;