source: trunk/tools/common/kFilePE.h@ 5120

Last change on this file since 5120 was 5053, checked in by bird, 25 years ago

Corrected kFileLX and kFilePE constructors.
Made kDump.exe work again.
Added import module dump to kFilePE.

File size: 3.4 KB
Line 
1/*
2 * kFilePE - PE files.
3 *
4 * Copyright (c) 1999 knut st. osmundsen
5 *
6 */
7
8#ifndef _kFilePE_h_
9#define _kFilePE_h_
10
11/*******************************************************************************
12* Defined Constants *
13*******************************************************************************/
14
15#if !defined(__WINE_PEEXE_H) && !defined(_WINNT_)
16#if 0
17 #define PIMAGE_DOS_HEADER void*
18 #define PIMAGE_FILE_HEADER void*
19 #define PIMAGE_OPTIONAL_HEADER void*
20 #define PIMAGE_DATA_DIRECTORY void*
21 #define PIMAGE_SECTION_HEADER void*
22 #define PIMAGE_EXPORT_DIRECTORY void*
23 #define PIMAGE_IMPORT_DESCRIPTOR void*
24 #define PIMAGE_RESOURCE_DIRECTORY void*
25 #define PIMAGE_BASE_RELOCATION void*
26 #define PIMAGE_DEBUG_DIRECTORY void*
27 #define PSZ void*
28 #define PULONG void*
29 #define PIMAGE_TLS_DIRECTORY void*
30 #define PIMAGE_LOAD_CONFIG_DIRECTORY void*
31 #define PIMAGE_IMPORT_DESCRIPTOR void*
32 #define PIMAGE_THUNK_DATA void*
33 #define PIMAGE_IMPORT_DESCRIPTOR void*
34#else
35#include <peexe.h>
36#endif
37#endif
38
39
40/*******************************************************************************
41* Structures and Typedefs *
42*******************************************************************************/
43
44/**
45 * PE (portable executable) files.
46 * TODO: error handling.
47 * @author knut st. osmundsen
48 */
49class kFilePE : public kFileFormatBase
50{
51 private:
52 void *pvBase;
53
54 /* headers */
55 PIMAGE_DOS_HEADER pDosHdr;
56 PIMAGE_FILE_HEADER pFileHdr;
57 PIMAGE_OPTIONAL_HEADER pOptHdr;
58 PIMAGE_DATA_DIRECTORY paDataDir;
59 PIMAGE_SECTION_HEADER paSectionHdr;
60
61 /** @cat
62 * Directory pointers.
63 */
64 PIMAGE_EXPORT_DIRECTORY pExportDir; /* 0 */
65 PIMAGE_IMPORT_DESCRIPTOR pImportDir; /* 1 */
66 PIMAGE_RESOURCE_DIRECTORY pRsrcDir; /* 2 */
67 PVOID pExcpDir; /* 3 */
68 PVOID pSecDir; /* 4 */
69 PIMAGE_BASE_RELOCATION pBRelocDir; /* 5 */
70 PIMAGE_DEBUG_DIRECTORY pDebugDir; /* 6 */
71 PSZ pCopyright; /* 7 */
72 PULONG pulGlobalPtr; /* 8 */ //is this the correct pointer type?
73 PIMAGE_TLS_DIRECTORY pTLSDir; /* 9 */
74 PIMAGE_LOAD_CONFIG_DIRECTORY pLoadConfigDir; /* 10 */
75 PIMAGE_IMPORT_DESCRIPTOR pBoundImportDir;/* 11 */ //is this the correct pointer type?
76 PIMAGE_THUNK_DATA pIATDir; /* 12 */ //is this the correct pointer type?
77 PIMAGE_IMPORT_DESCRIPTOR pDelayImportDir;/* 13 */
78 PVOID pComDir; /* 14 */
79 PVOID pv15; /* 15 */
80
81 public:
82 kFilePE(kFile *pFile) throw(int);
83 virtual ~kFilePE();
84
85 /* operations */
86 BOOL queryModuleName(char *pszBuffer);
87 BOOL findFirstExport(PEXPORTENTRY pExport);
88 BOOL findNextExport(PEXPORTENTRY pExport);
89 BOOL isPe() const { return TRUE;}
90
91 BOOL dump(kFile *pOut);
92};
93
94#endif
Note: See TracBrowser for help on using the repository browser.