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

htleent.cc

Go to the documentation of this file.
00001 /* 
00002  *      HT Editor
00003  *      htleent.cc
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 #include "htatom.h"
00022 #include "htnewexe.h"
00023 #include "htle.h"
00024 #include "htlehead.h"
00025 #include "httag.h"
00026 #include "formats.h"
00027 #include "snprintf.h"
00028 
00029 #include "lestruct.h"
00030 
00031 /* entry bundle */
00032 
00033 static ht_tag_flags_s le_entry_bundle_flags[] =
00034 {
00035         {-1, "LE - entrypoint bundle flags"},
00036         {0,  "[00] valid"},
00037         {1,  "[01] 32bit (16bit otherwise)"},
00038         {0, 0}
00039 };
00040 
00041 static ht_mask_ptable le_entry_bundle_header[]=
00042 {
00043         {"number of entries",   STATICTAG_EDIT_BYTE("00000000")},
00044         {"bundle flags",                STATICTAG_EDIT_BYTE("00000001")" "STATICTAG_FLAGS("00000001", ATOM_LE_ENTRY_BUNDLE_FLAGS_STR)},
00045         {"object index",                STATICTAG_EDIT_WORD_LE("00000002")},
00046         {0,0}
00047 };
00048 
00049 /* entry */
00050 
00051 static ht_tag_flags_s le_entry_flags[] =
00052 {
00053         {-1, "LE - entrypoint flags"},
00054         {0,  "[00] exported"},
00055         {1,  "[01] uses shared segment"},
00056         {0, 0}
00057 };
00058 
00059 static ht_mask_ptable le_entry16[]=
00060 {
00061         {"flags",               STATICTAG_EDIT_BYTE("00000000")" "STATICTAG_FLAGS("00000000", ATOM_LE_ENTRY_FLAGS_STR)},
00062         {"offset",      STATICTAG_EDIT_WORD_LE("00000001")},
00063         {0, 0}
00064 };
00065 
00066 static ht_mask_ptable le_entry32[]=
00067 {
00068         {"flags",               STATICTAG_EDIT_BYTE("00000000")" "STATICTAG_FLAGS("00000000", ATOM_LE_ENTRY_FLAGS_STR)},
00069         {"offset",      STATICTAG_EDIT_DWORD_LE("00000001")},
00070         {0, 0}
00071 };
00072 
00073 static ht_view *htleentrypoints_init(bounds *b, ht_streamfile *file, ht_format_group *group)
00074 {
00075         ht_le_shared_data *le_shared=(ht_le_shared_data *)group->get_shared_data();
00076 
00077         int h=le_shared->hdr_ofs;
00078         ht_uformat_viewer *v=new ht_uformat_viewer();
00079         v->init(b, DESC_LE_ENTRYPOINTS, VC_EDIT | VC_SEARCH, file, group);
00080         ht_mask_sub *m=new ht_mask_sub();
00081         m->init(file, 0);
00082         register_atom(ATOM_LE_ENTRY_FLAGS, le_entry_flags);
00083         register_atom(ATOM_LE_ENTRY_BUNDLE_FLAGS, le_entry_bundle_flags);
00084         char info[128];
00085         
00086         ht_snprintf(info, sizeof info, "* LE entry header at offset %08x", h+le_shared->hdr.enttab);
00087 
00088 /* FIXME: false */
00089         bool le_bigendian = false;
00090         m->add_mask(info);
00091         m->add_staticmask_ptable(le_entry_bundle_header, h+le_shared->hdr.enttab, le_bigendian);
00092         v->insertsub(m);
00093 
00094         FILEOFS o=h+le_shared->hdr.enttab;
00095         while (1) {
00096                 char t[32];
00097                 LE_ENTRYPOINT_BUNDLE hdr;
00098                 hdr.entry_count=0;
00099                 file->seek(o);
00100                 o+=file->read(&hdr, sizeof hdr);
00101                 if (!hdr.entry_count) break;
00102                 char *flags_str;
00103                 if (hdr.flags & LE_ENTRYPOINT_BUNDLE_32BIT) {
00104                         flags_str="32-bit";
00105                 } else {
00106                         flags_str="16-bit";
00107                 }
00108                 for (int i=0; i<hdr.entry_count; i++) {
00109                         m=new ht_mask_sub();
00110                         m->init(file, i);
00111                         if (hdr.flags & LE_ENTRYPOINT_BUNDLE_32BIT) {
00112                                 m->add_staticmask_ptable(le_entry32, o, le_bigendian);
00113                                 o+=1+4;
00114                         } else {
00115                                 m->add_staticmask_ptable(le_entry16, o, le_bigendian);
00116                                 o+=1+2;
00117                         }
00118                         ht_snprintf(t, sizeof t, "--- entry %d (%s) ---", i+1, flags_str);
00119 
00120                         ht_collapsable_sub *cs=new ht_collapsable_sub();
00121                         cs->init(file, m, 1, t, 1);
00122                         v->insertsub(cs);
00123                 }
00124         }
00125         
00126         return v;
00127 }
00128 
00129 format_viewer_if htleentrypoints_if = {
00130         htleentrypoints_init,
00131         0
00132 };

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