radare2/libr/asm/p/asm_java.c
pancake 6e1653881d * Load constant pool from RCore in RAsm
- this is a compiletime module dependency
  - java needs to share constantpool between anal, asm and bin
* Added compile-time introspection POC macros in r_types.h.h
2010-06-29 15:47:30 +02:00

43 lines
1.0 KiB
C

/* radare - GPL3 - Copyright 2009-2010 nibble<.ds@gmail.com> */
#include <r_types.h>
#include <r_util.h>
#include <r_lib.h>
#include <r_asm.h>
#include <java/javasm/javasm.h>
#include <r_core.h>
static const char *lastfile = NULL;
static int disassemble(RAsm *a, RAsmAop *aop, ut8 *buf, ut64 len) {
// XXX: crossmodule dependency
RCore *core = (RCore*)a->user;
if (core && core->file && lastfile != core->file->filename) {
lastfile = core->file->filename;
java_classdump (lastfile, 0);
} else javasm_init ();
return aop->inst_len = java_disasm (buf, aop->buf_asm);
}
static int assemble(RAsm *a, RAsmAop *aop, const char *buf) {
return aop->inst_len = java_assemble (aop->buf, buf);
}
RAsmPlugin r_asm_plugin_java = {
.name = "java",
.desc = "Java CLASS assembler/disassembler",
.arch = "java",
.bits = (int[]){ 8, 0 },
.init = NULL,
.fini = NULL,
.disassemble = &disassemble,
.assemble = &assemble
};
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
.type = R_LIB_TYPE_ASM,
.data = &r_asm_plugin_java
};
#endif