* Added anal_java plugin (copypasta from r1)

- Split java_ops array into a separate object file
* Fix r_config.vapi and add RConfig instance in RCore definition
This commit is contained in:
pancake 2010-05-23 14:31:18 +02:00
parent 2368a1e3b6
commit be12c8f284
15 changed files with 431 additions and 220 deletions

View File

@ -7,7 +7,8 @@ include ../config.mk
foo: pre libr_anal.${EXT_SO} libr_anal.${EXT_AR} plugins
include ${STATIC_ANAL_PLUGINS}
STATIC_OBJS=$(subst ..,p/..,$(subst anal_,p/anal_,$(STATIC_OBJ)))
#STATIC_OBJS=$(subst ..,p/..,$(subst anal_,p/anal_,$(STATIC_OBJ)))
STATIC_OBJS=$(subst ../ar,p/../ar,$(subst anal_,p/anal_,$(STATIC_OBJ)))
OBJ=${STATIC_OBJS} ctx.o reflines.o ref.o aop.o fcn.o bb.o var.o anal.o
pre:

189
libr/anal/p/anal_java.c Normal file
View File

@ -0,0 +1,189 @@
/* radare - LGPL - Copyright 2010 */
/* pancake<nopcode.org> */
#include <string.h>
#include <r_types.h>
#include <r_lib.h>
#include <r_asm.h>
#include <r_anal.h>
#include "../../asm/arch/java/javasm/javasm.h"
/* code analysis functions */
/* arch_aop for java */
// CMP ARG1
// 837d0801 cmp dword [ebp+0x8], 0x1
// SET VAR_41c
// 8985e4fbffff mov [ebp-41C],eax
// GET VAR_41c
// 8b85e4fbffff mov eax,[ebp-41C]
// 8b450c mov eax,[ebp+C]
// 8d85e8fbffff lea eax,[ebp-418]
// c68405e7fbffff. mov byte ptr [ebp+eax-419],0x0
// NOTE: buf should be at least 16 bytes!
// XXX addr should be off_t for 64 love
static int aop(RAnal *anal, RAnalOp *aop, ut64 addr, const ut8 *data, int len) {
unsigned int i;
int sz = 1;
/* get opcode size */
for(i = 0;java_ops[i].name != NULL;i++)
if (data[0] == java_ops[i].byte)
sz = java_ops[i].size;
if (aop == NULL)
return sz;
memset (aop, '\0', sizeof (RAnalOp));
aop->type = R_ANAL_OP_TYPE_UNK;
aop->length = sz;
switch(data[0]) {
case 0xa9: // ret
case 0xb1: // return
case 0xb0: // areturn
case 0xaf: // dreturn
case 0xae: // freturn
case 0xac: // ireturn
case 0xad: // lreturn
aop->type = R_ANAL_OP_TYPE_RET;
aop->eob = 1;
break;
case 0xa7: // goto
case 0xc8: // goto_w
aop->type = R_ANAL_OP_TYPE_JMP;
aop->jump = 0; // TODO
aop->eob = 1;
break;
case 0xa5: // acmpeq
case 0xa6: // acmpne
case 0x9f: // icmpeq
case 0xa0: // icmpne
case 0xa1: // icmplt
case 0xa2: // icmpge
case 0xa3: // icmpgt
case 0xa4: // icmple
case 0x99: // ifeq
case 0x9a: // ifne
case 0x9b: // iflt
case 0x9c: // ifge
case 0x9d: // ifgt
case 0x9e: // ifle
case 0xc7: // ifnonnull
case 0xc6: // ifnull
aop->type = R_ANAL_OP_TYPE_CJMP;
aop->jump = 0x0; // TODO
aop->fail = addr + sz;
aop->eob = 1;
break;
case 0xa8: // jsr
case 0xc9: // jsr_w
aop->type = R_ANAL_OP_TYPE_CALL;
aop->jump = 0x0; // TODO
aop->fail = addr + sz;
aop->eob = 1;
break;
case 0xb9: // invokeinterface
case 0xb7: // invokespecial
case 0xb8: // invokestatic
case 0xb6: // invokevirtual
case 0xbb: // new
case 0xbc: // newarray
case 0xc5: // multi new array
aop->type = R_ANAL_OP_TYPE_SWI;
break;
case 0xca: // breakpoint
aop->type = R_ANAL_OP_TYPE_TRAP;
break;
case 0xbf: // athrow
aop->type = R_ANAL_OP_TYPE_TRAP;
break;
case 0x00: // nop
aop->type = R_ANAL_OP_TYPE_NOP;
break;
case 0xba:
aop->type = R_ANAL_OP_TYPE_ILL;
break;
case 0x57: // pop
case 0x58: // pop2
aop->type = R_ANAL_OP_TYPE_POP;
break;
case 0x10: // bipush
case 0x11: // sipush
case 0x59: // dup
case 0x5a: // dup_x1
case 0x5b: // dup_x2
case 0x5c: // dup2
case 0x5d: // dup2_x1
case 0x5e: // dup2_x2
aop->type = R_ANAL_OP_TYPE_PUSH;
break;
case 0x60: // iadd
case 0x61: // ladd
case 0x62: // fadd
case 0x63: // dadd
aop->type = R_ANAL_OP_TYPE_ADD;
break;
case 0x64: // isub
case 0x65: // lsub
case 0x66: // fsub
case 0x67: // dsub
aop->type = R_ANAL_OP_TYPE_SUB;
break;
case 0x76: // neg
aop->type = R_ANAL_OP_TYPE_NOT;
break;
case 0x78: //ishl
case 0x79: //lshl
aop->type = R_ANAL_OP_TYPE_SHL;
break;
case 0x7a: //ishr
case 0x7b: //lshr
aop->type = R_ANAL_OP_TYPE_SHR;
break;
case 0x80: // ior
case 0x81: // lor
aop->type = R_ANAL_OP_TYPE_OR;
break;
case 0x82: // ixor
case 0x83: // lxor
aop->type = R_ANAL_OP_TYPE_XOR;
break;
case 0x7e: // iand
case 0x7f: // land
aop->type = R_ANAL_OP_TYPE_AND;
break;
case 0x68: // imul
case 0x69: // lmul
case 0x6a: // fmul
case 0x6b: // dmul
aop->type = R_ANAL_OP_TYPE_MUL;
break;
case 0x6c: // idiv
case 0x6d: // ldiv
case 0x6e: // fdiv
case 0x6f: // ddiv
aop->type = R_ANAL_OP_TYPE_DIV;
break;
}
return sz;
}
struct r_anal_handle_t r_anal_plugin_java = {
.name = "java",
.desc = "Java bytecode analysis plugin",
.init = NULL,
.fini = NULL,
.aop = &aop
};
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.data = &r_anal_plugin_java
};
#endif

