note : Get PID List
发布日期:2021-06-30 22:03:57 浏览次数:2 分类:技术文章

本文共 1257 字,大约阅读时间需要 4 分钟。

// srcProcessCnt.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include 
#include
typedef std::vector
VECTOR_INT;size_t fnGetPidList(VECTOR_INT & vec);int _tmain(int argc, _TCHAR* argv[]){ size_t nIndex = 0; size_t nProcessCnt = 0; VECTOR_INT vecPid; nProcessCnt = fnGetPidList(vecPid); /// printf PID List _tprintf(L"PID Counter = %d\r\n", nProcessCnt); for (nIndex = 0; nIndex < nProcessCnt; nIndex++) { _tprintf(L"PID[%d] = %d\r\n", nIndex, vecPid[nIndex]); } /** run results PID Counter = 101 PID[0] = 312 PID[1] = 424 PID[2] = 436 ... PID[98] = 7880 PID[99] = 8164 PID[100] = 8172 */ getwchar(); return 0;}size_t fnGetPidList(VECTOR_INT & vec){ int iIndex = 0; HANDLE hProcess = NULL; /// PID值是4的倍数 for (iIndex = 0; iIndex < 65536; iIndex += 4) { hProcess = OpenProcess(PROCESS_VM_READ, FALSE, iIndex); if (NULL != hProcess) { /** 只有2个系统进程无法读取内存(PROCESS_VM_READ) System PID = 4 System Idle Process PID = 0 */ vec.push_back(iIndex); CloseHandle(hProcess); } } return vec.size();}

转载地址:https://lostspeed.blog.csdn.net/article/details/11924847 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Disk Opt
下一篇:note : SSDT HOOK HOOK宏 转函数

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年04月17日 03时21分45秒