天马阁

 找回密码
 立即注册
                                        →→→→→→→→→→→→ 1点击查看所有VIP教程目录长列表(总教程数269个) 2办理VIP详情进入 ←←←←←←←←←←←←
1 x64CE与x64dbg入门基础教程 7课 已完结 2 x64汇编语言基础教程 16课 已完结 3 x64辅助入门基础教程 9课 已完结 4 C++x64内存辅助实战技术教程 149课 已完结
5 C++x64内存检测与过检测技术教程 10课 已完结 6 C+x64二叉树分析遍历与LUA自动登陆教程 19课已完结 7 C++BT功能原理与x64实战教程 29课 已完结 8 C+FPS框透视与自瞄x64实现原理及防护思路 30课完结
64驱?封? 9 64反驱? 10 64位V? 11 绝? 12 ???课?
13 64透 ? 14 64U ? 15 64Q ? 16 64功 ?
17 64U ? 18 64模 ? 19 64多 ? 20 64网 ?
21 64注 ? 22 64火 ? 23 64棋 ? 24 64自二链L?
25 64破 ? VIP会员办理QQ: 89986068   
【请先加好友,然后到好友列表双击联系客服办理,不然可能无法接受到信息。】
27 加入2000人交流群637034024 3 28 免责声明?
查看: 1201|回复: 0

在驱动里面枚举进程列表源码

[复制链接]

15

主题

0

回帖

18

积分

编程入门

Rank: 1

天马币
30
发表于 2024-3-11 13:25:42 | 显示全部楼层 |阅读模式
typedef enum _SYSTEM_INFORMATION_CLASS {  
    SystemBasicInformation,                 // 0  
    SystemProcessorInformation,             // 1  
    SystemPerformanceInformation,           // 2
    SystemTimeOfDayInformation,             // 3
    SystemNotImplemented1,              // 4
    SystemProcessesAndThreadsInformation,       // 5
    SystemCallCounts,                   // 6
    SystemConfigurationInformation,             // 7
    SystemProcessorTimes,               // 8
    SystemGlobalFlag,                   // 9
    SystemNotImplemented2,              // 10
    SystemModuleInformation,                // 11
    SystemLockInformation,              // 12
    SystemNotImplemented3,              // 13
    SystemNotImplemented4,              // 14
    SystemNotImplemented5,              // 15
    SystemHandleInformation,                // 16
    SystemObjectInformation,                // 17
    SystemPagefileInformation,              // 18
    SystemInstructionEmulationCounts,           // 19
    SystemInvalidInfoClass1,                // 20
    SystemCacheInformation,                 // 21
    SystemPoolTagInformation,               // 22
    SystemProcessorStatistics,              // 23
    SystemDpcInformation,               // 24
    SystemNotImplemented6,              // 25
    SystemLoadImage,                    // 26
    SystemUnloadImage,              // 27
    SystemTimeAdjustment,               // 28
    SystemNotImplemented7,              // 29
    SystemNotImplemented8,              // 30
    SystemNotImplemented9,              // 31
    SystemCrashDumpInformation,             // 32
    SystemExceptionInformation,             // 33
    SystemCrashDumpStateInformation,            // 34
    SystemKernelDebuggerInformation,            // 35
    SystemContextSwitchInformation,             // 36
    SystemRegistryQuotaInformation,             // 37
    SystemLoadAndCallImage,                 // 38
    SystemPrioritySeparation,               // 39
    SystemNotImplemented10,                 // 40
    SystemNotImplemented11,                 // 41
    SystemInvalidInfoClass2,                // 42
    SystemInvalidInfoClass3,                // 43
    SystemTimeZoneInformation,              // 44
    SystemLookasideInformation,             // 45
    SystemSetTimeSlipEvent,                 // 46
    SystemCreateSession,                // 47
    SystemDeleteSession,                // 48
    SystemInvalidInfoClass4,                // 49
    SystemRangeStartInformation,            // 50
    SystemVerifierInformation,              // 51
    SystemAddVerifier,              // 52
    SystemSessionProcessesInformation           // 53
} SYSTEM_INFORMATION_CLASS;

//查询系统信息的nt服务函数
NTSTATUS ZwQuerySystemInformation(
                         IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
                         OUT PVOID SystemInformation,
                         IN ULONG SystemInformationLength,
                         OUT PULONG ReturnLength OPTIONAL
                         );
//在驱动里面枚举进程列表
VOID EnumProcess()
{
    //初始化大小
    ULONG ulSize = 0x1000;
    PVOID pBuffer;
    NTSTATUS status;
    //保存进程信息的结构体指针
    PSYSTEM_PROCESS_INFORMATION pSystemProcessInformation;
    //循环
    do
    {
        pBuffer = ExAllocatePool (NonPagedPool, ulSize);
        status = ZwQuerySystemInformation(SystemProcessesAndThreadsInformation, pBuffer, ulSize, NULL);
        //如果缓冲区空间过小
        if (status == STATUS_INFO_LENGTH_MISMATCH)
        {
            ExFreePool(pBuffer);
            //以2倍于自身的大小增长
            ulSize=ulSize*2;
        }
    }
    while (status == STATUS_INFO_LENGTH_MISMATCH);
    //指针类型转换
    pSystemProcessInformation = (PSYSTEM_PROCESS_INFORMATION)pBuffer;
    //遍历列表
    for (;;)  
    {
        //在这里打印
        DbgPrint("pid %d ps %S\n",pSystemProcessInformation->ProcessId,pSystemProcessInformation->ProcessName.Buffer);
        //如果下一个节点指针为空,则跳出循环
        if (pSystemProcessInformation->NextEntryDelta == 0)  
            break;  
        //移动指针到下一个节点处
        pSystemProcessInformation = (PSYSTEM_PROCESS_INFORMATION)(((PUCHAR)pSystemProcessInformation)+ pSystemProcessInformation->NextEntryDelta);  
    }
    //最后释放
    ExFreePool(pBuffer);
}

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

天马阁|C/C++辅助教程|安卓逆向安全| 论坛导航|免责申明|Archiver||网站地图
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表天马阁立场!
任何人不得以任何方式翻录、盗版或出售本站视频,一经发现我们将追究其相关责任!
我们一直在努力成为最好的编程论坛!
Copyright© 2010-2021 All Right Reserved.
快速回复 返回顶部 返回列表