10
libr/anal/p/java.mk Normal file
View File

@ -0,0 +1,10 @@
OBJ_JAVA=anal_java.o
OBJ_JAVA+=../asm/arch/java/javasm/java_ops.o
STATIC_OBJ+=${OBJ_JAVA}
TARGET_JAVA=anal_java.${EXT_SO}
ALL_TARGETS+=${TARGET_JAVA}
${TARGET_JAVA}: ${OBJ_JAVA}
${CC} ${CFLAGS} -o anal_java.${EXT_SO} ${OBJ_JAVA}

View File

@ -8,4 +8,3 @@ ALL_TARGETS+=${TARGET_X86}
${TARGET_X86}: ${OBJ_X86}
${CC} -shared ${CFLAGS} -o anal_x86.${EXT_SO} ${OBJ_X86}
@#strip -s anal_x86.${EXT_SO}

View File

@ -0,0 +1,209 @@
#include <stdio.h>
#include "javasm.h"
struct java_op java_ops[] = {
{ "aconst_null" , 0x01 , 1 } ,
{ "aload" , 0x19 , 2 } ,
{ "aload_0" , 0x2a , 1 } ,
{ "aload_1" , 0x2b , 1 } ,
{ "aload_2" , 0x2c , 1 } ,
{ "aload_3" , 0x2d , 1 } ,
{ "areturn" , 0xb0 , 1 } ,
{ "arraylength" , 0xbe , 1 } ,
{ "astore" , 0x3a , 2 } ,
{ "astore_0" , 0x4b , 1 } ,
{ "astore_1" , 0x4c , 1 } ,
{ "astore_2" , 0x4d , 1 } ,
{ "astore_3" , 0x4e , 1 } ,
{ "athrow" , 0xbf , 1 } ,
{ "baload" , 0x33 , 1 } ,
{ "bastore" , 0x54 , 1 } ,
{ "bipush" , 0x10 , 2 } ,
{ "caload" , 0x34 , 1 } ,
{ "castore" , 0x55 , 1 } ,
{ "checkcast" , 0xc0 , 3 } ,
{ "d2f" , 0x90 , 1 } ,
{ "d2i" , 0x8e , 1 } ,
{ "d2l" , 0x8f , 1 } ,
{ "dadd" , 0x63 , 1 } ,
{ "daload" , 0x31 , 1 } ,
{ "dastore" , 0x52 , 1 } ,
{ "dcmpg" , 0x98 , 1 } ,
{ "dcmpl" , 0x97 , 1 } ,
{ "dconst_0" , 0x0e , 1 } ,
{ "dconst_1" , 0x0f , 1 } ,
{ "ddiv" , 0x6f , 1 } ,
{ "dload" , 0x18 , 2 } ,
{ "dload_0" , 0x26 , 1 } ,
{ "dload_1" , 0x27 , 1 } ,
{ "dload_2" , 0x28 , 1 } ,
{ "dload_3" , 0x29 , 1 } ,
{ "dmul" , 0x6b , 1 } ,
{ "dneg" , 0x77 , 1 } ,
{ "drem" , 0x73 , 1 } ,
{ "dreturn" , 0xaf , 1 } ,
{ "dstore" , 0x39 , 2 } ,
{ "dstore_0" , 0x47 , 1 } ,
{ "dstore_1" , 0x48 , 1 } ,
{ "dstore_2" , 0x49 , 1 } ,
{ "dstore_3" , 0x4a , 1 } ,
{ "dsub" , 0x67 , 1 } ,
{ "dup" , 0x59 , 1 } ,
{ "dup_x1" , 0x5a , 1 } ,
{ "dup_x2" , 0x5b , 1 } ,
{ "dup2" , 0x5c , 1 } ,
{ "dup2_x1" , 0x5d , 1 } ,
{ "dup2_x2" , 0x5e , 1 } ,
{ "f2d" , 0x8d , 1 } ,
{ "f2i" , 0x8b , 1 } ,
{ "f2l" , 0x8c , 1 } ,
{ "fadd" , 0x62 , 1 } ,
{ "faload" , 0x30 , 1 } ,
{ "fastore" , 0x51 , 1 } ,
{ "fcmpg" , 0x96 , 1 } ,
{ "fcmpl" , 0x95 , 1 } ,
{ "fconst_0" , 0x0b , 1 } ,
{ "fconst_1" , 0x0c , 1 } ,
{ "fconst_2" , 0x0d , 1 } ,
{ "fdiv" , 0x6e , 1 } ,
{ "fload" , 0x17 , 2 } ,
{ "fload_0" , 0x22 , 1 } ,
{ "fload_1" , 0x23 , 1 } ,
{ "fload_2" , 0x24 , 1 } ,
{ "fload_3" , 0x25 , 1 } ,
{ "fmul" , 0x6a , 1 } ,
{ "fneg" , 0x76 , 1 } ,
{ "frem" , 0x72 , 1 } ,
{ "freturn" , 0xae , 1 } ,
{ "fstore" , 0x38 , 2 } ,
{ "fstore_0" , 0x43 , 1 } ,
{ "fstore_1" , 0x44 , 1 } ,
{ "fstore_2" , 0x45 , 1 } ,
{ "fstore_3" , 0x46 , 1 } ,
{ "fsub" , 0x66 , 1 } ,
{ "getfield" , 0xb4 , 3 } ,
{ "getstatic" , 0xb2 , 3 } ,
{ "goto" , 0xa7 , 3 } ,
{ "goto_w" , 0xc8 , 5 } ,
{ "i2b" , 0x91 , 1 } ,
{ "i2c" , 0x92 , 1 } ,
{ "i2d" , 0x87 , 1 } ,
{ "i2f" , 0x86 , 1 } ,
{ "i2l" , 0x85 , 1 } ,
{ "i2s" , 0x93 , 1 } ,
{ "iadd" , 0x60 , 1 } ,
{ "iaload" , 0x2e , 1 } ,
{ "iand" , 0x7e , 1 } ,
{ "iastore" , 0x4f , 1 } ,
{ "iconst_m1" , 0x02 , 1 } ,
{ "iconst_0" , 0x03 , 1 } ,
{ "iconst_1" , 0x04 , 1 } ,
{ "iconst_2" , 0x05 , 1 } ,
{ "iconst_3" , 0x06 , 1 } ,
{ "iconst_4" , 0x07 , 1 } ,
{ "iconst_5" , 0x08 , 1 } ,
{ "idiv" , 0x6c , 1 } ,
{ "if_acmpeq" , 0xa5 , 3 } ,
{ "if_acmpne" , 0xa6 , 3 } ,
{ "if_icmpeq" , 0x9f , 3 } ,
{ "if_icmpne" , 0xa0 , 3 } ,
{ "if_icmplt" , 0xa1 , 3 } ,
{ "if_icmpge" , 0xa2 , 3 } ,
{ "if_icmpgt" , 0xa3 , 3 } ,
{ "if_icmple" , 0xa4 , 3 } ,
{ "ifeq" , 0x99 , 3 } ,
{ "ifne" , 0x9a , 3 } ,
{ "iflt" , 0x9b , 3 } ,
{ "ifge" , 0x9c , 3 } ,
{ "ifgt" , 0x9d , 3 } ,
{ "ifle" , 0x9e , 3 } ,
{ "ifnonnull" , 0xc7 , 3 } ,
{ "ifnull" , 0xc6 , 3 } ,
{ "iinc" , 0x84 , 3 } ,
{ "iload" , 0x15 , 2 } ,
{ "iload_0" , 0x1a , 1 } ,
{ "iload_1" , 0x1b , 1 } ,
{ "iload_2" , 0x1c , 1 } ,
{ "iload_3" , 0x1d , 1 } ,
{ "imul" , 0x68 , 1 } ,
{ "ineg" , 0x74 , 1 } ,
{ "instanceof" , 0xc1 , 3 } ,
{ "invokevirtual" , 0xb6 , 3 } ,
{ "invokespecial" , 0xb7 , 3 } ,
{ "invokestatic" , 0xb8 , 3 } ,
{ "invokeinterface" , 0xb9 , 5 } ,
{ "ior" , 0x80 , 1 } ,
{ "irem" , 0x70 , 1 } ,
{ "ireturn" , 0xac , 1 } ,
{ "ishl" , 0x78 , 1 } ,
{ "ishr" , 0x7a , 1 } ,
{ "istore" , 0x36 , 2 } ,
{ "istore_0" , 0x3b , 1 } ,
{ "istore_1" , 0x3c , 1 } ,
{ "istore_2" , 0x3d , 1 } ,
{ "istore_3" , 0x3e , 1 } ,
{ "isub" , 0x64 , 1 } ,
{ "iushr" , 0x7c , 1 } ,
{ "ixor" , 0x82 , 1 } ,
{ "lxor" , 0x83 , 1 } ,
{ "jsr" , 0xa8 , 3 } ,
{ "jsr_w" , 0xc9 , 5 } ,
{ "l2d" , 0x8a , 1 } ,
{ "l2f" , 0x89 , 1 } ,
{ "l2i" , 0x88 , 1 } ,
{ "ladd" , 0x61 , 1 } ,
{ "laload" , 0x2f , 1 } ,
{ "land" , 0x7f , 1 } ,
{ "lastore" , 0x50 , 1 } ,
{ "lcmp" , 0x94 , 1 } ,
{ "lconst_0" , 0x09 , 1 } ,
{ "lconst_1" , 0x0a , 1 } ,
{ "ldc" , 0x12 , 2 } ,
{ "ldc_w" , 0x13 , 3 } ,
{ "ldc2_w" , 0x14 , 3 } ,
{ "ldiv" , 0x6d , 1 } ,
{ "lload" , 0x16 , 2 } ,
{ "lload_0" , 0x1e , 1 } ,
{ "lload_1" , 0x1f , 1 } ,
{ "lload_2" , 0x20 , 1 } ,
{ "lload_3" , 0x21 , 1 } ,
{ "lmul" , 0x69 , 1 } ,
{ "lneg" , 0x75 , 1 } ,
{ "lookupswitch" , 0xab , 3 } , // XXX broken opcode
{ "lor" , 0x81 , 1 } ,
{ "lrem" , 0x71 , 1 } ,
{ "lreturn" , 0xad , 1 } ,
{ "lshl" , 0x79 , 1 } ,
{ "lshr" , 0x7b , 1 } ,
{ "lstore" , 0x37 , 2 } ,
{ "lstore_0" , 0x3f , 1 } ,
{ "lstore_1" , 0x40 , 1 } ,
{ "lstore_2" , 0x41 , 1 } ,
{ "lstore_3" , 0x42 , 1 } ,
{ "lsub" , 0x65 , 1 } ,
{ "lushr" , 0x7d , 1 } ,
{ "lxor" , 0x83 , 1 } ,
{ "monitorenter" , 0xc2 , 1 } ,
{ "monitorexit" , 0xc3 , 1 } ,
{ "multinewarray" , 0xc5 , 3 } , // XXX broken opcode ?
{ "new" , 0xbb , 3 } ,
{ "newarray" , 0xbc , 2 } ,
{ "nop" , 0x00 , 1 } ,
{ "pop" , 0x57 , 1 } ,
{ "pop2" , 0x58 , 1 } ,
{ "putfield" , 0xb5 , 3 } ,
{ "putstatic" , 0xb3 , 3 } ,
{ "ret" , 0xa9 , 2 } ,
{ "return" , 0xb1 , 1 } ,
{ "saload" , 0x35 , 1 } ,
{ "sastore" , 0x36 , 1 } ,
{ "sipush" , 0x11 , 3 } ,
{ "swap" , 0x5f , 1 } ,
{ "tableswitch" , 0xaa , 3 } , // broken opcode
{ "wide" , 0xc4 , 1 } , // broken opcode - variable length
{ "breakpoint" , 0xca , 1 } ,
{ "impdep1" , 0xfe , 1 } ,
{ "impdep2" , 0xff , 1 } ,
{ "unused" , 0xba , 1 } ,
{ NULL, 0x0, 0 }
};

