00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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;
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
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