Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

javadis.h

Go to the documentation of this file.
00001 /* 
00002  *      HT Editor
00003  *      javadis.h
00004  *
00005  *      Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de)
00006  *
00007  *      This program is free software; you can redistribute it and/or modify
00008  *      it under the terms of the GNU General Public License version 2 as
00009  *      published by the Free Software Foundation.
00010  *
00011  *      This program is distributed in the hope that it will be useful,
00012  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *      GNU General Public License for more details.
00015  *
00016  *      You should have received a copy of the GNU General Public License
00017  *      along with this program; if not, write to the Free Software
00018  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 #ifndef __JAVADIS_H__
00022 #define __JAVADIS_H__
00023 
00024 #include "asm.h"
00025 #include "javaopc.h"
00026 
00027 /* x86-specific styles */
00028 //#define X86DIS_STYLE_EXPLICIT_MEMSIZE 0x00000001              /* IF SET: mov word ptr [0000], ax      ELSE: mov [0000], ax */
00029 //#define X86DIS_STYLE_OPTIMIZE_ADDR            0x00000002              /* IF SET: mov [eax*3], ax                      ELSE: mov [eax+eax*2+00000000], ax */
00030 /*#define X86DIS_STYLE_USE16                    0x00000004
00031 #define X86DIS_STYLE_USE32                      0x00000008*/
00032 
00033 #define JAVAINSN_MAX_PARAM_COUNT        2
00034 
00035 struct javadis_insn {
00036         bool invalid;
00037         byte size;
00038         int opcode;
00039         bool wideopcode;
00040         char *name;
00041         java_insn_op op[JAVAINSN_MAX_PARAM_COUNT];
00042 };
00043 
00044 /*
00045  *      CLASS x86dis
00046  */
00047 
00048 typedef int (*java_token_func)(char *result, int maxlen, dword token, void *context);
00049 
00050 class javadis: public Disassembler {
00051 protected:
00052         javadis_insn insn;
00053         char insnstr[1024];
00054 /* initme! */
00055         unsigned char *codep, *ocodep;
00056         int addr;
00057         int maxlen;
00058         java_token_func token_func;
00059         void *context;
00060 /* new */
00061                         void decode_insn(javaopc_insn *insn);
00062                         void decode_op(int optype, bool wideopc, java_insn_op *op);
00063                         byte getbyte();
00064                         word getword();
00065                         dword getdword();
00066                         void invalidate();
00067                         void str_format(char **str, char **format, char *p, char *n, char *op[3], int oplen[3], char stopchar, int print);
00068         virtual void str_op(char *opstr, int *opstrlen, javadis_insn *insn, java_insn_op *op);
00069 public:
00070         javadis();
00071         javadis(java_token_func token_func, void *context);
00072         virtual ~javadis();
00073 
00074 /* overwritten */
00075         virtual dis_insn *decode(byte *code, int maxlen, CPU_ADDR addr);
00076         virtual dis_insn *duplicateInsn(dis_insn *disasm_insn);
00077         virtual void getOpcodeMetrics(int &min_length, int &max_length, int &min_look_ahead, int &avg_look_ahead, int &addr_align);
00078         virtual char *getName();
00079         virtual byte getSize(dis_insn *disasm_insn);
00080                    int load(ht_object_stream *f);
00081         virtual OBJECT_ID object_id() const;
00082         virtual char *str(dis_insn *disasm_insn, int options);
00083         virtual char *strf(dis_insn *disasm_insn, int options, char *format);
00084         virtual void store(ht_object_stream *f);
00085         virtual bool validInsn(dis_insn *disasm_insn);
00086 };
00087 
00088 #endif /* __JAVADIS_H__ */
00089 

Generated on Fri May 7 21:15:40 2004 by doxygen 1.3.5