disassembler in Java?
disassembler in Java?
Hi, after searching the google, There not much x86 disassembler written in Java.
But I found this lib is good http://bastard.sourceforge.net/libdisasm.html , It provides many information that ndisasm don't have, but It works in linux only.
But I found this lib is good http://bastard.sourceforge.net/libdisasm.html , It provides many information that ndisasm don't have, but It works in linux only.
-
- Member
- Posts: 25
- Joined: Fri Dec 04, 2009 10:08 am
Re: disassembler in Java?
Isn't it trivially obvious??? It's like using assembly to write web applications it's just funny.earlz wrote:A java disassembler? Um, why would you want such a thing?
Re: disassembler in Java?
because this http://peter-bochs.googlecode.com is written in Java
Re: disassembler in Java?
Hi Peter,
There is nothing wrong with writing a disassembler in java and you might develop it much quickly as well .But what's the utility ? What does it accomplish more than dissassemblers available presently ?If its for a pedagogic/didactic purpose , then java is a very good choice .
--Thomas
There is nothing wrong with writing a disassembler in java and you might develop it much quickly as well .But what's the utility ? What does it accomplish more than dissassemblers available presently ?If its for a pedagogic/didactic purpose , then java is a very good choice .
--Thomas
Re: disassembler in Java?
Hi Thomas
I am making peter-bochs (a bochs gui debugger) can single step trace on ELF (on c level source). Bochs build-in disassembler can only disassemble on the current location cs:eip. So I need a disassembler that can disasseble at any location.
I can do it in these way
1) capture the output from ndisasm (netwide disassembler)
2) capture the output from http://bastard.sourceforge.net/libdisasm.html
second option would be better, because it has more professional output, it can give me these informations (the following). But this library can only run on Linux
typedef struct {
/* information about the instruction */
unsigned long addr; /* load address */
unsigned long offset; /* offset into file/buffer */
enum x86_insn_group group; /* meta-type, e.g. INS_EXEC */
enum x86_insn_type type; /* type, e.g. INS_BRANCH */
enum x86_insn_note note; /* note, e.g. RING0 */
unsigned char bytes[MAX_INSN_SIZE];
unsigned char size; /* size of insn in bytes */
/* 16/32-bit mode settings */
unsigned char addr_size; /* default address size : 2 or 4 */
unsigned char op_size; /* default operand size : 2 or 4 */
/* CPU/instruction set */
enum x86_insn_cpu cpu;
enum x86_insn_isa isa;
/* flags */
enum x86_flag_status flags_set; /* flags set or tested by insn */
enum x86_flag_status flags_tested;
/* stack */
unsigned char stack_mod; /* 0 or 1 : is the stack modified? */
long stack_mod_val; /* val stack is modified by if known */
/* the instruction proper */
enum x86_insn_prefix prefix; /* prefixes ORed together */
char prefix_string[MAX_PREFIX_STR]; /* prefixes [might be truncated] */
char mnemonic[MAX_MNEM_STR];
x86_oplist_t *operands; /* list of explicit/implicit operands */
size_t operand_count; /* total number of operands */
size_t explicit_count; /* number of explicit operands */
} x86_insn_t;
I am making peter-bochs (a bochs gui debugger) can single step trace on ELF (on c level source). Bochs build-in disassembler can only disassemble on the current location cs:eip. So I need a disassembler that can disasseble at any location.
I can do it in these way
1) capture the output from ndisasm (netwide disassembler)
2) capture the output from http://bastard.sourceforge.net/libdisasm.html
second option would be better, because it has more professional output, it can give me these informations (the following). But this library can only run on Linux
typedef struct {
/* information about the instruction */
unsigned long addr; /* load address */
unsigned long offset; /* offset into file/buffer */
enum x86_insn_group group; /* meta-type, e.g. INS_EXEC */
enum x86_insn_type type; /* type, e.g. INS_BRANCH */
enum x86_insn_note note; /* note, e.g. RING0 */
unsigned char bytes[MAX_INSN_SIZE];
unsigned char size; /* size of insn in bytes */
/* 16/32-bit mode settings */
unsigned char addr_size; /* default address size : 2 or 4 */
unsigned char op_size; /* default operand size : 2 or 4 */
/* CPU/instruction set */
enum x86_insn_cpu cpu;
enum x86_insn_isa isa;
/* flags */
enum x86_flag_status flags_set; /* flags set or tested by insn */
enum x86_flag_status flags_tested;
/* stack */
unsigned char stack_mod; /* 0 or 1 : is the stack modified? */
long stack_mod_val; /* val stack is modified by if known */
/* the instruction proper */
enum x86_insn_prefix prefix; /* prefixes ORed together */
char prefix_string[MAX_PREFIX_STR]; /* prefixes [might be truncated] */
char mnemonic[MAX_MNEM_STR];
x86_oplist_t *operands; /* list of explicit/implicit operands */
size_t operand_count; /* total number of operands */
size_t explicit_count; /* number of explicit operands */
} x86_insn_t;
Re: disassembler in Java?
Hi Peter ,
I really do not understand why a dissaembler library would be too dependent on operating system ( It can be on the CPU ) . It should'nt be too difficult to port . C# has Platform Invoke which will help you invoke platfrom specific function calls. I am very confident that java also will have something similar . ( Yes it does !JNI ). You can possibly write wrapper calls to the library and use the library as such .
-- Thomas
I really do not understand why a dissaembler library would be too dependent on operating system ( It can be on the CPU ) . It should'nt be too difficult to port . C# has Platform Invoke which will help you invoke platfrom specific function calls. I am very confident that java also will have something similar . ( Yes it does !JNI ). You can possibly write wrapper calls to the library and use the library as such .
-- Thomas
Re: disassembler in Java?
Hi, I think I use ndisasm.exe at this stage. don't want to spend too much time to port the library to windows. Hope somebody will do it
Also, I really scare ELF format now.
Also, I really scare ELF format now.
Re: disassembler in Java?
You are probably kiddingmcheung63 wrote:Hi Thomas
I am making peter-bochs (a bochs gui debugger) can single step trace on ELF (on c level source). Bochs build-in disassembler can only disassemble on the current location cs:eip. So I need a disassembler that can disasseble at any location.
build-in Bochs disassembler is stateless module and don't know anything about "current" CS or "current" EIP.
The disasm command is:
Code: Select all
unsigned disasm(bx_bool is_32, bx_bool is_64, bx_address base, bx_address ip, const Bit8u *instr, char *disbuf);
Stanislav
- AndrewAPrice
- Member
- Posts: 2303
- Joined: Mon Jun 05, 2006 11:00 pm
- Location: USA (and Australia)
Re: disassembler in Java?
http://www.viksoe.dk/code/asmil.htmmonkeykoder wrote:Isn't it trivially obvious??? It's like using assembly to write web applications it's just funny.
Need I comment.
My OS is Perception.
Re: disassembler in Java?
Try libudis86. I ported it for my OS - it has no linux dependencies at all.mcheung63 wrote:Hi Thomas
I am making peter-bochs (a bochs gui debugger) can single step trace on ELF (on c level source). Bochs build-in disassembler can only disassemble on the current location cs:eip. So I need a disassembler that can disasseble at any location.
I can do it in these way
1) capture the output from ndisasm (netwide disassembler)
2) capture the output from http://bastard.sourceforge.net/libdisasm.html
second option would be better, because it has more professional output, it can give me these informations (the following). But this library can only run on Linux
typedef struct {
/* information about the instruction */
unsigned long addr; /* load address */
unsigned long offset; /* offset into file/buffer */
enum x86_insn_group group; /* meta-type, e.g. INS_EXEC */
enum x86_insn_type type; /* type, e.g. INS_BRANCH */
enum x86_insn_note note; /* note, e.g. RING0 */
unsigned char bytes[MAX_INSN_SIZE];
unsigned char size; /* size of insn in bytes */
/* 16/32-bit mode settings */
unsigned char addr_size; /* default address size : 2 or 4 */
unsigned char op_size; /* default operand size : 2 or 4 */
/* CPU/instruction set */
enum x86_insn_cpu cpu;
enum x86_insn_isa isa;
/* flags */
enum x86_flag_status flags_set; /* flags set or tested by insn */
enum x86_flag_status flags_tested;
/* stack */
unsigned char stack_mod; /* 0 or 1 : is the stack modified? */
long stack_mod_val; /* val stack is modified by if known */
/* the instruction proper */
enum x86_insn_prefix prefix; /* prefixes ORed together */
char prefix_string[MAX_PREFIX_STR]; /* prefixes [might be truncated] */
char mnemonic[MAX_MNEM_STR];
x86_oplist_t *operands; /* list of explicit/implicit operands */
size_t operand_count; /* total number of operands */
size_t explicit_count; /* number of explicit operands */
} x86_insn_t;
Re: disassembler in Java?
thanks james
hi stlw, yeah , I wasted a day
hi stlw, yeah , I wasted a day