// Hiermit kann man sich die Namen der Prozeduren und/oder Funktionen anzeigen
// lassen, welche eine DLL exportiert.


// Variante 1: Getestet mit D4 unter XP

uses ImageHlp;     
 
type 
  arr = array[0..1048575] of Cardinal; 
 
procedure Show_DLL_Exports(DLL: string; gefunden: TStrings); 
var 
  nfo: _LOADED_IMAGE; 
  pExDir: ^_IMAGE_EXPORT_DIRECTORY; 
  dSize: Cardinal; 
  pSecHead: PImageSectionHeader; 
  x: Cardinal; 
  p: ^arr; 
begin 
  gefunden.Clear; 
  if MapAndLoad(PChar(DLL), nil, @nfo, true, true) then begin 
    try 
      pExDir := ImageDirectoryEntryToData(nfo.MappedAddress, 
        false, IMAGE_DIRECTORY_ENTRY_EXPORT, dSize); 
      if (pExDir <> nil) then begin 
        p := ImageRvaToVa(nfo.FileHeader, nfo.MappedAddress, 
          DWORD(pExDir^.AddressOfNames), pSecHead); 
        for x := 0 to pExDir^.NumberOfNames - 1 do begin 
          gefunden.Add(PChar(ImageRvaToVa(nfo.FileHeader, nfo.MappedAddress, 
            p^[x], pSecHead))); 
        end; 
      end; 
    finally 
      UnMapAndLoad(@nfo); 
    end; 
  end; 
end; 
 
 
// Beispielaufruf 
procedure TForm1.Button1Click(Sender: TObject); 
begin 
  Show_DLL_Exports('C:\Windows\System32\rasapi32.dll', Listbox1.Items); 
end;
 

//---------------------------------------------

 

// Variante 2: Getestet mit D2010 unter W7

...

procedure Show_DLL_Exports(DLL: String; gefunden: TStrings); 
var 
  nfo: _LOADED_IMAGE; 
  pExDir: ^_IMAGE_EXPORT_DIRECTORY; 
  dSize: Cardinal; 
  pSecHead: PImageSectionHeader; 
  x: Cardinal; 
  p: ^arr; 
begin 
  gefunden.Clear; 
  if MapAndLoad(PAnsiChar(AnsiString(DLL)), nil, @nfo, true, true) then 
  begin 
    try 
      pExDir := ImageDirectoryEntryToData(nfo.MappedAddress, false, 
        IMAGE_DIRECTORY_ENTRY_EXPORT, dSize); 
      if (pExDir <> nil) then 
      begin 
        p := ImageRvaToVa(nfo.FileHeader, nfo.MappedAddress, 
          DWORD(pExDir^.AddressOfNames), pSecHead); 
        for x := 0 to pExDir^.NumberOfNames - 1 do 
        begin 
          gefunden.Add(String(PAnsiChar(ImageRvaToVa(nfo.FileHeader, 
                  nfo.MappedAddress, p^[x], pSecHead)))); 
        end; 
      end; 
    finally 
      UnMapAndLoad(@nfo); 
    end; 
  end; 
end;

...



Zugriffe seit 6.9.2001 auf Delphi-Ecke