原文发表于百度空间,2008-7-31
==========================================================================
前面已经通过遍历活动进程双链,来得到一个进程列表.
但是,这个链表中有些进程其实是已经退出的进程.
因此,在得到一个EPROCESS之后,必须对其进行识别,判断其是否已经退出.
通过对一死一活两个进程的EPROCESS的对比,发现以下标志可以用作判断进程是否退出的标准.
这是已经退出的IceSword的EPROCESS
lkd> dt _EPROCESS FDCE6518
nt!_EPROCESS
+0x000 Pcb : _KPROCESS
+0x06c ProcessLock : _EX_PUSH_LOCK
+0x070 CreateTime : _LARGE_INTEGER 0x1c8f265`a3f26690
+0x078 ExitTime : _LARGE_INTEGER 0x1c8f265`c12e5c1e //不为0
+0x080 RundownProtect : _EX_RUNDOWN_REF
+0x084 UniqueProcessId : 0x00000934
+0x088 ActiveProcessLinks : _LIST_ENTRY [ 0x814c9a08 - 0x813370b8 ]
+0x090 QuotaUsage : [3] 0
+0x09c QuotaPeak : [3] 0x1578
+0x0a8 CommitCharge : 0
+0x0ac PeakVirtualSize : 0x2fa8000
+0x0b0 VirtualSize : 0x230d000
+0x0b4 SessionProcessLinks : _LIST_ENTRY [ 0xf89b9014 - 0x813370e4 ]
+0x0bc DebugPort : (null)
+0x0c0 ExceptionPort : 0xe15bf1d8
+0x0c4 ObjectTable : (null) //为NULL
+0x0c8 Token : _EX_FAST_REF
+0x0cc WorkingSetLock : _FAST_MUTEX
+0x0ec WorkingSetPage : 0x19c5c
+0x0f0 AddressCreationLock : _FAST_MUTEX
+0x110 HyperSpaceLock : 0
+0x114 ForkInProgress : (null)
+0x118 HardwareTrigger : 0
+0x11c VadRoot : (null) //为NULL
+0x120 VadHint : (null) //为NULL
+0x124 CloneRoot : (null)
+0x128 NumberOfPrivatePages : 0 //为NULL
+0x12c NumberOfLockedPages : 0
+0x130 Win32Process : (null)
+0x134 Job : (null)
+0x138 SectionObject : (null) //为NULL
+0x13c SectionBaseAddress : 0x00400000
+0x140 QuotaBlock : 0x816f87c8 _EPROCESS_QUOTA_BLOCK
+0x144 WorkingSetWatch : (null)
+0x148 Win32WindowStation : 0x00000024
+0x14c InheritedFromUniqueProcessId : 0x000005e8
+0x150 LdtInformation : (null)
+0x154 VadFreeHint : (null)
+0x158 VdmObjects : (null)
+0x15c DeviceMap : 0xe26c13a0
+0x160 PhysicalVadList : _LIST_ENTRY [ 0xfdce6678 - 0xfdce6678 ]
+0x168 PageDirectoryPte : _HARDWARE_PTE
+0x168 Filler : 0
+0x170 Session : 0xf89b9000
+0x174 ImageFileName : [16] "IceSword.exe"
+0x184 JobLinks : _LIST_ENTRY [ 0x0 - 0x0 ]
+0x18c LockedPagesList : (null)
+0x190 ThreadListHead : _LIST_ENTRY [ 0xfdce66a8 - 0xfdce66a8 ]
+0x198 SecurityPort : (null)
+0x19c PaeTop : (null)
+0x1a0 ActiveThreads : 0 //为0
+0x1a4 GrantedAccess : 0x1f0fff
+0x1a8 DefaultHardErrorProcessing : 0x8000
+0x1ac LastThreadExitStatus : 0
+0x1b0 Peb : 0x7ffdf000 _PEB
+0x1b4 PrefetchTrace : _EX_FAST_REF
+0x1b8 ReadOperationCount : _LARGE_INTEGER 0xc2
+0x1c0 WriteOperationCount : _LARGE_INTEGER 0x5
+0x1c8 OtherOperationCount : _LARGE_INTEGER 0x3875
+0x1d0 ReadTransferCount : _LARGE_INTEGER 0x38ecb2
+0x1d8 WriteTransferCount : _LARGE_INTEGER 0x33cd5
+0x1e0 OtherTransferCount : _LARGE_INTEGER 0x93d458
+0x1e8 CommitChargeLimit : 0
+0x1ec CommitChargePeak : 0x861
+0x1f0 AweInfo : (null)
+0x1f4 SeAuditProcessCreationInfo : _SE_AUDIT_PROCESS_CREATION_INFO
+0x1f8 Vm : _MMSUPPORT
+0x238 LastFaultCount : 0
+0x23c ModifiedPageCount : 0xcd
+0x240 NumberOfVads : 0
+0x244 JobStatus : 0
+0x248 Flags : 0xc082c
+0x248 CreateReported : 0y0
+0x248 NoDebugInherit : 0y0
+0x248 ProcessExiting : 0y1 //为1
+0x248 ProcessDelete : 0y1 //为1
+0x248 Wow64SplitPages : 0y0
+0x248 VmDeleted : 0y1 //为1
+0x248 OutswapEnabled : 0y0
+0x248 Outswapped : 0y0
+0x248 ForkFailed : 0y0
+0x248 HasPhysicalVad : 0y0
+0x248 AddressSpaceInitialized : 0y10
+0x248 SetTimerResolution : 0y0
+0x248 BreakOnTermination : 0y0
+0x248 SessionCreationUnderway : 0y0
+0x248 WriteWatch : 0y0
+0x248 ProcessInSession : 0y0 //为0
+0x248 OverrideAddressSpace : 0y0
+0x248 HasAddressSpace : 0y1
+0x248 LaunchPrefetched : 0y1
+0x248 InjectInpageErrors : 0y0
+0x248 VmTopDown : 0y0
+0x248 Unused3 : 0y0
+0x248 Unused4 : 0y0
+0x248 VdmAllowed : 0y0
+0x248 Unused : 0y00000 (0)
+0x248 Unused1 : 0y0
+0x248 Unused2 : 0y0
+0x24c ExitStatus : 0
+0x250 NextPageColor : 0x4752
+0x252 SubSystemMinorVersion : 0 ''
+0x253 SubSystemMajorVersion : 0x4 ''
+0x252 SubSystemVersion : 0x400
+0x254 PriorityClass : 0x2 ''
+0x255 WorkingSetAcquiredUnsafe : 0 ''
+0x258 Cookie : 0xf02d7ae4
以上标志大部分都可以可靠地用作识别的标志,通常使用ObjectTable的指针是否为NULL来判断进程是否已经退出.由些也可以知道,Idle进程比较特殊,也是一个ObjectTable为NULL的死进程,但其ExitTime却为0(即没有退出),看来要遍历进程做判断的话,还是用ObjectTable比较可靠些.