(转)SystemProcessesAndThreadsInformation
http://hi.baidu.com/hanjdud8606/item/7a970408a95acc843d42e27f
NTSTATUS NTAPI ZwQuerySystemInformation(ULONG SystemInformationClass,PVOID SystemInformation,ULONG SystemInformationLength,PULONG ReturnLength );
第一个参数是一个枚举类型,传入的是你需要查询的信息的类型,如果你要查询进程的相关信息,则你需要传入SystemProcessesAndThreadsInformation,以下是这个enmu类型的定义。
typedef enum _SYSTEM_INFORMATION_CLASS {SystemBasicInformation, // 0 Y NSystemProcessorInformation, // 1 Y NSystemPerformanceInformation, // 2 Y NSystemTimeOfDayInformation, // 3 Y NSystemNotImplemented1, // 4 Y NSystemProcessesAndThreadsInformation, // 5 Y NSystemCallCounts, // 6 Y NSystemConfigurationInformation, // 7 Y NSystemProcessorTimes, // 8 Y NSystemGlobalFlag, // 9 Y YSystemNotImplemented2, // 10 Y NSystemModuleInformation, // 11 Y NSystemLockInformation, // 12 Y NSystemNotImplemented3, // 13 Y NSystemNotImplemented4, // 14 Y NSystemNotImplemented5, // 15 Y NSystemHandleInformation, // 16 Y NSystemObjectInformation, // 17 Y NSystemPagefileInformation, // 18 Y NSystemInstructionEmulationCounts, // 19 Y NSystemInvalidInfoClass1, // 20SystemCacheInformation, // 21 Y YSystemPoolTagInformation, // 22 Y NSystemProcessorStatistics, // 23 Y NSystemDpcInformation, // 24 Y YSystemNotImplemented6, // 25 Y NSystemLoadImage, // 26 N YSystemUnloadImage, // 27 N YSystemTimeAdjustment, // 28 Y YSystemNotImplemented7, // 29 Y NSystemNotImplemented8, // 30 Y NSystemNotImplemented9, // 31 Y NSystemCrashDumpInformation, // 32 Y NSystemExceptionInformation, // 33 Y NSystemCrashDumpStateInformation, // 34 Y Y/NSystemKernelDebuggerInformation, // 35 Y NSystemContextSwitchInformation, // 36 Y NSystemRegistryQuotaInformation, // 37 Y YSystemLoadAndCallImage, // 38 N YSystemPrioritySeparation, // 39 N YSystemNotImplemented10, // 40 Y NSystemNotImplemented11, // 41 Y NSystemInvalidInfoClass2, // 42SystemInvalidInfoClass3, // 43SystemTimeZoneInformation, // 44 Y NSystemLookasideInformation, // 45 Y NSystemSetTimeSlipEvent, // 46 N YSystemCreateSession, // 47 N YSystemDeleteSession, // 48 N YSystemInvalidInfoClass4, // 49SystemRangeStartInformation, // 50 Y NSystemVerifierInformation, // 51 Y YSystemAddVerifier, // 52 N YSystemSessionProcessesInformation // 53 Y N }SYSTEM_INFORMATION_CLASS;
当我们第一个参数传入的是SystemProcessesAndThreadsInformation则返回的一片内存空间一个PSYSTEM_PROCESSES的结构。
typedef struct _SYSTEM_PROCESSES {ULONG NextEntryDelta; //构成结构序列的偏移量;ULONG ThreadCount; //线程数目;ULONG Reserved1[6];LARGE_INTEGER CreateTime; //创建时间;LARGE_INTEGER UserTime;//用户模式(Ring 3)的CPU时间;LARGE_INTEGER KernelTime; //内核模式(Ring 0)的CPU时间;UNICODE_STRING ProcessName; //进程名称;KPRIORITY BasePriority;//进程优先权;ULONG ProcessId; //进程标识符;ULONG InheritedFromProcessId; //父进程的标识符;ULONG HandleCount; //句柄数目;ULONG Reserved2[2];VM_COUNTERS VmCounters; //虚拟存储器的结构,见下;IO_COUNTERS IoCounters; //IO计数结构,见下;SYSTEM_THREADS Threads[1]; //进程相关线程的结构数组 }SYSTEM_PROCESSES,*PSYSTEM_PROCESSES;
如果要遍历系统中的进程,我们只需要使用NextEntryDelta这个指针即可。
获取进程示例代码#include <windows.#include <ntsecapi.h>
#include "stdio.h"typedef DWORD (WINAPI *ZWQUERYSYSTEMINFORMATION)(DWORD, PVOID, DWORD, PDWORD);typedef struct _SYSTEM_PROCESS_INFORMATION {DWORD NextEntryDelta;DWORD ThreadCount;DWORD Reserved1[6];FILETIME ftCreateTime; FILETIME ftUserTime; FILETIME ftKernelTime; UNICODE_STRING ProcessName; // 进程名. DWORD BasePriority; DWORD ProcessId;DWORD InheritedFromProcessId;DWORD HandleCount;DWORD Reserved2[2];DWORD VmCounters; DWORD dCommitCharge; PVOID ThreadInfos[1]; } SYSTEM_PROCESS_INFORMATION, * PSYSTEM_PROCESS_INFORMATION;#define SystemProcessesAndThreadsInformation 5void main() {HMODULE hNtDLL = GetModuleHandle( "ntdll.dll" );if (!hNtDLL )return;ZWQUERYSYSTEMINFORMATION ZwQuerySystemInformation = (ZWQUERYSYSTEMINFORMATION)GetProcAddress(hNtDLL,"ZwQuerySystemInformation");ULONG cbBuffer = 0x20000; // 设置缓冲大小,与系统有关.LPVOID pBuffer = NULL;pBuffer = malloc(cbBuffer); if (pBuffer == NULL) return;ZwQuerySystemInformation(SystemProcessesAndThreadsInformation, pBuffer, cbBuffer, NULL);PSYSTEM_PROCESS_INFORMATION pInfo = (PSYSTEM_PROCESS_INFORMATION)pBuffer;for (;;){printf("ProcessID: %d (%ls)\n", pInfo->ProcessId, pInfo->ProcessName.Buffer);if (pInfo->NextEntryDelta == 0)break;// 查找下一个进程的结构地址.pInfo = (PSYSTEM_PROCESS_INFORMATION)(((PUCHAR)pInfo) + pInfo->NextEntryDelta);} free(pBuffer);getchar(); //暂停. }
转载于:https://www.cnblogs.com/himessage/archive/2013/01/25/2876175.html
(转)SystemProcessesAndThreadsInformation相关推荐
- 内核级HOOK的几种实现与应用
实现内核级 HOOK 对于拦截.分析.跟踪系统内核起着致关重要的作用.实现的方法不同意味着应用侧重点的不同.如想要拦截 NATIVE API 那么可能常用的就是 HOOK SERVICE TABLE ...
- VC++实现恢复SSDT
SSDT(System Services Descriptor Table),系统服务描述符表.这个表就是一个把ring3的Win32 API和ring0的内核API联系起来.SSDT并不仅仅只包含一 ...
- 函数ZwQuerySystemInformation小结
函数存在于NTDLL.DLL动态链接库中.NTDLL.DLL负责ring3与ring0之间的通信.当使用子系统方式进行系统调用的时候,ntdll.dll和SSDT会配合使用. 关于ZwQuerySys ...
- 静态反调试技术(2)
文章目录 NtQueryInformationProcess() `ProcessDebugPort`(0x7) CheckRemoteDebuggerPresent() ProcessDebugOb ...
- 驱动列举进程输出到应用层
本篇算是前两篇的综合,驱动列举出进程,并将进程名加入到一个链表中, 最后应用层程序通过IOCTL读出驱动传递出来的数据. 驱动irp3.h文件: #include <ntddk.h> ...
- SSDTShadow Hook的实现,完整代码。可编译
原文连接:http://bbs.pediy.com/showthread.php?t=138747&highlight=inline+hook 转自看雪,写复制到自己博客上慢慢啃,呵呵 #in ...
- 内核下枚举进程 (二)ZwQuerySystemInformation
说明: SYSTEM_INFORMATION_CLASS 的5号功能枚举进程信息.其是这个函数对应着ring3下的 NtQuerySystemInformation,但msdn上说win8以后ZwQu ...
- 通过ntdll.dll提供的API函数实现当前进程的枚举
这种枚举的方法是通过ntdll.dll提供的API函数ZwQuery?SystemInformation()来实现,此方法比前面所提供的方法复杂一些, 下面提供实际的代码如下: #include &l ...
- 在NT系列操作系统里让自己“消失”
创建时间:2004-03-06 文章属性:原创 文章提交:SoBeIt (kinsephi_at_hotmail.com) ===================[ 在NT系列操作系统里让自己&quo ...
最新文章
- Linux:常用命令大全
- Spring Bean作用域实例
- 串口通讯基础及S3C2410 UART控制器
- 互联网日报 | 北斗三号全球卫星导航系统正式开通;拼多多上线首届“真香节”;海尔电器私有化草案出炉...
- ELK 原理部署过程
- KL散度的通俗易懂理解
- fragment嵌套viewpager嵌套fragment第二次加载数据不显示问题
- 爱上Ada语言与系统
- 【UVA10256】The Great Divide(凸包相离判定)
- ccs软件5.5安装
- Arcgis 安装教程
- 计算机无法添加本地策略组,解决win10找不到本地组策略和本地用户的方法
- python去重脚本
- React中文文档 9. 表单
- linux修改默认22端口失败,【原创文章】修改亚马逊AWS EC2 LINUX系统SSH默认22端口失败的原因和解决办法...
- canvas绘制飞线效果
- HashMap源码逐行分析
- dash live 播放
- 使用jenkins去gitlab拉取代码并部署到服务器
- mBio | 西北农林植保学院在真菌RNA编辑研究上取得新进展