使用NtQuerySystemInformation()获取所有正在运行的进程,返回除当前进程之外的所有进程

时间:2013-10-01 15:39:32

标签: windows winapi

我的代码使用未记录的winnt函数NtQuerySystemInformation()来获取所有正在运行的进程。虽然没有正式记录,但那里有很多第三方文档(http://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/System%20Information/NtQuerySystemInformation.htmlhttp://www.exploit-monday.com/2013/06/undocumented-ntquerysysteminformation.html开头)。该函数是动态加载的(使用LoadLibrary()GetProcAddress()),但为方便起见,我会将调用直接写入NtQuerySystemInformation()

PSYSTEM_PROCESS_INFORMATION pspi = NULL;
ULONG info_length = 0;
NTSTATUS result = NtQuerySystemInformation(SystemProcessInformation, NULL , 0, &info_length);
pspi = (PSYSTEM_PROCESS_INFORMATION ) HeapAlloc ( .. , info_length , ..);
result = NtQuerySystemInformation(SystemProcessInformation, pspi , info_length, &info_length);
if ( result != NT_SUCESS ) return ;
while (..)
{
  ...

  cout << pspi.ImageName.buffer ; 

  ...
}

此[伪]代码打印机器上运行的所有进程 EXCEPT 调用进程。 我不知道是什么原因导致这种行为。

0 个答案:

没有答案
相关问题