Windbg 如何进入特定进程上下文?
有时要查win32K.sys中的代码,
但其必须在csrss.exe进程上下文才有效,
那怎么办呢?
步骤分二步:
1.列出所有进程(!process)
2.进入指定进程的进程空间(.process)
操作如下:
0: kd> !process 0 0
**** NT ACTIVE PROCESS DUMP ****
PROCESS 8fabe7a8 SessionId: none Cid: 0004 Peb: 00000000 ParentCid: 0000
DirBase: 393c0020 ObjectTable: e1003e38 HandleCount: 306.
Image: System
PROCESS 8f83dc50 SessionId: none Cid: 011c Peb: 7ffd6000 ParentCid: 0004
DirBase: 393c0040 ObjectTable: e12f80a0 HandleCount: 19.
Image: smss.exe
PROCESS 8f577020 SessionId: 0 Cid: 0150 Peb: 7ffd8000 ParentCid: 011c
DirBase: 393c0060 ObjectTable: e14803f8 HandleCount: 403.
Image: csrss.exe
PROCESS 8f837d88 SessionId: 0 Cid: 0168 Peb: 7ffd7000 ParentCid: 011c
DirBase: 393c0080 ObjectTable: e15c11a0 HandleCount: 274.
Image: winlogon.exe
PROCESS 8f2715f0 SessionId: 0 Cid: 0198 Peb: 7ffdf000 ParentCid: 0168
DirBase: 393c00a0 ObjectTable: e1723fb8 HandleCount: 280.
Image: services.exe
PROCESS 8f00d968 SessionId: 0 Cid: 01a4 Peb: 7ffdd000 ParentCid: 0168
DirBase: 393c00c0 ObjectTable: e17428e0 HandleCount: 367.
Image: lsass.exe
PROCESS 8f420020 SessionId: 0 Cid: 0240 Peb: 7ffd4000 ParentCid: 0198
DirBase: 393c00e0 ObjectTable: e17b6720 HandleCount: 40.
Image: vmacthlp.exe
PROCESS 8f26a888 SessionId: 0 Cid: 0260 Peb: 7ffd7000 ParentCid: 0198
DirBase: 393c0100 ObjectTable: e17b65b0 HandleCount: 95.
Image: svchost.exe
PROCESS 8f009ba0 SessionId: 0 Cid: 0294 Peb: 7ffd8000 ParentCid: 0198
DirBase: 393c0120 ObjectTable: e17f34a0 HandleCount: 219.
Image: svchost.exe
PROCESS 8f005468 SessionId: 0 Cid: 02c8 Peb: 7ffde000 ParentCid: 0198
DirBase: 393c0140 ObjectTable: e17fb560 HandleCount: 809.
Image: svchost.exe
PROCESS 8f56bc78 SessionId: 0 Cid: 02e8 Peb: 7ffda000 ParentCid: 0198
DirBase: 393c0160 ObjectTable: e17fb510 HandleCount: 130.
Image: svchost.exe
PROCESS 8f6bd020 SessionId: 0 Cid: 031c Peb: 7ffdb000 ParentCid: 0198
DirBase: 393c0180 ObjectTable: e180d3c8 HandleCount: 90.
Image: svchost.exe
PROCESS 8f7d1468 SessionId: 0 Cid: 0364 Peb: 7ffd8000 ParentCid: 0198
DirBase: 393c01a0 ObjectTable: e13be6f0 HandleCount: 144.
Image: spoolsv.exe
PROCESS 8f6b9020 SessionId: 0 Cid: 03b0 Peb: 7ffd5000 ParentCid: 0198
DirBase: 393c01c0 ObjectTable: e1738a90 HandleCount: 41.
Image: svchost.exe
PROCESS 8f401d88 SessionId: 0 Cid: 0430 Peb: 7ffdb000 ParentCid: 0198
DirBase: 393c0200 ObjectTable: e17a0c68 HandleCount: 152.
Image: VMwareService.exe
PROCESS 8f3f3d88 SessionId: 0 Cid: 0468 Peb: 7ffdb000 ParentCid: 0198
DirBase: 393c0220 ObjectTable: e18f0148 HandleCount: 146.
Image: svchost.exe
PROCESS 8f3eed88 SessionId: 0 Cid: 0480 Peb: 7ffd4000 ParentCid: 0198
DirBase: 393c0240 ObjectTable: e1609608 HandleCount: 212.
Image: dllhost.exe
PROCESS 8f3e5c58 SessionId: 0 Cid: 04c8 Peb: 7ffd3000 ParentCid: 0198
DirBase: 393c01e0 ObjectTable: e1990ef0 HandleCount: 227.
Image: dllhost.exe
PROCESS 8ed4bd88 SessionId: 0 Cid: 05ec Peb: 7ffd4000 ParentCid: 05d8
DirBase: 393c0280 ObjectTable: e1c29038 HandleCount: 480.
Image: explorer.exe
PROCESS 8f679d88 SessionId: 0 Cid: 0650 Peb: 7ffdb000 ParentCid: 0198
DirBase: 393c02a0 ObjectTable: e1c86d08 HandleCount: 173.
Image: msdtc.exe
PROCESS 8f391728 SessionId: 0 Cid: 06b0 Peb: 7ffde000 ParentCid: 05ec
DirBase: 393c02c0 ObjectTable: e1ce70e0 HandleCount: 53.
Image: VMwareTray.exe
PROCESS 8f3905a0 SessionId: 0 Cid: 06b8 Peb: 7ffda000 ParentCid: 05ec
DirBase: 393c02e0 ObjectTable: e1d784a8 HandleCount: 122.
Image: VMwareUser.exe
PROCESS 8f7c37a0 SessionId: 0 Cid: 06c4 Peb: 7ffda000 ParentCid: 05ec
DirBase: 393c0300 ObjectTable: e18432e8 HandleCount: 80.
Image: ctfmon.exe
PROCESS 8f66d428 SessionId: 0 Cid: 0740 Peb: 7ffd8000 ParentCid: 0198
DirBase: 393c0320 ObjectTable: e1e51f78 HandleCount: 132.
Image: vssvc.exe
PROCESS 8f654940 SessionId: 0 Cid: 00cc Peb: 7ffdb000 ParentCid: 05ec
DirBase: 393c0260 ObjectTable: e143de50 HandleCount: 111.
Image: DriverMonitor.exe
PROCESS 8ed2e5b0 SessionId: 0 Cid: 00e4 Peb: 7ffd7000 ParentCid: 05ec
DirBase: 393c0340 ObjectTable: e1d76198 HandleCount: 197.
Image: IEXPLORE.EXE
以上列出所有进程,
下一步进入进程空间.
0: kd> .process 8f577020
Implicit process is now 8f577020
WARNING: .cache forcedecodeuser is not enabled
这样就可以了,
现在可以看win32K.sys的代码也,
0: kd> u NtUserSendInput
win32k!NtUserSendInput:
bf8f4132 6a18 push 18h
bf8f4134 68c83d99bf push offset win32k!`string'+0x34 (bf993dc8)
bf8f4139 e82240faff call win32k!_SEH_prolog (bf898160)
bf8f413e 8365e400 and dword ptr [ebp-1Ch],0
bf8f4142 e87940faff call win32k!EnterCrit (bf8981c0)
bf8f4147 837d101c cmp dword ptr [ebp+10h],1Ch
bf8f414b 75d2 jne win32k!NtUserSendInput+0xdf (bf8f411f)
bf8f414d 8b7508 mov esi,dword ptr [ebp+8]