函数原型:
 NTSTATUS WINAPI NtQuerySystemInformation(
    _In_      SYSTEM_INFORMATION_CLASS SystemInformationClass,
    _Inout_   PVOID                    SystemInformation,
    _In_      ULONG                    SystemInformationLength,
    _Out_opt_ PULONG                   ReturnLength
    );

该函数未文档化,再ntdll.dll 中导出,
SYSTEM_INFORMATION_CLASS为要查询信息的类型,是一个枚举型的,其他参数不说了。
简单举一例说明。
这里我们要枚举的是SystemProcessInformation信息,
先看一下该结构体:
typedef struct _SYSTEM_PROCESS_INFORMATION {
    ULONG NextEntryOffset;      //下一个结构的偏移量,最后一个偏移量为0
    ULONG NumberOfThreads;
    LARGE_INTEGER SpareLi1;
    LARGE_INTEGER SpareLi2;
    LARGE_INTEGER SpareLi3;
    LARGE_INTEGER CreateTime;
    LARGE_INTEGER UserTime;
    LARGE_INTEGER KernelTime;
    UNICODE_STRING ImageName;     //进程名
    KPRIORITY BasePriority;
    HANDLE UniqueProcessId;               //进程ID
    HANDLE InheritedFromUniqueProcessId;   //父进程ID
    ULONG HandleCount;
    ULONG SessionId;       //会话ID                    
    ULONG_PTR PageDirectoryBase;
    SIZE_T PeakVirtualSize;
    SIZE_T VirtualSize;
    ULONG PageFaultCount;
    SIZE_T PeakWorkingSetSize;
    SIZE_T WorkingSetSize;
    SIZE_T QuotaPeakPagedPoolUsage;
    SIZE_T QuotaPagedPoolUsage;
    SIZE_T QuotaPeakNonPagedPoolUsage;
    SIZE_T QuotaNonPagedPoolUsage;
    SIZE_T PagefileUsage;
    SIZE_T PeakPagefileUsage;
    SIZE_T PrivatePageCount;
    LARGE_INTEGER ReadOperationCount;
    LARGE_INTEGER WriteOperationCount;
    LARGE_INTEGER OtherOperationCount;
    LARGE_INTEGER ReadTransferCount;
    LARGE_INTEGER WriteTransferCount;
    LARGE_INTEGER OtherTransferCount;
} SYSTEM_PROCESS_INFORMATION, *PSYSTEM_PROCESS_INFORMATION;

#include "stdafx.h"
#include <Windows.h>
#include <winternl.h>
using namespace std; typedef NTSTATUS (WINAPI *PFUN_NtQuerySystemInformation)(
_In_ SYSTEM_INFORMATION_CLASS SystemInformationClass,
_Inout_ PVOID SystemInformation,
_In_ ULONG SystemInformationLength,
_Out_opt_ PULONG ReturnLength
);
int _tmain(int argc, _TCHAR* argv[])
{
PFUN_NtQuerySystemInformation pFun = NULL;
pFun = (PFUN_NtQuerySystemInformation)GetProcAddress(GetModuleHandle(L"ntdll.dll"), "NtQuerySystemInformation"); char szInfo[0x20000] = { 0 };
ULONG uReturnedLEngth = 0;
NTSTATUS status = pFun(SystemProcessInformation, szInfo, sizeof(szInfo), &uReturnedLEngth);
if (status != 0)
return 0;
PSYSTEM_PROCESS_INFORMATION pSystemInformation = (PSYSTEM_PROCESS_INFORMATION)szInfo;
DWORD dwID = (DWORD)pSystemInformation->UniqueProcessId;
HANDLE hHandle = NULL;
PWCHAR pImageName = (PWCHAR)*(DWORD*)((PCHAR)pSystemInformation + 0x3c);
printf("ProcessID: %d\tprocessName: %ws \n", dwID, pImageName);
while (true)
{
if (pSystemInformation->NextEntryOffset == 0)
break; pSystemInformation = (PSYSTEM_PROCESS_INFORMATION)((PCHAR)pSystemInformation + pSystemInformation->NextEntryOffset);
dwID = (DWORD)pSystemInformation->UniqueProcessId;
hHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, dwID);
pImageName = (PWCHAR)*(DWORD*)((PCHAR)pSystemInformation + 0x3c);
printf("ProcessID: %d\tprocessName: %ws \n", dwID, pImageName);
}
getchar();
} 结果如下:

