Afficher les noms des fonctions contenues dans une DLL

uses
ImageHlp;

procedure ListDLLExports( const FileName: string; List: TStrings);
type
TDWordArray = array [0..$FFFFF] of DWORD;
var
imageinfo: LoadedImage;
pExportDirectory: PImageExportDirectory;
dirsize: Cardinal;
pDummy: PImageSectionHeader;
i: Cardinal;
pNameRVAs: ^TDWordArray;
Name: string;
begin
List.Clear;
if MapAndLoad(PChar(FileName), nil, @imageinfo, True, True) then
begin
try
pExportDirectory := ImageDirectoryEntryToData(imageinfo.MappedAddress,
False, IMAGE_DIRECTORY_ENTRY_EXPORT, dirsize);
if (pExportDirectory <> nil) then
begin
pNameRVAs := ImageRvaToVa(imageinfo.FileHeader, imageinfo.MappedAddress,
DWORD(pExportDirectory^.AddressOfNames), pDummy);
for i := 0 to pExportDirectory^.NumberOfNames - 1 do
begin
Name := PChar(ImageRvaToVa(imageinfo.FileHeader, imageinfo.MappedAddress,
pNameRVAs^[i], pDummy));
List.Add(Name);
end;
end;
finally
UnMapAndLoad(@imageinfo);
end;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
List: TStrings;
i: Integer;
s: string;
begin
List := TStringList.Create;
try
ListDLLExports('C:WINDOWSSYSTEMWininet.dll', List);
ShowMessage(IntToStr(list.Count) + ' function s in dll');
s := 'List of function s:';
for i := 0 to List.Count - 1 do
s := s + #13#10 + List[i];
ShowMessage(S);
finally
List.Free
end;
end;
Ajouter un commentaire
Pseudo
Adresse email
Site internet (optionnel)
Votre commentaire
Fiche de l'article
Mise a jour23/05/2004
VisualisationVu 1089 fois
PublicInternaute zz
CategorieDelphi - Trucs et astuces - Fichier
Auteur de l'article
SwissDelphiCenter SwissDelphiCenter
connecté le 02/11/2011
329 articles dans la section
Contacter l'auteur