函数原型:
 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. 解析Spring第一天

    目的:了解spring框架中的注解 前言:同样是使用idea创建一个普通的maven工程(如何创建一个普通的Maven工程可以参考mybatis入门第一天的详解). 项目结构: 代码编辑: 在项目中引 ...

  2. C++ 俄罗斯方块

    #include <iostream> #include <string.h> #include <stdlib.h> #include <time.h> ...

  3. jmeter+ant+jenkins 搭建接口自动化测试环境

    过程参考:http://www.cnblogs.com/lxs1314/p/7487066.html 1. 安装ant 2. 安装jenkins 遇到问题: 启动Tomcat后,访问http://lo ...

  4. thingkphp 路由实例

    我们已经了解了如何定义路由规则,下面我们来举个例子加深印象. 假设我们定义了News控制器如下(代码实现仅供参考): namespace Home\Controller; use Think\Cont ...

  5. SpringCloud网关无法加载权限及IP黑名单白名单

    启动springcloud服务注册中心base,再启动网关远程调用base的接口读取权限等数据,控制台出现加载null权限ERROR提示.在远程调用处打断点,先进入代理,找到抛出异常的原因是reque ...

  6. jquery学习笔记(一):选择器

    内容来自[汇智网]jquery学习课程 1.1 基础选择器 选择器 功能 返回值 #id 根据给定的id匹配一个元素 单个元素 element 根据给定的元素名匹配所有元素 元素集合 .class 根 ...

  7. System.Web.Mvc.JavaScriptResult.cs

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

  8. 全面理解python中self的用法

    self代表类的实例,而非类. class Test: def prt(self): print(self) print(self.__class__) t = Test() t.prt() 执行结果 ...

  9. Android开发 StateListDrawable详解

    前言 StateListDrawable是与xml中的selector属性对应代码实现类,它需要配合GradientDrawable的使用,如果你还不了解GradientDrawable可以参考我的另 ...

  10. ie中报错---不能执行已释放 Script 的代码

    我的原因:使用jquery.colorbox.js.在页面中使用弹框,对于父页面中的变量进行修改(弹框页面的js--window.parent.obj.arr= 数组;), 当弹框关闭之后,在父页面中 ...