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

htcoff.h

Go to the documentation of this file.
00001 /* 
00002  *      HT Editor
00003  *      htcoff.h
00004  *
00005  *      Copyright (C) 1999-2003 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 __HTCOFF_H__
00022 #define __HTCOFF_H__
00023 
00024 #include "formats.h"
00025 #include "coff_s.h"
00026 #include "htcoffhd.h"
00027 #include "htendian.h"
00028 
00029 #define DESC_COFF                       "coff - unix common obj file"
00030 #define DESC_COFF_HEADER                "coff/header"
00031 #define DESC_COFF_IMAGE                 "coff/image"
00032 
00033 #define ATOM_COFF_MACHINES                      0xf0450000
00034 #define ATOM_COFF_MACHINES_STR                  "f0450000"
00035 
00036 #define ATOM_COFF_OPTIONAL_MAGICS               0xf0450001
00037 #define ATOM_COFF_OPTIONAL_MAGICS_STR            "f0450001"
00038 
00039 #define ATOM_COFF_OPTIONAL_SIZES                0xf0450002
00040 #define ATOM_COFF_OPTIONAL_SIZES_STR             "f0450002"
00041 
00042 #define ATOM_COFF_CHARACTERISTICS               0xf0450003
00043 #define ATOM_COFF_CHARACTERISTICS_STR            "f0450003"
00044 
00045 #define ATOM_COFF_SECTION_CHARACTERISTICS       0xf0450004
00046 #define ATOM_COFF_SECTION_CHARACTERISTICS_STR    "f0450004"
00047 
00048 extern format_viewer_if htcoff_if;
00049 
00050 struct coff_section_headers {
00051         UINT hdr_ofs;           // duplicate of ht_coff_shared_data.hdr_ofs (!)
00052         UINT section_count;
00053         COFF_SECTION_HEADER *sections;
00054 };
00055 
00056 struct ht_coff_shared_data {
00057         dword hdr_ofs;
00058         COFF_HEADER coffheader;
00059         word opt_magic;
00060         endianess endian;
00061         union {
00062                 COFF_OPTIONAL_HEADER32 coff32header;
00063         };
00064         coff_section_headers sections;
00065         ht_viewer *v_header;
00066         ht_viewer *v_image;
00067 };
00068 
00069 /*
00070  *      CLASS ht_coff
00071  */
00072 
00073 class ht_coff: public ht_format_group {
00074 private:
00075         ht_coff_shared_data *coff_shared;
00076 public:
00077                 void init(bounds *b, ht_streamfile *file, format_viewer_if **ifs, ht_format_group *format_group, FILEOFS header_ofs, endianess end);
00078         virtual void done();
00079 };
00080 
00081 int coff_rva_to_section(coff_section_headers *section_headers, RVA rva, int *section);
00082 int coff_rva_to_ofs(coff_section_headers *section_headers, RVA rva, dword *ofs);
00083 int coff_rva_is_valid(coff_section_headers *section_headers, RVA rva);
00084 int coff_rva_is_physical(coff_section_headers *section_headers, RVA rva);
00085 
00086 int coff_ofs_to_rva(coff_section_headers *section_headers, dword ofs, RVA *rva);
00087 int coff_ofs_to_section(coff_section_headers *section_headers, dword ofs, UINT *section);
00088 int coff_ofs_to_rva_and_section(coff_section_headers *section_headers, dword ofs, RVA *rva, UINT *section);
00089 
00090 #endif /* !__HTCOFF_H__ */

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