楼主很细心,内核陷入的代码 (细节) 变动的相对频繁,这个问题要分情况说明。《软件调试》一书里列出的 nt!KiFastCallEntry 应该是 Win-2000 平台下的,大致如下:kd> u nt!KiFastCallEntrynt!KiFastCallEntry:804647dd 368b2540f0dfff mov esp,dword ptr ss:[0FFDFF040h]804647e4 8b642404 mov esp,dword ptr [esp+4]804647e8 6a23 push 23h804647ea 52 push edx804647eb 832c2404 sub dword ptr [esp],4804647ef 9c pushfd804647f0 810c2400020000 or dword ptr [esp],200h804647f7 6a1b push 1Bh804647f9 51 push ecx804647fa 6a00 push 0804647fc 55 push ebp804647fd 53 push ebx804647fe 56 push esi804647ff 57 push edi80464800 0fa0 push fs80464802 bb30000000 mov ebx,30h80464807 668ee3 mov fs,bx8046480a ff3500f0dfff push dword ptr ds:[0FFDFF000h]80464810 c70500f0dfffffffffff mov dword ptr ds:[0FFDFF000h],0FFFFFFFFh8046481a 8b3524f1dfff mov esi,dword ptr ds:[0FFDFF124h]80464820 ffb634010000 push dword ptr [esi+134h]80464826 83ec48 sub esp,48h80464829 8b5c246c mov ebx,dword ptr [esp+6Ch]8046482d 83e301 and ebx,180464830 889e34010000 mov byte ptr [esi+134h],bl80464836 8bec mov ebp,esp80464838 8b9e28010000 mov ebx,dword ptr [esi+128h]8046483e 895d3c mov dword ptr [ebp+3Ch],ebx80464841 89ae28010000 mov dword ptr [esi+128h],ebp80464847 fc cld80464848 f6462cff test byte ptr [esi+2Ch],0FFh8046484c 0f850affffff jne nt!Dr_kfce_a (8046475c)80464852 fb sti80464853 e9de000000 jmp nt!KiSystemService+0x59 (80464936)80464858 90 nop........函数的最后会陷入 IDT 0x2E - nt!KiSystemService。在 0 e 804647dd 0001 (0001) nt!KiFastCallEntry下断点会发现,该断点不会被命中,因为内核陷入机制采用的是 IDT 0x2E 处理例程。kd> u KiSystemServicent!KiSystemService:804648dd 6a00 push 0804648df 55 push ebp804648e0 53 push ebx804648e1 56 push esi804648e2 57 push edi804648e3 0fa0 push fs804648e5 bb30000000 mov ebx,30h804648ea 668ee3 mov fs,bx804648ed ff3500f0dfff push dword ptr ds:[0FFDFF000h]804648f3 c70500f0dfffffffffff mov dword ptr ds:[0FFDFF000h],0FFFFFFFFh804648fd 8b3524f1dfff mov esi,dword ptr ds:[0FFDFF124h]80464903 ffb634010000 push dword ptr [esi+134h]80464909 83ec48 sub esp,48h8046490c 8b5c246c mov ebx,dword ptr [esp+6Ch]80464910 83e301 and ebx,180464913 889e34010000 mov byte ptr [esi+134h],bl80464919 8bec mov ebp,esp8046491b 8b9e28010000 mov ebx,dword ptr [esi+128h]80464921 895d3c mov dword ptr [ebp+3Ch],ebx80464924 89ae28010000 mov dword ptr [esi+128h],ebp8046492a fc cld8046492b f6462cff test byte ptr [esi+2Ch],0FFh8046492f 0f8524ffffff jne nt!Dr_kss_a (80464859)80464935 fb sti80464936 8bf8 mov edi,eax ; 注意这里就是 nt!KiFastCallEntry 跳转过来的地方80464938 c1ef08 shr edi,88046493b 83e730 and edi,30h8046493e 8bcf mov ecx,edi80464940 03bedc000000 add edi,dword ptr [esi+0DCh]80464946 8bd8 mov ebx,eax80464948 25ff0f0000 and eax,0FFFh8046494d 3b4708 cmp eax,dword ptr [edi+8]80464950 0f83bcfdffff jae nt!KiBBTUnexpectedRange (80464712)80464956 83f910 cmp ecx,10h80464959 751a jne nt!KiSystemService+0x98 (80464975)8046495b 8b0d18f0dfff mov ecx,dword ptr ds:[0FFDFF018h]80464961 33db xor ebx,ebx80464963 0b99700f0000 or ebx,dword ptr [ecx+0F70h]80464969 740a je nt!KiSystemService+0x98 (80464975)8046496b 52 push edx8046496c 50 push eax8046496d ff15a01a4880 call dword ptr [nt!KeGdiFlushUserBatch (80481aa0)]80464973 58 pop eax80464974 5a pop edx80464975 ff05dcf5dfff inc dword ptr ds:[0FFDFF5DCh]8046497b 8bf2 mov esi,edx8046497d 8b5f0c mov ebx,dword ptr [edi+0Ch]80464980 33c9 xor ecx,ecx80464982 8a0c18 mov cl,byte ptr [eax+ebx]80464985 8b3f mov edi,dword ptr [edi]80464987 8b1c87 mov ebx,dword ptr [edi+eax*4]8046498a 2be1 sub esp,ecx8046498c c1e902 shr ecx,28046498f 8bfc mov edi,esp80464991 3b3548cc4680 cmp esi,dword ptr [nt!MmUserProbeAddress (8046cc48)]80464997 0f83e4010000 jae nt!KiServiceExit+0x1ce (80464b81)8046499d f3a5 rep movs dword ptr es:[edi],dword ptr [esi]8046499f ffd3 call ebx........这个就是正常的 Win-2000 下内核服务派遣流程。可以看出楼主研究的平台是 Win-XP+,这些平台下的操作系统会判断处理器的版本(CPUID),进而选择是否采用“快速系统调用”。此时 msr 176 是 nt!KiFastCallEntry:nt!KiFastCallEntry:80541510 b923000000 mov ecx,23h80541515 6a30 push 30h80541517 0fa1 pop fs80541519 8ed9 mov ds,cx8054151b 8ec1 mov es,cx8054151d 648b0d40000000 mov ecx,dword ptr fs:[40h]80541524 8b6104 mov esp,dword ptr [ecx+4]80541527 6a23 push 23h80541529 52 push edx8054152a 9c pushfd8054152b 6a02 push 28054152d 83c208 add edx,880541530 9d popfd80541531 804c240102 or byte ptr [esp+1],280541536 6a1b push 1Bh80541538 ff350403dfff push dword ptr ds:[0FFDF0304h]8054153e 6a00 push 080541540 55 push ebp80541541 53 push ebx80541542 56 push esi80541543 57 push edi80541544 648b1d1c000000 mov ebx,dword ptr fs:[1Ch]8054154b 6a3b push 3Bh8054154d 8bb324010000 mov esi,dword ptr [ebx+124h]80541553 ff33 push dword ptr [ebx]80541555 c703ffffffff mov dword ptr [ebx],0FFFFFFFFh8054155b 8b6e18 mov ebp,dword ptr [esi+18h]8054155e 6a01 push 180541560 83ec48 sub esp,48h80541563 81ed9c020000 sub ebp,29Ch80541569 c6864001000001 mov byte ptr [esi+140h],180541570 3bec cmp ebp,esp80541572 758d jne nt!KiFastCallEntry2+0x49 (80541501)80541574 83652c00 and dword ptr [ebp+2Ch],080541578 f6462cff test byte ptr [esi+2Ch],0FFh8054157c 89ae34010000 mov dword ptr [esi+134h],ebp80541582 0f8538feffff jne nt!Dr_FastCallDrSave (805413c0)80541588 8b5d60 mov ebx,dword ptr [ebp+60h]8054158b 8b7d68 mov edi,dword ptr [ebp+68h]8054158e 89550c mov dword ptr [ebp+0Ch],edx80541591 c74508000ddbba mov dword ptr [ebp+8],0BADB0D00h80541598 895d00 mov dword ptr [ebp],ebx8054159b 897d04 mov dword ptr [ebp+4],edi8054159e fb sti8054159f 8bf8 mov edi,eax ; 注意这里就是 nt!KiSystemService 跳转过来的地方805415a1 c1ef08 shr edi,8805415a4 83e730 and edi,30h805415a7 8bcf mov ecx,edi805415a9 03bee0000000 add edi,dword ptr [esi+0E0h]805415af 8bd8 mov ebx,eax805415b1 25ff0f0000 and eax,0FFFh805415b6 3b4708 cmp eax,dword ptr [edi+8]805415b9 0f8333fdffff jae nt!KiBBTUnexpectedRange (805412f2)805415bf 83f910 cmp ecx,10h805415c2 751b jne nt!KiFastCallEntry+0xcf (805415df)805415c4 648b0d18000000 mov ecx,dword ptr fs:[18h]805415cb 33db xor ebx,ebx805415cd 0b99700f0000 or ebx,dword ptr [ecx+0F70h]805415d3 740a je nt!KiFastCallEntry+0xcf (805415df)805415d5 52 push edx805415d6 50 push eax805415d7 ff1528c75580 call dword ptr [nt!KeGdiFlushUserBatch (8055c728)]805415dd 58 pop eax805415de 5a pop edx805415df 64ff0538060000 inc dword ptr fs:[638h]805415e6 8bf2 mov esi,edx805415e8 8b5f0c mov ebx,dword ptr [edi+0Ch]805415eb 33c9 xor ecx,ecx805415ed 8a0c18 mov cl,byte ptr [eax+ebx]805415f0 8b3f mov edi,dword ptr [edi]805415f2 8b1c87 mov ebx,dword ptr [edi+eax*4]805415f5 2be1 sub esp,ecx805415f7 c1e902 shr ecx,2805415fa 8bfc mov edi,esp805415fc 3b3514215680 cmp esi,dword ptr [nt!MmUserProbeAddress (80562114)]80541602 0f83a8010000 jae nt!KiSystemCallExit2+0x9f (805417b0)80541608 f3a5 rep movs dword ptr es:[edi],dword ptr [esi]8054160a ffd3 call ebx........这个是标准的内核服务派遣流程。而 nt!KiSystemService 函数此时只是 nt!KiFastCallEntry 的封装: nt!KiSystemService:80541441 6a00 push 080541443 55 push ebp80541444 53 push ebx80541445 56 push esi80541446 57 push edi80541447 0fa0 push fs80541449 bb30000000 mov ebx,30h8054144e 668ee3 mov fs,bx80541451 64ff3500000000 push dword ptr fs:[0]80541458 64c70500000000ffffffff mov dword ptr fs:[0],0FFFFFFFFh80541463 648b3524010000 mov esi,dword ptr fs:[124h]8054146a ffb640010000 push dword ptr [esi+140h]80541470 83ec48 sub esp,48h80541473 8b5c246c mov ebx,dword ptr [esp+6Ch]80541477 83e301 and ebx,18054147a 889e40010000 mov byte ptr [esi+140h],bl80541480 8bec mov ebp,esp80541482 8b9e34010000 mov ebx,dword ptr [esi+134h]80541488 895d3c mov dword ptr [ebp+3Ch],ebx8054148b 89ae34010000 mov dword ptr [esi+134h],ebp80541491 fc cld80541492 8b5d60 mov ebx,dword ptr [ebp+60h]80541495 8b7d68 mov edi,dword ptr [ebp+68h]80541498 89550c mov dword ptr [ebp+0Ch],edx8054149b c74508000ddbba mov dword ptr [ebp+8],0BADB0D00h805414a2 895d00 mov dword ptr [ebp],ebx805414a5 897d04 mov dword ptr [ebp+4],edi805414a8 f6462cff test byte ptr [esi+2Ch],0FFh805414ac 0f858afeffff jne nt!Dr_kss_a (8054133c)805414b2 fb sti805414b3 e9e7000000 jmp nt!KiFastCallEntry+0x8f (8054159f)........用中断计数工具查看会发现 IDT 0x2E 不会被系统主动触发(从中断系统走)。如图: