00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _CLASS_H
00022 #define _CLASS_H
00023
00024 #include "htformat.h"
00025 #include "stddata.h"
00026
00027 typedef unsigned char u1;
00028 typedef unsigned int u2;
00029 typedef unsigned long u4;
00030
00031
00032 static const u2 jACC_PUBLIC = 0x0001;
00033 static const u2 jACC_PRIVATE = 0x0002;
00034 static const u2 jACC_PROTECTED = 0x0004;
00035 static const u2 jACC_STATIC = 0x0008;
00036 static const u2 jACC_FINAL = 0x0010;
00037 static const u2 jACC_SUPER = 0x0020;
00038 static const u2 jACC_SYNCHRONIZED = 0x0020;
00039 static const u2 jACC_VOLATILE = 0x0040;
00040 static const u2 jACC_TRANSIENT = 0x0080;
00041 static const u2 jACC_NATIVE = 0x0100;
00042 static const u2 jACC_INTERFACE = 0x0200;
00043 static const u2 jACC_ABSTRACT = 0x0400;
00044 static const u2 jACC_STRICT = 0x0800;
00045 static const u2 jACC_JNM = 0x4000;
00046
00047
00048 static const u1 CONSTANT_Utf8 = 1;
00049 static const u1 CONSTANT_Integer = 3;
00050 static const u1 CONSTANT_Float = 4;
00051 static const u1 CONSTANT_Long = 5;
00052 static const u1 CONSTANT_Double = 6;
00053 static const u1 CONSTANT_Class = 7;
00054 static const u1 CONSTANT_String = 8;
00055 static const u1 CONSTANT_Fieldref = 9;
00056 static const u1 CONSTANT_Methodref = 10;
00057 static const u1 CONSTANT_InterfaceMethodref = 11;
00058 static const u1 CONSTANT_NameAndType = 12;
00059
00060 typedef struct _cp_info {
00061 u4 offset;
00062 u1 tag;
00063 union {
00064 char *string;
00065 double dval;
00066 float fval;
00067 long lval;
00068 int ival;
00069 long llval[2];
00070 } value;
00071 } cp_info;
00072
00073 static const u2 ATTRIB_ConstantValue = 1;
00074 static const u2 ATTRIB_Code = 2;
00075 static const u2 ATTRIB_Exceptions = 3;
00076 static const u2 ATTRIB_InnerClasses = 4;
00077 static const u2 ATTRIB_Synthetic = 5;
00078 static const u2 ATTRIB_SourceFile = 6;
00079 static const u2 ATTRIB_LineNumberTable = 7;
00080 static const u2 ATTRIB_LocalVariableTable = 8;
00081 static const u2 ATTRIB_Deprecated = 9;
00082
00083 typedef struct _attrib_info {
00084 u4 offset;
00085 u2 tag;
00086 u2 name;
00087 u4 len;
00088 union {
00089 struct {
00090 u2 max_stack;
00091 u2 max_locals;
00092 u4 len;
00093 u4 start;
00094 } code;
00095 };
00096 } attrib_info;
00097
00098
00099 typedef struct _mf_info {
00100 u4 offset;
00101 u2 flags;
00102 char *name;
00103 char *desc;
00104 u2 attribs_count;
00105 attrib_info **attribs;
00106 } mf_info;
00107
00108
00109 typedef struct _classfile {
00110 u4 offset;
00111 u4 magic;
00112 u2 minor_version;
00113 u2 major_version;
00114 u2 cpool_count;
00115 cp_info **cpool;
00116 u4 coffset;
00117 u2 access_flags;
00118 u2 this_class;
00119 u2 super_class;
00120 u2 interfaces_count;
00121 u2 *interfaces;
00122 u4 foffset;
00123 u2 fields_count;
00124 mf_info **fields;
00125 u4 moffset;
00126 u2 methods_count;
00127 mf_info **methods;
00128 u4 aoffset;
00129 u2 attribs_count;
00130 attrib_info **attribs;
00131 } classfile;
00132
00133 struct ht_class_shared_data {
00134 ht_stree *methods;
00135 classfile *file;
00136 Area *valid;
00137 Area *initialized;
00138 int flags;
00139 struct {
00140 char *thisclass;
00141 char *superclass;
00142 ht_list *interfaces;
00143 } classinfo;
00144 };
00145
00146 extern ht_class_shared_data *class_read(ht_streamfile *);
00147 extern void class_unread(ht_class_shared_data *);
00148 extern attrib_info *attribute_read(ht_stream *, classfile *);
00149
00150 int token_translate(char *buf, int maxlen, dword token, ht_class_shared_data *shared);
00151 void java_demangle(char *result, char *classname, char *name, char *type, int flags);
00152 char *java_demangle_flags(char *result, int flags);
00153
00154 class cview : public ht_format_group {
00155 public:
00156 void init(bounds *, ht_streamfile *, format_viewer_if **,
00157 ht_format_group *, FILEOFS, void *shared);
00158 virtual void done();
00159 };
00160
00161 #define ClassAddress dword
00162
00163 class ClassMethod: public Object {
00164 public:
00165 char *name;
00166 char *type;
00167 ClassAddress start;
00168 UINT length;
00169 int flags;
00170 ClassMethod(char *name, char *type, ClassAddress start, UINT length, int flags);
00171 virtual ~ClassMethod();
00172 virtual int compareTo(const Object *obj) const;
00173 };
00174
00175
00176 #define DESC_JAVA "java - class file"
00177 #define DESC_JAVA_HEADERS "java/headers"
00178 #define DESC_JAVA_IMAGE "java/image"
00179
00180 extern format_viewer_if htcls_if;
00181
00182 #endif
00183