|
| 1 | +//================================== |
| 2 | +// PEDUMP - Matt Pietrek 1997 |
| 3 | +// FILE: COMMON.H |
| 4 | +//================================== |
| 5 | + |
| 6 | +// MakePtr is a macro that allows you to easily add to values (including |
| 7 | +// pointers) together without dealing with C's pointer arithmetic. It |
| 8 | +// essentially treats the last two parameters as DWORDs. The first |
| 9 | +// parameter is used to typecast the result to the appropriate pointer type. |
| 10 | +#define MakePtr( cast, ptr, addValue ) (cast)( (DWORD)(ptr) + (DWORD)(addValue)) |
| 11 | + |
| 12 | +void DumpHeader(PIMAGE_FILE_HEADER pImageFileHeader); |
| 13 | +void DumpOptionalHeader(PIMAGE_OPTIONAL_HEADER pImageOptionalHeader); |
| 14 | +void DumpSectionTable(PIMAGE_SECTION_HEADER section, |
| 15 | + unsigned cSections, |
| 16 | + BOOL IsEXE); |
| 17 | +LPVOID GetSectionPtr(PSTR name, PIMAGE_NT_HEADERS pNTHeader, DWORD imageBase); |
| 18 | +LPVOID GetPtrFromRVA( DWORD rva, PIMAGE_NT_HEADERS pNTHeader, DWORD imageBase ); |
| 19 | +PIMAGE_SECTION_HEADER GetSectionHeader(PSTR name, PIMAGE_NT_HEADERS pNTHeader); |
| 20 | +PIMAGE_SECTION_HEADER GetEnclosingSectionHeader(DWORD rva, |
| 21 | + PIMAGE_NT_HEADERS pNTHeader); |
| 22 | +void DumpRawSectionData(PIMAGE_SECTION_HEADER section, |
| 23 | + PVOID base, |
| 24 | + unsigned cSections); |
| 25 | +void DumpDebugDirectory(PIMAGE_DEBUG_DIRECTORY debugDir, DWORD size, DWORD base); |
| 26 | +void DumpCOFFHeader(PIMAGE_COFF_SYMBOLS_HEADER pDbgInfo); |
| 27 | +void HexDump(PBYTE ptr, DWORD length); |
| 28 | + |
| 29 | +PSTR GetMachineTypeName( WORD wMachineType ); |
| 30 | + |
| 31 | +#define GetImgDirEntryRVA( pNTHdr, IDE ) \ |
| 32 | + (pNTHdr->OptionalHeader.DataDirectory[IDE].VirtualAddress) |
| 33 | + |
| 34 | +#define GetImgDirEntrySize( pNTHdr, IDE ) \ |
| 35 | + (pNTHdr->OptionalHeader.DataDirectory[IDE].Size) |
| 36 | + |
0 commit comments