NtQuerySystemInformation 枚举进程的更多相关文章

  1. 内核下枚举进程 (二)ZwQuerySystemInformation

    说明: SYSTEM_INFORMATION_CLASS 的5号功能枚举进程信息.其是这个函数对应着ring3下的 NtQuerySystemInformation,但msdn上说win8以后ZwQu ...

  2. NtQuerySystemInformation的使用(提供50余种信息)

    今天,我们主要讨论的是一个函数NtQuerySystemInformation(ZwQuerySystemInformation).当然,你不要小看这么一个函数,它却为我们提供了丰富的系统信息,同时还 ...

  3. delphi中获得进程列表或想要的进程(枚举进程、遍历进程)

    一个常见的编程任务是枚举所有运行的"应用程序".Windows 任务管理器就是一个很好的例子.它用两种方式列出"应用程序".任务管理器的第一个选项卡列出桌面上的 ...

  4. ZwQueryVirtualMemory枚举进程模块

    ZwQueryVirtualMemory算是枚举进程方法中的黑科技吧,主要是该方法可以检测出隐藏的模块(类似IceSword). 代码VS2015测试通过 再次奉上源码链接:https://githu ...

  5. 利用NtQuerySystemInformation函数遍历进程,遍历线程,获取线程挂起或运行状态

    版权声明:专注于计算机网络安全学习 https://blog.csdn.net/u011672712/article/details/51586030 1 2 3 4 5 6 7 8 9 10 11 ...

  6. ZwQueryVirtualMemory暴力枚举进程模块

    0x01 前言 同学问过我进程体中EPROCESS的三条链断了怎么枚举模块,这也是也腾讯面试题.我当时听到也是懵逼的. 后来在网上看到了一些内存暴力枚举的方法ZwQueryVirtualMemory. ...

  7. NtQuerySystemInformation

    #include "stdafx.h" #include <Windows.h> #include <winternl.h> using namespace ...

  8. 枚举进程,线程,堆 CreateToolhelp32Snapshot

    Takes a snapshot of the processes and the heaps, modules, and threads used by the processes.对当前系统进行一 ...

  9. NtQuerySystemInformation获取进程/线程状态

    __kernel_entry NTSTATUS NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS SystemInformationClass, P ...

随机推荐

  1. redis笔记_源码_字典dict

    参考:https://redissrc.readthedocs.io/en/latest/datastruct/dict.html Expand: 条件: 新的table 大小: Rehash: 条件 ...

  2. 【JZOJ6360】最大菱形和(rhombus)

    description analysis 容易想到把原矩阵翻转\(45°\),然后每个数再用\(0\)隔开 然后就变成了求最大子正方形,求完二维前缀和之后就很好做了 code #pragma GCC ...

  3. day23 内置函数,匿名函数,递归

    Python之路,Day11 = Python基础11 内置函数divmod(x, y)   # (商, 模)enumerate(可迭代对象)     # (序号,值)eval(字符串) # 把字符串 ...

  4. luoguP3414 SAC#1 - 组合数

    题目背景 本题由世界上最蒟蒻最辣鸡最撒比的SOL提供. 寂月城网站是完美信息教室的官网.地址:http://191.101.11.174/mgzd . 题目描述 辣鸡蒟蒻SOL是一个傻逼,他居然觉得数 ...

  5. 0910CSP-S模拟测试赛后总结

    %%%外校参加国赛大佬kai神-rank1 ---------------以上选手实力开挂---------------- %%%skyh.NC锅-rank2 %%%神牛170-rank4 %%%迪哥 ...

  6. python封装email模块

    一.代码 from email.mime.text import MIMEText from email.header import Header from email.utils import pa ...

  7. Kmeans算法实现

    下面的demo是根据kmeans算法原理实现的demo,使用到的数据是kmeans.txt 1.658985 4.285136 -3.453687 3.424321 4.838138 -1.15153 ...

  8. System.Web.Mvc.JavaScriptResult.cs

    ylbtech-System.Web.Mvc.JavaScriptResult.cs 1.程序集 System.Web.Mvc, Version=5.2.3.0, Culture=neutral, P ...

  9. iOS开发NSLayoutConstraint代码自动布局

    1.NSLayoutConstraint简介 适配界面大多用Masonry工具,也是基于NSLayoutConstraint写的!通过使用两个类方法实现自动布局: + (NSArray<__ki ...

  10. python语句结构(range函数)

    python语句结构(range函数) range()函数 如果你需要遍历数字序列,可以使用内置range()函数,它会生成序列 也可以通过range()函数指定序列的区间 也可以使用range()函 ...