function ImageDirectoryEntryToData(Base:Pointer;MappedAsImage:ByteBool;DirectoryEntry:Word;var Size:ULONG):PIMAGE_IMPORT_DESCRIPTOR;stdcall;external 'IMAGEHLP.DLL';
Hand:=GetModuleHandle(PChar('ws2_32.dll'));
if Hand=0 then
begin
Hand:=Loadlibrary(PChar('ws2_32.dll')) ;
if Hand=0 then
begin
Memo1.Lines.Add('获取模块句柄失败...') ;
Exit ;
end;
end;
pImportDir:=ImageDirectoryEntryToData(Pointer(Hand),True,IMAGE_DIRECTORY_ENTRY_IMPORT,Size);
if pImportDir^.FirstThunk=0 then
begin
Memo1.Lines.Add('获取导入表失败...') ;
Exit ;
end;
while pImportDir^.FirstThunk<>0 do
begin
L:=Hand+pImportDir^.Name ;
IatName:=@L ;
Memo1.Lines.Add(Format('RVA %X %10S FirstThunk%15X,Name %s',[pImportDir^.FirstThunk,'',L,IatName^])) ;
///---------------------------------------------------上面的代码是正确的
///
///
///
pITD:=Pointer(Hand+pImportDir^.FirstThunk) ;
while pITD^.ForwarderString<>0 do
begin