我的代码使用未记录的winnt
函数NtQuerySystemInformation()
来获取所有正在运行的进程。虽然没有正式记录,但那里有很多第三方文档(http://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/System%20Information/NtQuerySystemInformation.html和http://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 调用进程。 我不知道是什么原因导致这种行为。