{$include _00_00_A98_PEDUMP_COMPILER_DIRECTIVES.inc }
{ STARTING_ERROR: none } { TODO }
// ----------------------------------------------------------------------------
// the following defines are present to suppress output during developement
{$define dosheader }
{$define dosstub }
{$define ntheader }
{$define fileheader }
// even though the data directory is part of the optional header, it is dumped
// separately to keep the program's logic simple
{$define optionalheader }
{$define datadirectory }
{$define sectionheaders }
{$define imageheadersfillerbytes }
// ---------------------------------------------
// data directory references
{ NOTE: commenting out the processing of the exports directory requires }
{ commenting out the processing of the load config directory and the }
{ imports directory because the processing of these two directories }
{ create two tables (exports and imports respectively) that _may_ be }
{ used when processing the LOAD CONFIG. if those tables are needed }
{ and they are not present an access violation will occur }
{ 01 } {$define exportsdirectory }
{ 02 } {$define importsdirectory }
{ 03 } {$define resourcesdirectory }
{ 04 } {$define exceptionsdirectory }
{ 05 } {$define certificatesdirectory }
{ 06 } {$define relocationsdirectory }
{ 07 } {$define debugdirectory }
{ 08 } {$define architecturedirectory }
{ 09 } {$define globalpointerdirectory }
{ 10 } {$define tlsdirectory }
{ NOTE: processing the load config directory requires that the processing }
{ of the exports directory and imports directory _not_ be commented }
{ out because the load config _may_ need the table of imports and }
{ exports created when processing them }
{ 11 } {$define loadconfigdirectory }
{ 12 } {$define boundimportsdirectory }
{ 13 } {$define importsaddresstabledirectory}
{ 14 } {$define delayloadimportsdirectory }
{ 15 } {$define dotnetdirectory }
{ 16 } {$define reserveddirectory }
// ---------------------------------------------
// PE file areas not in directories
{ } {$define coffsymboltable }
{ } {$define PeInformation }
UNIT _05_60_000_DumpPE;
// -----------------------------------------------------------------------------
INTERFACE
// -----------------------------------------------------------------------------
USES
_05_50_PeData
;
// -----------------------------------------------------------------------------
function DumpPE(var InoutPeData : TPE_DATA) : boolean;
// outputs all the parts of a PE file
// -----------------------------------------------------------------------------
IMPLEMENTATION
// -----------------------------------------------------------------------------
USES
_05_60_010_DumpDosHeader,
_05_60_020_DumpDosStub,
// IMAGE Headers
_05_60_030_DumpNtHeader,
_05_60_040_DumpFileHeader,
_05_60_050_DumpOptionalHeader,
_05_60_060_DumpDataDirectory,
_05_60_070_DumpSectionHeaders,
_05_60_080_DumpImageHeadersFillerBytes,
// DATA DIRECTORY
_05_60_090_DumpExportsDirectory,
_05_60_100_DumpImportsDirectory,
_05_60_110_DumpResourcesDirectory,
_05_60_120_DumpExceptionsDirectory,
_05_60_130_DumpCertificatesDirectory,
_05_60_140_DumpRelocationsDirectory,
_05_60_150_DumpDebugDirectory,
_05_60_160_DumpArchitectureDirectory,
_05_60_170_DumpGlobalPointerDirectory,
_05_60_180_DumpTlsDirectory,
_05_60_190_00_DumpLoadConfigDirectory,
_05_60_200_DumpBoundImportsDirectory,
_05_60_210_DumpImportsAddressTableDirectory,
_05_60_220_DumpDelayLoadImportsDirectory,
_05_60_230_DumpDotNetDirectory,
_05_60_240_DumpReservedDirectory,
// PE file areas not in directories
_05_60_250_DumpCoffSymbolTable,
// output some notable PE features/characteristics found in the module
_05_60_300_DumpPeInformation,
// ---------------------------------------------
// support functions
_60_Io
;
// -----------------------------------------------------------------------------
function DumpPE(var InoutPeData : TPE_DATA) : boolean;
// outputs all the parts of a PE file
begin
result := FALSE;
// ---------------------------------------------------------------------------
// MS DOS header and stub
{$ifdef dosheader }
Newline();
Newline();
Newline();
if not DumpDosHeader (InoutPeData) then exit;
{$endif}
{$ifdef dosstub }
Newline();
Newline();
Newline();
if not DumpDosStub (InoutPeData) then exit;
{$endif}
// ---------------------------------------------------------------------------
// image headers
{$ifdef ntheader }
Newline();
Newline();
Newline();
if not DumpNtHeader (InoutPeData) then exit;
{$endif}
{$ifdef fileheader }
Newline();
if not DumpFileHeader (InoutPeData) then exit;
{$endif}
{$ifdef optionalheader }
Newline();
if not DumpOptionalHeader (InoutPeData) then exit;
{$endif}
{$ifdef datadirectory }
Newline();
Newline();
if not DumpDataDirectory (InoutPeData) then exit;
{$endif}
// ---------------------------------------------------------------------------
// section headers
{$ifdef sectionheaders }
Newline();
Newline();
Newline();
if not DumpSectionHeaders (InoutPeData) then exit;
{$endif}
// ---------------------------------------------------------------------------
// image headers filler bytes
{$ifdef imageheadersfillerbytes }
Newline();
if not DumpImageHeadersFillerBytes (InoutPeData) then exit;
{$endif}
// ---------------------------------------------------------------------------
// data directory
{ 1 } {$ifdef exportsdirectory }
Newline();
Newline();
Newline();
if not DumpExportsDirectory (InoutPeData) then exit;
{$endif}
{ 2 } {$ifdef importsdirectory }
Newline();
Newline();
Newline();
if not DumpImportsDirectory (InoutPeData) then exit;
{$endif}
{ 3 } {$ifdef resourcesdirectory }
Newline();
Newline();
Newline();
if not DumpResourcesDirectory (InoutPeData) then exit;
{$endif}
{ 4 } {$ifdef exceptionsdirectory }
Newline();
Newline();
Newline();
if not DumpExceptionsDirectory (InoutPeData) then exit;
{$endif}
{ 5 } {$ifdef certificatesdirectory }
Newline();
Newline();
Newline();
if not DumpCertificatesDirectory (InoutPeData) then exit;
{$endif}
{ 6 } {$ifdef relocationsdirectory }
Newline();
Newline();
Newline();
if not DumpRelocationsDirectory (InoutPeData) then exit;
{$endif}
{ 7 } {$ifdef debugdirectory }
Newline();
Newline();
Newline();
if not DumpDebugDirectory (InoutPeData) then exit;
{$endif}
{ 8 } {$ifdef architecturedirectory }
Newline();
Newline();
Newline();
if not DumpArchitectureDirectory (InoutPeData) then exit;
{$endif}
{ 9 } {$ifdef globalpointerdirectory }
Newline();
Newline();
Newline();
if not DumpGlobalPointerDirectory (InoutPeData) then exit;
{$endif}
{ 10 } {$ifdef tlsdirectory }
Newline();
Newline();
Newline();
if not DumpTlsDirectory (InoutPeData) then exit;
{$endif}
{ 11 } {$ifdef loadconfigdirectory }
Newline();
Newline();
Newline();
if not DumpLoadConfigDirectory (InoutPeData) then exit;
{$endif}
{ 12 } {$ifdef boundimportsdirectory }
Newline();
Newline();
Newline();
if not DumpBoundImportsDirectory (InoutPeData) then exit;
{$endif}
{ 13 } {$ifdef importsaddresstabledirectory }
Newline();
Newline();
Newline();
if not DumpImportsAddressTableDirectory (InoutPeData) then exit;
{$endif}
{ 14 } {$ifdef delayloadimportsdirectory }
Newline();
Newline();
Newline();
if not DumpDelayLoadImportsDirectory (InoutPeData) then exit;
{$endif}
{ 15 } {$ifdef dotnetdirectory }
Newline();
Newline();
Newline();
if not DumpDotNetDirectory (InoutPeData) then exit;
{$endif}
{ 16 } {$ifdef reserveddirectory }
Newline();
Newline();
Newline();
if not DumpReservedDirectory (InoutPeData) then exit;
{$endif}
// ---------------------------------------------------------------------------
// PE file areas not in headers and directories
{$ifdef coffsymboltable }
// don't output any separating lines unless there is a COFF
// symbol table to output
if not DumpCoffSymbolTable (InoutPeData) then exit;
{$endif}
{$ifdef PeInformation}
Newline();
Newline();
Newline();
if not DumpPeInformation (InoutPeData) then exit;
{$endif}
result := TRUE; // let the fat lady sing now
end;
END.
// end of file.
// -----------------------------------------------------------------------------