Got an iPhone or iPad? We have a brand new Pastebin App for both devices, and it's totally free! Click here to download the new Pastebin App for iOS.
Guest

JimmySkull

By: a guest on Jun 18th, 2008  |  syntax: Delphi  |  size: 1.51 KB  |  hits: 54  |  expires: Never
download  |  raw  |  embed  |  report abuse
This paste has a previous version, view the difference. Copied
  1. // Listar funções exportadas de uma DLL
  2. // http://0x1f.blogspot.com/
  3.  
  4. uses
  5.   ImageHlp;
  6.  
  7. procedure ListDLLExports(const FileName: string; List: TStrings);
  8. type
  9.   TDWordArray = array [0..$FFFFF] of DWORD;
  10. var
  11.   imageinfo: LoadedImage;
  12.   pExportDirectory: PImageExportDirectory;
  13.   dirsize: Cardinal;
  14.   pDummy: PImageSectionHeader;
  15.   i: Cardinal;
  16.   pNameRVAs: ^TDWordArray;
  17.   Name: string;
  18. begin
  19.   List.Clear;
  20.   if MapAndLoad(PChar(FileName), nil, @imageinfo, True, True) then
  21.   try
  22.     pExportDirectory := ImageDirectoryEntryToData(imageinfo.MappedAddress, False, IMAGE_DIRECTORY_ENTRY_EXPORT, dirsize);
  23.     if (pExportDirectory <> nil) then
  24.     begin
  25.       pNameRVAs := ImageRvaToVa(imageinfo.FileHeader, imageinfo.MappedAddress,
  26.       DWORD(pExportDirectory^.AddressOfNames), pDummy);
  27.       for i := 0 to pExportDirectory^.NumberOfNames - 1 do
  28.       begin
  29.         Name := PChar(ImageRvaToVa(imageinfo.FileHeader, imageinfo.MappedAddress,
  30.         pNameRVAs^[i], pDummy));
  31.         List.Add(Name);
  32.       end;
  33.     end;
  34.   finally
  35.     UnMapAndLoad(@imageinfo);
  36.   end;
  37. end;
  38.  
  39. procedure TForm1.Button1Click(Sender: TObject);
  40. var
  41.   List: TStrings;
  42.   i: Integer;
  43.   s: string;
  44. begin
  45.   List := TStringList.Create;
  46.   try
  47.     ListDLLExports('C:\WINDOWS\SYSTEM32\browseui.dll', List);
  48.     ShowMessage(IntToStr(list.Count) + ' funções exportadas pela DLL');
  49.     s := 'Lista de funções:';
  50.     for i := 0 to List.Count - 1 do
  51.       s := s + #13 + List[i];
  52.     ShowMessage(S);
  53.   finally
  54.     List.Free
  55.   end;
  56. end;