NetRoc's Blog

N-Tech

 

WinDbg 文档翻译----81

cc682/NetRoc

http://netroc682.spaces.live.com/

!job

!job 扩展用来显示一个作业(job)对象。

语法

!job [Process [Flags]] 

参数

Process

指定要查看的job对象所关联的进程或者线程的16进制地址。如果省略或者设为-1(Windows 2000中)或者0 (Windows XP和之后),则显示当前进程关联的job对象。

Flags

指定显示中包含的内容。可以是任意下面这些位值的和。默认值为0x1:

Bit 0 (0x1)

显示job的设置和统计。

Bit 1 (0x2)

显示job中所有进程的列表。

DLL

Windows NT 4.0

不可用

Windows 2000

Kdextx86.dll

Windows XP和之后

Kdexts.dll

 

注释

下面是该扩展输出的示例:

kd> !process 52c
Searching for Process with Cid == 52c
PROCESS 8276c550  SessionId: 0  Cid: 052c    Peb: 7ffdf000  ParentCid: 0060
    DirBase: 01289000  ObjectTable: 825f0368  TableSize:  24.
    Image: cmd.exe
    VadRoot 825609e8 Vads 30 Clone 0 Private 77. Modified 0. Locked 0.
    DeviceMap e1733f38
    Token                             e1681610
    ElapsedTime                       0:00:12.0949
    UserTime                          0:00:00.0359
    .....
    CommitCharge                      109
    Job                               8256e1f0

kd> !job 8256e1f0
Job at ffffffff8256e1f0
  TotalPageFaultCount      0
  TotalProcesses           1
  ActiveProcesses          1
  TotalTerminatedProcesses 0
  LimitFlags               0
  MinimumWorkingSetSize    0
  MaximumWorkingSetSize    0
  ActiveProcessLimit       0
  PriorityClass            0
  UIRestrictionsClass      0
  SecurityLimitFlags       0
  Token                    00000000

附加信息

关于job对象的信息,查看Mark Russinovich 和David Solomon 编写的Microsoft Windows Internals

!kb, !kv

!kb!kv 扩展命令已经废除。使用kb (Display Stack Backtrace)kv (Display Stack Backtrace) 命令来替代。

!loadermemorylist

!loadermemorylist 扩展显示Windows boot loader传递给Windows的内存分配列表。

语法

!loadermemorylist ListHeadAddress 

参数

ListHeadAddress

指定列表头的地址。

DLL

Windows NT 4.0

Kdexts.dll

Windows 2000

Kdexts.dll

Windows XP
Windows Server 2003

Kdexts.dll

Windows Vista和之后

Kdexts.dll

注释

该扩展是设计在Ntldr正在运行的系统引导早期使用的。它会在内存分配列表中显示开始位置、结束为止和每个页范围的类型。

任何时候按下CTRL+BREAK (WinDbg) 或CTRL+C (KD)都可以中断命令的执行。

!lockedpages

!lockedpages 扩展在Windows 2000中显示当前进程的driver-locked page,在Windows XP和之后的系统中显示指定进程的driver-locked page。

语法

Windows 2000的语法

!lockedpages 

Windows XP和之后的语法

