_Trap_Frame
无论3环是中断门还是systementer进入0环,3环的寄存器都会寄存在_Trap_Frame结构体中,结构体如下:
具体参考如下
ETHREAD
每个线程有一个ETHREAD结构体,该结构体保存了线程的状态
kd> dt _ETHREAD
ntdll!_ETHREAD
+0x000 Tcb : _KTHREAD
+0x1c0 CreateTime : _LARGE_INTEGER
+0x1c0 NestedFaultCount : Pos 0, 2 Bits
+0x1c0 ApcNeeded : Pos 2, 1 Bit
+0x1c8 ExitTime : _LARGE_INTEGER
+0x1c8 LpcReplyChain : _LIST_ENTRY
+0x1c8 KeyedWaitChain : _LIST_ENTRY
+0x1d0 ExitStatus : Int4B
+0x1d0 OfsChain : Ptr32 Void
+0x1d4 PostBlockList : _LIST_ENTRY
+0x1dc TerminationPort : Ptr32 _TERMINATION_PORT
+0x1dc ReaperLink : Ptr32 _ETHREAD
+0x1dc KeyedWaitValue : Ptr32 Void
+0x1e0 ActiveTimerListLock : Uint4B
+0x1e4 ActiveTimerListHead : _LIST_ENTRY
+0x1ec Cid : _CLIENT_ID
+0x1f4 LpcReplySemaphore : _KSEMAPHORE
+0x1f4 KeyedWaitSemaphore : _KSEMAPHORE
+0x208 LpcReplyMessage : Ptr32 Void
+0x208 LpcWaitingOnPort : Ptr32 Void
+0x20c ImpersonationInfo : Ptr32 _PS_IMPERSONATION_INFORMATION
+0x210 IrpList : _LIST_ENTRY
+0x218 TopLevelIrp : Uint4B
+0x21c DeviceToVerify : Ptr32 _DEVICE_OBJECT
+0x220 ThreadsProcess : Ptr32 _EPROCESS //当前线程所属进程,该进程创建了该线程。
+0x224 StartAddress : Ptr32 Void
+0x228 Win32StartAddress : Ptr32 Void
+0x228 LpcReceivedMessageId : Uint4B
+0x22c ThreadListEntry : _LIST_ENTRY
+0x234 RundownProtect : _EX_RUNDOWN_REF
+0x238 ThreadLock : _EX_PUSH_LOCK
+0x23c LpcReplyMessageId : Uint4B
+0x240 ReadClusterSize : Uint4B
+0x244 GrantedAccess : Uint4B
+0x248 CrossThreadFlags : Uint4B
+0x248 Terminated : Pos 0, 1 Bit
+0x248 DeadThread : Pos 1, 1 Bit
+0x248 HideFromDebugger : Pos 2, 1 Bit
+0x248 ActiveImpersonationInfo : Pos 3, 1 Bit
+0x248 SystemThread : Pos 4, 1 Bit
+0x248 HardErrorsAreDisabled : Pos 5, 1 Bit
+0x248 BreakOnTermination : Pos 6, 1 Bit
+0x248 SkipCreationMsg : Pos 7, 1 Bit
+0x248 SkipTerminationMsg : Pos 8, 1 Bit
+0x24c SameThreadPassiveFlags : Uint4B
+0x24c ActiveExWorker : Pos 0, 1 Bit
+0x24c ExWorkerCanWaitUser : Pos 1, 1 Bit
+0x24c MemoryMaker : Pos 2, 1 Bit
+0x250 SameThreadApcFlags : Uint4B
+0x250 LpcReceivedMsgIdValid : Pos 0, 1 Bit
+0x250 LpcExitThreadCalled : Pos 1, 1 Bit
+0x250 AddressSpaceOwner : Pos 2, 1 Bit
+0x254 ForwardClusterOnly : UChar
+0x255 DisablePageFaultClustering : UChar
KTHREAD结构体如下
kd> dt _KTHREAD
ntdll!_KTHREAD
+0x000 Header : _DISPATCHER_HEADER
+0x010 MutantListHead : _LIST_ENTRY
+0x018 InitialStack : Ptr32 Void
+0x01c StackLimit : Ptr32 Void
+0x020 Teb : Ptr32 Void
+0x024 TlsArray : Ptr32 Void
+0x028 KernelStack : Ptr32 Void
+0x02c DebugActive : UChar
+0x02d State : UChar
+0x02e Alerted : [2] UChar
+0x030 Iopl : UChar
+0x031 NpxState : UChar
+0x032 Saturation : Char
+0x033 Priority : Char
+0x034 ApcState : _KAPC_STATE
ntdll!_KAPC_STATE
+0x000 ApcListHead : [2] _LIST_ENTRY
+0x010 Process : Ptr32 _KPROCESS //指向当前线程所属进程,该进程为该线程提供Cr3
+0x014 KernelApcInProgress : UChar
+0x015 KernelApcPending : UChar
+0x016 UserApcPending : UChar
+0x04c ContextSwitches : Uint4B
+0x050 IdleSwapBlock : UChar
+0x051 Spare0 : [3] UChar
+0x054 WaitStatus : Int4B
+0x058 WaitIrql : UChar
+0x059 WaitMode : Char
+0x05a WaitNext : UChar
+0x05b WaitReason : UChar
+0x05c WaitBlockList : Ptr32 _KWAIT_BLOCK
+0x060 WaitListEntry : _LIST_ENTRY
+0x060 SwapListEntry : _SINGLE_LIST_ENTRY
+0x068 WaitTime : Uint4B
+0x06c BasePriority : Char
+0x06d DecrementCount : UChar
+0x06e PriorityDecrement : Char
+0x06f Quantum : Char
+0x070 WaitBlock : [4] _KWAIT_BLOCK
+0x0d0 LegoData : Ptr32 Void
+0x0d4 KernelApcDisable : Uint4B
+0x0d8 UserAffinity : Uint4B
+0x0dc SystemAffinityActive : UChar
+0x0dd PowerState : UChar
+0x0de NpxIrql : UChar
+0x0df InitialNode : UChar
+0x0e0 ServiceTable : Ptr32 Void
+0x0e4 Queue : Ptr32 _KQUEUE
+0x0e8 ApcQueueLock : Uint4B
+0x0f0 Timer : _KTIMER
+0x118 QueueListEntry : _LIST_ENTRY
+0x120 SoftAffinity : Uint4B
+0x124 Affinity : Uint4B
+0x128 Preempted : UChar
+0x129 ProcessReadyQueue : UChar
+0x12a KernelStackResident : UChar
+0x12b NextProcessor : UChar
+0x12c CallbackStack : Ptr32 Void
+0x130 Win32Thread : Ptr32 Void
+0x134 TrapFrame : Ptr32 _KTRAP_FRAME
+0x138 ApcStatePointer : [2] Ptr32 _KAPC_STATE
+0x140 PreviousMode : Char
+0x141 EnableStackSwap : UChar
+0x142 LargeStack : UChar
+0x143 ResourceIndex : UChar
+0x144 KernelTime : Uint4B
+0x148 UserTime : Uint4B
+0x14c SavedApcState : _KAPC_STATE
+0x164 Alertable : UChar
+0x165 ApcStateIndex : UChar
+0x166 ApcQueueable : UChar
+0x167 AutoAlignment : UChar
+0x168 StackBase : Ptr32 Void
+0x16c SuspendApc : _KAPC
+0x19c SuspendSemaphore : _KSEMAPHORE
+0x1b0 ThreadListEntry : _LIST_ENTRY
+0x1b8 FreezeCount : Char
+0x1b9 SuspendCount : Char
+0x1ba IdealProcessor : UChar
+0x1bb DisableBoost : UChar
KPCR
KPCR叫CPU控制区(Processor Control Region)
(1)线程进入0环,fs:[0]指向KPCR。(3环时,fs:[0]指向TEB)
(2)每个CPU都有一个KPCR结构体,一个核一个。
(3)KPCR中存储了CPU本身要用的一些重要数据,如GDT、IDT等
KPCR结构体如下:
KPCR结构体如下
nt!_KPCR
+0x000 NtTib : _NT_TIB
ntdll!_NT_TIB
+0x000 ExceptionList : Ptr32 _EXCEPTION_REGISTRATION_RECORD //0环的异常处理函数
+0x004 StackBase : Ptr32 Void //当前线程栈底
+0x008 StackLimit : Ptr32 Void //当前线程栈限
+0x00c SubSystemTib : Ptr32 Void
+0x010 FiberData : Ptr32 Void
+0x010 Version : Uint4B
+0x014 ArbitraryUserPointer : Ptr32 Void
+0x018 Self : Ptr32 _NT_TIB //指向 _NT_TIB结构体自身,编程方便
+0x01c SelfPcr : Ptr32 _KPCR //指向当前_KPCR结构体自身
+0x020 Prcb : Ptr32 _KPRCB //指向_KPRCB子结构体
+0x024 Irql : UChar
+0x028 IRR : Uint4B
+0x02c IrrActive : Uint4B
+0x030 IDR : Uint4B
+0x034 KdVersionBlock : Ptr32 Void
+0x038 IDT : Ptr32 _KIDTENTRY //IDT表基址
+0x03c GDT : Ptr32 _KGDTENTRY //GDT表基址,IDT、GDT表不通用,每个CPU每个核有各自的IDT、GDT(内容可能一样)。
+0x040 TSS : Ptr32 _KTSS //指向TSS,每个CPU有一个TSS,TSS存储的是当前线程的0环寄存器状态。
+0x044 MajorVersion : Uint2B
+0x046 MinorVersion : Uint2B
+0x048 SetMember : Uint4B
+0x04c StallScaleFactor : Uint4B
+0x050 DebugActive : UChar
+0x051 Number : UChar //当前CPU编号
+0x052 Spare0 : UChar
+0x053 SecondLevelCacheAssociativity : UChar
+0x054 VdmAlert : Uint4B
+0x058 KernelReserved : [14] Uint4B
+0x090 SecondLevelCacheSize : Uint4B
+0x094 HalReserved : [16] Uint4B
+0x0d4 InterruptMode : Uint4B
+0x0d8 Spare1 : UChar
+0x0dc KernelReserved2 : [17] Uint4B
+0x120 PrcbData : _KPRCB //拓展结构体
0x120处 _KPRCB结构一天如下:
kd> dt _KPRCB
ntdll!_KPRCB
+0x000 MinorVersion : Uint2B
+0x002 MajorVersion : Uint2B
+0x004 CurrentThread : Ptr32 _KTHREAD //当前线程
+0x008 NextThread : Ptr32 _KTHREAD //下一个要切换的线程
+0x00c IdleThread : Ptr32 _KTHREAD //空闲线程
+0x010 Number : Char
+0x011 Reserved : Char
+0x012 BuildType : Uint2B
+0x014 SetMember : Uint4B
+0x018 CpuType : Char
+0x019 CpuID : Char
+0x01a CpuStep : Uint2B
+0x01c ProcessorState : _KPROCESSOR_STATE
+0x33c KernelReserved : [16] Uint4B
+0x37c HalReserved : [16] Uint4B
+0x3bc PrcbPad0 : [92] UChar
+0x418 LockQueue : [16] _KSPIN_LOCK_QUEUE
+0x498 PrcbPad1 : [8] UChar
+0x4a0 NpxThread : Ptr32 _KTHREAD
+0x4a4 InterruptCount : Uint4B
+0x4a8 KernelTime : Uint4B
+0x4ac UserTime : Uint4B
+0x4b0 DpcTime : Uint4B
+0x4b4 DebugDpcTime : Uint4B
+0x4b8 InterruptTime : Uint4B
+0x4bc AdjustDpcThreshold : Uint4B
+0x4c0 PageColor : Uint4B
+0x4c4 SkipTick : Uint4B
+0x4c8 MultiThreadSetBusy : UChar
+0x4c9 Spare2 : [3] UChar
+0x4cc ParentNode : Ptr32 _KNODE
+0x4d0 MultiThreadProcessorSet : Uint4B
+0x4d4 MultiThreadSetMaster : Ptr32 _KPRCB
+0x4d8 ThreadStartCount : [2] Uint4B
+0x4e0 CcFastReadNoWait : Uint4B
+0x4e4 CcFastReadWait : Uint4B
+0x4e8 CcFastReadNotPossible : Uint4B
+0x4ec CcCopyReadNoWait : Uint4B
+0x4f0 CcCopyReadWait : Uint4B
+0x4f4 CcCopyReadNoWaitMiss : Uint4B
+0x4f8 KeAlignmentFixupCount : Uint4B
+0x4fc KeContextSwitches : Uint4B
+0x500 KeDcacheFlushCount : Uint4B
+0x504 KeExceptionDispatchCount : Uint4B
+0x508 KeFirstLevelTbFills : Uint4B
+0x50c KeFloatingEmulationCount : Uint4B
+0x510 KeIcacheFlushCount : Uint4B
+0x514 KeSecondLevelTbFills : Uint4B
+0x518 KeSystemCalls : Uint4B
+0x51c SpareCounter0 : [1] Uint4B
+0x520 PPLookasideList : [16] _PP_LOOKASIDE_LIST
+0x5a0 PPNPagedLookasideList : [32] _PP_LOOKASIDE_LIST
+0x6a0 PPPagedLookasideList : [32] _PP_LOOKASIDE_LIST
+0x7a0 PacketBarrier : Uint4B
+0x7a4 ReverseStall : Uint4B
+0x7a8 IpiFrame : Ptr32 Void
+0x7ac PrcbPad2 : [52] UChar
+0x7e0 CurrentPacket : [3] Ptr32 Void
+0x7ec TargetSet : Uint4B
+0x7f0 WorkerRoutine : Ptr32 void
+0x7f4 IpiFrozen : Uint4B
+0x7f8 PrcbPad3 : [40] UChar
+0x820 RequestSummary : Uint4B
+0x824 SignalDone : Ptr32 _KPRCB
+0x828 PrcbPad4 : [56] UChar
+0x860 DpcListHead : _LIST_ENTRY
+0x868 DpcStack : Ptr32 Void
+0x86c DpcCount : Uint4B
+0x870 DpcQueueDepth : Uint4B
+0x874 DpcRoutineActive : Uint4B
+0x878 DpcInterruptRequested : Uint4B
+0x87c DpcLastCount : Uint4B
+0x880 DpcRequestRate : Uint4B
+0x884 MaximumDpcQueueDepth : Uint4B
+0x888 MinimumDpcRate : Uint4B
+0x88c QuantumEnd : Uint4B
+0x890 PrcbPad5 : [16] UChar
+0x8a0 DpcLock : Uint4B
+0x8a4 PrcbPad6 : [28] UChar
+0x8c0 CallDpc : _KDPC
+0x8e0 ChainedInterruptList : Ptr32 Void
+0x8e4 LookasideIrpFloat : Int4B
+0x8e8 SpareFields0 : [6] Uint4B
+0x900 VendorString : [13] UChar
+0x90d InitialApicId : UChar
+0x90e LogicalProcessorsPerPhysicalProcessor : UChar
+0x910 MHz : Uint4B
+0x914 FeatureBits : Uint4B
+0x918 UpdateSignature : _LARGE_INTEGER
+0x920 NpxSaveArea : _FX_SAVE_AREA
+0xb30 PowerState : _PROCESSOR_POWER_STATE
查看电脑CPU数量:
dd KeNumberProcessors
查看KPCR
dd KiProcessorBlock L2 //有n个核,可以加Ln,这里假设有2个核
KiSystemService反汇编详解
nt!KiSystemService:
1| 8053e481 6a00 push 0 //入栈,位置为_Trap_Frame的ErrorCOde(0X064)处
1| 8053e483 55 push ebp
1| 8053e484 53 push ebx
1| 8053e485 56 push esi
1| 8053e486 57 push edi
1| 8053e487 0fa0 push fs
1| 8053e489 bb30000000 mov ebx,30h
1| 8053e48e 668ee3 mov fs,bx //30h为段选择子,30h-->00110000,其中index=00110,代表第6个段描述符,1| TI=0代表查GDT表,RPL=0。该处段描述符为ffc093df`f0000001,表明base=ffdff000,该处指向KPCR,即进入0环后,FS寄存器指向KPCR;而在3环,FS指向TEB
1| 8053e491 ff3500f0dfff push dword ptr ds:[0FFDFF000h]//ffdff000指向_KPCR的_NT_TIB->ExceptionList
//把老的EXCEPTION_LIST 存入 _Ktrap_frame 结构体中(fs上边那部分)
1| 8053e497 c70500f0dfffffffffff mov dword ptr ds:[0FFDFF000h],0FFFFFFFFh //新的EXCEPTION_LIST = -1,代表空。
1| 8053e4a1 8b3524f1dfff mov esi,dword ptr ds:[0FFDFF124h]//在ffdff000基础上偏移124,即KPCR+124,将CurrentThread,即当前线程的ETHREAD存储在esi寄存器中
1| 8053e4a7 ffb640010000 push dword ptr [esi+140h] //入栈,将KTHREAD中PreviousMode存储在_Trap_Frame结构体中
1| 8053e4ad 83ec48 sub esp,48h //esp指向_Trap_Frame结构体首地址
1| 8053e4b0 8b5c246c mov ebx,dword ptr [esp+6Ch] //ebx=CS
1| 8053e4b4 83e301 and ebx,1 //将原来CS的值进行与运算, 0环最低为为0,3环最低为为1
1| 8053e4b7 889e40010000 mov byte ptr [esi+140h],bl //新的"先PreviousMode",原来是三环模式为1;原来是零环模式为0
1| 8053e4bd 8bec mov ebp,esp //ebp指向_Trap_Frame结构体首地址
1| 8053e4bf 8b9e34010000 mov ebx,dword ptr [esi+134h] //KTHREAD指向的TrapFrame存储到ebx
1| 8053e4c5 895d3c mov dword ptr [ebp+3Ch],ebx //_Trap_Frame结构体edx临时存储KTHREAD指向的TrapFrame
1| 8053e4c8 89ae34010000 mov dword ptr [esi+134h],ebp //将新的_Trap_Frame结构体首地址存储到KTHREAD结构体的TrapFrame处。
1| 8053e4ce fc cld
1| 8053e4cf 8b5d60 mov ebx,dword ptr [ebp+60h]
1| 8053e4d2 8b7d68 mov edi,dword ptr [ebp+68h]
1| 8053e4d5 89550c mov dword ptr [ebp+0Ch],edx //edx存储的是参数指针,将其保存在_Trap_Frame中的DbgArgPointer处
1| 8053e4d8 c74508000ddbba mov dword ptr [ebp+8],0BADB0D00h //DbgArgMark
1| 8053e4df 895d00 mov dword ptr [ebp],ebx
1| 8053e4e2 897d04 mov dword ptr [ebp+4],edi
1| 8053e4e5 f6462cff test byte ptr [esi+2Ch],0FFh //判断KTHREAD的DebugActive是否为-1,若是-1,代表非调试状态;否则为调试状态
1| 8053e4e9 0f858dfeffff jne nt!Dr_kss_a (8053e37c)
1| 8053e4ef fb sti
1| 8053e4f0 e9d8000000 jmp nt!KiFastCallEntry+0x8d (8053e5cd)
nt!KiFastCallEntry2:
1| 8053e4f5 b930000000 mov ecx,30h
1| 8053e4fa 8ee1 mov fs,cx
1| 8053e4fc b923000000 mov ecx,23h
1| 8053e501 8ed9 mov ds,cx
1| 8053e503 8ec1 mov es,cx
1| 8053e505 8b0d40f0dfff mov ecx,dword ptr ds:[0FFDFF040h]
1| 8053e50b 8b6104 mov esp,dword ptr [ecx+4]
1| 8053e50e 6a23 push 23h
1| 8053e510 52 push edx
1| 8053e511 9c pushfd
1| 8053e512 804c240101 or byte ptr [esp+1],1
1| 8053e517 eb41 jmp nt!KiFastCallEntry+0x1a (8053e55a)
1| 8053e519 8b0d40f0dfff mov ecx,dword ptr ds:[0FFDFF040h]
1| 8053e51f 8b6104 mov esp,dword ptr [ecx+4]
1| 8053e522 6a00 push 0
1| 8053e524 6a00 push 0
1| 8053e526 6a00 push 0
1| 8053e528 6a00 push 0
1| 8053e52a 6a23 push 23h
1| 8053e52c 6a00 push 0
1| 8053e52e 6802020200 push 20202h
1| 8053e533 6a1b push 1Bh
1| 8053e535 6a00 push 0
1| 8053e537 e9f8150000 jmp nt!KiTrap06 (8053fb34)
1| 8053e53c ebdb jmp nt!KiFastCallEntry2+0x24 (8053e519)
1| 8053e53e 8bff mov edi,edi
nt!KiFastCallEntry:
1| 8053e540 b923000000 mov ecx,23h
1| 8053e545 6a30 push 30h
1| 8053e547 0fa1 pop fs
1| 8053e549 8ed9 mov ds,cx
1| 8053e54b 8ec1 mov es,cx
1| 8053e54d 8b0d40f0dfff mov ecx,dword ptr ds:[0FFDFF040h]
1| 8053e553 8b6104 mov esp,dword ptr [ecx+4]
1| 8053e556 6a23 push 23h
1| 8053e558 52 push edx
1| 8053e559 9c pushfd
1| 8053e55a 6a02 push 2
1| 8053e55c 83c208 add edx,8
1| 8053e55f 9d popfd
1| 8053e560 804c240102 or byte ptr [esp+1],2
1| 8053e565 6a1b push 1Bh
1| 8053e567 ff350403dfff push dword ptr ds:[0FFDF0304h]
1| 8053e56d 6a00 push 0
1| 8053e56f 55 push ebp
1| 8053e570 53 push ebx
1| 8053e571 56 push esi
1| 8053e572 57 push edi
1| 8053e573 8b1d1cf0dfff mov ebx,dword ptr ds:[0FFDFF01Ch]
1| 8053e579 6a3b push 3Bh
1| 8053e57b 8bb324010000 mov esi,dword ptr [ebx+124h]
1| 8053e581 ff33 push dword ptr [ebx]
1| 8053e583 c703ffffffff mov dword ptr [ebx],0FFFFFFFFh
1| 8053e589 8b6e18 mov ebp,dword ptr [esi+18h]
1| 8053e58c 6a01 push 1
1| 8053e58e 83ec48 sub esp,48h
1| 8053e591 81ed9c020000 sub ebp,29Ch
1| 8053e597 c6864001000001 mov byte ptr [esi+140h],1
1| 8053e59e 3bec cmp ebp,esp
1| 8053e5a0 759a jne nt!KiFastCallEntry2+0x47 (8053e53c)
1| 8053e5a2 83652c00 and dword ptr [ebp+2Ch],0
1| 8053e5a6 f6462cff test byte ptr [esi+2Ch],0FFh
1| 8053e5aa 89ae34010000 mov dword ptr [esi+134h],ebp
1| 8053e5b0 0f854afeffff jne nt!Dr_FastCallDrSave (8053e400)
1| 8053e5b6 8b5d60 mov ebx,dword ptr [ebp+60h]
1| 8053e5b9 8b7d68 mov edi,dword ptr [ebp+68h]
1| 8053e5bc 89550c mov dword ptr [ebp+0Ch],edx
1| 8053e5bf c74508000ddbba mov dword ptr [ebp+8],0BADB0D00h
1| 8053e5c6 895d00 mov dword ptr [ebp],ebx
1| 8053e5c9 897d04 mov dword ptr [ebp+4],edi
1| 8053e5cc fb sti
1| 8053e5cd 8bf8 mov edi,eax //取出系统调用号,这是有3环传入的
1| 8053e5cf c1ef08 shr edi,8 //系统调用号右移8位
1| 8053e5d2 83e730 and edi,30h //由于系统调用号只有低13位起作用,其中第13位代表访问的是第一个SystemServiceTable还是第二个SystemServiceTable,故系统调用号右移8位与30h相与后,不是0x00就是0x10;
1| 8053e5d5 8bcf mov ecx,edi //ecx中存储的值为0x00或者0x10
1| 8053e5d7 03bee0000000 add edi,dword ptr [esi+0E0h] // esi指向_KTHREAD,_KTHREAD ->ServiceTable(+0XE0),即SSDT表第一项
1| 8053e5dd 8bd8 mov ebx,eax //ebx存储系统调用号
1| 8053e5df 25ff0f0000 and eax,0FFFh //取系统调用号后12位,作为index去访问SystemServiceTable
1| 8053e5e4 3b4708 cmp eax,dword ptr [edi+8] //与SystemServiceTable第3项 NumberOfService 比较,判断索引有没有越界,越界则调用 nt!KiBBTUnexpectedRange
1| 8053e5e7 0f8345fdffff jae nt!KiBBTUnexpectedRange (8053e332)
1| 8053e5ed 83f910 cmp ecx,10h //
1| 8053e5f0 751a jne nt!KiFastCallEntry+0xcc (8053e60c) //调用第一个SystemServiceTable,则跳转
1| 8053e5f2 8b0d18f0dfff mov ecx,dword ptr ds:[0FFDFF018h]
1| 8053e5f8 33db xor ebx,ebx
1| 8053e5fa 0b99700f0000 or ebx,dword ptr [ecx+0F70h]
1| 8053e600 740a je nt!KiFastCallEntry+0xcc (8053e60c) //只有调用第二个SystemServiceTable才会执行该函数
1| 8053e602 52 push edx
1| 8053e603 50 push eax
1| 8053e604 ff15e43f5580 call dword ptr [nt!KeGdiFlushUserBatch (80553fe4)]
1| 8053e60a 58 pop eax
1| 8053e60b 5a pop edx
1| 8053e60c ff0538f6dfff inc dword ptr ds:[0FFDFF638h] //_KPRCB ->+0x518 KeSystemCalls +1
1| 8053e612 8bf2 mov esi,edx //edx存储三环传入的函数的指针
1| 8053e614 8b5f0c mov ebx,dword ptr [edi+0Ch] //edi指向SystemServiceTable,0C是第四个参数,即ArgumentTable
1| 8053e617 33c9 xor ecx,ecx
1| 8053e619 8a0c18 mov cl,byte ptr [eax+ebx] //ebx指向ArgumentTable,eax存储系统调用号,这里cl存储了调用函数的参数个数
1| 8053e61c 8b3f mov edi,dword ptr [edi] //SystemServiceTable -> ServiceTable ,即函数表首地址
1| 8053e61e 8b1c87 mov ebx,dword ptr [edi+eax*4] //eax存储系统调用号,作为index,*4是因为一个表项4字节,edi存储ServiceTable
1| 8053e621 2be1 sub esp,ecx //ecx是参数的大小,以B为单位
1| 8053e623 c1e902 shr ecx,2//参数个数
1| 8053e626 8bfc mov edi,esp
1| 8053e628 3b35d4995580 cmp esi,dword ptr [nt!MmUserProbeAddress (805599d4)]
1| 8053e62e 0f83a8010000 jae nt!KiSystemCallExit2+0x9f (8053e7dc)
1| 8053e634 f3a5 rep movs dword ptr es:[edi],dword ptr [esi]