获取系统进程模块信息

本文详细介绍了如何在操作系统中获取进程的模块信息,包括使用特定的API调用或命令行工具,解析内存映射,以及理解不同操作系统下的模块结构。通过对进程上下文的深入探究,读者将能够有效地监测和分析系统中的进程模块。
摘要由CSDN通过智能技术生成
uses
  TlHelp32;

procedure TForm1.FormCreate(Sender: TObject);
var
  Pname: string;
  I, Pid: DWORD;
  Prc: TProcessEntry32;
  modu: TModuleEntry32;
  hModu, hand32: THandle;
  Node: TTreeNode;
begin
  try
    i := 0;
    hand32 := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    Prc.dwSize := SizeOf(Prc);
    if Process32First(hand32, prc) then
    begin
      Pname := string(Prc.szExeFile);
      Pid := Prc.th32ProcessID;
      node := tv1.Items.Add(nil, Pname);
      Inc(i);
      begin
        hModu := CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, Pid);
        Modu.dwSize := SizeOf(Modu);
        if Module32First(hModu, modu) then
          tv1.Items.AddChild(Node, modu.szExePath);
        while Module32Next(hModu, modu) do
          tv1.Items.AddChild(Node, modu.szExePath);
      end;
      while process32next(hand32, prc) do
      begin
        inc(i);
        Pname := string(Prc.szExeFile);
        Pid := Prc.th32ProcessID;
        node := tv1.Items.Add(nil, Pname);
        begin
          hModu := CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, Pid);
          Modu.dwSize := SizeOf(Modu);
          if Module32First(hModu, modu) then
            while Module32Next(hModu, modu) do
              tv1.Items.AddChild(Node, modu.szExePath);
        end;
      end;
      ShowMessage(IntToStr(i));
    end;
  finally
    CloseHandle(hand32);
    CloseHandle(hModu);
  end;
end;


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值