Take a DLL all output function name

zhaozj2021-02-08  267

Get a DLL all output function name plus imagehlp in Uses

procedure 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 longth (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 covend

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.freend;

// Rock // Reprinted please keep this information

转载请注明原文地址:https://www.9cbs.com/read-2795.html

New Post(0)