program pe;

{$APPTYPE CONSOLE}
uses
SysUtils,windows;
type
PImageImportDescriptor = ^TImageImportDescriptor;
TImageImportDescriptor = packed record
originalFirstThunk: DWord;
TimeDateStamp : DWord;
ForwarderChain : DWord;
DLLName : DWord;
FirstThunk : DWord;
end;
PImageThunkData=^TImageThunkData;
TImageThunkData = record
case integer of
1:( ForwarderString : DWord; );
2:( Function_ : DWord; );
3:( ordinal : DWord; );
4:( AddressOfData : DWord; );
end;

var
DosHeader: pIMAGEDOSHEADER;
ntheader:pimagentheaders;
optheader: pimageoptionalheader;
importdesc:pimageimportdescriptor;
vra:longint;
hmod:longint;
sectionnum:integer;
begin
hmod:=GetModuleHandle(NiL);
writeln(format('exe-imagebase:%8X',[hmod]));
dosheader:=pimagedosheader(hmod);
writeln(format('dos-header:%8p',[dosheader]));
ntheader:=pimagentheaders(hmod+dosheader^._lfanew) ;
writeln(format('nt-header:%8p',[ntheader]));
optheader:=pimageoptionalheader(dword(ntheader)+24);
writeln(format('opt-header:%8p',[optheader]));
vra:=OptHeader^.DataDirectory[1].VirtualAddress ;
writeln(format('import-vra-adress:%8x',[vra]));
importdesc:=pimageimportdescriptor(byte(hmod)+vra);
writeln(format('import-first-desc-adress:%8p',[importdesc]));
sectionnum:=ntheader^.FileHeader.NumberOfSections ;
writeln(format('sections:%8d',[sectionnum]));
end.