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

htfltimg.cc

Go to the documentation of this file.
00001 /*
00002  *      HT Editor
00003  *      htfltimg.cc
00004  *
00005  *      Copyright (C) 2003 Sebastian Biallas (sb@biallas.net)
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 #include "log.h"
00022 #include "htfltimg.h"
00023 #include "htpal.h"
00024 #include "htstring.h"
00025 #include "formats.h"
00026 #include "snprintf.h"
00027 #include "tools.h"
00028 
00029 #include "fltstruc.h"
00030 #include "flt_analy.h"
00031 
00032 static ht_view *htfltimage_init(bounds *b, ht_streamfile *file, ht_format_group *group)
00033 {
00034         ht_flt_shared_data *flt_shared=(ht_flt_shared_data *)group->get_shared_data();
00035 
00036         LOG("%s: FLAT: loading image (starting analyser)...", file->get_filename());
00037         FLTAnalyser *p = new FLTAnalyser();
00038         p->init(flt_shared, file);
00039 
00040         bounds c=*b;
00041         ht_group *g=new ht_group();
00042         g->init(&c, VO_RESIZE, DESC_FLT_IMAGE"-g");
00043         AnalyInfoline *head;
00044 
00045         c.y+=2;
00046         c.h-=2;
00047         ht_flt_aviewer *v=new ht_flt_aviewer();
00048         v->init(&c, DESC_FLT_IMAGE, VC_EDIT | VC_GOTO | VC_SEARCH, file, group, p, flt_shared);
00049 
00050         c.y-=2;
00051         c.h=2;
00052         head=new AnalyInfoline();
00053         head->init(&c, v, ANALY_STATUS_DEFAULT);
00054 
00055         v->attachInfoline(head);
00056 
00057         /* find lowest/highest address */
00058         Address *low;
00059         Address *high;
00060 
00061         low = p->createAddress32(flt_shared->code_start);
00062         high = p->createAddress32(flt_shared->bss_end-1);
00063 
00064         ht_analy_sub *analy=new ht_analy_sub();
00065 
00066         if (low->compareTo(high) < 0) {
00067                 analy->init(file, v, p, low, high);
00068                 v->analy_sub = analy;
00069                 v->insertsub(analy);
00070         } else {
00071                 delete analy;
00072                 v->done();
00073                 delete v;
00074                 head->done();          
00075                 delete head;
00076                 g->done();
00077                 delete g;
00078                 delete high;
00079                 delete low;
00080                 return NULL;
00081         }
00082         
00083         delete high;
00084         delete low;
00085 
00086         v->sendmsg(msg_complete_init, 0);
00087 
00088         Address *tmpaddr = p->createAddress32(flt_shared->header.entry);        
00089         v->gotoAddress(tmpaddr, NULL);
00090         delete tmpaddr;
00091 
00092         g->insert(head);
00093         g->insert(v);
00094 
00095         g->setpalette(palkey_generic_window_default);
00096 
00097 //      macho_shared->v_image=v;
00098         return g;
00099 }
00100 
00101 format_viewer_if htfltimage_if = {
00102         htfltimage_init,
00103         0
00104 };
00105 
00106 /*
00107  *      CLASS ht_flt_aviewer
00108  */
00109 void ht_flt_aviewer::init(bounds *b, char *desc, int caps, ht_streamfile *File, ht_format_group *format_group, Analyser *Analy, ht_flt_shared_data *FLT_shared)
00110 {
00111         ht_aviewer::init(b, desc, caps, File, format_group, Analy);
00112         flt_shared = FLT_shared;
00113 }
00114 
00115 void ht_flt_aviewer::setAnalyser(Analyser *a)
00116 {
00117         ((FLTAnalyser *)a)->flt_shared = flt_shared;
00118         ((FLTAnalyser *)a)->file = file;
00119         analy = a;
00120         analy_sub->setAnalyser(a);
00121 }

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