函数ZwQuerySystemInformation枚举内核模块

发布时间:2013年11月20日 作者:未知 查看次数:2470

函数ZwQuerySystemInformation枚举内核模块


函数ZwQuerySystemInformation枚举内核模块

 

 

 

学习用函数ZwQuerySystemInformation枚举内核模块

 

.386

.model flat,stdcall

option casemap:none

 

include windows.inc

include kernel32.inc

include user32.inc

includelib kernel32.lib

includelib user32.lib

 

USHORT       typedef WORD

PWSTR         typedef DWORD

 

 

;typedef enum _SYSTEM_INFORMATION_CLASS {

                                                                   ; Query          Set

SystemBasicInformation                           equ 0  ;    Y        N

SystemProcessorInformation                    equ 1  ;    Y        N

SystemPerformanceInformation               equ 2  ;    Y        N

SystemTimeOfDayInformation                      equ 3  ;    Y        N

SystemNotImplemented1                          equ 4  ;    Y        N

SystemProcessesAndThreadsInformation      equ 5  ;    Y        N

SystemCallCounts                               equ 6  ;    Y        N

SystemConfigurationInformation             equ 7  ;    Y        N

SystemProcessorTimes                        equ 8  ;    Y        N

SystemGlobalFlag                               equ 9  ;    Y        Y

SystemNotImplemented2                          equ 10 ;    Y        N

SystemModuleInformation                       equ 11 ;    Y        N

SystemLockInformation                            equ 12 ;    Y        N

SystemNotImplemented3                          equ 13 ;    Y        N

SystemNotImplemented4                          equ 14 ;    Y        N

SystemNotImplemented5                          equ 15 ;    Y        N

SystemHandleInformation                        equ 16 ;    Y        N

SystemObjectInformation                         equ 17 ;    Y        N

SystemPagefileInformation                      equ 18 ;    Y        N

SystemInstructionEmulationCounts         equ 19 ;    Y        N

SystemInvalidInfoClass1                          equ 20

SystemCacheInformation                          equ 21 ;    Y        Y

SystemPoolTagInformation                      equ 22 ;    Y        N

SystemProcessorStatistics                   equ 23 ;    Y        N

SystemDpcInformation                        equ 24 ;    Y        Y

SystemNotImplemented6                          equ 25 ;    Y        N

SystemLoadImage                                     equ 26 ;    N        Y

SystemUnloadImage                                 equ 27 ;    N        Y

SystemTimeAdjustment                            equ 28 ;    Y        Y

SystemNotImplemented7                          equ 29 ;    Y        N

SystemNotImplemented8                          equ 30 ;    Y        N

SystemNotImplemented9                          equ 31 ;    Y        N

SystemCrashDumpInformation                      equ 32 ;    Y        N

SystemExceptionInformation                   equ 33 ;    Y        N

SystemCrashDumpStateInformation              equ 34 ;    Y        Y/N

SystemKernelDebuggerInformation               equ 35 ;    Y        N

SystemContextSwitchInformation            equ 36 ;    Y        N

SystemRegistryQuotaInformation            equ 37 ;    Y        Y

SystemLoadAndCallImage                       equ 38 ;    N        Y

SystemPrioritySeparation                    equ 39 ;    N        Y

SystemNotImplemented10                        equ 40 ;    Y        N

SystemNotImplemented11                        equ 41 ;    Y         N

SystemInvalidInfoClass2                          equ 42

SystemInvalidInfoClass3                          equ 43

SystemTimeZoneInformation                   equ 44 ;    Y        N

SystemLookasideInformation                   equ 45 ;    Y        N

SystemSetTimeSlipEvent                          equ 46 ;    N        Y

SystemCreateSession                                equ 47 ;    N        Y

SystemDeleteSession                                equ 48 ;    N        Y

SystemInvalidInfoClass4                          equ 49

SystemRangeStartInformation                  equ 50 ;    Y        N

SystemVerifierInformation                  equ 51 ;    Y        Y

SystemAddVerifier                              equ 52 ;    N        Y

SystemSessionProcessesInformation        equ 53 ;    Y        N

STATUS_INFO_LENGTH_MISMATCH      equ 0C0000004h

STATUS_SUCCESS      equ 0

 

MY_UNICODE_STRING STRUCT

      tLength USHORT <>     ;buffer的字节长度,不包括终止符“NULL

      MaximumLength USHORT <>      ;buffer的总的字节大小

      Buffer PWSTR ?      ;指向宽字符串的指针

MY_UNICODE_STRING ENDS

 

 

MY_VM_COUNTERS STRUCT

      PeakVirtualSize dd ?     ;虚拟存储峰值大小

      VirtualSize dd ?  ;虚拟存储大小

      PageFaultCount dd ?     ;页故障数目

      PeakWorkingSetSize dd ?   ;工作集峰值大小

      WorkingSetSize dd ?     ;工作集大小

      QuotaPeakPagedPoolUsage dd ?   ;分页池使用配额峰值

      QuotaPagedPoolUsage dd ?      ;分页池使用配额

      QuotaPeakNonPagedPoolUsage dd ?  ;非分页池使用配额峰值

      QuotaNonPagedPoolUsage dd ?    ;非分页池使用配额

      PagefileUsage dd ?        ;页文件使用情况

      PeakPagefileUsage dd ?           ;页文件使用峰值

MY_VM_COUNTERS ENDS

 

MY_IO_COUNTERS STRUCT

      ReadOperationCount LARGE_INTEGER <> ;I/O读操作数目

      WriteOperationCount LARGE_INTEGER <>     ;I/O写操作数目

      OtherOperationCount LARGE_INTEGER <>     ;I/O其他操作数目

      ReadTransferCount LARGE_INTEGER <>   ;I/O读数据数目

      WriteTransferCount LARGE_INTEGER <>  ;I/O写数据数目

      OtherTransferCount LARGE_INTEGER <>  ;I/O其他操作数据数目

MY_IO_COUNTERS ENDS

 

MY_CLIENT_ID STRUCT ; sizeof = 8

      UniqueProcess    HANDLE ?

      UniqueThread     HANDLE ?

MY_CLIENT_ID ENDS

 

MY_SYSTEM_THREADS STRUCT

      KernelTime LARGE_INTEGER <>    ;CPU内核模式使用时间;

      UserTime LARGE_INTEGER <>  ;CPU用户模式使用时间;

      CreateTime LARGE_INTEGER <>     ;线程创建时间;

      WaitTime dd ?               ;等待时间;

      StartAddress dd ?          ;线程开始的虚拟地址;

      ClientId MY_CLIENT_ID <>   ;线程标识符;

      Priority dd ?             ;线程优先级;

      BasePriority dd ?           ;基本优先级;

      ContextSwitchCount dd ?         ;环境切换数目;

      State db ?            ;当前状态;(THREAD_STATE)

      WaitReason db ?            ;等待原因;(KWAIT_REASON)

MY_SYSTEM_THREADS ENDS

 

;DQ(qword)

MY_SYSTEM_PROCESSES STRUCT

      NextEntryDelta dd ?           ;NextEntryOffset构成结构序列的偏移量

      ThreadCount dd ?          ;线程数目

      Reserved1 DWORD 6 dup(?)   ;

      CreateTime LARGE_INTEGER <>     ;创建时间

      UserTime LARGE_INTEGER <>  ;用户模式(Ring 3)的CPU时间

      KernelTime LARGE_INTEGER <>    ;内核模式(Ring 0)的CPU时间

      ProcessName MY_UNICODE_STRING <>   ;进程名称

      BasePriority dd ?           ;进程优先权

      ProcessId dd ?                ;进程标识符

      InheritedFromProcessId dd ?    ;父进程的标识符

      HandleCount dd ?          ;句柄数目

      Reserved2 DWORD 2 dup(?)   ;

      VmCounters MY_VM_COUNTERS <>   ;虚拟存储器的结构

      IoCounters MY_IO_COUNTERS <>  ;IO计数结构

      Threads MY_SYSTEM_THREADS <>    ;进程相关线程的结构

MY_SYSTEM_PROCESSES ENDS

 

.data?

hd_ntDll dd ?

h_ZwQuerySystemInformation dd ?

dwRtnFl dd ?

dwNeedSize dd ?

buffer db 50000h dup(?)           ;为了简单设足够大的存放空间

szShouBuf db 200 dup(?)

szTmpBuf db 100 dup(?)

 

.data

sz_ZwQuerySystemInformation db "ZwQuerySystemInformation",0

sz_ntDll db "ntdll.dll",0

szFormat1 db "[系统] %d - System Idle Process",0

szFormat2 db "[进程] %d - %d - %s",0

 

.code

myDebugShow2 proc uses esi edi ebx ecx edx tdebugEdx:DWORD

local tdbgBuf[100]:BYTE

      lea ebx,debugFmt2

      mov ecx,tdebugEdx

      invoke wsprintf,addr tdbgBuf,ebx,ecx

      lea ebx,debugWin2

      invoke MessageBox,0,addr tdbgBuf,ebx,0

      ret

debugFmt2 db "%x",0

debugWin2 db "测试",0

myDebugShow2 endp

 

start:

      invoke LoadLibrary,addr sz_ntDll

      .if eax!=0

           mov hd_ntDll,eax

           invoke GetProcAddress,hd_ntDll,addr sz_ZwQuerySystemInformation

           .if eax!=0

                 mov h_ZwQuerySystemInformation,eax

                 mov dwNeedSize,0

                 lea ebx,dwNeedSize

                 push ebx

                 push 0

                 push NULL

                 push SystemProcessesAndThreadsInformation

                 call h_ZwQuerySystemInformation               ;取实际需要的缓冲区大小到dwNeedSize中

                 mov dwRtnFl,eax

                 .if dwRtnFl==STATUS_INFO_LENGTH_MISMATCH

                      lea ebx,dwNeedSize

                      push ebx

                      mov ebx,dwNeedSize

                      push ebx

                      lea ebx,buffer

                      push ebx

                      push SystemProcessesAndThreadsInformation

                      call h_ZwQuerySystemInformation          ;检索指定的系统信息,这里是有关进程的信息

                      .if eax==STATUS_SUCCESS              ;返回成功

                            invoke myDebugShow2,100h

                            assume esi:ptr MY_SYSTEM_PROCESSES

                            lea esi,buffer

                            mov ecx,200

                            .while ecx>0

                                  push ecx

                                  push esi

                                  mov ebx,[esi].ProcessId

                                  mov szShouBuf[0],0

                                  .if ebx==0                 ;进程标识符为0的是System Idle Process,需手动标明(无进程名)

                                       invoke wsprintf,addr szShouBuf,addr szFormat1,ebx

                                  .else

                                       ;取进程名称(为Unicode转为ANSI)

                                       mov edx,0

                                       mov dx,[esi].ProcessName.tLength

                                       mov esi,[esi].ProcessName.Buffer

                                       mov ecx,edx

                                       mov szTmpBuf[0],0

                                       lea edi,szTmpBuf

                                       .while ecx>0

                                             .if byte ptr [esi]==0

                                                  .break

                                             .endif

                                             movsb

                                             inc esi

                                             dec ecx

                                             dec ecx

                                       .endw

                                       mov byte ptr [edi],0

                                       invoke wsprintf,addr szShouBuf,addr szFormat2,ebx,edx,addr szTmpBuf

                                  .endif

                                  invoke MessageBox,0,addr szShouBuf,0,0

                                  pop esi

                                  add esi,[esi].NextEntryDelta    ;指向下一个进程的信息

                                  pop ecx

                                  dec ecx

                                  .if [esi].NextEntryDelta==0

                                       .break

                                  .endif

                            .endw

                            assume esi:nothing

                      .else

                            invoke myDebugShow2,6

                      .endif

                      invoke myDebugShow2,dwNeedSize

                 .else

                      invoke myDebugShow2,5

                 .endif

           .else

                 invoke myDebugShow2,4

           .endif

      .else

           invoke myDebugShow2,3

      .endif

      invoke  ExitProcess,0

end start

 

 

参考以下资料:

http://zhan.renren.com/aczordia?gid=3602888498030659745&checked=true

该函数存在于NTDLL.DLL动态链接库中。NTDLL.DLL负责ring3与ring0之间的通信。当使用子系统方式进行系统调用的时候,ntdll.dll和SSDT会配合使用。关于SSDT技术以后会讲解到。

关于ZwQuerySystemInformation这个函数可以用来查询进程信息、内核信息、硬件信息(例如CPU数目)、句柄信息、时间信息等54个系统信息。

该函数的原型是

NTSTATUS WINAPI ZwQuerySystemInformation(

  __in          SYSTEM_INFORMATION_CLASS SystemInformationClass,

  __in_out     PVOID SystemInformation,

  __in          ULONG SystemInformationLength,

  __out_opt    PULONG ReturnLength

);

至于第一个参数SYSTEM_INFORMATION_CLASS是一个枚举结构。枚举了所有的54个系统信息。该结构在最后将会列举出来。

一、用户模式下的ZwQuerySystemInformation

在用户模式下必须用LoadLibrary与GetProcAddress来获取该函数地址。

代码如下,先声明一个函数。

typedef NTSTATUS (WINAPI *NTQUERYSYSTEMINFORMATION)(IN SYSTEM_INFORMATION_CLASS,IN OUT PVOID, INULONG, OUTPULONG);

加载NTDLL.DLL,获取函数地址。

NTQUERYSYSTEMINFORMATION ZwQuerySystemInformation = NULL;

ZwQuerySystemInformation = (NTQUERYSYSTEMINFORMATION)GetProcAddress(ntdll.dll,"ZwQuerySystemInformation");

举例:枚举进程信息

要想获取进程信息,必须使用第二个参数,第二个参数指向一块内存。必须使用参数1中每个系统信息对应的结构体来将该内存进行转换。

假设我们要枚举进程信息,必须使用下列结构,该结构描述了进程名,线程数,指向下一个模块的指针,创建时间等等。结构描述如下:(结构参考其它资料)

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;


 

图1 参数2指针指向的结构

PSYSTEM_PROCESSES psp=NULL;

        //先为参数2设为空,dwNeedSize获取保存该结构体的内存大小

        status = ZwQuerySystemInformation(SystemProcessesAndThreadsInformation,      NULL, 0, &dwNeedSize); 

       //若用户提供的缓冲//区大小不够,则返回STATUS_INFO_LENGTH_MISMATCH,并返回实际需要的缓冲区大小

        if ( status == STATUS_INFO_LENGTH_MISMATCH ) {  

            pBuffer = new BYTE[dwNeedSize];  

            status = ZwQuerySystemInformation(SystemProcessesAndThreadsInformation, (PVOID)pBuffer, dwNeedSize, NULL);  

            if ( status == STATUS_SUCCESS )  

            {  

                psp = (PSYSTEM_PROCESSES)pBuffer; //强制转换

                printf("PID  线程数工作集大小进程名\n");

                do {  

                    printf("%-4d", psp->ProcessId);

                    printf(" %3d", psp->ThreadCount);  

                    printf(" %8dKB", psp->VmCounters.WorkingSetSize/1024);

                    wprintf(L" %s\n", psp->ProcessName.Buffer);

                    psp = (PSYSTEM_PROCESSES)((ULONG)psp + psp->NextEntryDelta );  

                } while ( psp->NextEntryDelta != 0 ); //循环遍历

        }

        delete []pBuffer; 

        pBuffer = NULL; 

  }

二、内核模式下的ZwQuerySystemInformation

内核模式下的ZwQuerySystemInformation的地址的获取没有应用层那么麻烦。直接声明一下该函数即可。详细参见:http://www.2cto.com/kf/200901/31447.html

NTSYSAPI

NTSTATUS

NTAPI ZwQuerySystemInformation(

            IN ULONG SystemInformationClass,

            IN OUT PVOID SystemInformation,

            IN ULONG SystemInformationLength,

            OUT PULONG ReturnLength);

直接使用即可:

ZwQuerySystemInformation(SystemProcessesAndThreadsInformation,pBuffer, cbBuffer, NULL);

这是一个C代码程序,该程序是在ring3层写的,主要内容是获取CPU个数,枚举进程,枚举内核模块。该代码是从网上下载的,因为要用到这个函数,所以小小地研究了一下。

 地址:http://nokyo.blogbus.com/logs/33162795.html

SYSTEM_INFORMATION_CLASS枚举结构,大家有兴趣的话可以去好好研究。

typedef enum _SYSTEM_INFORMATION_CLASS  

 {   SystemBasicInformation,                 //  0 Y N  

    SystemProcessorInformation,             //  1 Y N  

    SystemPerformanceInformation,           //  2 Y N  

    SystemTimeOfDayInformation,             //  3 Y N  

    SystemNotImplemented1,                  //  4 Y N  

    SystemProcessesAndThreadsInformation,   //  5 Y N  

    SystemCallCounts,                       //  6 Y N  

    SystemConfigurationInformation,         //  7 Y N  

    SystemProcessorTimes,                   //  8 Y N  

    SystemGlobalFlag,                       //  9 Y Y  

    SystemNotImplemented2,                  // 10 Y N  

    SystemModuleInformation,                // 11 Y N  

    SystemLockInformation,                  // 12 Y N  

    SystemNotImplemented3,                  // 13 Y N  

    SystemNotImplemented4,                  // 14 Y N  

    SystemNotImplemented5,                  // 15 Y N  

    SystemHandleInformation,                // 16 Y N  

    SystemObjectInformation,                // 17 Y N  

    SystemPagefileInformation,              // 18 Y N  

    SystemInstructionEmulationCounts,       // 19 Y N  

    SystemInvalidInfoClass1,                // 20  

    SystemCacheInformation,                 // 21 Y Y  

    SystemPoolTagInformation,               // 22 Y N  

    SystemProcessorStatistics,              // 23 Y N  

    SystemDpcInformation,                   // 24 Y Y  

    SystemNotImplemented6,                  // 25 Y N  

    SystemLoadImage,                        // 26 N Y  

    SystemUnloadImage,                      // 27 N Y  

    SystemTimeAdjustment,                   // 28 Y Y  

    SystemNotImplemented7,                  // 29 Y N  

    SystemNotImplemented8,                  // 30 Y N  

    SystemNotImplemented9,                  // 31 Y N  

    SystemCrashDumpInformation,             // 32 Y N  

    SystemExceptionInformation,             // 33 Y N  

    SystemCrashDumpStateInformation,        // 34 Y Y/N  

    SystemKernelDebuggerInformation,        // 35 Y N  

    SystemContextSwitchInformation,         // 36 Y N  

    SystemRegistryQuotaInformation,       &, nbsp; // 37 Y Y  

    SystemLoadAndCallImage,                 // 38 N Y  

    SystemPrioritySeparation,               // 39 N Y  

    SystemNotImplemented10,                 // 40 Y N  

    SystemNotImplemented11,                 // 41 Y N  

    SystemInvalidInfoClass2,                // 42  

    SystemInvalidInfoClass3,                // 43  

    SystemTimeZoneInformation,              // 44 Y N  

    SystemLookasideInformation,             // 45 Y N  

    SystemSetTimeSlipEvent,                 // 46 N Y  

    SystemCreateSession,                    // 47 N Y  

    SystemDeleteSession,                    // 48 N Y  

    SystemInvalidInfoClass4,                // 49  

    SystemRangeStartInformation,            // 50 Y N  

    SystemVerifierInformation,              // 51 Y Y  

    SystemAddVerifier,                      // 52 N Y  

    SystemSessionProcessesInformation       // 53 Y N  

} SYSTEM_INFORMATION_CLASS;

 

 

------------------------------------------------------------------------------------------------------

有关结构类型的定义参考资料:

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;

 

 

typedef struct _SYSTEM_THREADS

{

        LARGE_INTEGER KernelTime;               //CPU内核模式使用时间;

        LARGE_INTEGER UserTime;                 //CPU用户模式使用时间;

        LARGE_INTEGER CreateTime;               //线程创建时间;

        ULONG         WaitTime;                 //等待时间;

        PVOID         StartAddress;             //线程开始的虚拟地址;

        CLIENT_ID     ClientId;                 //线程标识符;

        KPRIORITY     Priority;                 //线程优先级;

        KPRIORITY     BasePriority;             //基本优先级;

        ULONG         ContextSwitchCount;       //环境切换数目;

        THREAD_STATE  State;                    //当前状态;

        KWAIT_REASON  WaitReason;               //等待原因;

}SYSTEM_THREADS,*PSYSTEM_THREADS;

 

 

typedef struct _VM_COUNTERS

{

        ULONG PeakVirtualSize;                  //虚拟存储峰值大小;

        ULONG VirtualSize;                      //虚拟存储大小;

        ULONG PageFaultCount;                   //页故障数目;

        ULONG PeakWorkingSetSize;               //工作集峰值大小;

        ULONG WorkingSetSize;                   //工作集大小;

        ULONG QuotaPeakPagedPoolUsage;          //分页池使用配额峰值;

        ULONG QuotaPagedPoolUsage;              //分页池使用配额;

        ULONG QuotaPeakNonPagedPoolUsage;       //非分页池使用配额峰值;

        ULONG QuotaNonPagedPoolUsage;           //非分页池使用配额;

        ULONG PagefileUsage;                    //页文件使用情况;

        ULONG PeakPagefileUsage;                //页文件使用峰值;

}VM_COUNTERS,*PVM_COUNTERS;

 

typedef struct _IO_COUNTERS

{

        LARGE_INTEGER ReadOperationCount;       //I/O读操作数目;

        LARGE_INTEGER WriteOperationCount;      //I/O写操作数目;

        LARGE_INTEGER OtherOperationCount;      //I/O其他操作数目;

        LARGE_INTEGER ReadTransferCount;        //I/O读数据数目;

        LARGE_INTEGER WriteTransferCount;       //I/O写数据数目;

        LARGE_INTEGER OtherTransferCount;       //I/O其他操作数据数目;

}IO_COUNTERS,*PIO_COUNTERS;

以上这些信息应该是比较全面的了,在Win32 API里为我们提供了PSAPI(进程状态)和ToolHelp32这两种探测系统进程/线程信息的方式,在Windows2K/XP/2003都支持它们。

现在,我们来看看系统的性能信息,性能结构SYSTEM_PERFORMANCE_INFORMATION为我们提供了70余种系统性能方面的信息,真是太丰富了,请慢慢体会~

typedef struct _SYSTEM_PERFORMANCE_INFORMATION

{

        LARGE_INTEGER  IdleTime;                    //CPU空闲时间;

        LARGE_INTEGER  ReadTransferCount;           //I/O读操作数目;

        LARGE_INTEGER  WriteTransferCount;          //I/O写操作数目;

        LARGE_INTEGER  OtherTransferCount;          //I/O其他操作数目;

        ULONG          ReadOperationCount;          //I/O读数据数目;

        ULONG          WriteOperationCount;         //I/O写数据数目;

        ULONG          OtherOperationCount;         //I/O其他操作数据数目;

        ULONG          AvailablePages;              //可获得的页数目;

        ULONG          TotalCommittedPages;         //总共提交页数目;

        ULONG          TotalCommitLimit;            //已提交页数目;

        ULONG          PeakCommitment;              //页提交峰值;

        ULONG          PageFaults;                  //页故障数目;

        ULONG          WriteCopyFaults;             //Copy-On-Write故障数目;

        ULONG          TransitionFaults;            //软页故障数目;

        ULONG          Reserved1;

        ULONG          DemandZeroFaults;            //需求0故障数;

        ULONG          PagesRead;                   //读页数目;

        ULONG          PageReadIos;                 //读页I/O操作数;

        ULONG          Reserved2[2];

        ULONG          PagefilePagesWritten;        //已写页文件页数;

        ULONG          PagefilePageWriteIos;        //已写页文件操作数;

        ULONG          MappedFilePagesWritten;      //已写映射文件页数;

        ULONG          MappedFileWriteIos;          //已写映射文件操作数;

        ULONG          PagedPoolUsage;              //分页池使用;

        ULONG          NonPagedPoolUsage;           //非分页池使用;

        ULONG          PagedPoolAllocs;             //分页池分配情况;

        ULONG          PagedPoolFrees;              //分页池释放情况;

        ULONG          NonPagedPoolAllocs;          //非分页池分配情况;

        ULONG          NonPagedPoolFress;           //非分页池释放情况;

        ULONG          TotalFreeSystemPtes;         //系统页表项释放总数;

        ULONG          SystemCodePage;              //操作系统代码页数;

        ULONG          TotalSystemDriverPages;      //可分页驱动程序页数;

        ULONG          TotalSystemCodePages;        //操作系统代码页总数;

        ULONG          SmallNonPagedLookasideListAllocateHits; //小非分页侧视列表分配次数;

        ULONG          SmallPagedLookasideListAllocateHits;    //小分页侧视列表分配次数;

        ULONG          Reserved3;                  

        ULONG          MmSystemCachePage;          //系统缓存页数;

        ULONG          PagedPoolPage;              //分页池页数;

        ULONG          SystemDriverPage;           //可分页驱动页数;

        ULONG          FastReadNoWait;             //异步快速读数目;

        ULONG          FastReadWait;               //同步快速读数目;

        ULONG          FastReadResourceMiss;       //快速读资源冲突数;

        ULONG          FastReadNotPossible;        //快速读失败数;

        ULONG          FastMdlReadNoWait;          //异步MDL快速读数目;

        ULONG          FastMdlReadWait;            //同步MDL快速读数目;

        ULONG          FastMdlReadResourceMiss;    //MDL读资源冲突数;

        ULONG          FastMdlReadNotPossible;     //MDL读失败数;

        ULONG          MapDataNoWait;              //异步映射数据次数;

        ULONG          MapDataWait;                //同步映射数据次数;

        ULONG          MapDataNoWaitMiss;          //异步映射数据冲突次数;

        ULONG          MapDataWaitMiss;            //同步映射数据冲突次数;

        ULONG          PinMappedDataCount;         //牵制映射数据数目;

        ULONG          PinReadNoWait;              //牵制异步读数目;

        ULONG          PinReadWait;                //牵制同步读数目;

        ULONG          PinReadNoWaitMiss;          //牵制异步读冲突数目;

        ULONG          PinReadWaitMiss;            //牵制同步读冲突数目;

        ULONG          CopyReadNoWait;             //异步拷贝读次数;

        ULONG          CopyReadWait;               //同步拷贝读次数;

        ULONG          CopyReadNoWaitMiss;         //异步拷贝读故障次数;

        ULONG          CopyReadWaitMiss;           //同步拷贝读故障次数;

        ULONG          MdlReadNoWait;              //异步MDL读次数;

        ULONG          MdlReadWait;                //同步MDL读次数;

        ULONG          MdlReadNoWaitMiss;          //异步MDL读故障次数;

 

        ULONG          MdlReadWaitMiss;            //同步MDL读故障次数;

        ULONG          ReadAheadIos;               //向前读操作数目;

        ULONG          LazyWriteIos;               //LAZY写操作数目;

        ULONG          LazyWritePages;             //LAZY写页文件数目;

        ULONG          DataFlushes;                //缓存刷新次数;

        ULONG          DataPages;                  //缓存刷新页数;

        ULONG          ContextSwitches;            //环境切换数目;

        ULONG          FirstLevelTbFills;          //第一层缓冲区填充次数;

        ULONG          SecondLevelTbFills;         //第二层缓冲区填充次数;

        ULONG          SystemCall;                 //系统调用次数;

}SYSTEM_PERFORMANCE_INFORMATION,*PSYSTEM_PERFORMANCE_INFORMATION;

现在看到的是结构SYSTEM_PROCESSOR_TIMES提供的系统处理器的使用情况,包括各种情况下的使用时间及中断数目:

typedef struct __SYSTEM_PROCESSOR_TIMES

{

        LARGE_INTEGER IdleTime;               //空闲时间;

        LARGE_INTEGER KernelTime;             //内核模式时间;

        LARGE_INTEGER UserTime;               //用户模式时间;

        LARGE_INTEGER DpcTime;                //延迟过程调用时间;

        LARGE_INTEGER InterruptTime;          //中断时间;

        ULONG         InterruptCount;         //中断次数;

}SYSTEM_PROCESSOR_TIMES,*PSYSTEM_PROCESSOR_TIMES;

页文件的使用情况,SYSTEM_PAGEFILE_INFORMATION提供了所需的相关信息:

typedef struct _SYSTEM_PAGEFILE_INFORMATION

{

        ULONG NetxEntryOffset;                //下一个结构的偏移量;

        ULONG CurrentSize;                    //当前页文件大小;

        ULONG TotalUsed;                      //当前使用的页文件数;

        ULONG PeakUsed;                       //当前使用的页文件峰值数;

        UNICODE_STRING FileName;              //页文件的文件名称;

}SYSTEM_PAGEFILE_INFORMATION,*PSYSTEM_PAGEFILE_INFORMATION;

系统高速缓存的使用情况参见结构SYSTEM_CACHE_INFORMATION提供的信息:

typedef struct _SYSTEM_CACHE_INFORMATION

{

        ULONG SystemCacheWsSize;              //高速缓存大小;

        ULONG SystemCacheWsPeakSize;          //高速缓存峰值大小;

        ULONG SystemCacheWsFaults;            //高速缓存页故障数目;

        ULONG SystemCacheWsMinimum;           //高速缓存最小页大小;

        ULONG SystemCacheWsMaximum;           //高速缓存最大页大小;

        ULONG TransitionSharedPages;          //共享页数目;

        ULONG TransitionSharedPagesPeak;      //共享页峰值数目;

        ULONG Reserved[2];

}SYSTEM_CACHE_INFORMATION,*PSYSTEM_CACHE_INFORMATION;

 

 



版权所有!www.sieye.cn
E.Mail:sieye@sohu.com QQ:66697110