阿杰 发表于 2011-7-31 02:03:19

取dll所有输出函数名

取得某一dll所有输出函数名来源:考试大
  在uses里加上ImageHlp
procedure ListDLLFunctions(DLLName: string; List: TStrings);
type
chararr = array of Char;
var
H: THandle;
I,
    fc: integer;
st: string;
arr: Pointer;
ImageDebugInformation: PImageDebugInformation;
begin
List.Clear;
DLLName := ExpandFileName(DLLName);
if FileExists(DLLName) then
begin
    H := CreateFile(PChar(DLLName), GENERIC_READ, FILE_SHARE_READ or
      FILE_SHARE_WRITE, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
    if H <> INVALID_HANDLE_VALUE then
    try
      ImageDebugInformation := MapDebugInformation(H, PChar(DLLName), nil, 0);
      if ImageDebugInformation <> nil then
      try
      arr := ImageDebugInformation^.ExportedNames;
      fc := 0;
      for I := 0 to ImageDebugInformation^.ExportedNamesSize - 1 do
          if chararr(arr^) = #0 then
          begin
            st := PChar(@chararr(arr^));
            if Length(st) > 0 then
            List.Add(st);
            if (I > 0) and (chararr(arr^) = #0) then
            Break;
            fc := I + 1
          end
      finally
      UnmapDebugInformation(ImageDebugInformation)
      end
    finally
      CloseHandle(H)
    end
end
end;

procedure TForm1.Button1Click(Sender: TObject);
var
List: TStrings;
I: integer;
S: string;

begin
List := TStringList.Create;

ListDLLFunctions(&#39; c: windowssystemAbcsda.dll&#39; , List);
showmessage(inttostr(list.count));
S := &#39; List of functions&#39; ;
for I := 0 to List.Count - 1 do
    S := S + #13#10 + List;
ShowMessage(S);

List.Free
end;

  //rock
来源:http://www.examda.com/ncre2/Delphi/zonghe/20090914/081347578.html

wofan 发表于 2011-7-31 16:57:17

你取到了DLL输出函数名了吗?

wofan 发表于 2011-7-31 16:59:22

\

感觉这份代码莫名其妙。

wofan 发表于 2011-7-31 17:02:22

有空我来传一份真正的取DLL输出函数名的delphi代码上来。

wofan 发表于 2011-7-31 17:03:46

我觉着在这个论坛,Delphi版块很不专业。

ywledoc 发表于 2011-8-2 23:21:47

wofan 发表于 2011-7-31 17:03 static/image/common/back.gif
我觉着在这个论坛,Delphi版块很不专业。

这于DELPHI关系不大吧,对PE结构的熟悉程序关系大点。

Tesla.Angela 发表于 2011-8-3 16:16:26

RE: 取dll所有输出函数名

naylon 发表于 2011-7-31 18:20 static/image/common/back.gif
这个还是论坛比较冷清,多数人都集中在WIN32内核板块、VB板块。
另外取DLL导出函数的话有个简单的偏方: ...

好像不是【空格】。。。是NULL吧。。。

Tesla.Angela 发表于 2011-8-7 18:58:14

naylon 发表于 2011-8-7 13:07 static/image/common/back.gif
好吧我写错了~记事本打开0x20和0x00没区别。。

用notepad++能看到区别。

upring 发表于 2015-4-9 09:15:19

代码很不错哦
页: [1]
查看完整版本: 取dll所有输出函数名