[TRUCO DELPHI] Mostrar la Lista de funciones exportadas de una DLL.
Hay que adicionar esta unidad
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.MappedAddr ess, DWORD(pExportDirectory^.AddressOfNames), pDummy); for i := 0 to pExportDirectory^.NumberOfNames - 1 do begin Name := PChar(ImageRvaToVa(imageinfo.FileHeader, imageinfo.MappedA ddress, pNameRVAs^[i], pDummy)); List.Add(Name); end; end; finally UnMapAndLoad(@imageinfo); end; end; end;
Ejemplo de uso:
procedure TForm1.Button1Click(Sender: TObject); var List: TStrings; i: Integer; s: string; begin List := TStringList.Create; try ListDLLExports('C:\WINDOWS\SYSTEM32\browseui.dll', List); ShowMessage(IntToStr(list.Count) + ' functions in dll'); s := 'Lista de funciones:'; for i := 0 to List.Count - 1 do s := s + #13#10 + List[i]; ShowMessage(S); finally List.Free end; end;
Saludos!