mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-25 22:29:48 +00:00
* Initial support for 'jb' opcode in x86.nz
- hello.r now is broken because of this use - Ignore prefixed '$' in numeric values for r_egg * Apply @capi_x's patch fixing a bug in 'wb' and rsc/msdn
This commit is contained in:
parent
c53a78bd88
commit
1424bf9701
@ -15,7 +15,7 @@ hello:
|
||||
$R -s hello.r | tee hello.s
|
||||
$R -x hello.r | tee hello.x
|
||||
$R -F -o a.out hello.r
|
||||
-./a.out ; RET=$$? ; if [ $$RET = 0 ]; then echo It Works ; else echo Oops.. Fail ; fi
|
||||
#-./a.out ; RET=$$? ; if [ $$RET = 0 ]; then echo It Works ; else echo Oops.. Fail ; fi
|
||||
|
||||
hi:
|
||||
rm -f a.out
|
||||
|
@ -5,9 +5,9 @@ exit@syscall(1);
|
||||
main@global(128) {
|
||||
.var0 = 4;
|
||||
.var4 = "Hello World\n";
|
||||
while (.var0) {
|
||||
while (.var0 > 0) {
|
||||
write (1, .var4, 12);
|
||||
.var0 -= 1;
|
||||
.var0 -= 2;
|
||||
}
|
||||
exit (0);
|
||||
}
|
||||
|
@ -14,6 +14,6 @@ PRINT=0
|
||||
echo "$DUMP" | while read LINE; do
|
||||
[[ "$LINE" = *"Send comments about this topic to Microsoft"* ]] && PRINT=0
|
||||
[[ $PRINT -eq 1 ]] && echo "$LINE"
|
||||
[[ "$LINE" = *"$QUERY Minimize"* ]] && PRINT=1
|
||||
[[ "$LINE" = *"Expand Minimize"* ]] && PRINT=1
|
||||
done | less
|
||||
|
||||
|
@ -6,6 +6,11 @@
|
||||
#include <r_lib.h>
|
||||
#include <r_asm.h>
|
||||
|
||||
#if 0
|
||||
Add support for AND, OR, ..
|
||||
0x100000ec5 1 4883e4f0 and rsp, 0xfffffffffffffff0
|
||||
#endif
|
||||
|
||||
static ut8 getreg(const char *str) {
|
||||
int i;
|
||||
const char *regs[] = { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", NULL };
|
||||
@ -22,6 +27,8 @@ static ut8 getreg(const char *str) {
|
||||
}
|
||||
|
||||
static int getnum(const char *s) {
|
||||
if (*s=='$')
|
||||
s++;
|
||||
if (*s=='0' && s[1]=='x') {
|
||||
int n;
|
||||
sscanf (s+2, "%x", &n);
|
||||
@ -598,6 +605,24 @@ static int assemble(RAsm *a, RAsmOp *ao, const char *str) {
|
||||
return l;
|
||||
}
|
||||
} else
|
||||
if (!strcmp (op, "jb")) {
|
||||
ut64 dst = r_num_math (NULL, arg) - offset;
|
||||
int d, num = getnum (arg);
|
||||
d = num - a->pc;
|
||||
//if (num>-127 && num<127) {
|
||||
if (d>-127 && d<127) {
|
||||
d-=2;
|
||||
data[l++] = 0x72;
|
||||
data[l++] = (char)d;
|
||||
return l;
|
||||
} else {
|
||||
data[l++]=0x0f;
|
||||
data[l++]=0x82;
|
||||
dst -= 6;
|
||||
memcpy (data+l, &dst, 4);
|
||||
return l+4;
|
||||
}
|
||||
} else
|
||||
if (!strcmp (op, "jnz")) {
|
||||
ut64 dst = r_num_math (NULL, arg) - offset;
|
||||
int num = getnum (arg);
|
||||
|
@ -1,7 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
AS=x86.as
|
||||
|
||||
foo() {
|
||||
A=$(rasm2 -a x86.as -b ${BITS} "$1")
|
||||
A=$(rasm2 -a ${AS} -b ${BITS} "$1")
|
||||
B=$(rasm2 -a x86.nz -b ${BITS} "$1")
|
||||
D=$(rasm2 -b ${BITS} -d "$A")
|
||||
if [ "${A}" = "${B}" ]; then
|
||||
@ -17,6 +19,14 @@ if [ -n "$1" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
AS=x86.olly
|
||||
foo 'call 0x8049100'
|
||||
foo 'jmp 0x8049200'
|
||||
foo 'jb 0x8049300'
|
||||
exit 0
|
||||
|
||||
AS=x86.as
|
||||
|
||||
foo "sub dword ptr [eax], 1"
|
||||
foo "add dword ptr [eax], 1"
|
||||
foo "add dword ptr [ebx], 1"
|
||||
|
@ -2855,10 +2855,16 @@ static int cmd_write(void *data, const char *input) {
|
||||
int len = strlen (input);
|
||||
ut8 *buf = alloca (len);
|
||||
len = r_hex_str2bin (input+1, buf);
|
||||
r_mem_copyloop (core->block, buf, core->blocksize, len);
|
||||
r_core_write_at (core, core->offset, core->block, core->blocksize);
|
||||
WSEEK (core, core->blocksize);
|
||||
r_core_block_read (core, 0);
|
||||
if (len > 0) {
|
||||
r_mem_copyloop (core->block, buf, core->blocksize, len);
|
||||
r_core_write_at (core, core->offset, core->block, core->blocksize);
|
||||
WSEEK (core, core->blocksize);
|
||||
r_core_block_read (core, 0);
|
||||
} else {
|
||||
eprintf ("Wrong argument\n");
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
|
@ -28,6 +28,7 @@
|
||||
static char *regs[] = R_GP;
|
||||
|
||||
static void emit_init (REgg *egg) {
|
||||
// TODO: add 'andb rsp, 0xf0'
|
||||
if (attsyntax) r_egg_printf (egg, "mov %esp, %ebp\n");
|
||||
else r_egg_printf (egg, "mov ebp, esp\n");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user