//枚举 模块列表
procedure CPETool.GetProcessModuleList(ListView : TListView );
var
hSnapShot:Thandle;
lphl :TModuleEntry32;
begin
if ListView =nil then Raise(Exception.Create('未指定信息输出域(TListView)'));
//初始化标题
SetListViewAttrib(ListView);
with ListView.Columns.Add do begin Caption :='hModule'; Width:=100; end;
with ListView.Columns.Add do begin Caption :='modBaseAddr'; Width:=100; end; 这里就是模块基地址。
with ListView.Columns.Add do begin Caption :='modBaseSize'; Width:=100; end;
with ListView.Columns.Add do begin Caption :='szModule'; Width:=100; end;
with ListView.Columns.Add do begin Caption :='szExePath'; Width:=100; end;
with ListView.Columns.Add do begin Caption :='th32ModuleID'; Width:=100; end;
with ListView.Columns.Add do begin Caption :='dwSize'; Width:=100; end;
with ListView.Columns.Add do begin Caption :='th32ProcessID'; Width:=100; end;
with ListView.Columns.Add do begin Caption :='GlblcntUsage'; Width:=100; end;
with ListView.Columns.Add do begin Caption :='ProccntUsage'; Width:=100; end;
hSnapShot:=CreateToolHelp32SnapShot(TH32CS_SNAPMODULE,Self.CurDbgProcessID );
if hSnapShot=0 then exit;
lphl.dwSize :=Sizeof(TModuleEntry32);
if Module32First(hSnapShot,lphl) then
repeat
with ListView.Items.Add do
begin
Caption :=(IntToHex(lphl.hModule , 8));
SubItems.Add(IntToHex(DWord (lphl.modBaseAddr) , 8));
SubItems.Add(IntToHex(lphl.modBaseSize , 8));
SubItems.Add(lphl.szModule );
SubItems.Add(lphl.szExePath);
SubItems.Add(IntToHex(lphl.th32ModuleID,8));
SubItems.Add(IntToHex(lphl.dwSize , 8));
SubItems.Add(IntToHex(lphl.th32ProcessID , 8));
SubItems.Add(IntToHex(lphl.GlblcntUsage , 8));
SubItems.Add(IntToHex(lphl.ProccntUsage , 8));
Data :=@lphl;
end;
until not Module32Next(hSnapShot,lphl) ;
end;
//枚举 模块列表
procedure CPETool.GetProcessModuleList(ListView : TListView );
var
hSnapShot:Thandle;
lphl :TModuleEntry32;
begin
if ListView =nil then Raise(Exception.Create('未指定信息输出域(TListView)'));
//初始化标题
SetListViewAttrib(ListView);
with ListView.Columns.Add do begin Caption :='hModule'; Width:=100; end;
with ListView.Columns.Add do begin Caption :='modBaseAddr'; Width:=100; end;
with ListView.Columns.Add do begin Caption :='modBaseSize'; Width:=100; end;
with ListView.Columns.Add do begin Caption :='szModule'; Width:=100; end;
with ListView.Columns.Add do begin Caption :='szExePath'; Width:=100; end;
with ListView.Columns.Add do begin Caption :='th32ModuleID'; Width:=100; end;
with ListView.Columns.Add do begin Caption :='dwSize'; Width:=100; end;
with ListView.Columns.Add do begin Caption :='th32ProcessID'; Width:=100; end;
with ListView.Columns.Add do begin Caption :='GlblcntUsage'; Width:=100; end;
with ListView.Columns.Add do begin Caption :='ProccntUsage'; Width:=100; end;
hSnapShot:=CreateToolHelp32SnapShot(TH32CS_SNAPMODULE,Self.CurDbgProcessID );
if hSnapShot=0 then exit;
lphl.dwSize :=Sizeof(TModuleEntry32);
if Module32First(hSnapShot,lphl) then
repeat
with ListView.Items.Add do
begin
Caption :=(IntToHex(lphl.hModule , 8));
SubItems.Add(IntToHex(DWord (lphl.modBaseAddr) , 8));
SubItems.Add(IntToHex(lphl.modBaseSize , 8));
SubItems.Add(lphl.szModule );
SubItems.Add(lphl.szExePath);
SubItems.Add(IntToHex(lphl.th32ModuleID,8));
SubItems.Add(IntToHex(lphl.dwSize , 8));
SubItems.Add(IntToHex(lphl.th32ProcessID , 8));
SubItems.Add(IntToHex(lphl.GlblcntUsage , 8));
SubItems.Add(IntToHex(lphl.ProccntUsage , 8));
Data :=@lphl;
end;
until not Module32Next(hSnapShot,lphl) ;
end;