| 1 | /* $Id: kFilePE.h,v 1.4 2001-04-17 00:26:11 bird Exp $
|
|---|
| 2 | * kFilePE - PE files.
|
|---|
| 3 | *
|
|---|
| 4 | * Copyright (c) 1999-2001 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 1
|
|---|
| 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 | */
|
|---|
| 49 | class kFilePE : public kFileFormatBase, public kExecutableI
|
|---|
| 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 | /** @cat Module information methods. */
|
|---|
| 86 | BOOL moduleGetName(char *pszBuffer, int cchSize = 260);
|
|---|
| 87 |
|
|---|
| 88 | /** @cat Export enumeration methods. */
|
|---|
| 89 | BOOL exportFindFirst(kExportEntry *pExport);
|
|---|
| 90 | BOOL exportFindNext(kExportEntry *pExport);
|
|---|
| 91 | void exportFindClose(kExportEntry *pExport);
|
|---|
| 92 |
|
|---|
| 93 | /** @cat Export Lookup methods */
|
|---|
| 94 | BOOL exportLookup(unsigned long ulOrdinal, kExportEntry *pExport);
|
|---|
| 95 | BOOL exportLookup(const char * pszName, kExportEntry *pExport);
|
|---|
| 96 |
|
|---|
| 97 | BOOL isPe() const { return TRUE;}
|
|---|
| 98 |
|
|---|
| 99 | BOOL dump(kFile *pOut);
|
|---|
| 100 | };
|
|---|
| 101 |
|
|---|
| 102 | #endif
|
|---|