2014-02-25 17:03:12 +01:00
|
|
|
/* radare - LGPL - Copyright 2009-2014 - nibble, pancake */
|
2009-03-05 16:58:13 +01:00
|
|
|
|
|
|
|
#include <r_types.h>
|
|
|
|
#include <r_util.h>
|
|
|
|
#include <r_lib.h>
|
|
|
|
#include <r_asm.h>
|
2010-06-29 15:47:30 +02:00
|
|
|
#include <r_core.h>
|
2012-11-16 01:34:26 +01:00
|
|
|
|
2014-06-25 04:11:43 +02:00
|
|
|
#include "../../shlr/java/code.h"
|
|
|
|
#include "../../shlr/java/class.h"
|
2014-03-18 02:37:38 +01:00
|
|
|
|
2013-04-09 22:54:04 +02:00
|
|
|
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
|
2013-02-26 01:37:42 +01:00
|
|
|
//void *cp;
|
2012-12-20 11:31:38 +01:00
|
|
|
RBinJavaObj *obj = NULL;
|
2014-05-08 18:35:04 -05:00
|
|
|
RBin *bin = a->binb.bin;
|
2014-09-30 23:37:20 +02:00
|
|
|
RBinPlugin *plugin = bin && bin->cur && bin->cur->o ?
|
|
|
|
bin->cur->o->plugin : NULL;
|
2014-05-08 18:35:04 -05:00
|
|
|
if (plugin) {
|
|
|
|
if (!strcmp (plugin->name, "java")) { // XXX slow
|
|
|
|
obj = bin->cur->o->bin_obj; //o;
|
2014-01-09 16:57:04 -06:00
|
|
|
//eprintf("Handling: %s disasm.\n", b->cur.file);
|
2013-02-20 02:24:37 +01:00
|
|
|
}
|
2012-12-20 11:31:38 +01:00
|
|
|
}
|
2014-04-01 16:22:29 -05:00
|
|
|
|
2016-04-10 01:23:18 +02:00
|
|
|
op->size = r_java_disasm (obj, a->pc, buf, len,
|
2012-12-20 11:31:38 +01:00
|
|
|
op->buf_asm, sizeof (op->buf_asm));
|
2015-07-12 19:52:29 +02:00
|
|
|
return op->size;
|
2009-03-05 16:58:13 +01:00
|
|
|
}
|
|
|
|
|
2011-02-24 16:50:29 +01:00
|
|
|
static int assemble(RAsm *a, RAsmOp *op, const char *buf) {
|
2012-11-16 02:29:30 +01:00
|
|
|
// TODO: get class info from bin if possible
|
2013-12-06 05:04:17 +01:00
|
|
|
return op->size = r_java_assemble (op->buf, buf);
|
2009-03-05 16:58:13 +01:00
|
|
|
}
|
|
|
|
|
2010-05-26 01:42:22 +02:00
|
|
|
RAsmPlugin r_asm_plugin_java = {
|
2009-09-24 12:29:05 +02:00
|
|
|
.name = "java",
|
2014-02-25 17:03:12 +01:00
|
|
|
.desc = "Java bytecode",
|
2009-04-11 21:22:20 +00:00
|
|
|
.arch = "java",
|
2013-12-19 23:10:16 -06:00
|
|
|
.license = "Apache",
|
2013-12-05 18:41:13 +01:00
|
|
|
.bits = 32,
|
2016-04-26 19:09:15 +10:00
|
|
|
.endian = R_SYS_ENDIAN_BIG,
|
2009-03-05 16:58:13 +01:00
|
|
|
.disassemble = &disassemble,
|
|
|
|
.assemble = &assemble
|
|
|
|
};
|
|
|
|
|
2009-03-08 23:49:15 +00:00
|
|
|
#ifndef CORELIB
|
2009-03-05 16:58:13 +01:00
|
|
|
struct r_lib_struct_t radare_plugin = {
|
|
|
|
.type = R_LIB_TYPE_ASM,
|
2015-07-12 16:04:10 +02:00
|
|
|
.data = &r_asm_plugin_java,
|
|
|
|
.version = R2_VERSION
|
2009-03-05 16:58:13 +01:00
|
|
|
};
|
2009-03-08 23:49:15 +00:00
|
|
|
#endif
|