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

htpe.h

Go to the documentation of this file.
00001 /* 
00002  *      HT Editor
00003  *      htpe.h
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 #ifndef __HTPE_H__
00022 #define __HTPE_H__
00023 
00024 #include "formats.h"
00025 #include "pestruct.h"
00026 #include "htpeexp.h"
00027 #include "htpeil.h"
00028 #include "htpeimp.h"
00029 #include "htpedimp.h"
00030 
00031 #define DESC_PE "pe - win32 portable exe"
00032 #define DESC_PE_HEADER "pe/header"
00033 #define DESC_PE_IMPORTS "pe/imports"
00034 #define DESC_PE_DIMPORTS "pe/delay-imports"
00035 #define DESC_PE_EXPORTS "pe/exports"
00036 #define DESC_PE_RESOURCES "pe/resources"
00037 #define DESC_PE_IMAGE "pe/image"
00038 #define DESC_PE_IL "pe/il"
00039 
00040 #define ATOM_PE_MACHINES                        0x50450000
00041 #define ATOM_PE_MACHINES_STR                     "50450000"
00042 
00043 #define ATOM_PE_OPTIONAL_MAGICS                 0x50450001
00044 #define ATOM_PE_OPTIONAL_MAGICS_STR              "50450001"
00045 
00046 #define ATOM_PE_SUBSYSTEMS                      0x50450002
00047 #define ATOM_PE_SUBSYSTEMS_STR                   "50450002"
00048 
00049 #define ATOM_PE_CHARACTERISTICS                 0x50450003
00050 #define ATOM_PE_CHARACTERISTICS_STR              "50450003"
00051 
00052 #define ATOM_PE_DLL_CHARACTERISTICS             0x50450004
00053 #define ATOM_PE_DLL_CHARACTERISTICS_STR          "50450004"
00054 
00055 #define ATOM_PE_SECTION_CHARACTERISTICS         0x50450005
00056 #define ATOM_PE_SECTION_CHARACTERISTICS_STR      "50450005"
00057 
00058 extern format_viewer_if htpe_if;
00059 
00060 struct pe_section_headers {
00061         UINT section_count;
00062         COFF_SECTION_HEADER *sections;
00063 };
00064 
00065 struct ht_pe_shared_data {
00066         FILEOFS header_ofs;
00067         COFF_HEADER coffheader;
00068         word opt_magic;
00069         union {
00070                 struct {
00071                         COFF_OPTIONAL_HEADER32 header;
00072                         PE_OPTIONAL_HEADER32_NT header_nt;
00073                 } pe32;
00074                 struct {
00075                         COFF_OPTIONAL_HEADER64 header;
00076                         PE_OPTIONAL_HEADER64_NT header_nt;
00077                 } pe64;
00078         };
00079         pe_section_headers sections;
00080         ht_pe_il *il;
00081         ht_pe_export exports;
00082         ht_pe_import imports;
00083         ht_pe_import dimports;
00084         ht_format_viewer *v_header;
00085         ht_view *v_exports;
00086         ht_view *v_imports;
00087         ht_view *v_dimports;
00088         ht_view *v_resources;
00089         ht_view *v_il;
00090         ht_format_viewer *v_image;      
00091 };
00092 
00093 /*
00094  *      CLASS ht_pe
00095  */
00096 
00097 class ht_pe: public ht_format_group {
00098 protected:
00099         bool loc_enum;
00100 public:
00101                         void init(bounds *b, ht_streamfile *file, format_viewer_if **ifs, ht_format_group *format_group, FILEOFS header_ofs);
00102         virtual void done();
00103 /* overwritten */
00104         virtual   void loc_enum_start();
00105         virtual   bool loc_enum_next(ht_format_loc *loc);
00106 };
00107 
00108 bool pe_rva_to_section(pe_section_headers *section_headers, RVA rva, int *section);
00109 bool pe_rva_to_ofs(pe_section_headers *section_headers, RVA rva, FILEOFS *ofs);
00110 bool pe_rva_is_valid(pe_section_headers *section_headers, RVA rva);
00111 bool pe_rva_is_physical(pe_section_headers *section_headers, RVA rva);
00112 
00113 bool pe_ofs_to_rva(pe_section_headers *section_headers, FILEOFS ofs, RVA *rva);
00114 bool pe_ofs_to_section(pe_section_headers *section_headers, FILEOFS ofs, int *section);
00115 bool pe_ofs_to_rva_and_section(pe_section_headers *section_headers, FILEOFS ofs, RVA *rva, int *section);
00116 
00117 bool pe_section_name_to_section(pe_section_headers *section_headers, const char *name, int *section);
00118 
00119 #endif /* !__HTPE_H__ */

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