枚举导出函数

unit Unit1;

interface

uses ImageHlp,Windows,Dialogs;

  procedure ListDLLExports(const AFileName:string);

implementation

procedure ListDLLExports(const AFileName:string);

type
  TDWordArray = array [0..$FFFFF] of DWORD;

var
  image:TLoadedImage;
  pExpDir:PImageExportDirectory;
  iSize:Cardinal;
  pNameRVAs:^TDWordArray;
  i: Integer;
  sName:string;
  lrs:PImageSectionHeader;
begin
  if MapAndLoad(PAnsiChar(AFileName),nil,@image,true,true) then
  try
    pExpDir := ImageDirectoryEntryToData(image.MappedAddress,false,IMAGE_DIRECTORY_ENTRY_EXPORT,iSize);
    if pExpDir <> nil then
    begin
      lrs := nil;
      pNameRVAs := ImageRvaToVa(image.FileHeader,image.MappedAddress,DWORD(pExpDir^.AddressOfNames),lrs);
      for i := 0 to Pred(pExpDir^.NumberOfNames) do
      begin
        lrs := nil;
        sName := PAnsiChar(ImageRvaToVa(image.FileHeader,image.MappedAddress,DWORD(pNameRVAs^[i]),lrs));
        ShowMessage(sName);
      end;
    end;
  finally
    UnMapAndLoad(@image);
  end;
end;

end.
View Code

原文地址:https://www.cnblogs.com/key-ok/p/3380554.html