1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Menus,structures,imagehlp;
type
TForm1 = class(TForm)
ListBox1: TListBox;
MainMenu1: TMainMenu;
File1: TMenuItem;
Open1: TMenuItem;
OpenDialog1: TOpenDialog;
ListBox2: TListBox;
procedure Open1Click(Sender: TObject);
private
public
procedure DLLFuncstoList(fname:string;alistbox:tlistbox);
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.DLLFuncstoList(fname:string;alistbox:tlistbox);
var
fih:LOADED_IMAGE;
pexpdir:PIMAGE_EXPORT_DIRECTORY;
pexpnames:pdword;//pointer sur la liste des fonctions exportées
pt1:PImageSectionHeader;
i:integer;
exportedfuncname:pchar;//Nom de la fonction exportée
begin
alistbox.items.clear;
pt1:=nil;
MapAndLoad(pchar(fname),pchar('#0'),@fih,true,true);//Charge le fichier en mémoire.
pExpDir:=PIMAGE_EXPORT_DIRECTORY(fih.FileHeader.OptionalHeader.
DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);
pExpDir:=PIMAGE_EXPORT_DIRECTORY(ImageRvaToVa
(fih.FileHeader,fih.MappedAddress,DWORD(pExpDir),pt1));
pExpNames:= pExpDir.pAddressOfNames;
pExpNames:=PDWORD(ImageRvaToVa
(fih.FileHeader,fih.MappedAddress,dword(pExpNames),pt1));
pt1:=nil;
for i:=0 to pexpdir.NumberOfNames-1 do
begin
exportedfuncname:=pchar(ImageRvaToVa
(fih.FileHeader,fih.MappedAddress,dword(pExpNames^),pt1));
alistbox.items.add(exportedfuncname);
inc(pexpnames);
end;
UnMapAndLoad(@fih);//Décharge le fichier de la mémoire. end;
procedure TForm1.Open1Click(Sender: TObject);
var
begin
if opendialog1.execute = true then
begin
DLLFuncstoList(opendialog1.filename,listbox1);
end;
end;
end. |
Partager