Einzelnen Beitrag anzeigen

TopDogg

Registriert seit: 28. Jun 2002
51 Beiträge
 
#3

Re: Alle exportierten Funktionen einer DLL auflisten

  Alt 3. Mai 2004, 10:03
hi,
Delphi-Quellcode:
uses
  ImageHlp;

procedure LoadedDLLExportsFunc(aFileName: string; aList: tStrings);
type
  PDWORDArray = ^TDWORDArray;
  TDWORDArray = array[0..0] of DWORD;
var
  imageinfo: LoadedImage;
  pExportDirectory: PImageExportDirectory;
  dirsize: Cardinal;
  pDummy: PImageSectionHeader;
  i: Cardinal;
  pNameRVAs: PDWORDArray;
  Name: string;
begin
  imageinfo.MappedAddress := PChar(GetModuleHandle(@aFileName[1]));
  if Assigned(imageinfo.MappedAddress) then
  try
    imageinfo.FileHeader := ImageNtHeader(imageinfo.MappedAddress);
    pExportDirectory := ImageDirectoryEntryToData(imageinfo.MappedAddress,
      True, IMAGE_DIRECTORY_ENTRY_EXPORT, dirsize);
    if (pExportDirectory <> nil) then
    begin
      try
        pNameRVAs := PDWORDArray(PChar(imageinfo.MappedAddress) + DWORD(pExportDirectory^.AddressOfNames));
      except
        aList.Add('ERROR: #' + IntToStr(GetLastError));
      end;
      for i := 0 to pExportDirectory^.NumberOfNames - 1 do
        aList.Add(PChar(imageinfo.MappedAddress) + pNameRVAs^[i]);
    end;
  finally
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  LoadedDLLExportsFunc('ntdll.dll', Listbox1.Items);
end;
hab ich von assarbads seite.
  Mit Zitat antworten Zitat