* Implement xchg opcode in x86.nz

* Honor 0x in r_str_case (to uppercase)
This commit is contained in:
pancake 2011-09-22 12:26:44 +02:00
parent 677a499440
commit 829a2bb69f
5 changed files with 31 additions and 7 deletions

3
TODO
View File

@ -33,6 +33,7 @@
* search.kwidx must be search.lastidx or search.idx ?
* add support for sockets in rarun2
* shell encoder - get x86-64 one from twitter
- http://funoverip.net/2011/09/simple-shellcode-obfuscation/
* RBinCreate:
- mach0 create for darwin-ppc
- pe64
@ -47,8 +48,6 @@ BOTTLENECKS:
OSX
===
* Cant set register values in OSX debugger
- This is probably because we are using the 32bit binary on 64bit dbg
* Proper support for MACH-O binaries
- rabin2 -f works? i think its used with '-a'

View File

@ -100,6 +100,20 @@ static int assemble(RAsm *a, RAsmOp *ao, const char *str) {
//arg2 = skipspaces (arg2+1);
for (arg2++; *arg2==' '; arg2++);
}
if (!strcmp (op, "xchg")) {
if (arg2) {
if (*arg == '[' || *arg2=='[') {
eprintf ("xchg with memory access not yet implemented\n");
} else {
data[l++] = 0x87;
data[l++] = 0xc0 | getreg (arg) | getreg (arg2)<<3;
return l;
}
} else {
eprintf ("xchg expects 2 arguments\n");
return 0;
}
} else
if (!strcmp (op, "add")) {
int pfx;
if (*arg=='[') {

View File

@ -19,6 +19,16 @@ if [ -n "$1" ]; then
exit 0
fi
AS=x86.olly
foo 'xchg eax,eax'
foo 'xchg eax,esp'
foo 'xchg eax,ebx'
foo 'xchg ecx,ebp'
foo 'xchg ecx,ecx'
foo 'xchg ebx,ecx'
foo 'xchg ecx,ebx'
# exit 0
if true ; then
AS=x86.olly
foo 'jl patata'

View File

@ -6,7 +6,7 @@
R_API int r_hash_pcprint(const ut8 *buffer, ut64 len) {
const ut8 *end = buffer + len;
int n;
for(n=0; buffer<end; buffer++)
for (n=0; buffer<end; buffer++)
if (IS_PRINTABLE (*buffer))
n++;
return ((100*n)/len);
@ -15,7 +15,7 @@ R_API int r_hash_pcprint(const ut8 *buffer, 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++) {
for (;buf<end;buf++) {
ut8 x = buf[0];
ones += ((x&128)?1:0) + ((x&64)?1:0) + ((x&32)?1:0) + ((x&16)?1:0) +
((x&8)?1:0) + ((x&4)?1:0) + ((x&2)?1:0) + ((x&1)?1:0);

View File

@ -167,10 +167,11 @@ R_API const char *r_str_bool(int b) {
R_API void r_str_case(char *str, int up) {
if (up) {
for (;*str;str++)
*str = toupper (*str);
char oc;
for (; *str; oc = *str++)
*str = (*str=='x' && oc=='0') ? 'x': toupper (*str);
} else {
for (;*str; str++)
for (; *str; str++)
*str = tolower (*str);
}
}