View File

@ -53,217 +53,6 @@ static struct constant_t {
{ NULL, 0, 0 }
};
static struct java_op {
char *name;
unsigned char byte;
int size;
} java_ops[] = {
{ "aconst_null" , 0x01 , 1 } ,
{ "aload" , 0x19 , 2 } ,
{ "aload_0" , 0x2a , 1 } ,
{ "aload_1" , 0x2b , 1 } ,
{ "aload_2" , 0x2c , 1 } ,
{ "aload_3" , 0x2d , 1 } ,
{ "areturn" , 0xb0 , 1 } ,
{ "arraylength" , 0xbe , 1 } ,
{ "astore" , 0x3a , 2 } ,
{ "astore_0" , 0x4b , 1 } ,
{ "astore_1" , 0x4c , 1 } ,
{ "astore_2" , 0x4d , 1 } ,
{ "astore_3" , 0x4e , 1 } ,
{ "athrow" , 0xbf , 1 } ,
{ "baload" , 0x33 , 1 } ,
{ "bastore" , 0x54 , 1 } ,
{ "bipush" , 0x10 , 2 } ,
{ "caload" , 0x34 , 1 } ,
{ "castore" , 0x55 , 1 } ,
{ "checkcast" , 0xc0 , 3 } ,
{ "d2f" , 0x90 , 1 } ,
{ "d2i" , 0x8e , 1 } ,
{ "d2l" , 0x8f , 1 } ,
{ "dadd" , 0x63 , 1 } ,
{ "daload" , 0x31 , 1 } ,
{ "dastore" , 0x52 , 1 } ,
{ "dcmpg" , 0x98 , 1 } ,
{ "dcmpl" , 0x97 , 1 } ,
{ "dconst_0" , 0x0e , 1 } ,
{ "dconst_1" , 0x0f , 1 } ,
{ "ddiv" , 0x6f , 1 } ,
{ "dload" , 0x18 , 2 } ,
{ "dload_0" , 0x26 , 1 } ,
{ "dload_1" , 0x27 , 1 } ,
{ "dload_2" , 0x28 , 1 } ,
{ "dload_3" , 0x29 , 1 } ,
{ "dmul" , 0x6b , 1 } ,
{ "dneg" , 0x77 , 1 } ,
{ "drem" , 0x73 , 1 } ,
{ "dreturn" , 0xaf , 1 } ,
{ "dstore" , 0x39 , 2 } ,
{ "dstore_0" , 0x47 , 1 } ,
{ "dstore_1" , 0x48 , 1 } ,
{ "dstore_2" , 0x49 , 1 } ,
{ "dstore_3" , 0x4a , 1 } ,
{ "dsub" , 0x67 , 1 } ,
{ "dup" , 0x59 , 1 } ,
{ "dup_x1" , 0x5a , 1 } ,
{ "dup_x2" , 0x5b , 1 } ,
{ "dup2" , 0x5c , 1 } ,
{ "dup2_x1" , 0x5d , 1 } ,
{ "dup2_x2" , 0x5e , 1 } ,
{ "f2d" , 0x8d , 1 } ,
{ "f2i" , 0x8b , 1 } ,
{ "f2l" , 0x8c , 1 } ,
{ "fadd" , 0x62 , 1 } ,
{ "faload" , 0x30 , 1 } ,
{ "fastore" , 0x51 , 1 } ,
{ "fcmpg" , 0x96 , 1 } ,
{ "fcmpl" , 0x95 , 1 } ,
{ "fconst_0" , 0x0b , 1 } ,
{ "fconst_1" , 0x0c , 1 } ,
{ "fconst_2" , 0x0d , 1 } ,
{ "fdiv" , 0x6e , 1 } ,
{ "fload" , 0x17 , 2 } ,
{ "fload_0" , 0x22 , 1 } ,
{ "fload_1" , 0x23 , 1 } ,
{ "fload_2" , 0x24 , 1 } ,
{ "fload_3" , 0x25 , 1 } ,
{ "fmul" , 0x6a , 1 } ,
{ "fneg" , 0x76 , 1 } ,
{ "frem" , 0x72 , 1 } ,
{ "freturn" , 0xae , 1 } ,
{ "fstore" , 0x38 , 2 } ,
{ "fstore_0" , 0x43 , 1 } ,
{ "fstore_1" , 0x44 , 1 } ,
{ "fstore_2" , 0x45 , 1 } ,
{ "fstore_3" , 0x46 , 1 } ,
{ "fsub" , 0x66 , 1 } ,
{ "getfield" , 0xb4 , 3 } ,
{ "getstatic" , 0xb2 , 3 } ,
{ "goto" , 0xa7 , 3 } ,
{ "goto_w" , 0xc8 , 5 } ,
{ "i2b" , 0x91 , 1 } ,
{ "i2c" , 0x92 , 1 } ,
{ "i2d" , 0x87 , 1 } ,
{ "i2f" , 0x86 , 1 } ,
{ "i2l" , 0x85 , 1 } ,
{ "i2s" , 0x93 , 1 } ,
{ "iadd" , 0x60 , 1 } ,
{ "iaload" , 0x2e , 1 } ,
{ "iand" , 0x7e , 1 } ,
{ "iastore" , 0x4f , 1 } ,
{ "iconst_m1" , 0x02 , 1 } ,
{ "iconst_0" , 0x03 , 1 } ,
{ "iconst_1" , 0x04 , 1 } ,
{ "iconst_2" , 0x05 , 1 } ,
{ "iconst_3" , 0x06 , 1 } ,
{ "iconst_4" , 0x07 , 1 } ,
{ "iconst_5" , 0x08 , 1 } ,
{ "idiv" , 0x6c , 1 } ,
{ "if_acmpeq" , 0xa5 , 3 } ,
{ "if_acmpne" , 0xa6 , 3 } ,
{ "if_icmpeq" , 0x9f , 3 } ,
{ "if_icmpne" , 0xa0 , 3 } ,
{ "if_icmplt" , 0xa1 , 3 } ,
{ "if_icmpge" , 0xa2 , 3 } ,
{ "if_icmpgt" , 0xa3 , 3 } ,
{ "if_icmple" , 0xa4 , 3 } ,
{ "ifeq" , 0x99 , 3 } ,
{ "ifne" , 0x9a , 3 } ,
{ "iflt" , 0x9b , 3 } ,
{ "ifge" , 0x9c , 3 } ,
{ "ifgt" , 0x9d , 3 } ,
{ "ifle" , 0x9e , 3 } ,
{ "ifnonnull" , 0xc7 , 3 } ,
{ "ifnull" , 0xc6 , 3 } ,
{ "iinc" , 0x84 , 3 } ,
{ "iload" , 0x15 , 2 } ,
{ "iload_0" , 0x1a , 1 } ,
{ "iload_1" , 0x1b , 1 } ,
{ "iload_2" , 0x1c , 1 } ,
{ "iload_3" , 0x1d , 1 } ,
{ "imul" , 0x68 , 1 } ,
{ "ineg" , 0x74 , 1 } ,
{ "instanceof" , 0xc1 , 3 } ,
{ "invokevirtual" , 0xb6 , 3 } ,
{ "invokespecial" , 0xb7 , 3 } ,
{ "invokestatic" , 0xb8 , 3 } ,
{ "invokeinterface" , 0xb9 , 5 } ,
{ "ior" , 0x80 , 1 } ,
{ "irem" , 0x70 , 1 } ,
{ "ireturn" , 0xac , 1 } ,
{ "ishl" , 0x78 , 1 } ,
{ "ishr" , 0x7a , 1 } ,
{ "istore" , 0x36 , 2 } ,
{ "istore_0" , 0x3b , 1 } ,
{ "istore_1" , 0x3c , 1 } ,
{ "istore_2" , 0x3d , 1 } ,
{ "istore_3" , 0x3e , 1 } ,
{ "isub" , 0x64 , 1 } ,
{ "iushr" , 0x7c , 1 } ,
{ "ixor" , 0x82 , 1 } ,
{ "lxor" , 0x83 , 1 } ,
{ "jsr" , 0xa8 , 3 } ,
{ "jsr_w" , 0xc9 , 5 } ,
{ "l2d" , 0x8a , 1 } ,
{ "l2f" , 0x89 , 1 } ,
{ "l2i" , 0x88 , 1 } ,
{ "ladd" , 0x61 , 1 } ,
{ "laload" , 0x2f , 1 } ,
{ "land" , 0x7f , 1 } ,
{ "lastore" , 0x50 , 1 } ,
{ "lcmp" , 0x94 , 1 } ,
{ "lconst_0" , 0x09 , 1 } ,
{ "lconst_1" , 0x0a , 1 } ,
{ "ldc" , 0x12 , 2 } ,
{ "ldc_w" , 0x13 , 3 } ,
{ "ldc2_w" , 0x14 , 3 } ,
{ "ldiv" , 0x6d , 1 } ,
{ "lload" , 0x16 , 2 } ,
{ "lload_0" , 0x1e , 1 } ,
{ "lload_1" , 0x1f , 1 } ,
{ "lload_2" , 0x20 , 1 } ,
{ "lload_3" , 0x21 , 1 } ,
{ "lmul" , 0x69 , 1 } ,
{ "lneg" , 0x75 , 1 } ,
{ "lookupswitch" , 0xab , 3 } , // XXX broken opcode
{ "lor" , 0x81 , 1 } ,
{ "lrem" , 0x71 , 1 } ,
{ "lreturn" , 0xad , 1 } ,
{ "lshl" , 0x79 , 1 } ,
{ "lshr" , 0x7b , 1 } ,
{ "lstore" , 0x37 , 2 } ,
{ "lstore_0" , 0x3f , 1 } ,
{ "lstore_1" , 0x40 , 1 } ,
{ "lstore_2" , 0x41 , 1 } ,
{ "lstore_3" , 0x42 , 1 } ,
{ "lsub" , 0x65 , 1 } ,
{ "lushr" , 0x7d , 1 } ,
{ "lxor" , 0x83 , 1 } ,
{ "monitorenter" , 0xc2 , 1 } ,
{ "monitorexit" , 0xc3 , 1 } ,
{ "multinewarray" , 0xc5 , 3 } , // XXX broken opcode ?
{ "new" , 0xbb , 3 } ,
{ "newarray" , 0xbc , 2 } ,
{ "nop" , 0x00 , 1 } ,
{ "pop" , 0x57 , 1 } ,
{ "pop2" , 0x58 , 1 } ,
{ "putfield" , 0xb5 , 3 } ,
{ "putstatic" , 0xb3 , 3 } ,
{ "ret" , 0xa9 , 2 } ,
{ "return" , 0xb1 , 1 } ,
{ "saload" , 0x35 , 1 } ,
{ "sastore" , 0x36 , 1 } ,
{ "sipush" , 0x11 , 3 } ,
{ "swap" , 0x5f , 1 } ,
{ "tableswitch" , 0xaa , 3 } , // broken opcode
{ "wide" , 0xc4 , 1 } , // broken opcode - variable length
{ "breakpoint" , 0xca , 1 } ,
{ "impdep1" , 0xfe , 1 } ,
{ "impdep2" , 0xff , 1 } ,
{ "unused" , 0xba , 1 } ,
{ NULL, 0x0, 0 }
};
static struct classfile cf;
static ut16 r_ntohs (ut16 foo) {

View File

@ -25,6 +25,12 @@ struct cp_item {
ut64 off;
};
struct java_op {
char *name;
unsigned char byte;
int size;
};
extern struct java_op java_ops[];
//extern struct cp_item *cp_items;
//extern struct cp_item cp_null_item; // NOTE: must be initialized for safe use

View File

@ -1,4 +1,4 @@
/* radare - GPL3 - Copyright 2009 nibble<.ds@gmail.com> */
/* radare - GPL3 - Copyright 2009-2010 nibble<.ds@gmail.com> */
#include <r_types.h>
#include <r_util.h>
@ -8,16 +8,14 @@
#include <java/javasm/javasm.h>
static int disassemble(struct r_asm_t *a, struct r_asm_aop_t *aop, ut8 *buf, ut64 len)
{
static int disassemble(struct r_asm_t *a, struct r_asm_aop_t *aop, ut8 *buf, ut64 len) {
javasm_init();
aop->inst_len = java_disasm(buf, aop->buf_asm);
return aop->inst_len;
}
static int assemble(struct r_asm_t *a, struct r_asm_aop_t *aop, const char *buf)
{
static int assemble(struct r_asm_t *a, struct r_asm_aop_t *aop, const char *buf) {
aop->inst_len = java_assemble(aop->buf, buf);
return aop->inst_len;
}

View File

@ -1,5 +1,6 @@
OBJ_JAVA=asm_java.o
OBJ_JAVA+=../arch/java/javasm/javasm.o
OBJ_JAVA+=../arch/java/javasm/java_ops.o
STATIC_OBJ+=${OBJ_JAVA}
TARGET_JAVA=asm_java.${EXT_SO}

View File

@ -294,6 +294,7 @@ extern RAnalHandle r_anal_plugin_arm;
extern RAnalHandle r_anal_plugin_x86;
extern RAnalHandle r_anal_plugin_x86_x86im;
extern RAnalHandle r_anal_plugin_ppc;
extern RAnalHandle r_anal_plugin_java;
#endif
#endif

View File

@ -21,3 +21,9 @@ TODO
of the plugins to properly setup the environment for the script execution.
* Add support for STATIC_PLUGINS for r-Lang too
BUGS
====
dlerror(/usr/lib/radare2/lang_perl.so): libperl.so: cannot open shared object file: No such file or directory
This issue is fixed by setting LD_LIBRARY_PATH...looks like dlopen ignores rpath

View File

@ -42,7 +42,7 @@ R_API void *r_lib_dl_open(const char *libname) {
ret = DLOPEN (libname);
if (ret == NULL)
#if __UNIX__
eprintf ("dlerror: %s\n", dlerror());
eprintf ("dlerror(%s): %s\n", libname, dlerror());
#else
eprintf ("r_lib_dl_open: Cannot open '%s'\n", libname);
#endif

View File

@ -10,6 +10,7 @@ asm.x86_olly
anal.x86
anal.x86_x86im
anal.arm
anal.java
anal.csr
anal.ppc
bin.dummy

View File

@ -7,7 +7,7 @@ namespace Radare {
public int eval(string str);
public weak string get(string name);
public unowned string get(string name);
public uint64 get_i(string name);
public RConfigNode set(string name, string val);

View File

@ -9,6 +9,7 @@ public class RCore {
/* lifecycle */
public RCore();
public RCons cons;
public RConfig config;
public RAsm assembler;
public RAnal anal;