제목 그대로 입니다. 아래 함수를 ListDllFunctions( 'MyDll.dll', loNameList ); 와
같이 호출하면 됩니다.
procedure ListDLLFunctions( psDllName : String; poList : TStrings );
type
lcaCharArr = Array [ 0..$FFFFFF ] of Char;
var
lhFile : THandle;
i,
liNameIdx : Integer;
lsName : String;
lpNamePtr : Pointer;
lrpDebugInfo : PImageDebugInformation;
begin
psDllName := ExpandFileName( psDllName );
if FileExists( psDllName ) = FALSE then
EXIT;
poList.Clear;
lhFile := CreateFile( PChar( psDllName ),
GENERIC_READ, FILE_SHARE_READ or FILE_SHARE_WRITE,
nil,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0 );
if lhFile <> INVALID_HANDLE_VALUE then
try
lrpDebugInfo := MapDebugInformation( lhFile, PChar( psDllName ), nil, 0 );
if lrpDebugInfo <> nil then
try
lpNamePtr := lrpDebugInfo^.ExportedNames;
liNameIdx := 0;
for i := 0 to lrpDebugInfo^.ExportedNamesSize - 1 do
if lcaCharArr( lpNamePtr^ )[ i ] = #0 then
begin
lsName := PChar( @lcaCharArr( lpNamePtr^ )[ liNameIdx ] );
if Length( lsName ) > 0 then
poList.Add( lsName );
if ( i > 0 ) and
( lcaCharArr( lpNamePtr^ )[ i - 1 ] = #0 ) then
Break;
liNameIdx := i + 1
end;
finally
UnmapDebugInformation( lrpDebugInfo )
end;
finally
CloseHandle( lhFile );
end;
end;
|