!lockedpages [Process

参数

Process

(仅Windows XP和之后) 指定某个进程。如果省略Process,则使用当前进程。

DLL

Windows NT 4.0

不可用

Windows 2000

Kdextx86.dll

Windows XP和之后

Kdexts.dll

注释

任何时候按下CTRL+BREAK (WinDbg) 或CTRL+C (KD)都可以中断命令的执行。

!locks (!kdext*.locks)

Kdextx86.dllKdexts.dll中的!locks 扩展命令显示内核ERESOURCE 锁的信息。

该命令不要和!ntsdexts.locks 扩展命令混淆。

语法

!locks [Options] [Address

参数

Options

指定要显示的信息数量。可以是下面这些选项的任意组合:

-v

显示每个锁的详细信息。

-p

显示锁的所有可能的信息,包括性能统计。

-d

显示所有锁的信息。否则只显示出现争用的锁。

Address

指定要显示的ERESOURCE 锁的16进制地址。如果Address为0或者省略,则显示系统中所有ERESOURCE 锁。

DLL

Windows NT 4.0

Kdextx86.dll

Windows 2000

Kdextx86.dll

Windows XP和之后

Kdexts.dll

注释

!locks 扩展显示线程为资源而持有的所有的锁。锁可以是共享的(shared)或者独占的(exclusive),独占意味着其它线程不能访问该资源。当系统发生死锁时这个信息很有用。死锁是由于某个非执行的线程持有了某个资源的独占锁,但是其它执行的线程又需要这个所的时候会发生。

在Microsoft Windows 2000中通常可以通过查找非执行线程持有了某个执行线程请求的某个资源的独占锁的情况,来定位死锁。大多数的锁都是共享的。

下面是基本的!locks 输出的示例:

kd> !locks
**** DUMP OF ALL RESOURCE OBJECTS ****
KD: Scanning for held locks......

Resource @ 0x80e97620    Shared 4 owning threads
     Threads: ff688da0-01<*> ff687da0-01<*> ff686da0-01<*> ff685da0-01<*> 
KD: Scanning for held locks.......................................................

Resource @ 0x80e23f38    Shared 1 owning threads
     Threads: 80ed0023-01<*> *** Actual Thread 80ed0020
KD: Scanning for held locks.

Resource @ 0x80d8b0b0    Shared 1 owning threads
     Threads: 80ed0023-01<*> *** Actual Thread 80ed0020
2263 total locks, 3 locks currently held

注意显示出来的每个线程的地址后面都跟有线程计数 (例如"-01")。如果某个线程后跟有 I "<*>",则该线程是锁的所有者。有些情况下,初始线程的地址会包含一个偏移。这种情况下,实际的线程地址也会显示出来。

如果想查看这些资源对象中某一个的更多信息,可以将"Resource @"后的地址作为其它命令的参数。要查看上面例子中的第二个资源,可以使用dt ERESOURCE 80d8b0b0 或者 !thread 80ed0020。或者也可以带-v选项再次使用!locks

kd> !locks -v 80d8b0b0

Resource @ 0x80d8b0b0    Shared 1 owning threads
     Threads: 80ed0023-01<*> *** Actual Thread 80ed0020

     THREAD 80ed0020  Cid 4.2c  Teb: 00000000 Win32Thread: 00000000 WAIT: (WrQueue) KernelMode Non-Alertable
         8055e100  Unknown
     Not impersonating
GetUlongFromAddress: unable to read from 00000000
     Owning Process 80ed5238
     WaitTime (ticks)          44294977
     Context Switch Count      147830             
     UserTime                  0:00:00.0000
     KernelTime                0:00:02.0143
     Start Address nt!ExpWorkerThread (0x80506aa2)
     Stack Init fafa4000 Current fafa3d18 Base fafa4000 Limit fafa1000 Call 0
     Priority 13 BasePriority 13 PriorityDecrement 0
ChildEBP RetAddr  
fafa3d30 804fe997 nt!KiSwapContext+0x25 (FPO: [EBP 0xfafa3d48] [0,0,4]) [D:\NT\base\ntos\ke\i386\ctxswap.asm @ 139]
fafa3d48 80506a17 nt!KiSwapThread+0x85 (FPO: [Non-Fpo]) (CONV: fastcall) [d:\nt\base\ntos\ke\thredsup.c @ 1960]
fafa3d78 80506b36 nt!KeRemoveQueue+0x24c (FPO: [Non-Fpo]) (CONV: stdcall) [d:\nt\base\ntos\ke\queueobj.c @ 542]
fafa3dac 805ad8bb nt!ExpWorkerThread+0xc6 (FPO: [Non-Fpo]) (CONV: stdcall) [d:\nt\base\ntos\ex\worker.c @ 1130]
fafa3ddc 8050ec72 nt!PspSystemThreadStartup+0x2e (FPO: [Non-Fpo]) (CONV: stdcall) [d:\nt\base\ntos\ps\create.c @ 2164]
00000000 00000000 nt!KiThreadStartup+0x16 [D:\NT\base\ntos\ke\i386\threadbg.asm @ 81]

1 total locks, 1 locks currently held

!logonsession

!logonsession 扩展显示指定的登陆会话(logon session)的信息。

语法

Free Build 语法

!logonsession LUID 

Checked Build语法

!logonsession LUID [InfoLevel

参数

LUID

指定要显示的登陆会话的局部唯一标识符(LUID)。 如果LUID为0,则显示所有登陆会话的信息。

要在check版中显示系统会话和所有系统令牌(system token),输入!logonsession 3e7 1

InfoLevel

(仅Checked Build) 指定要显示多少令牌信息(token information)。InfoLevel 参数可以是0到4之间的值,0表示最少的信息,4表示最多。

DLL

Windows NT 4.0

不可用

Windows 2000

不可用

Windows XP和之后

Kdexts.dll

注释

下面是该扩展命令在free build上的输出示例:

kd> !logonsession 0

Dumping all logon sessions.

** Session   0 = 0x0
   LogonId     = {0x0 0x0}
   References  = 0
** Session   1 = 0x8ebb50
   LogonId     = {0xe9f1 0x0}
   References  = 21
** Session   2 = 0x6e31e0
   LogonId     = {0x94d1 0x0}
   References  = 1
** Session   3 = 0x8ecd60
   LogonId     = {0x6b31 0x0}
   References  = 0
** Session   4 = 0xe0000106
   LogonId     = {0x0 0x0}
   References  = 0
** Session   5 = 0x0
   LogonId     = {0x0 0x0}
   References  = 0
** Session   6 = 0x8e9720
   LogonId     = {0x3e4 0x0}
   References  = 6
** Session   7 = 0xe0000106
   LogonId     = {0x0 0x0}
   References  = 0
** Session   8 = 0xa2e160
   LogonId     = {0x3e5 0x0}
   References  = 3
** Session   9 = 0xe0000106
   LogonId     = {0x0 0x0}
   References  = 0
** Session  10 = 0x3ca0
   LogonId     = {0x3e6 0x0}
   References  = 2
** Session  11 = 0xe0000106
   LogonId     = {0x0 0x0}
   References  = 0
** Session  12 = 0x1cd0
   LogonId     = {0x3e7 0x0}
   References  = 33
** Session  13 = 0xe0000106
   LogonId     = {0x0 0x0}
   References  = 0
14 sessions in the system.

任何时候都可以通过按下CTRL+BREAK (WinDbg) 或CTRL+C (KD)来中止命令执行。

附加信息

关于登陆会话的信息,查看Microsoft Windows SDK 文档和Mark Russinovich 和David Solomon 编写的Microsoft Windows Internals

!lookaside

!lookaside 扩展可以显示look-aside lists的信息、重置look-aside list的计数器、或者改变look-aside list的深度。

语法

!lookaside [Address [Options [Depth]]] 

参数

Address

指定要使用的look-aside lists的16进制地址。如果Address为0或者省略,则显示所有的系统look-aside list。

Options

控制要进行的操作。支持下面这些可能的Options 。默认值为0:

0

显示指定的look-aside list 的信息。 (如果Address为0,则显示所有系统look-aside list。)

1

重置指定look-aside list的计数器。(仅Windows NT 4.0:如果Address 为0,则重置所有small pool look-aside list。)

2

改变指定look-aside list 的深度。该选项只有在Address 非0时可以使用。

Depth

设置给定的look-aside list的最大深度。该参数仅在Addres非0,并且Options 等于 2时可用。

DLL

Windows NT 4.0

Kdextx86.dll

Windows 2000

Kdextx86.dll

Windows XP和之后

Kdexts.dll

注释

Look-aside list是一种用于管理固定大小的分页或非分页内存池的多处理器安全的机制。

由于在大多数平台上都不使用自旋锁(spin lock),所以look-aside list是高效的。

注意如果look-aside list的当前深度大于它的最大深度,则释放关联到该list的结构时会释放到池内存中,而不是释放到list内存中。

下面是该扩展的输出示例:

kd> !lookaside e0000165f7621800

Lookaside "" @ e0000165f7621800 "Ntfs"
    Type     =     0011 PagedPool RaiseIfAllocationFailure
    Current Depth  =        0   Max Depth  =        4
    Size           =      488   Max Alloc  =     1952
    AllocateMisses =        3   FreeMisses =        0
    TotalAllocates =        4   TotalFrees =        4
    Hit Rate       =       25%  Hit Rate   =      100%

附加信息

关于look-aside list的信息,查看Windows Driver Kit (WDK) 文档,以及 Mark Russinovich 和David Solomon编写的Microsoft Windows Internals

!lpc

!lpc 扩展显示目标系统中的本地过程调用(local procedure call (LPC))端口和信息。

语法

Windows NT 4.0的语法

!lpc 

Windows 2000的语法

!lpc message MessageID 
!lpc port Port 
!lpc scan Port 
!lpc thread Thread 
!lpc 

Windows Server 2003 和Windows XP的语法

!lpc message MessageID 
!lpc port Port 
!lpc scan Port 
!lpc thread Thread 
!lpc PoolSearch 
!lpc 

参数

message

(仅Windows Server 2003、Windows XP、和Windows 2000) 如果有的话,显示某条消息的信息,例如队列中包含该消息的服务器端口(server port)、等待该消息的线程。

MessageID

(仅Windows Server 2003、Windows XP、和Windows 2000) 指定要显示的消息的消息ID。如果该参数的值为0或者省略,!lpc message 命令显示消息的摘要列表。(在Windows 2000 Service Pack 1 (SP1)中,摘要包括LPC zone 的所有消息。在Windows 2000 Service Pack 2 (SP2)、 Windows XP和之后版本的Windows中,摘要包括系统池中的所有消息。已经被页换出得消息不会包含。)

port

(仅Windows Server 2003、Windows XP、和Windows 2000) 显示端口信息,如端口的名字、信号量状态、队列中的消息、裁剪队列(rundown queue)中的线程、句柄数量、引用、以及相关的端口。

scan

(仅Windows Server 2003、Windows XP、和Windows 2000) 显示指定端口以及连接到它的所有端口的摘要信息。

Port

(仅Windows Server 2003、Windows XP、和Windows 2000) 指定要显示的端口的16进制地址。如果使用!lpc port 命令,并且 Port 为0或省略,则显示所由LPC端口的摘要列表。如果使用!lpc scan 命令,Port 必须指定一个实际的端口地址。

thread

(仅Windows Server 2003、Windows XP、和Windows 2000) 显示在rundown port queue中包含指定线程的所有端口的信息。

Thread

(仅Windows Server 2003、Windows XP、和Windows 2000) 指定线程的16进制地址。如果为0或者省略,!lpc thread命令显示所有正在进行LPC操作的线程的摘要列表。

PoolSearch

(仅Windows Server 2003、Windows XP、和Windows 2000) 指定!lpc message命令是否在内核池(kernel pool)中搜索消息。每次使用!lpc PoolSearch时,该设置会在打开和关闭之间切换(初始设置是不搜索内核池)。它仅作用于MessageID指定为非0值的!lpc message命令。

DLL

Windows NT 4.0

Kdextx86.dll

Windows 2000

Kdextx86.dll

Windows XP
Windows Server 2003

Kdexts.dll

注释

该扩展在Windows Vista和之后版本的Windows中不支持。

在Windows NT 4.0,不带参数使用 !lpc 会显示目标机上所有LPC端口和消息,类似在Windows 2000和之后系统中使用!lpc port 然后使用 !lpc message

在Windows Server 2003、Windows XP和Windows 2000中,不带参数使用!lpc 会在调试器命令窗口中显示该扩展命令的帮助文本。

如果有某个线程被标记为在等待某条消息返回,可以使用!lpc message 命令和这条延迟的消息的ID。命令会显示该消息、包含它的端口、以及所有被延迟的线程。

如果找不到消息,并且没有读取错误(例如"Unable to access zone segment"),则服务器已经接收到了这条消息。

这种情况下,服务器端口一般可以通过!lpc thread命令找到。等待响应的线程连接到服务器通信队列(server communication queue)上。这条命令可以显示所有包含指定线程的端口。知道了端口地址之后,可以使用!lpc port 命令。通过使用!lpc thread 命令和线程地址,可以获得关于每条线程的更多信息。

下面是扩展命令在Windows XP系统上的输出示例:

这个例子中,显示了所有LPC端口。

kd> !lpc port
Scanning 225 objects
       1  Port: 0xe1405650 Connection: 0xe1405650  Communication: 0x00000000  'SeRmCommandPort' 
       1  Port: 0xe141ef50 Connection: 0xe141ef50  Communication: 0x00000000  'SmApiPort' 
       1  Port: 0xe13c5740 Connection: 0xe13c5740  Communication: 0x00000000  'ApiPort' 
       1  Port: 0xe13d9550 Connection: 0xe13d9550  Communication: 0x00000000  'SbApiPort' 
       3  Port: 0xe13d8830 Connection: 0xe141ef50  Communication: 0xe13d8910  '' 
80000004  Port: 0xe13d8910 Connection: 0xe141ef50  Communication: 0xe13d8830  '' 
       3  Port: 0xe13d8750 Connection: 0xe13d9550  Communication: 0xe13a4030  '' 
       .....

上面例子中,地址e14ae238 处的端口没有消息,即所有消息都已经被接收并且没有新消息到达。

kd> !lpc port e14ae238

Server connection port e14ae238  Name: ApiPort
    Handles: 1   References: 107
    Server process  : 84aa0140 (csrss.exe)
    Queue semaphore : 84a96da8
    Semaphore state 0 (0x0)
    The message queue is empty
    The LpcDataInfoChainHead queue is empty

上面例子中,0xe14ae238 处的端口有已排队但是还没有被服务器接收的消息。

kd> !lpc port 0xe14ae238

Server connection port e14ae238  Name: ApiPort
    Handles: 1   References: 108
    Server process  : 84aa0140 (csrss.exe)
    Queue semaphore : 84a96da8
    Semaphore state 0 (0x0)
        Messages in queue:
        0000 e20d9b80 - Busy  Id=0002249c  From: 0584.0680  Context=00000021  [e14ae248 . e14ae248]
                   Length=0098007c  Type=00000001 (LPC_REQUEST)
                   Data: 00000000 0002021e 00000584 00000680 002f0001 00000007
    The message queue contains 1 messages
    The LpcDataInfoChainHead queue is empty

剩下的这些Windows XP上的示例是关于可以在这条扩展命令中使用的其它选项的。

kd> !lpc message 222be
Searching message 222be in threads ...
Client thread 842a4db0 waiting a reply from 222be
Searching thread 842a4db0 in port rundown queues ...

Server communication port 0xe114a3c0
    Handles: 1   References: 1
    The LpcDataInfoChainHead queue is empty
        Connected port: 0xe1e7b948      Server connection port: 0xe14ae238

Client communication port 0xe1e7b948
    Handles: 1   References: 3
    The LpcDataInfoChainHead queue is empty

Server connection port e14ae238  Name: ApiPort
    Handles: 1   References: 107
    Server process  : 84aa0140 (csrss.exe)
    Queue semaphore : 84a96da8
    Semaphore state 0 (0x0)
    The message queue is empty
    The LpcDataInfoChainHead queue is empty
Done.

kd> !lpc thread 842a4db0
Searching thread 842a4db0 in port rundown queues ...

Server communication port 0xe114a3c0
    Handles: 1   References: 1
    The LpcDataInfoChainHead queue is empty
        Connected port: 0xe1e7b948      Server connection port: 0xe14ae238

Client communication port 0xe1e7b948
    Handles: 1   References: 3
    The LpcDataInfoChainHead queue is empty

Server connection port e14ae238  Name: ApiPort
    Handles: 1   References: 107
    Server process  : 84aa0140 (csrss.exe)
    Queue semaphore : 84a96da8
    Semaphore state 0 (0x0)
    The message queue is empty
    The LpcDataInfoChainHead queue is empty

kd> !lpc scan e13d8830
Scanning 225 objects
       3  Port: 0xe13d8830 Connection: 0xe141ef50  Communication: 0xe13d8910  '' 
80000004  Port: 0xe13d8910 Connection: 0xe141ef50  Communication: 0xe13d8830  '' 
Scanning 3 objects

下面是在Windows NT 4.0系统上的输出示例:

kd> !lpc
Scanning 2 objects of type 'Port'
Connection Port Object at e11b8bc0 - Name='\SmApiPort' created by smss.exe
Connection Port Object at e11ba040 - Name='\SeRmCommandPort' created by System

附加信息

关于LPC的信息,查看Windows Driver Kit (WDK) 文档,以及Mark Russinovich 和David Solomon 编写的Microsoft Windows Internals

posted on 2008-07-24 14:43 NetRoc 阅读(826) 评论(1)  编辑 收藏 引用

评论

# re: WinDbg 文档翻译----81 2008-07-25 20:14 xzchina

读中文就是爽,强烈感谢 netroc所做的一切!  回复  更多评论   

只有注册用户登录后才能发表评论。

导航

统计

常用链接

留言簿(7)

随笔档案(99)

文章分类(35)

文章档案(32)

Friends

Mirror

搜索

最新评论

阅读排行榜

评论排行榜