获取PE文件的导出函数列表
uses ImageHlp; function GetDLLFileExports( szFileName: PChar; mStrings: TStrings ): Boolean; var hFile: THANDLE; hFileMapping: THANDLE; lpFileBase: Pointer; pImg_DOS_Header: PImageDosHeader; pImg_NT_Header: PImageNtHeaders; pImg_Export_Dir: PImageExportDirectory; ppdwNames: ^PDWORD; szFunc: PChar; i: Integer; begin Result := False; if not Assigned(mStrings) then Exit; hFile := CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); if(hFile = INVALID_HANDLE_VALUE) then Exit; hFileMapping := CreateFileMapping(hFile, nil, PAGE_READONLY, 0, 0, nil); if hFileMapping = 0 then begin CloseHandle(hFile); Exit; end; lpFileBase := MapViewOfFile(hFileMapping, FILE_MAP_READ, 0, 0, 0); if lpFileBase = nil then begin CloseHandle(hFileMapping); CloseHandle(hFile); Exit; end; pImg_DOS_Header := PImageDosHeader(lpFileBase); pImg_NT_Header := PImageNtHeaders( Integer(pImg_DOS_Header) + Integer(pImg_DOS_Header._lfanew)); if IsBadReadPtr(pImg_NT_Header, SizeOf(IMAGE_NT_HEADERS)) or (pImg_NT_Header.Signature <> IMAGE_NT_SIGNATURE) then begin UnmapViewOfFile(lpFileBase); CloseHandle(hFileMapping); CloseHandle(hFile); Exit; end; pImg_Export_Dir := PImageExportDirectory( pImg_NT_Header.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT]. VirtualAddress); if not Assigned(pImg_Export_Dir) then begin
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。