delphi获取dll的函数列表
来源:互联网 发布:js的insertbefore参数 编辑:程序博客网 时间:2024/05/20 15:11
找了几个,终于找到一个好用的
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
UnmapViewOfFile(lpFileBase);
CloseHandle(hFileMapping);
CloseHandle(hFile);
Exit;
end;
// 63 63 72 75 6E 2E 63 6F 6D
pImg_Export_Dir := PImageExportDirectory(
ImageRvaToVa(pImg_NT_Header, pImg_DOS_Header, DWORD(pImg_Export_Dir),
PImageSectionHeader(Pointer(nil)^)));
ppdwNames := Pointer(pImg_Export_Dir.AddressOfNames);
ppdwNames := Pointer(ImageRvaToVa(pImg_NT_Header, pImg_DOS_Header,
DWORD(ppdwNames), PImageSectionHeader(Pointer(nil)^)));
if not Assigned(ppdwNames) then
begin
UnmapViewOfFile(lpFileBase);
CloseHandle(hFileMapping);
CloseHandle(hFile);
Exit;
end;
for i := 0 to pImg_Export_Dir.NumberOfNames - 1 do
begin
szFunc := PChar(ImageRvaToVa(pImg_NT_Header, pImg_DOS_Header,
DWORD(ppdwNames^), PImageSectionHeader(Pointer(nil)^)));
mStrings.Add(szFunc);
Inc(ppdwNames);
end;
UnmapViewOfFile(lpFileBase);
CloseHandle(hFileMapping);
CloseHandle(hFile);
Result := True;
end;
//调用示例
procedure TF_Main.btnTestClick(Sender: TObject);
begin
GetDLLFileExports('F:\光盘刻录\Reclib\librtmp.dll', Memo1.Lines);
end;
- delphi获取dll的函数列表
- delphi的函数列表
- VS2010获取dll中的函数列表
- Delphi的Dll中获取文件路径
- Delphi的Dll中获取文件路径
- delphi dll及函数指针的使用
- 获取一个DLL的导出方法列表
- delphi 获取串口列表
- Delphi DLL 输出函数
- Delphi函数列表
- Delphi函数列表(2)
- delphi Date函数列表
- CoreDll.dll函数列表
- delphi 获取Exe或DLL的文件版本信息
- delphi获取硬盘序列号的dll代码,支持win7
- delphi获取硬盘序列号的dll代码,支持win7
- Delphi:获取系统目录的函数
- Delphi常用获取系统信息的函数
- 人力资源管理在企业ERP中的地位与作用
- c++中指针与动态内存的分配
- C#正则表达式(5):命名空间System.Text.RegularExpressions下面的类简介2
- Session和Cookie的一些事
- c语言不使用中间变量交换两个数
- delphi获取dll的函数列表
- OSGi服务发布和获取方式
- int_ptr, long_ptr這些類型的含义
- repo常见命令用法与说明
- word中参考文献[1]、[2]等可以直接生成
- js 中的字符替换
- python创建目录
- java关键字大全
- 进程的内核空间共享