Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 팁&트릭
Delphi Programming Tip&Tricks
[129] DLL에 들어있는 exported된 모든 함수명을 알아내자
박정모 [] 5493 읽음    2001-12-22 20:51

제목 그대로 입니다. 아래 함수를 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;


+ -

관련 글 리스트
129 DLL에 들어있는 exported된 모든 함수명을 알아내자 박정모 5493 2001/12/22
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.