00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "class.h"
00022 #include "class_analy.h"
00023 #include "classimg.h"
00024 #include "formats.h"
00025 #include "htanaly.h"
00026 #include "htpal.h"
00027 #include "log.h"
00028 #include "snprintf.h"
00029
00030 ht_view *htclassimage_init(bounds *b, ht_streamfile *file, ht_format_group *group)
00031 {
00032 ht_class_shared_data *class_shared=(ht_class_shared_data *)group->get_shared_data();
00033
00034 LOG("%s: JAVA: loading image (starting analyser)...", file->get_filename());
00035 ClassAnalyser *a = new ClassAnalyser();
00036 a->init(class_shared, file);
00037
00038 bounds c = *b;
00039 ht_group *g = new ht_group();
00040 g->init(&c, VO_RESIZE, DESC_JAVA_IMAGE"-g");
00041 AnalyInfoline *head;
00042
00043 c.y+=2;
00044 c.h-=2;
00045 ht_class_aviewer *v = new ht_class_aviewer();
00046 v->init(&c, DESC_JAVA_IMAGE, VC_EDIT | VC_GOTO | VC_SEARCH, file, group, a, class_shared);
00047
00048 c.y-=2;
00049 c.h=2;
00050 head=new AnalyInfoline();
00051 head->init(&c, v, ANALY_STATUS_DEFAULT);
00052
00053 v->attachInfoline(head);
00054
00055 ht_analy_sub *analy=new ht_analy_sub();
00056 Address *low = a->createAddress32(0);
00057
00058 Address *high = (Address*)class_shared->valid->findPrev(NULL);
00059 if (!high) {
00060 high = a->createAddress32(0);
00061 } else {
00062 high = (Address *)high->duplicate();
00063 high->add(-1);
00064 }
00065 analy->init(file, v, a, low, high);
00066 delete low;
00067 delete high;
00068 v->analy_sub = analy;
00069 v->insertsub(analy);
00070
00071 v->sendmsg(msg_complete_init, 0);
00072
00073 viewer_pos entrypoint;
00074 if (v->string_to_pos("entrypoint", &entrypoint)) {
00075 v->goto_pos(entrypoint, false);
00076 }
00077
00078 g->insert(head);
00079 g->insert(v);
00080
00081 g->setpalette(palkey_generic_window_default);
00082
00083
00084 return g;
00085 }
00086
00087 format_viewer_if htclassimage_if = {
00088 htclassimage_init,
00089 0
00090 };
00091
00092
00093
00094
00095 void ht_class_aviewer::init(bounds *b, char *desc, int caps, ht_streamfile *File, ht_format_group *format_group, Analyser *Analy, ht_class_shared_data *Class_shared)
00096 {
00097 ht_aviewer::init(b, desc, caps, File, format_group, Analy);
00098 class_shared = Class_shared;
00099 file = File;
00100 }
00101
00102 void ht_class_aviewer::setAnalyser(Analyser *a)
00103 {
00104 ((ClassAnalyser *)a)->class_shared = class_shared;
00105 ((ClassAnalyser *)a)->file = file;
00106 analy = a;
00107 analy_sub->setAnalyser(a);
00108 }
00109
00110 #if 0
00111 static ht_view *
00112 class_image(bounds *b, ht_streamfile *file, ht_format_group *group)
00113 {
00114 classfile *clazz;
00115
00116 clazz = ((ht_class_shared_data *)group->get_shared_data())->file;
00117 if (clazz) {
00118
00119 ht_uformat_viewer *v = new ht_uformat_viewer();
00120 v->init(b, DESC_JAVA_IMAGE, VC_EDIT, file, group);
00121
00122 return v;
00123 } else {
00124 return NULL;
00125 }
00126 }
00127 #endif
00128