时间: 2021-07-31 作者:daque
在uses里加上imagehlpprocedure listdllfunctions(dllname: string; list: tstrings);type chararr = array [0..$ffffff] 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^)[i]=#0 then begin st := pchar(@chararr(arr^)[fc]); if length(st)>0 then list.add(st); if (i>0) and (chararr(arr^)[i-1]=#0) then break; fc := i + 1 end finally unmapdebuginformation(imagedebuginformation) end finally closehandle(h) end endend;procedure tform1.button1click(sender: tobject);var list: tstrings; i: integer; s: string;begin list := tstringlist.create; listdllfunctions('c:\windows\system\abcsda.dll', list); showmessage(inttostr(list.count)); s := 'list of functions'; for i := 0 to list.count - 1 do s := s + #13#10 + list[i]; showmessage(s); list.freeend;//rock//连载请保持此消息